diff --git a/rabies/parser.py b/rabies/parser.py index c24088e..d080b4b 100644 --- a/rabies/parser.py +++ b/rabies/parser.py @@ -156,6 +156,14 @@ def get_parser(): "(default: %(default)s)\n" "\n" ) + g_execution.add_argument( + "-f", "--force", dest='force', action='store_true', + help= + "The pipeline will not stop if previous outputs are encountered. \n" + "Previous outputs will be overwritten.\n" + "(default: %(default)s)\n" + "\n" + ) ####Preprocessing diff --git a/rabies/run_main.py b/rabies/run_main.py index 505aed7..7c83b78 100644 --- a/rabies/run_main.py +++ b/rabies/run_main.py @@ -79,12 +79,13 @@ def execute_workflow(args=None): def prep_logging(opts, output_folder): cli_file = f'{output_folder}/rabies_{opts.rabies_stage}.pkl' - if os.path.isfile(cli_file): + if os.path.isfile(cli_file) and not opts.force: raise ValueError(f""" A previous run was indicated by the presence of {cli_file}. This can lead to inconsistencies between previous outputs and the log files. - To prevent this, you are required to manually remove {cli_file}, and we - recommend also removing previous datasinks from the {opts.rabies_stage} RABIES step. + To prevent this, we recommend removing previous datasinks from the {opts.rabies_stage} + RABIES stage. To continue with your execution, the {cli_file} file must be + removed (use --force to automatically do so). """) # remove old versions of the log if already existing diff --git a/scripts/debug_workflow.py b/scripts/debug_workflow.py index 24431c4..4cbc3dd 100644 --- a/scripts/debug_workflow.py +++ b/scripts/debug_workflow.py @@ -1,24 +1,27 @@ #! /usr/bin/env python from rabies.utils import generate_token_data +from rabies.run_main import execute_workflow import tempfile tmppath = tempfile.mkdtemp() #### increase the number of scans generated to 3 if running group analysis -generate_token_data(tmppath, number_scans=1) +generate_token_data(tmppath, number_scans=3) output_folder = f'{tmppath}/outputs' #### HERE ARE SET THE DESIRED PARAMETERS FOR PREPROCESSING args = [ + f'--exclusion_ids',f'{tmppath}/inputs/sub-token1_bold.nii.gz', + '-f', #'--debug', 'preprocess', f'{tmppath}/inputs', output_folder, '--anat_inho_cor', 'method=disable,otsu_thresh=2,multiotsu=false', '--bold_inho_cor', 'method=disable,otsu_thresh=2,multiotsu=false', '--bold2anat_coreg', 'registration=no_reg,masking=false,brain_extraction=false', '--commonspace_reg', 'masking=false,brain_extraction=false,fast_commonspace=true,template_registration=no_reg', - '--data_type', 'int16', '--bold_only', + '--data_type', 'int16', '--anat_template', f'{tmppath}/inputs/sub-token1_T1w.nii.gz', '--brain_mask', f'{tmppath}/inputs/token_mask.nii.gz', '--WM_mask', f'{tmppath}/inputs/token_mask.nii.gz', @@ -27,5 +30,27 @@ '--labels', f'{tmppath}/inputs/token_mask.nii.gz', ] -from rabies.run_main import execute_workflow execute_workflow(args=args) + + + +''' + +args = [ + f'--exclusion_ids',f'{tmppath}/inputs/sub-token1_bold.nii.gz',f'{tmppath}/inputs/sub-token2_bold.nii.gz', + '-f', + 'confound_correction', output_folder, output_folder, + '--nativespace_analysis', + ] +execute_workflow(args=args) + + +args = [ + f'--exclusion_ids',f'{tmppath}/inputs/sub-token3_bold.nii.gz', + '-f', + 'analysis', output_folder, output_folder, + '--data_diagnosis' + ] +execute_workflow(args=args) + +'''