@pimms.calc('<STR_LIT>')<EOL>def save_volume_files(note, error, registrations, subject,<EOL>no_vol_export, volume_format, volume_path,<EOL>angle_tag, eccen_tag, label_tag, radius_tag):
if no_vol_export: return {'<STR_LIT>': ()}<EOL>volume_format = volume_format.lower()<EOL>if volume_format in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:default>']:<EOL><INDENT>volume_format = '<STR_LIT>' if volume_format == '<STR_LIT>' else '<STR_LIT>'<EOL>def export(flnm, d):<EOL><INDENT>flnm = flnm + '<STR_LIT:.>' + volume_format<EOL>dt = np.int32 if np.issubdtype(d.dtype, np.dtype(int).type) else np.float32<EOL>img = fsmgh.MGHImage(np.asarray(d, dtype=dt), subject.voxel_to_native_matrix)<EOL>img.to_filename(flnm)<EOL>return flnm<EOL><DEDENT><DEDENT>elif volume_format in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>volume_format = '<STR_LIT>' if volume_format == '<STR_LIT>' else '<STR_LIT>'<EOL>def export(flnm, p):<EOL><INDENT>flnm = flnm + '<STR_LIT:.>' + volume_format<EOL>dt = np.int32 if np.issubdtype(p.dtype, np.dtype(int).type) else np.float32<EOL>img = nib.Nifti1Image(np.asarray(p, dtype=dt), subject.voxel_to_native_matrix)<EOL>img.to_filename(flnm)<EOL>return flnm<EOL><DEDENT><DEDENT>else:<EOL><INDENT>error('<STR_LIT>' % volume_format)<EOL><DEDENT>path = volume_path if volume_path else os.path.join(subject.path, '<STR_LIT>')<EOL>files = []<EOL>note('<STR_LIT>')<EOL>hemis = [registrations[h]['<STR_LIT>'] if h in registrations else None<EOL>for h in ['<STR_LIT>', '<STR_LIT>']]<EOL>for (pname,tag) in zip(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>[angle_tag, eccen_tag, label_tag, radius_tag]):<EOL><INDENT>dat = tuple([None if h is None else h.prop(pname) for h in hemis])<EOL>(mtd,dt) = ('<STR_LIT>',np.int32) if pname == '<STR_LIT>' else ('<STR_LIT>',np.float32)<EOL>note('<STR_LIT>' % pname)<EOL>img = subject.cortex_to_image(dat, method=mtd, dtype=dt)<EOL>flnm = export(os.path.join(path, tag), img)<EOL>files.append(flnm)<EOL><DEDENT>return {'<STR_LIT>': tuple(files)}<EOL>
save_volume_files is the calculator that saves the registration data out as volume files,
which are put back in the registration as the value 'volume_files'.