@pimms.calc('<STR_LIT>', '<STR_LIT>')<EOL>def calc_filemap(atlas_properties, subject, atlas_version_tags, worklog,<EOL>output_path=None, overwrite=False, output_format='<STR_LIT>', create_directory=False):
if output_path is None:<EOL><INDENT>output_path = os.path.join(subject.path, '<STR_LIT>')<EOL>if not os.path.isdir(output_path): output_path = subject.path<EOL><DEDENT>output_format = '<STR_LIT>' if output_format is None else output_format.lower()<EOL>if output_format.startswith('<STR_LIT:.>'): output_format = output_format[<NUM_LIT:1>:]<EOL>(fmt,ending) = (('<STR_LIT>','<STR_LIT>') if output_format == '<STR_LIT>' else<EOL>('<STR_LIT>','<STR_LIT>') if output_format == '<STR_LIT>' else<EOL>('<STR_LIT>','<STR_LIT>'))<EOL>worklog('<STR_LIT>')<EOL>fm = AutoDict()<EOL>for (atl,atldat) in six.iteritems(atlas_properties):<EOL><INDENT>for (ver,verdat) in six.iteritems(atldat):<EOL><INDENT>vstr = atlas_version_tags[atl][ver]<EOL>for (h,hdat) in six.iteritems(verdat):<EOL><INDENT>for m in six.iterkeys(hdat):<EOL><INDENT>flnm = '<STR_LIT>' % (h, atl, m, vstr, ending)<EOL>flnm = os.path.join(output_path, flnm)<EOL>fm[flnm] = curry(lambda hdat,m: hdat[m], hdat, m)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>filemap = pimms.lazy_map(fm)<EOL>def export_all():<EOL><INDENT>'''<STR_LIT>'''<EOL>if not os.path.isdir(output_path):<EOL><INDENT>if not create_directory:<EOL><INDENT>raise ValueError('<STR_LIT>' % output_path)<EOL><DEDENT>os.makedirs(os.path.abspath(output_path), <NUM_LIT>)<EOL><DEDENT>filenames = []<EOL>worklog('<STR_LIT>')<EOL>wl = worklog.indent()<EOL>for flnm in six.iterkeys(filemap):<EOL><INDENT>wl(flnm)<EOL>filenames.append(nyio.save(flnm, filemap[flnm], fmt))<EOL><DEDENT>return filenames<EOL><DEDENT>return {'<STR_LIT>': filemap, '<STR_LIT>': export_all}<EOL>
calc_filemap is a calculator that converts the atlas properties nested-map into a single-depth
map whose keys are filenames and whose values are the interpolated property data.

Afferent parameters
  @ output_path 
    The directory into which the atlas files should be written. If not provided or None then
    uses the subject's surf directory. If this directory doesn't exist, then it uses the
    subject's directory itself.
  @ overwrite 
    Whether to overwrite existing atlas files. If True, then atlas files that already exist will
    be overwritten. If False, then no files are overwritten.
  @ create_directory 
    Whether to create the output path if it doesn't exist. This is False by default.
  @ output_format 
    The desired output format of the files to be written. May be one of the following: 'mgz',
    'mgh', or either 'curv' or 'morph'.

Efferent values:
  @ filemap 
    A pimms lazy map whose keys are filenames and whose values are interpolated atlas
    properties.
  @ export_all_fn 
    A function of no arguments that, when called, exports all of the files in the filemap to the
    output_path.