def to_path(self, obj, flatmap=None):
<EOL>if   flatmap is not None: fmap = flatmap<EOL>elif isinstance(obj, Mesh) and obj.coordinates.shape[<NUM_LIT:0>] == <NUM_LIT:2>: fmap = obj<EOL>else: fmap = self.map_projection(obj)<EOL>crv = self.curve<EOL>cids = fmap.container(crv.coordinates)<EOL>pts = crv.coordinates.T<EOL>if self.closed and not np.array_equal(pts[<NUM_LIT:0>], pts[-<NUM_LIT:1>]):<EOL><INDENT>pts = np.concatenate([pts, [pts[<NUM_LIT:0>]]])<EOL><DEDENT>allpts = []<EOL>for ii in range(len(pts) - <NUM_LIT:1>):<EOL><INDENT>allpts.append([pts[ii]])<EOL>seg  = pts[[ii,ii+<NUM_LIT:1>]]<EOL>ipts = segment_intersection_2D(seg, fmap.edge_coordinates)<EOL>ipts = np.transpose(ipts)<EOL>ipts = ipts[np.isfinite(ipts[:,<NUM_LIT:0>])]<EOL>dists = np.dot(ipts, seg[<NUM_LIT:1>] - seg[<NUM_LIT:0>])<EOL>allpts.append(ipts[np.argsort(dists)])<EOL><DEDENT>allpts.append([pts[-<NUM_LIT:1>]])<EOL>allpts = np.concatenate(allpts)<EOL>idcs = [<NUM_LIT:0>]<EOL>for ii in range(<NUM_LIT:1>, len(allpts)):<EOL><INDENT>d = np.sqrt(np.sum((allpts[idcs[-<NUM_LIT:1>]] - allpts[ii])**<NUM_LIT:2>))<EOL>if np.isclose(d, <NUM_LIT:0>): continue<EOL>idcs.append(ii)<EOL><DEDENT>allpts = allpts[idcs]<EOL>addrs = fmap.address(allpts)<EOL>return Path(obj, addrs, meta_data={'<STR_LIT>': self})<EOL>
trace.to_path(subj) yields a path reified on the given subject's cortical surface; the
  returned value is a Path object.
trace.to_path(topo) yields a path reified on the given topology/cortex object topo.
trace.to_path(mesh) yields a path reified on the given spherical mesh.

The optional argument flatmap (default: None) may be given if a flatmap has already been made
with the given path-trace's map_projection; this is recommended only if you know what you are
doing and need to save computational resources.