def save_volume_files(note, error, registrations, subject,
                      no_vol_export, volume_format, volume_path,
                      angle_tag, eccen_tag, label_tag, radius_tag):
    '''
    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'.
    '''
    if no_vol_export: return {'volume_files': ()}
    volume_format = volume_format.lower()
    # make an exporter for properties:
    if volume_format in ['mgh', 'mgz', 'auto', 'automatic', 'default']:
        volume_format = 'mgh' if volume_format == 'mgh' else 'mgz'
        def export(flnm, d):
            flnm = flnm + '.' + volume_format
            dt = np.int32 if np.issubdtype(d.dtype, np.dtype(int).type) else np.float32
            img = fsmgh.MGHImage(np.asarray(d, dtype=dt), subject.voxel_to_native_matrix)
            img.to_filename(flnm)
            return flnm
    elif volume_format in ['nifti', 'nii', 'niigz', 'nii.gz']:
        volume_format = 'nii' if volume_format == 'nii' else 'nii.gz'
        def export(flnm, p):
            flnm = flnm + '.' + volume_format
            dt = np.int32 if np.issubdtype(p.dtype, np.dtype(int).type) else np.float32
            img = nib.Nifti1Image(np.asarray(p, dtype=dt), subject.voxel_to_native_matrix)
            img.to_filename(flnm)
            return flnm
    else:
        error('Could not understand volume file-format %s' % volume_format)
    path = volume_path if volume_path else os.path.join(subject.path, 'mri')
    files = []
    note('Extracting predicted meshes for volume export...')
    hemis = [registrations[h]['predicted_mesh'] if h in registrations else None
             for h in ['lh', 'rh']]
    for (pname,tag) in zip(['polar_angle', 'eccentricity', 'visual_area', 'radius'],
                           [angle_tag, eccen_tag, label_tag, radius_tag]):
        # we have to make the volume first...
        dat = tuple([None if h is None else h.prop(pname) for h in hemis])
        (mtd,dt) = ('nearest',np.int32) if pname == 'visual_area' else ('linear',np.float32)
        note('Constructing %s image...' % pname)
        img = subject.cortex_to_image(dat, method=mtd, dtype=dt)
        flnm = export(os.path.join(path, tag), img)
        files.append(flnm)
    return {'volume_files': tuple(files)}
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'.