Skip to content

Commit 81bf8f5

Browse files
authored
Merge pull request #833 from nipreps/fix/bids-collect-data-dwi
FIX: Add DWI to the default queries of BIDS querying
2 parents 16ccaa9 + 7ddadd5 commit 81bf8f5

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

niworkflows/interfaces/bids.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class _BIDSDataGrabberOutputSpec(TraitedSpec):
226226
t2w = OutputMultiObject(desc="output T2w images")
227227
flair = OutputMultiObject(desc="output FLAIR images")
228228
pet = OutputMultiObject(desc="output PET images")
229+
dwi = OutputMultiObject(desc="output DWI images")
229230

230231

231232
class BIDSDataGrabber(SimpleInterface):

niworkflows/utils/bids.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
from packaging.version import Version
3131

3232

33+
DEFAULT_BIDS_QUERIES = {
34+
"bold": {"datatype": "func", "suffix": "bold", "part": ["mag", None]},
35+
"dwi": {"suffix": "dwi"},
36+
"flair": {"datatype": "anat", "suffix": "FLAIR", "part": ["mag", None]},
37+
"fmap": {"datatype": "fmap"},
38+
"pet": {"suffix": "pet"},
39+
"roi": {"datatype": "anat", "suffix": "roi"},
40+
"sbref": {"datatype": "func", "suffix": "sbref", "part": ["mag", None]},
41+
"t1w": {"datatype": "anat", "suffix": "T1w", "part": ["mag", None]},
42+
"t2w": {"datatype": "anat", "suffix": "T2w", "part": ["mag", None]},
43+
}
44+
45+
3346
class BIDSError(ValueError):
3447
def __init__(self, message, bids_root):
3548
indent = 10
@@ -151,11 +164,13 @@ def collect_participants(
151164
def collect_data(
152165
bids_dir,
153166
participant_label,
154-
session_id=Query.OPTIONAL,
167+
session_id=None,
155168
task=None,
156169
echo=None,
170+
group_echos=True,
157171
bids_validate=True,
158172
bids_filters=None,
173+
queries=None,
159174
):
160175
"""
161176
Uses pybids to retrieve the input data for a given participant
@@ -223,19 +238,10 @@ def collect_data(
223238
'return_type': 'file',
224239
'subject': participant_label,
225240
'extension': ['.nii', '.nii.gz'],
226-
'session': session_id,
241+
'session': session_id or Query.OPTIONAL,
227242
}
228243

229-
queries = {
230-
"fmap": {"datatype": "fmap"},
231-
"bold": {"datatype": "func", "suffix": "bold", "part": ["mag", None]},
232-
"sbref": {"datatype": "func", "suffix": "sbref", "part": ["mag", None]},
233-
"flair": {"datatype": "anat", "suffix": "FLAIR", "part": ["mag", None]},
234-
"t2w": {"datatype": "anat", "suffix": "T2w", "part": ["mag", None]},
235-
"t1w": {"datatype": "anat", "suffix": "T1w", "part": ["mag", None]},
236-
"roi": {"datatype": "anat", "suffix": "roi"},
237-
"pet": {"suffix": "pet"}
238-
}
244+
queries = queries or DEFAULT_BIDS_QUERIES
239245
bids_filters = bids_filters or {}
240246
for acq, entities in bids_filters.items():
241247
queries[acq].update(entities)
@@ -256,7 +262,11 @@ def collect_data(
256262
}
257263

258264
# Special case: multi-echo BOLD, grouping echos
259-
if any(["_echo-" in bold for bold in subj_data["bold"]]):
265+
if (
266+
group_echos
267+
and "bold" in subj_data
268+
and any(["_echo-" in bold for bold in subj_data["bold"]])
269+
):
260270
subj_data["bold"] = group_multiecho(subj_data["bold"])
261271

262272
return subj_data, layout

0 commit comments

Comments
 (0)