Skip to content

Commit

Permalink
Implemented a --force option to automatically ignore previous RABIES …
Browse files Browse the repository at this point in the history
…outputs.
  • Loading branch information
Gab-D-G committed Sep 25, 2023
1 parent 32f3461 commit a7262d7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
8 changes: 8 additions & 0 deletions rabies/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions rabies/run_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions scripts/debug_workflow.py
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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)
'''

0 comments on commit a7262d7

Please sign in to comment.