Skip to content

Commit ec67041

Browse files
committed
first quick attempt to add bids filters to further specify input
1 parent 243b227 commit ec67041

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

fmriprep/cli/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import gc
1414
import uuid
1515
import warnings
16+
import json
1617
from argparse import ArgumentParser
1718
from argparse import ArgumentDefaultsHelpFormatter
1819
from multiprocessing import cpu_count
@@ -81,6 +82,8 @@ def get_parser():
8182
# Re-enable when option is actually implemented
8283
# g_bids.add_argument('-r', '--run-id', action='store', default='single_run',
8384
# help='select a specific run to be processed')
85+
g_bids.add_argument('bids_filters', action='store', type=Path,
86+
help='the path to a JSON file describing custom BIDS input filter')
8487
g_bids.add_argument('-t', '--task-id', action='store',
8588
help='select a specific task to be processed')
8689
g_bids.add_argument('--echo-idx', action='store', type=int,
@@ -509,6 +512,7 @@ def build_workflow(opts, retval):
509512
from niworkflows.reports import generate_reports
510513
from ..__about__ import __version__
511514
from ..workflows.base import init_fmriprep_wf
515+
from nipype.interfaces.base import Undefined
512516

513517
build_log = nlogging.getLogger('nipype.workflow')
514518

@@ -522,6 +526,8 @@ def build_workflow(opts, retval):
522526
bids_dir = opts.bids_dir.resolve()
523527
output_dir = opts.output_dir.resolve()
524528
work_dir = opts.work_dir.resolve()
529+
bids_filters_file = opts.bids_filters.resolve()
530+
bids_filters = json.load(bids_filters_file) if bids_filters_file else Undefined
525531

526532
retval['return_code'] = 1
527533
retval['workflow'] = None
@@ -672,6 +678,7 @@ def build_workflow(opts, retval):
672678
use_bbr=opts.use_bbr,
673679
use_syn=opts.use_syn_sdc,
674680
work_dir=str(work_dir),
681+
bids_filters=bids_filters,
675682
)
676683
retval['return_code'] = 0
677684

fmriprep/workflows/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def init_fmriprep_wf(
6969
use_bbr,
7070
use_syn,
7171
work_dir,
72+
bids_filters,
7273
):
7374
"""
7475
This workflow organizes the execution of FMRIPREP, with a sub-workflow for
@@ -123,6 +124,7 @@ def init_fmriprep_wf(
123124
use_bbr=True,
124125
use_syn=True,
125126
work_dir='.',
127+
bids_filters=None,
126128
)
127129
128130
@@ -257,6 +259,7 @@ def init_fmriprep_wf(
257259
use_aroma=use_aroma,
258260
use_bbr=use_bbr,
259261
use_syn=use_syn,
262+
bids_filters=bids_filters,
260263
)
261264

262265
single_subject_wf.config['execution']['crashdump_dir'] = (
@@ -308,6 +311,7 @@ def init_single_subject_wf(
308311
use_aroma,
309312
use_bbr,
310313
use_syn,
314+
bids_filters,
311315
):
312316
"""
313317
This workflow organizes the preprocessing pipeline for a single subject.
@@ -363,6 +367,7 @@ def init_single_subject_wf(
363367
use_aroma=False,
364368
use_bbr=True,
365369
use_syn=True,
370+
bids_filters=None,
366371
)
367372
368373
@@ -449,7 +454,8 @@ def init_single_subject_wf(
449454
use_syn : bool
450455
**Experimental**: Enable ANTs SyN-based susceptibility distortion correction (SDC).
451456
If fieldmaps are present and enabled, this is not run, by default.
452-
457+
bids_filters : dict
458+
For BIDSDataGrabber output_query
453459
454460
Inputs
455461
@@ -517,7 +523,7 @@ def init_single_subject_wf(
517523
inputnode = pe.Node(niu.IdentityInterface(fields=['subjects_dir']),
518524
name='inputnode')
519525

520-
bidssrc = pe.Node(BIDSDataGrabber(subject_data=subject_data, anat_only=anat_only),
526+
bidssrc = pe.Node(BIDSDataGrabber(subject_data=subject_data, anat_only=anat_only, output_query=bids_filters),
521527
name='bidssrc')
522528

523529
bids_info = pe.Node(BIDSInfo(

0 commit comments

Comments
 (0)