예제 #1
0
def modify_template_contents(template_contents, user_settings, scene_file,
                             sbref_nii, dtseries_sm):
    """
    Customizes a template file to a specific working directory, by
    replacing all relative path references and place holder paths
    with references to specific files.
    """

    surfs_dir = os.path.join(user_settings.work_dir, user_settings.subject,
                             'MNINonLinear', 'fsaverage_LR32k')
    T1w_nii = os.path.join(user_settings.work_dir, user_settings.subject,
                           'MNINonLinear', 'T1w.nii.gz')
    dtseries_sm_base = os.path.basename(dtseries_sm)
    dtseries_sm_base_noext = dtseries_sm_base.replace('.dtseries.nii', '')

    txt = template_contents.replace('SURFS_SUBJECT', user_settings.subject)
    txt = txt.replace('SURFS_MESHNAME', user_settings.surf_mesh)
    txt = replace_path_references(txt, 'SURFSDIR', surfs_dir, scene_file)
    txt = replace_all_references(txt, 'T1W', T1w_nii, scene_file)
    txt = replace_all_references(txt, 'SBREF', sbref_nii, scene_file)
    txt = replace_all_references(txt, 'S0DTSERIES', user_settings.dtseries_s0,
                                 scene_file)
    txt = replace_path_references(txt, 'SMDTSERIES',
                                  os.path.dirname(dtseries_sm), scene_file)
    txt = txt.replace('SMDTSERIES_BASENOEXT', dtseries_sm_base_noext)

    return txt
예제 #2
0
def modify_template_contents(template_contents, scene_file, settings, vertex):
    """
    Customizes a template file to a specific working directory, by
    replacing all relative path references and place holder paths
    with references to specific files.
    """
    surfs_dir = os.path.join(settings.work_dir, settings.subject,
      'MNINonLinear', 'fsaverage_LR32k')
    T1w_nii = os.path.join(settings.work_dir, settings.subject,
          'MNINonLinear', 'T1w.nii.gz')
    txt = template_contents.replace('SURFS_SUBJECT', settings.subject)
    txt = txt.replace('SURFS_MESHNAME', '.32k_fs_LR')
    txt = replace_path_references(txt, 'SURFSDIR', surfs_dir, scene_file)
    txt = replace_all_references(txt, 'T1W', T1w_nii, scene_file)
    txt = replace_all_references(txt, 'TOPSCALAR', vertex.rois, scene_file)
    txt = replace_all_references(txt, 'MIDSCALAR', vertex.seed_corr, scene_file)

    return txt
예제 #3
0
def modify_template_contents(template_contents, scene_file, settings):
    """
    Customizes a template file to a specific working directory, by
    replacing all relative path references and place holder paths
    with references to specific files.
    """
    sulc_map = os.path.join(
        settings.surf_dir,
        '{}.sulc{}.dscalar.nii'.format(settings.surf_subject,
                                       settings.surf_mesh))

    txt = template_contents.replace('SURFS_SUBJECT', settings.surf_subject)
    txt = txt.replace('SURFS_MESHNAME', settings.surf_mesh)
    txt = replace_path_references(txt, 'SURFSDIR', settings.surf_dir,
                                  scene_file)
    txt = replace_all_references(txt, 'T1W', settings.T1w, scene_file)
    txt = replace_all_references(txt, 'TOPSCALAR', settings.snap, scene_file)
    txt = replace_all_references(txt, 'MIDSCALAR', sulc_map, scene_file)

    return txt