def read_cmd_args(argv=None): from src.utils import args_utils as au import argparse parser = argparse.ArgumentParser(description='MMVT electrodes preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-t', '--task', help='task', required=False) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=au.is_true) parser.add_argument('-f', '--function', help='function name', required=False, default='all', type=au.str_arr_type) parser.add_argument('--exclude', help='functions not to run', required=False, default='', type=au.str_arr_type) parser.add_argument('--good_channels', help='good channels', required=False, default='', type=au.str_arr_type) parser.add_argument('--bad_channels', help='bad channels', required=False, default='', type=au.str_arr_type) parser.add_argument('--from_t', help='from_t', required=False, default=0, type=float) # was -500 parser.add_argument('--to_t', help='to_t', required=False, default=0, type=float) # was 2000 parser.add_argument('--from_t_ind', help='from_t_ind', required=False, default=0, type=int) # was -500 parser.add_argument('--to_t_ind', help='to_t_ind', required=False, default=-1, type=int) # was 2000 parser.add_argument('--indices_shift', help='indices_shift', required=False, default=0, type=int) # was 1000 parser.add_argument('--conditions', help='conditions', required=False, default='') parser.add_argument('--raw_fname', help='raw fname', required=False, default='') parser.add_argument('--stat', help='stat', required=False, default=STAT_DIFF, type=int) parser.add_argument('--electrodes_names_field', help='electrodes_names_field', required=False, default='names') parser.add_argument('--moving_average_window_size', help='', required=False, default=0, type=int) parser.add_argument('--field_cond_template', help='', required=False, default='{}') parser.add_argument('--input_type', help='', required=False, default='ERP') parser.add_argument('--input_matlab_fname', help='', required=False, default='') parser.add_argument('--ras_xls_sheet_name', help='ras_xls_sheet_name', required=False, default='') parser.add_argument('--do_plot', help='do plot', required=False, default=0, type=au.is_true) args = utils.Bag(au.parse_parser(parser, argv)) print(args) return args
def read_args(argv=None): parser = su.add_default_args() parser.add_argument('--python_cmd', help='python cmd', required=False, default=sys.executable) return su.Bag(au.parse_parser(parser, argv))
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT stim preprocessing') parser.add_argument('-c', '--conditions', help='conditions names', required=False, default='contrast', type=au.str_arr_type) parser.add_argument('--mat_fname', help='matlab connection file name', required=False, default='') parser.add_argument('--mat_field', help='matlab connection field name', required=False, default='') parser.add_argument('--labels_exclude', help='rois to exclude', required=False, default='unknown,corpuscallosum', type=au.str_arr_type) parser.add_argument('--bipolar', help='', required=False, default=0, type=au.is_true) parser.add_argument('--norm_by_percentile', help='', required=False, default=1, type=au.is_true) parser.add_argument('--norm_percs', help='', required=False, default='1,99', type=au.int_arr_type) parser.add_argument('--stat', help='', required=False, default=STAT_DIFF, type=int) parser.add_argument('--windows', help='', required=False, default=0, type=int) parser.add_argument('--t_max', help='', required=False, default=0, type=int) parser.add_argument('--threshold_percentile', help='', required=False, default=0, type=int) parser.add_argument('--threshold', help='', required=False, default=0, type=float) parser.add_argument('--color_map', help='', required=False, default='jet') parser.add_argument('--symetric_colors', help='', required=False, default=1, type=au.is_true) parser.add_argument('--data_max', help='', required=False, default=0, type=float) parser.add_argument('--data_min', help='', required=False, default=0, type=float) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) if len(args.conditions) == 1: args.stat = STAT_AVG print(args) return args
def read_cmd_args(argv=None): import argparse parser = argparse.ArgumentParser(description='MMVT anatomy preprocessing') parser.add_argument('--template_subject', help='template subject', required=False, default='fsaverage') parser.add_argument('--surf_name', help='surf_name', required=False, default='pial') parser.add_argument('--cerebellum_segmentation_loose', help='', required=False, default=1, type=au.is_true) parser.add_argument('--overwrite', help='overwrite', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_subcorticals', help='overwrite', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_annotation', help='overwrite_annotation', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_morphing_labels', help='overwrite_morphing_labels', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_hemis_srf', help='overwrite_hemis_srf', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_labels_ply_files', help='overwrite_labels_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_faces_verts', help='overwrite_faces_verts', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_ply_files', help='overwrite_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--solve_labels_collisions', help='solve_labels_collisions', required=False, default=0, type=au.is_true) parser.add_argument('--morph_labels_from_fsaverage', help='morph_labels_from_fsaverage', required=False, default=1, type=au.is_true) parser.add_argument('--fs_labels_fol', help='fs_labels_fol', required=False, default='') pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['aseg.mgz', 'norm.mgz', 'ribbon.mgz', 'T1.mgz', 'orig.mgz'], 'surf': ['rh.pial', 'lh.pial', 'rh.inflated', 'lh.inflated', 'lh.curv', 'rh.curv', 'rh.sphere.reg', 'lh.sphere.reg', 'lh.white', 'rh.white', 'rh.smoothwm','lh.smoothwm'], 'mri:transforms' : ['talairach.xfm']} if args.overwrite: args.overwrite_annotation = True args.overwrite_morphing_labels = True args.overwrite_hemis_srf = True args.overwrite_labels_ply_files = True args.overwrite_faces_verts = True args.overwrite_fs_files = True print(args) return args
def read_cmd_args(argv=None): import argparse parser = argparse.ArgumentParser(description='UDP listener') parser.add_argument('-b', '--buffer_size', required=False, default=10, type=int) # parser.add_argument('-p', '--python_cmd', required=False, default='python') # parser.add_argument('-f', '--function', required=False, default='') return utils.Bag(au.parse_parser(parser, argv))
def read_cmd_args(argv): import argparse parser = argparse.ArgumentParser(description='MMVT freeview preprocessing') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_aseg_file', help='overwrite_aseg_file', required=False, default=0, type=au.is_true) parser.add_argument('--create_volume_file', help='create_volume_file', required=False, default=1, type=au.is_true) parser.add_argument('--electrodes_pos_fname', help='electrodes_pos_fname', required=False, default='') parser.add_argument('--way_points', help='way_points', required=False, default=0, type=au.is_true) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['T1.mgz', 'orig.mgz']} # print(args) return args
def read_cmd_args(argv=None): import argparse parser = argparse.ArgumentParser(description='MMVT template preprocessing') parser.add_argument('--flag', help='', required=False, default='') pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) return args
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT template preprocessing') pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser)) # print(args) return args
def parse_args(parser, argv, raise_exception_if_subject_is_empty=True): args = Bag(au.parse_parser(parser, argv)) args.real_atlas = get_real_atlas_name(args.atlas) if ((len(args.subjects) == 0 and args.subject == '') or (len(args.subjects) > 0 and args.subject != '')) and \ raise_exception_if_subject_is_empty: # print(args) raise Exception('You need to set --subject or --subjects!') return args
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT template preprocessing') pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser)) print(args) return args
def parse_args(parser, argv): args = Bag(au.parse_parser(parser, argv)) args.real_atlas = get_full_atlas_name(args.atlas) if (len(args.subjects) == 0 and args.subject == '') or (len(args.subjects) > 0 and args.subject != ''): raise Exception('You need to set --subject or --subjects!') return args
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='Description of your program') parser.add_argument('-s', '--subject', help='subject name', required=True) parser.add_argument('-f', '--function', help='function name', required=False, default='all') parser.add_argument('-c', '--contrast', help='contrast name', required=True) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-t', '--threshold', help='clustering threshold', required=False, default='2') parser.add_argument('-T', '--task', help='task', required=True) parser.add_argument('--existing_format', help='existing format', required=False, default='mgz') parser.add_argument('--volume_type', help='volume type', required=False, default='mni305') parser.add_argument('--volume_name', help='volume file name', required=False, default='') parser.add_argument('--surface_name', help='surface_name', required=False, default='pial') parser.add_argument('--meg_subject', help='meg_subject', required=False, default='') parser.add_argument('--inverse_method', help='inverse method', required=False, default='dSPM') parser.add_argument('--n_jobs', help='cpu num', required=False, default=-1) args = utils.Bag(au.parse_parser(parser, argv)) args.n_jobs = utils.get_n_jobs(args.n_jobs) print(args) return args
def read_cmd_args(argv): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT freeview preprocessing') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_aseg_file', help='overwrite_aseg_file', required=False, default=0, type=au.is_true) parser.add_argument('--create_volume_file', help='create_volume_file', required=False, default=1, type=au.is_true) parser.add_argument('--electrodes_pos_fname', help='electrodes_pos_fname', required=False, default='') parser.add_argument('--way_points', help='way_points', required=False, default=0, type=au.is_true) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['T1.mgz', 'orig.mgz']} print(args) return args
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT stim preprocessing') parser.add_argument('--stim_channel', help='stim channel', required=True) parser.add_argument('--colors_map', help='activity colors map', required=False, default='OrRd') parser.add_argument('--norm_percs', help='normalization percerntiles', required=False, type=au.int_arr_type, default='1,95') parser.add_argument('--downsample', help='downsample', required=False, type=int, default=1) parser.add_argument('--file_frefix', help='file_frefix', required=False, default='psd_') parser.add_argument('--error_radius', help='error_radius', required=False, default=3, type=int) parser.add_argument('--elec_length', help='elec_length', required=False, default=4, type=int) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser)) print(args) return args
def main(): import collections parser = argparse.ArgumentParser(description='MMVT') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas') parser.add_argument('-u', '--sftp_username', help='sftp username', required=False, default='npeled') parser.add_argument('-d', '--sftp_domain', help='sftp domain', required=False, default='door.nmr.mgh.harvard.edu') parser.add_argument('--remote_subject_dir', help='remote_subjects_dir', required=False, default='/space/thibault/1/users/npeled/subjects/{subject}') parser.add_argument('-f', '--function', help='function name', required=True) # choices=[f_name for f_name, f in globals().items() if isinstance(f, collections.Callable) # if f_name not in ['Gooey', 'main']] args = utils.Bag(au.parse_parser(parser)) # for subject in args.subject: globals()[args.function](args)
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT anatomy preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-f', '--function', help='functions to run', required=False, default='all', type=au.str_arr_type) parser.add_argument('--exclude', help='functions not to run', required=False, default='', type=au.str_arr_type) parser.add_argument('--ignore_missing', help='ignore missing files', required=False, default=0, type=au.is_true) parser.add_argument('--fsaverage', help='fsaverage', required=False, default='fsaverage') parser.add_argument('--remote_subject_dir', help='remote_subject_dir', required=False, default='') parser.add_argument('--surf_name', help='surf_name', required=False, default='pial') parser.add_argument('--overwrite', help='overwrite', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_fs_files', help='overwrite freesurfer files', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_annotation', help='overwrite_annotation', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_morphing_labels', help='overwrite_morphing_labels', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_hemis_srf', help='overwrite_hemis_srf', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_labels_ply_files', help='overwrite_labels_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_faces_verts', help='overwrite_faces_verts', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_ply_files', help='overwrite_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--solve_labels_collisions', help='solve_labels_collisions', required=False, default=0, type=au.is_true) parser.add_argument('--morph_labels_from_fsaverage', help='morph_labels_from_fsaverage', required=False, default=1, type=au.is_true) parser.add_argument('--fs_labels_fol', help='fs_labels_fol', required=False, default='') parser.add_argument('--sftp', help='copy subjects files over sftp', required=False, default=0, type=au.is_true) parser.add_argument('--sftp_username', help='sftp username', required=False, default='') parser.add_argument('--sftp_domain', help='sftp domain', required=False, default='') parser.add_argument('--print_traceback', help='print_traceback', required=False, default=1, type=au.is_true) parser.add_argument('--n_jobs', help='cpu num', required=False, default=-1) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['aseg.mgz', 'norm.mgz', 'ribbon.mgz', 'T1.mgz'], 'surf': ['rh.pial', 'lh.pial', 'rh.inflated', 'lh.inflated', 'lh.curv', 'rh.curv', 'rh.sphere.reg', 'lh.sphere.reg', 'lh.white', 'rh.white', 'rh.smoothwm','lh.smoothwm'], 'mri:transforms' : ['talairach.xfm']} args.n_jobs = utils.get_n_jobs(args.n_jobs) if args.overwrite: args.overwrite_annotation = True args.overwrite_morphing_labels = True args.overwrite_hemis_srf = True args.overwrite_labels_ply_files = True args.overwrite_faces_verts = True args.overwrite_fs_files = True print(args) return args
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT anatomy preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-f', '--function', help='functions to run', required=False, default='all', type=au.str_arr_type) parser.add_argument('--exclude', help='functions not to run', required=False, default='', type=au.str_arr_type) parser.add_argument('--ignore_missing', help='ignore missing files', required=False, default=0, type=au.is_true) parser.add_argument('--fsaverage', help='fsaverage', required=False, default='fsaverage') parser.add_argument('--remote_subject_dir', help='remote_subject_dir', required=False, default='') parser.add_argument('--remote_subjects_dir', help='remote_subjects_dir', required=False, default='') parser.add_argument('--surf_name', help='surf_name', required=False, default='pial') parser.add_argument('--overwrite', help='overwrite', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_fs_files', help='overwrite freesurfer files', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_annotation', help='overwrite_annotation', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_morphing_labels', help='overwrite_morphing_labels', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_hemis_srf', help='overwrite_hemis_srf', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_labels_ply_files', help='overwrite_labels_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_faces_verts', help='overwrite_faces_verts', required=False, default=0, type=au.is_true) parser.add_argument('--overwrite_ply_files', help='overwrite_ply_files', required=False, default=0, type=au.is_true) parser.add_argument('--solve_labels_collisions', help='solve_labels_collisions', required=False, default=0, type=au.is_true) parser.add_argument('--morph_labels_from_fsaverage', help='morph_labels_from_fsaverage', required=False, default=1, type=au.is_true) parser.add_argument('--fs_labels_fol', help='fs_labels_fol', required=False, default='') parser.add_argument('--sftp', help='copy subjects files over sftp', required=False, default=0, type=au.is_true) parser.add_argument('--sftp_username', help='sftp username', required=False, default='') parser.add_argument('--sftp_domain', help='sftp domain', required=False, default='') parser.add_argument('--print_traceback', help='print_traceback', required=False, default=1, type=au.is_true) parser.add_argument('--n_jobs', help='cpu num', required=False, default=-1) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['aseg.mgz', 'norm.mgz', 'ribbon.mgz'], 'surf': ['rh.pial', 'lh.pial', 'rh.sphere.reg', 'lh.sphere.reg', 'lh.white', 'rh.white', 'rh.smoothwm','lh.smoothwm']} args.n_jobs = utils.get_n_jobs(args.n_jobs) if args.overwrite: args.overwrite_annotation = True args.overwrite_morphing_labels = True args.overwrite_hemis_srf = True args.overwrite_labels_ply_files = True args.overwrite_faces_verts = True args.overwrite_fs_files = True print(args) return args
def main(): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT Setup') parser.add_argument('-l', '--links', help='links folder name', required=False, default='links') parser.add_argument('-g', '--gui', help='choose folders using gui', required=False, default='1', type=au.is_true) args = utils.Bag(au.parse_parser(parser)) links_created = create_links(args.links, args.gui) if not links_created: print('Not all the links were created! Make sure all the links are created before running MMVT.') else: links_dir = utils.get_links_dir() mmvt_root_dir = op.join(links_dir, 'mmvt') resource_file_exist = copy_resources_files(mmvt_root_dir) if not resource_file_exist: print('Not all the resources files were copied to the MMVT () folder.\n'.format(mmvt_root_dir) + 'Please copy them manually from the mmvt_code/resources folder') else: print('Finish!')
def read_cmd_args(argv=None): from src.utils import args_utils as au import argparse parser = argparse.ArgumentParser(description='MMVT electrodes preprocessing') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=au.is_true) parser.add_argument('--good_channels', help='good channels', required=False, default='', type=au.str_arr_type) parser.add_argument('--bad_channels', help='bad channels', required=False, default='', type=au.str_arr_type) parser.add_argument('--from_t', help='from_t', required=False, default='0', type=au.float_arr_type)# float) # was -500 parser.add_argument('--to_t', help='to_t', required=False, default='0', type=au.float_arr_type) # was 2000 parser.add_argument('--from_t_ind', help='from_t_ind', required=False, default=0, type=int) # was -500 parser.add_argument('--to_t_ind', help='to_t_ind', required=False, default=-1, type=int) # was 2000 parser.add_argument('--indices_shift', help='indices_shift', required=False, default=0, type=int) # was 1000 parser.add_argument('--conditions', help='conditions', required=False, default='') parser.add_argument('--raw_fname', help='raw fname', required=False, default='no_raw_fname_given') parser.add_argument('--ref_elec', help='referece electrode', required=False, default='') parser.add_argument('--stat', help='stat', required=False, default=STAT_DIFF, type=int) parser.add_argument('--electrodes_names_field', help='electrodes_names_field', required=False, default='names') parser.add_argument('--moving_average_window_size', help='', required=False, default=0, type=int) parser.add_argument('--field_cond_template', help='', required=False, default='{}') parser.add_argument('--input_type', help='', required=False, default='ERP') parser.add_argument('--input_matlab_fname', help='', required=False, default='') parser.add_argument('--start_time', help='', required=False, default='') parser.add_argument('--seizure_time', help='', required=False, default='') parser.add_argument('--window_length', help='', required=False, default=0, type=float) parser.add_argument('--seizure_onset_time', help='', required=False, default=0, type=float) parser.add_argument('--baseline_delta', help='', required=False, default=0, type=float) parser.add_argument('--time_format', help='', required=False, default='%H:%M:%S') parser.add_argument('--electrodes_groups_coloring_fname', help='', required=False, default='electrodes_groups_coloring.csv') parser.add_argument('--ras_xls_sheet_name', help='ras_xls_sheet_name', required=False, default='') parser.add_argument('--do_plot', help='do plot', required=False, default=0, type=au.is_true) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) args.ignore_missing = True for field in ['from_t', 'to_t']: if len(args[field]) == 1: args[field] = args[field][0] args.necessary_files = {'electrodes': ['{subject}_RAS.csv']} print(args) return args
def read_cmd_args(argv): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT freeview preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=bool) parser.add_argument('-f', '--function', help='function name', required=False, default='all', type=au.str_arr_type) parser.add_argument('--overwrite_aseg_file', help='overwrite_aseg_file', required=False, default=0, type=au.is_true) parser.add_argument('--create_volume_file', help='create_volume_file', required=False, default=1, type=au.is_true) parser.add_argument('--electrodes_pos_fname', help='electrodes_pos_fname', required=False, default='') parser.add_argument('--way_points', help='way_points', required=False, default=0, type=au.is_true) parser.add_argument('--remote_subject_dir', help='remote_subject_dir', required=False, default='') parser.add_argument('--overwrite_fs_files', help='overwrite freesurfer files', required=False, default=0, type=au.is_true) parser.add_argument('--sftp', help='copy subjects files over sftp', required=False, default=0, type=au.is_true) parser.add_argument('--sftp_username', help='sftp username', required=False, default='') parser.add_argument('--sftp_domain', help='sftp domain', required=False, default='') parser.add_argument('--print_traceback', help='print_traceback', required=False, default=1, type=au.is_true) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['T1.mgz', 'orig.mgz']} print(args) return args
def read_cmd_args(argv=None): import argparse parser = argparse.ArgumentParser(description='MMVT CT preprocessing') parser.add_argument('--ct_raw_input_fol', help='', required=False, default='') parser.add_argument('--ct_fol', help='', required=False, default='') parser.add_argument('--ct_org_name', help='', required=False, default='ct_org.mgz') parser.add_argument('--nnv_ct_name', help='', required=False, default='ct_no_large_negative_values.mgz') parser.add_argument('--register_ct_name', help='', required=False, default='ct_reg_to_mr.mgz') parser.add_argument('--negative_threshold', help='', required=False, default=-200, type=int) parser.add_argument('--no_negatives', help='', required=False, default=True, type=au.is_true) parser.add_argument('--register_cost_function', help='', required=False, default='nmi') parser.add_argument('--ct_threshold', help='', required=False, type=float, default=2000) parser.add_argument('--overwrite', help='', required=False, default=0, type=au.is_true) parser.add_argument('--print_only', help='', required=False, default=False, type=au.is_true) parser.add_argument('--ask_before', help='', required=False, default=False, type=au.is_true) parser.add_argument('--debug', help='', required=False, default=False, type=au.is_true) # find_electrodes: parser.add_argument('--n_components', help='', required=False, default=0, type=int) parser.add_argument('--n_groups', help='', required=False, default=0, type=int) parser.add_argument('--brain_mask_fname', help='', required=False, default='') parser.add_argument('--output_fol', help='', required=False, default=None, type=au.str_or_none) parser.add_argument('--clustering_method', help='', required=False, default='knn') parser.add_argument('--max_iters', help='', required=False, default=5, type=int) parser.add_argument('--cylinder_error_radius', help='', required=False, default=3, type=float) parser.add_argument('--min_elcs_for_lead', help='', required=False, default=4, type=int) parser.add_argument('--max_dist_between_electrodes', help='', required=False, default=20, type=float) parser.add_argument('--min_cylinders_ang', help='', required=False, default=0.1, type=float) parser.add_argument('--ct_thresholds', help='', required=False, default='99,99.9,99.95,99.99,99.995,99.999', type=au.float_arr_type) parser.add_argument('--min_joined_items_num', help='', required=False, default=1, type=int) parser.add_argument('--min_distance_beteen_electrodes', help='', required=False, default=2, type=float) # Dell parser.add_argument('--voxels', help='', required=False, default='', type=au.list_of_int_lists_type) parser.add_argument('--voxel', help='', required=False, default='', type=au.int_arr_type) # 102,99,131 parser.add_argument('--pixels_around_voxel', help='', required=False, default=30, type=int) parser.add_argument('--interactive', help='', required=False, default=0, type=au.is_true) parser.add_argument('--electrodes_names', help='', required=False, default='', type=au.str_arr_type) parser.add_argument('--group_name', help='', required=False, default='') parser.add_argument('--elc_name', help='', required=False, default='') parser.add_argument('--fig_name', help='', required=False, default='') parser.add_argument('--isotropization_type', help='', required=False, default=1, type=int) pu.add_common_args(parser) args = utils.Bag(au.parse_parser(parser, argv)) pu.set_default_folders(args) args.necessary_files = {'mri': ['brain.mgz']} global SUBJECTS_DIR, MMVT_DIR SUBJECTS_DIR = args.mri_dir MMVT_DIR = args.mmvt_dir print('Subjects dir: {}'.format(SUBJECTS_DIR)) print('MMVT dir: {}'.format(MMVT_DIR)) return args
args.mat_field = 'figure_file' args.windows = 1 args.stat = con.STAT_DIFF args.threshold_percentile = 99 args.conditions = ['task', 'rest'] con.save_rois_connectivity(subject, args) def example2(subject): # subject = 'fsaverage5c' args = con.read_cmd_args(['-s', subject]) args.atlas = 'laus125' args.mat_fname = '/cluster/neuromind/npeled/linda/figure_file3.mat' args.mat_field = 'matrix_cognition_ratio_fpn_dmn' args.windows = 1 args.threshold = 0 args.norm_by_percentile = False args.symetric_colors = False args.color_map = 'YlOrRd' args.data_min = 0.15 args.data_max = 0.6 con.save_rois_connectivity(subject, args) if __name__ == '__main__': parser = argparse.ArgumentParser(description='MMVT') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-f', '--function', help='function name', required=True) args = utils.Bag(au.parse_parser(parser)) for subject in args.subject: locals()[args.function](subject)
def read_cmd_args(argv): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT freeview preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-b', '--bipolar', help='bipolar', required=False, default=0, type=au.is_true) parser.add_argument('-f', '--function', help='function name', required=False, default='all', type=au.str_arr_type) parser.add_argument('--overwrite_aseg_file', help='overwrite_aseg_file', required=False, default=0, type=au.is_true) parser.add_argument('--create_volume_file', help='create_volume_file', required=False, default=1, type=au.is_true) parser.add_argument('--electrodes_pos_fname', help='electrodes_pos_fname', required=False, default='') parser.add_argument('--way_points', help='way_points', required=False, default=0, type=au.is_true) parser.add_argument('--remote_subject_dir', help='remote_subject_dir', required=False, default='') parser.add_argument('--overwrite_fs_files', help='overwrite freesurfer files', required=False, default=0, type=au.is_true) parser.add_argument('--sftp', help='copy subjects files over sftp', required=False, default=0, type=au.is_true) parser.add_argument('--sftp_username', help='sftp username', required=False, default='') parser.add_argument('--sftp_domain', help='sftp domain', required=False, default='') parser.add_argument('--print_traceback', help='print_traceback', required=False, default=1, type=au.is_true) args = utils.Bag(au.parse_parser(parser, argv)) args.necessary_files = {'mri': ['T1.mgz', 'orig.mgz']} print(args) return args
return atlas in ['aparc.DKTatlas40', 'aparc', 'aparc.a2009s'] def read_surface(subject, subjects_dir, surf_type='pial'): verts, faces = {}, {} for hemi in utils.HEMIS: surf_fname = op.join(subjects_dir, subject, 'surf', '{}.{}'.format(hemi, surf_type)) if not op.isfile(surf_fname): print('{} does not exist!'.format(surf_fname)) return None, None verts[hemi], faces[hemi] = nib.freesurfer.read_geometry(surf_fname) return verts, faces if __name__ == '__main__': import argparse from src.utils.utils import Bag from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT') parser.add_argument('-s', '--subject', help='subject name', required=True) parser.add_argument('-f', '--function', help='function name', required=True, type=au.str_arr_type) args = Bag(au.parse_parser(parser)) for func in args.function: locals()[func](**args)
def main(): import collections parser = argparse.ArgumentParser(description='MMVT') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas') parser.add_argument('-u', '--sftp_username', help='sftp username', required=False, default='npeled') parser.add_argument('-d', '--sftp_domain', help='sftp domain', required=False, default='door.nmr.mgh.harvard.edu') parser.add_argument( '--remote_subject_dir', help='remote_subjects_dir', required=False, default='/space/thibault/1/users/npeled/subjects/{subject}') parser.add_argument( '--fs_root', help='freesurfer_root', required=False, default='/space/megraid/clinical/MEG-MRI/seder/freesurfer') parser.add_argument('--dicoms_root', help='dicoms_root', required=False, default='/cluster/archive/331/siemens') parser.add_argument('--dicoms_fol', help='dicoms_fol', required=False, default='', type=au.str_arr_type) parser.add_argument('--clin_fol', help='clin_fol', required=False, default='', type=au.str_arr_type) parser.add_argument('--clin_root', help='clin_fol', required=False, default='/space/megraid/clinical/MEG-MRI/') parser.add_argument('--print_only', help='', required=False, default=0, type=au.is_true) parser.add_argument('-f', '--function', help='function name', required=True) parser.add_argument('--n_jobs', help='jobs num', required=False, default=4, type=int) # choices=[f_name for f_name, f in globals().items() if isinstance(f, collections.Callable) # if f_name not in ['Gooey', 'main']] args = utils.Bag(au.parse_parser(parser)) # for subject in args.subject: globals()[args.function](args)
def read_cmd_args(argv=None): import argparse from src.utils import args_utils as au parser = argparse.ArgumentParser(description='MMVT stim preprocessing') parser.add_argument('-s', '--subject', help='subject name', required=True, type=au.str_arr_type) parser.add_argument('-c', '--conditions', help='conditions names', required=False, default='contrast', type=au.str_arr_type) parser.add_argument('-a', '--atlas', help='atlas name', required=False, default='aparc.DKTatlas40') parser.add_argument('-f', '--function', help='function name', required=False, default='all', type=au.str_arr_type) parser.add_argument('--exclude', help='functions not to run', required=False, default='', type=au.str_arr_type) parser.add_argument('--mat_fname', help='matlab connection file name', required=False, default='') parser.add_argument('--mat_field', help='matlab connection field name', required=False, default='') parser.add_argument('--labels_exclude', help='rois to exclude', required=False, default='unknown,corpuscallosum', type=au.str_arr_type) parser.add_argument('--norm_by_percentile', help='', required=False, default=1, type=au.is_true) parser.add_argument('--norm_percs', help='', required=False, default='1,99', type=au.int_arr_type) parser.add_argument('--stat', help='', required=False, default=STAT_DIFF, type=int) parser.add_argument('--windows', help='', required=False, default=0, type=int) parser.add_argument('--t_max', help='', required=False, default=0, type=int) parser.add_argument('--threshold_percentile', help='', required=False, default=0, type=int) parser.add_argument('--threshold', help='', required=False, default=0, type=float) parser.add_argument('--color_map', help='', required=False, default='jet') parser.add_argument('--symetric_colors', help='', required=False, default=1, type=au.is_true) parser.add_argument('--data_max', help='', required=False, default=0, type=float) parser.add_argument('--data_min', help='', required=False, default=0, type=float) parser.add_argument('--n_jobs', help='cpu num', required=False, default=-1) args = utils.Bag(au.parse_parser(parser, argv)) args.n_jobs = utils.get_n_jobs(args.n_jobs) if len(args.conditions) == 1: args.stat = STAT_AVG print(args) return args
type=au.is_true) parser.add_argument('-v', '--only_verbose', help='only verbose', required=False, default='0', type=au.is_true) parser.add_argument('-d', '--default_folders', help='default options', required=False, default='1', type=au.is_true) parser.add_argument('-f', '--function', help='functions to run', required=False, default='all', type=au.str_arr_type) parser.add_argument('--links_file_name', help='', required=False, default='links.csv') parser.add_argument('--overwrite_links', help='', required=False, default=0, type=au.is_true) args = utils.Bag(au.parse_parser(parser)) main(args)