Skip to content

Commit 317828f

Browse files
authored
Fix handling of --ignore parameter (#953)
* Apply ignore fields to subj_data. * Remove sbref and flair fields. * Fix. * Update test_cli_run.py
1 parent c74ff2f commit 317828f

9 files changed

Lines changed: 23 additions & 17 deletions

File tree

docs/preprocessing.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ of the file you will send to ``--bids-filter-file``. The queries in *QSIPrep* ar
8181

8282
{
8383
"fmap": {"datatype": "fmap"},
84-
"sbref": {"datatype": "func", "suffix": "sbref"},
85-
"flair": {"datatype": "anat", "suffix": "FLAIR"},
8684
"t2w": {"datatype": "anat", "suffix": "T2w"},
8785
"t1w": {"datatype": "anat", "suffix": "T1w"},
8886
"roi": {"datatype": "anat", "suffix": "roi"},

qsiprep/cli/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _bids_filter(value, parser):
315315
action='store',
316316
nargs='+',
317317
default=[],
318-
choices=['fieldmaps', 'sbref', 't2w', 'flair', 'fmap-jacobian', 'phase'],
318+
choices=['fieldmaps', 't2w', 'phase'],
319319
help='Ignore selected aspects of the input dataset to disable corresponding '
320320
'parts of the workflow (a space delimited list)',
321321
)

qsiprep/interfaces/bids.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,9 @@ class BIDSDataGrabberInputSpec(BaseInterfaceInputSpec):
137137
class BIDSDataGrabberOutputSpec(TraitedSpec):
138138
out_dict = traits.Dict(desc='output data structure')
139139
fmap = OutputMultiPath(desc='output fieldmaps')
140-
bold = OutputMultiPath(desc='output functional images')
141-
sbref = OutputMultiPath(desc='output sbrefs')
142140
t1w = OutputMultiPath(desc='output T1w images')
143141
roi = OutputMultiPath(desc='output ROI images')
144142
t2w = OutputMultiPath(desc='output T2w images')
145-
flair = OutputMultiPath(desc='output FLAIR images')
146143
dwi = OutputMultiPath(desc='output DWI images')
147144

148145

@@ -213,7 +210,7 @@ def _run_interface(self, runtime):
213210
f'No DWI images found for subject sub-{self.inputs.subject_id}'
214211
)
215212

216-
for imtype in ['flair', 'fmap', 'sbref', 'roi', 'dwi']:
213+
for imtype in ['fmap', 'roi', 'dwi']:
217214
if not bids_dict[imtype]:
218215
LOGGER.warning("No '%s' images found for sub-%s", imtype, self.inputs.subject_id)
219216

qsiprep/tests/test_cli_run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def test_collect_data(tmpdir, name, skeleton, sessions, n_anats):
215215
session_id=sessions[0],
216216
filters=None,
217217
bids_validate=False,
218+
ignore=[],
218219
)[0]
219220
assert len(subj_data['t1w']) == n_anats[0], pprint.pformat(subj_data)
220221

@@ -224,6 +225,7 @@ def test_collect_data(tmpdir, name, skeleton, sessions, n_anats):
224225
session_id=sessions[1],
225226
filters=None,
226227
bids_validate=False,
228+
ignore=[],
227229
)[0]
228230
assert len(subj_data['t1w']) == n_anats[1], pprint.pformat(subj_data)
229231

@@ -233,5 +235,7 @@ def test_collect_data(tmpdir, name, skeleton, sessions, n_anats):
233235
session_id=sessions,
234236
filters=None,
235237
bids_validate=False,
238+
ignore=['t2w'],
236239
)[0]
237240
assert len(subj_data['t1w']) == n_anats[2], pprint.pformat(subj_data)
241+
assert len(subj_data['t2w']) == 0, pprint.pformat(subj_data)

qsiprep/utils/bids.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,14 @@ def collect_participants(bids_dir, participant_label=None, strict=False, bids_va
188188
return found_label
189189

190190

191-
def collect_data(bids_dir, participant_label, session_id=None, filters=None, bids_validate=True):
191+
def collect_data(
192+
bids_dir,
193+
participant_label,
194+
session_id=None,
195+
filters=None,
196+
bids_validate=True,
197+
ignore=None,
198+
):
192199
"""Use pybids to retrieve the input data for a given participant."""
193200
import yaml
194201

@@ -197,10 +204,11 @@ def collect_data(bids_dir, participant_label, session_id=None, filters=None, bid
197204
else:
198205
layout = BIDSLayout(str(bids_dir), validate=bids_validate)
199206

207+
# Coerce to list
208+
ignore = ignore or []
209+
200210
queries = {
201211
'fmap': {'datatype': 'fmap'},
202-
'sbref': {'datatype': 'func', 'suffix': 'sbref'},
203-
'flair': {'datatype': 'anat', 'suffix': 'FLAIR'},
204212
't2w': {'datatype': 'anat', 'suffix': 'T2w'},
205213
't1w': {'datatype': 'anat', 'suffix': 'T1w'},
206214
'roi': {'datatype': 'anat', 'suffix': 'roi'},
@@ -229,6 +237,10 @@ def collect_data(bids_dir, participant_label, session_id=None, filters=None, bid
229237
)
230238
for dtype, query in queries.items()
231239
}
240+
# Remove data types that are in the ignore list (this will catch t2w)
241+
for dtype in subj_data.keys():
242+
if dtype in ignore:
243+
subj_data[dtype] = []
232244

233245
config.loggers.workflow.log(
234246
25,

qsiprep/workflows/anatomical/volume.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ def init_anat_preproc_wf(
106106
List of T1-weighted structural images
107107
t2w
108108
List of T2-weighted structural images
109-
flair
110-
List of FLAIR images
111109
roi
112110
A mask to exclude regions during standardization (as list)
113111
subjects_dir
@@ -143,7 +141,7 @@ def init_anat_preproc_wf(
143141
workflow = Workflow(name=name)
144142
inputnode = pe.Node(
145143
niu.IdentityInterface(
146-
fields=['t1w', 't2w', 'roi', 'flair', 'subjects_dir', 'subject_id'],
144+
fields=['t1w', 't2w', 'roi', 'subjects_dir', 'subject_id'],
147145
),
148146
name='inputnode',
149147
)

qsiprep/workflows/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def init_single_subject_wf(subject_id: str, session_ids: list):
139139
session_id=session_ids,
140140
filters=config.execution.bids_filters,
141141
bids_validate=False,
142+
ignore=config.workflow.ignore,
142143
)[0]
143144

144145
# Make sure we always go through these two checks
@@ -290,7 +291,6 @@ def init_single_subject_wf(subject_id: str, session_ids: list):
290291
('t1w', 'inputnode.t1w'),
291292
('t2w', 'inputnode.t2w'),
292293
('roi', 'inputnode.roi'),
293-
('flair', 'inputnode.flair'),
294294
]),
295295
(summary, anat_preproc_wf, [('subject_id', 'inputnode.subject_id')]),
296296
(bidssrc, ds_report_summary, [

qsiprep/workflows/dwi/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ def init_dwi_preproc_wf(
183183
niu.IdentityInterface(
184184
fields=[
185185
'dwi_files',
186-
'sbref_file',
187186
'subjects_dir',
188187
'subject_id',
189188
't1_preproc',
@@ -218,7 +217,6 @@ def init_dwi_preproc_wf(
218217
'dwi_mask',
219218
'hmc_xforms',
220219
'fieldwarps',
221-
'sbref_file',
222220
'original_files',
223221
'original_bvecs',
224222
'raw_qc_file',

qsiprep/workflows/dwi/finalize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def init_dwi_finalize_wf(
186186
'hmc_xforms',
187187
'fieldwarps',
188188
'output_grid',
189-
'sbref_file',
190189
'subjects_dir',
191190
'subject_id',
192191
't1_preproc',

0 commit comments

Comments
 (0)