def test_define_subpath(self): s = file_finder.SubjectFiles( subpath=os.path.join('path', 'to', 'm2m_sub')) assert s.subpath == os.path.join('path', 'to', 'm2m_sub') assert s.subid == 'sub' assert s.basedir == os.path.join('path', 'to') assert s.fnamehead == os.path.join('path', 'to', 'sub.msh')
def test_cap_files(self): s = file_finder.SubjectFiles(os.path.join('path', 'to', 'sub.msh')) assert s.eeg_cap_folder == os.path.join('path', 'to', 'm2m_sub', 'eeg_positions') assert s.eeg_cap_1010 == os.path.join('path', 'to', 'm2m_sub', 'eeg_positions', 'EEG10-10_UI_Jurak_2007.csv') assert s.get_eeg_cap('test.csv') == os.path.join( 'path', 'to', 'm2m_sub', 'eeg_positions', 'test.csv')
def test_define_fnamehead_subpath(self): s = file_finder.SubjectFiles(os.path.join('some', 'random', 'file.msh'), subpath=os.path.join( 'path', 'to', 'm2m_sub')) assert s.fnamehead == os.path.join('some', 'random', 'file.msh') assert s.subid == 'sub' assert s.basedir == os.path.join('path', 'to') assert s.subpath == os.path.join('path', 'to', 'm2m_sub')
def main(): args = parse_arguments(sys.argv[1:]) m2m_dir = os.path.abspath(os.path.realpath(os.path.expanduser(args.m2mpath))) if not os.path.isdir(m2m_dir): raise IOError('Could not find directory: {0}'.format(args.m2mpath)) subject_files = file_finder.SubjectFiles(subpath=m2m_dir) os.makedirs(args.out_folder, exist_ok=True) for hemi in ['lh', 'rh']: # I have a parallel implementation here fn_atlas = os.path.join( file_finder.templates.cat_atlases_surfaces, f'{hemi}.aparc_{args.atlas}.freesurfer.annot' ) labels, colors, names = nibabel.freesurfer.io.read_annot(fn_atlas) if subject_files.seg_type == 'headreco': read_fun = read_gifti_surface elif subject_files.seg_type == 'mri2mesh': read_fun = read_freesurfer_surface if hemi == 'lh': ref_surf = read_gifti_surface(file_finder.templates.cat_lh_sphere_ref) sub_surf = read_fun(subject_files.lh_reg) if hemi == 'rh': ref_surf = read_gifti_surface(file_finder.templates.cat_rh_sphere_ref) sub_surf = read_fun(subject_files.rh_reg) labels_sub, _ = transformations._surf2surf(labels, ref_surf, sub_surf) fn_out = os.path.join( args.out_folder, f'{hemi}.{subject_files.subid}_{args.atlas}.annot' ) logger.info('Writing: ' + fn_out) nibabel.freesurfer.io.write_annot( fn_out, labels_sub, colors, names, fill_ctab=True )
def test_tensor_file(self): s = file_finder.SubjectFiles(os.path.join('path', 'to', 'sub.msh')) assert s.tensor_file == os.path.join('path', 'to', 'd2c_sub', 'dti_results_T1space', 'DTI_conf_tensor.nii.gz')