def make_workflow_from_user_options(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type = 'defacing' user_dir, id_list, images_for_id, defaced_name, mri_name, render_name \ = check_inputs_defacing(user_args.user_dir, user_args.defaced_name, user_args.mri_name, user_args.render_name, user_args.id_list) out_dir = check_out_dir(user_args.out_dir, user_dir) wf = RatingWorkflowDefacing(id_list, images_for_id, user_dir, out_dir, defaced_name, mri_name, render_name, cfg.defacing_default_issue_list, vis_type) return wf
def make_workflow_from_user_options(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type = 'func_mri' type_of_features = 'func_mri' if user_args.bids_dir is not None and user_args.user_dir is None: in_dir, in_dir_type = check_bids_dir(user_args.bids_dir) id_list = None name_pattern = None images_for_id = None elif user_args.bids_dir is None and user_args.user_dir is not None: name_pattern = user_args.name_pattern in_dir = realpath(user_args.user_dir) in_dir_type = 'generic' id_list, images_for_id = check_id_list_with_regex(user_args.id_list, in_dir, name_pattern) else: raise ValueError('Invalid args: specify only one of bids_dir or user_dir, not both.') out_dir = check_out_dir(user_args.out_dir, in_dir) no_preproc = user_args.no_preproc views = check_views(user_args.views) num_slices_per_view, num_rows_per_view = check_finite_int(user_args.num_slices, user_args.num_rows) outlier_method, outlier_fraction, \ outlier_feat_types, disable_outlier_detection = check_outlier_params( user_args.outlier_method, user_args.outlier_fraction, user_args.outlier_feat_types, user_args.disable_outlier_detection, id_list, vis_type, type_of_features) wf = FmriRatingWorkflow(in_dir, out_dir, id_list=id_list, images_for_id=images_for_id, issue_list=cfg.func_mri_default_issue_list, name_pattern=name_pattern, in_dir_type=in_dir_type, no_preproc=no_preproc, outlier_method=outlier_method, outlier_fraction=outlier_fraction, outlier_feat_types=outlier_feat_types, disable_outlier_detection=disable_outlier_detection, prepare_first=user_args.prepare_first, vis_type=vis_type, views=views, num_slices_per_view=num_slices_per_view, num_rows_per_view=num_rows_per_view) return wf
def parse_user_args(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) # TODO methods to restore from previous runs, without having re-enter all parameters vis_type, label_set = check_labels(user_args.vis_type, user_args.labels) in_dir, source_of_features = check_input_dir(user_args.fs_dir, user_args.user_dir, vis_type) mri_name = user_args.mri_name seg_name = user_args.seg_name id_list, images_for_id = check_id_list(user_args.id_list, in_dir, vis_type, mri_name, seg_name) out_dir = check_out_dir(user_args.out_dir, in_dir) alpha_set = check_alpha_set(user_args.alpha_set) views = check_views(user_args.views) num_slices, num_rows = check_finite_int(user_args.num_slices, user_args.num_rows) contour_color = user_args.contour_color if not is_color_like(contour_color): raise ValueError( 'Specified color is not valid. Choose a valid spec from\n https://matplotlib.org/users/colors.html' ) outlier_method, outlier_fraction, outlier_feat_types, no_outlier_detection = check_outlier_params( user_args.outlier_method, user_args.outlier_fraction, user_args.outlier_feat_types, user_args.disable_outlier_detection, id_list, vis_type, source_of_features) qcw = QCWorkflow(in_dir, id_list, images_for_id, out_dir, user_args.prepare_first, vis_type, source_of_features, label_set, alpha_set, outlier_method, outlier_fraction, outlier_feat_types, no_outlier_detection, views, num_slices, num_rows, mri_name, seg_name, contour_color) # if the workflow could be instantiated, it means things are in order! qcw.save_cmd() return qcw
def make_workflow_from_user_options(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type = 'collage_t1_mri' type_of_features = 't1_mri' in_dir, in_dir_type = check_input_dir_T1(user_args.fs_dir, user_args.user_dir, user_args.bids_dir) if in_dir_type.upper() in ('BIDS', ): mri_name = None in_dir, bids_dir_type = check_bids_dir(in_dir) id_list, images_for_id = find_anatomical_images_in_BIDS(in_dir) else: mri_name = user_args.mri_name id_list, images_for_id = check_id_list(user_args.id_list, in_dir, vis_type, mri_name, seg_name=None, in_dir_type=in_dir_type) out_dir = check_out_dir(user_args.out_dir, in_dir) views = check_views(user_args.views) num_slices_per_view, num_rows_per_view = check_finite_int(user_args.num_slices, user_args.num_rows) outlier_method, outlier_fraction, \ outlier_feat_types, disable_outlier_detection = check_outlier_params( user_args.outlier_method, user_args.outlier_fraction, user_args.outlier_feat_types, user_args.disable_outlier_detection, id_list, vis_type, type_of_features) wf = RatingWorkflowT1(id_list, in_dir, out_dir, cfg.t1_mri_default_issue_list, mri_name, in_dir_type, images_for_id, outlier_method, outlier_fraction, outlier_feat_types, disable_outlier_detection, user_args.prepare_first, vis_type, views, num_slices_per_view, num_rows_per_view) return wf
def parse_args(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type, label_set = check_labels(user_args.vis_type, user_args.labels) in_dir = check_input_dir(user_args.fs_dir, user_args.user_dir, vis_type) mri_name = user_args.mri_name seg_name = user_args.seg_name id_list = check_id_list(user_args.id_list, in_dir, vis_type, mri_name, seg_name) out_dir = check_out_dir(user_args.out_dir, in_dir) alpha_set = check_alpha_set(user_args.alpha_set) views = check_views(user_args.views) num_slices, num_rows = check_finite_int(user_args.num_slices, user_args.num_rows) contour_color = user_args.contour_color if not is_color_like(contour_color): raise ValueError( 'Specified color is not valid. Choose a valid spec from\n https://matplotlib.org/users/colors.html' ) return in_dir, id_list, out_dir, vis_type, label_set, \ alpha_set, views, num_slices, num_rows, mri_name, seg_name, contour_color
def make_workflow_from_user_options(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type, label_set = check_labels(user_args.vis_type, user_args.label_set) in_dir, source_of_features = check_input_dir( user_args.fs_dir, None, vis_type, freesurfer_install_required=False) mri_name = user_args.mri_name seg_name = user_args.seg_name id_list, images_for_id = check_id_list(user_args.id_list, in_dir, vis_type, mri_name, seg_name) out_dir = check_out_dir(user_args.out_dir, in_dir) alpha_set = check_alpha_set(user_args.alpha_set) views = check_views(user_args.views) num_slices, num_rows = check_finite_int(user_args.num_slices, user_args.num_rows) contour_color = user_args.contour_color if not is_color_like(contour_color): raise ValueError( 'Specified color is not valid. Choose a valid spec from\n' ' https://matplotlib.org/users/colors.html') outlier_method, outlier_fraction, outlier_feat_types, disable_outlier_detection = \ check_outlier_params(user_args.outlier_method, user_args.outlier_fraction, user_args.outlier_feat_types, user_args.disable_outlier_detection, id_list, vis_type, source_of_features) wf = FreesurferRatingWorkflow( id_list, images_for_id, in_dir, out_dir, vis_type=vis_type, label_set=label_set, issue_list=cfg.default_rating_list, mri_name=mri_name, seg_name=seg_name, alpha_set=alpha_set, outlier_method=outlier_method, outlier_fraction=outlier_fraction, outlier_feat_types=outlier_feat_types, disable_outlier_detection=disable_outlier_detection, source_of_features=source_of_features, no_surface_vis=user_args.no_surface_vis, views=views, num_slices_per_view=num_slices, num_rows_per_view=num_rows) return wf
def make_workflow_from_user_options(): """Parser/validator for the cmd line args.""" parser = get_parser() if len(sys.argv) < 2: print('Too few arguments!') parser.print_help() parser.exit(1) # parsing try: user_args = parser.parse_args() except: parser.exit(1) vis_type = cfg.alignment_default_vis_type type_of_features = 'alignment' in_dir, in_dir_type = check_input_dir_alignment(user_args.in_dir) image1 = user_args.image1 image2 = user_args.image2 id_list, images_for_id = check_id_list(user_args.id_list, in_dir, vis_type, image1, image2, in_dir_type=in_dir_type) delay_in_animation = check_time(user_args.delay_in_animation, var_name='Delay') out_dir = check_out_dir(user_args.out_dir, in_dir) views = check_views(user_args.views) num_slices_per_view, num_rows_per_view = check_finite_int( user_args.num_slices, user_args.num_rows) outlier_method, outlier_fraction, \ outlier_feat_types, disable_outlier_detection = check_outlier_params( user_args.outlier_method, user_args.outlier_fraction, user_args.outlier_feat_types, user_args.disable_outlier_detection, id_list, vis_type, type_of_features) wf = AlignmentRatingWorkflow( id_list, in_dir, image1, image2, out_dir=out_dir, in_dir_type=in_dir_type, prepare_first=user_args.prepare_first, vis_type=vis_type, delay_in_animation=delay_in_animation, outlier_method=outlier_method, outlier_fraction=outlier_fraction, outlier_feat_types=outlier_feat_types, disable_outlier_detection=disable_outlier_detection, views=views, num_slices_per_view=num_slices_per_view, num_rows_per_view=num_rows_per_view) return wf