def save(self, f):
if not isinstance(self.model, RetinotopyMeshModel):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if pimms.is_str(f):<EOL><INDENT>with open(f, '<STR_LIT:w>') as fl:<EOL><INDENT>self.save(fl)<EOL><DEDENT>return f<EOL><DEDENT>m = self.model<EOL>x0 = self.map_projection.center<EOL>x1 = self.map_projection.center_right<EOL>tx = np.eye(<NUM_LIT:3>) if m.transform is None else m.transform<EOL>chir = self.map_projection.chirality<EOL>if chir is not None: chir = chir.upper()<EOL>for ln in ['<STR_LIT>',<EOL>'<STR_LIT>' % m.coordinates.shape[<NUM_LIT:1>],<EOL>'<STR_LIT>' % m.faces.shape[<NUM_LIT:1>],<EOL>'<STR_LIT>' % self.map_projection.registration,<EOL>'<STR_LIT>' % chir,<EOL>'<STR_LIT>' % (x0[<NUM_LIT:0>], x0[<NUM_LIT:1>], x0[<NUM_LIT:2>]),<EOL>'<STR_LIT>' % (x1[<NUM_LIT:0>], x1[<NUM_LIT:1>], x1[<NUM_LIT:2>]),<EOL>'<STR_LIT>' % self.map_projection.method.capitalize(),<EOL>'<STR_LIT>' % tuple(tuple(x) for x in tx)]:<EOL><INDENT>f.write(ln + '<STR_LIT:\n>')<EOL><DEDENT>if self.area_name_to_id:<EOL><INDENT>lbls = [x for (_,x) in sorted(six.iteritems(self.area_name_to_id), key=lambda x:x[<NUM_LIT:0>])]<EOL>f.write('<STR_LIT>' % '<STR_LIT:U+0020>'.join(lbls))<EOL><DEDENT>(xs,ys) = m.coordinates<EOL>for (x,y,t,r,a) in zip(xs, ys, m.polar_angles, m.eccentricities, m.visual_areas):<EOL><INDENT>f.write('<STR_LIT>' % (x,y,t,r,a))<EOL><DEDENT>for (a,b,c) in zip(**(m.faces + <NUM_LIT:1>)):<EOL><INDENT>f.write('<STR_LIT>' % (a,b,c))<EOL><DEDENT>return f<EOL>
model.save(filename) saves an FMM-formatted file to the given filename; the FMM format is
used by neuropythy to save and load registered retinotopy models; it can be loaded with the
load_fmm_model function.
model.save(file) will write the text directly to the given file.