diff --git a/docs/workflows.rst b/docs/workflows.rst index 4a3246bef..60ea69569 100644 --- a/docs/workflows.rst +++ b/docs/workflows.rst @@ -62,6 +62,7 @@ is presented below: use_aroma=False, use_bbr=True, use_syn=True, + bids_filters=None, ) T1w/T2w preprocessing diff --git a/fmriprep/cli/run.py b/fmriprep/cli/run.py index 70bc1f5a3..224b5d9ed 100755 --- a/fmriprep/cli/run.py +++ b/fmriprep/cli/run.py @@ -10,6 +10,7 @@ import gc import uuid import warnings +import json from argparse import ArgumentParser from argparse import ArgumentDefaultsHelpFormatter from multiprocessing import cpu_count @@ -76,6 +77,11 @@ def get_parser(): # Re-enable when option is actually implemented # g_bids.add_argument('-r', '--run-id', action='store', default='single_run', # help='select a specific run to be processed') + g_bids.add_argument( + '--bids-filter-file', action='store', type=Path, metavar='PATH', + help='a JSON file describing custom BIDS input filter using pybids ' + '{:{:,...},...} ' + '(https://github.com/bids-standard/pybids/blob/master/bids/layout/config/bids.json)') g_bids.add_argument('-t', '--task-id', action='store', help='select a specific task to be processed') g_bids.add_argument('--echo-idx', action='store', type=int, @@ -500,6 +506,7 @@ def build_workflow(opts, retval): bids_dir = opts.bids_dir.resolve() output_dir = opts.output_dir.resolve() work_dir = opts.work_dir.resolve() + bids_filters = json.loads(opts.bids_filter_file.read_text()) if opts.bids_filter_file else None if opts.clean_workdir: from niworkflows.utils.misc import clean_directory @@ -675,6 +682,7 @@ def build_workflow(opts, retval): use_bbr=opts.use_bbr, use_syn=opts.use_syn_sdc, work_dir=str(work_dir), + bids_filters=bids_filters, ) retval['return_code'] = 0 diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index 19d2bf628..c0ceb5ebf 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -67,12 +67,14 @@ def init_fmriprep_wf( use_bbr, use_syn, work_dir, + bids_filters, ): """ Build *fMRIPrep*'s pipeline. This workflow organizes the execution of FMRIPREP, with a sub-workflow for each subject. + If FreeSurfer's ``recon-all`` is to be run, a corresponding folder is created and populated with any needed template subjects under the derivatives folder. @@ -129,6 +131,7 @@ def init_fmriprep_wf( use_bbr=True, use_syn=True, work_dir='.', + bids_filters=None, ) @@ -213,6 +216,9 @@ def init_fmriprep_wf( If fieldmaps are present and enabled, this is not run, by default. work_dir : str Directory in which to store workflow execution state and temporary files + bids_filters : dict + Provides finer specification of the pipeline input files using pybids entities filters. + A dict with the following structure {:{:,...},...} """ fmriprep_wf = Workflow(name='fmriprep_wf') @@ -265,6 +271,7 @@ def init_fmriprep_wf( use_aroma=use_aroma, use_bbr=use_bbr, use_syn=use_syn, + bids_filters=bids_filters, ) single_subject_wf.config['execution']['crashdump_dir'] = ( @@ -316,6 +323,7 @@ def init_single_subject_wf( use_aroma, use_bbr, use_syn, + bids_filters, ): """ This workflow organizes the preprocessing pipeline for a single subject. @@ -377,6 +385,7 @@ def init_single_subject_wf( use_aroma=False, use_bbr=True, use_syn=True, + bids_filters=None, ) Parameters @@ -463,6 +472,9 @@ def init_single_subject_wf( use_syn : bool **Experimental**: Enable ANTs SyN-based susceptibility distortion correction (SDC). If fieldmaps are present and enabled, this is not run, by default. + bids_filters : dict + Provides finer specification of the pipeline input files using pybids entities filters. + A dict with the following structure {:{:,...},...} Inputs ------ @@ -477,7 +489,8 @@ def init_single_subject_wf( 'bold': ['/completely/made/up/path/sub-01_task-nback_bold.nii.gz'] } else: - subject_data = collect_data(layout, subject_id, task_id, echo_idx)[0] + subject_data = collect_data(layout, subject_id, task_id, echo_idx, + bids_filters=bids_filters)[0] # Make sure we always go through these two checks if not anat_only and subject_data['bold'] == []: diff --git a/setup.cfg b/setup.cfg index bfbeecc42..e9dd0d5e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,14 +24,14 @@ install_requires = nibabel >= 3.0.1 nipype >=1.3.1 nitime - niworkflows ~= 1.1.6 + niworkflows @ git+https://github.com/poldracklab/niworkflows.git@edeea81352f3f2b276f11e42e7829e1c5a03770f numpy pandas psutil >=5.4 pybids ~= 0.9.4 pyyaml sdcflows ~=1.1.0 - smriprep ~= 0.5.1 + smriprep @ git+https://github.com/poldracklab/smriprep.git@07a7ba3fce8a9953923bcd0fa6ffbffac401208d tedana >=0.0.5 templateflow ~= 0.4.2rc1 test_requires =