Skip to content

Commit 7337fb1

Browse files
authored
Merge pull request #922 from mgxd/fix/t2w-only-bidsdatagrabber
ENH: Parse kwargs to allow no T1w
2 parents 2ec6b23 + 83b887e commit 7337fb1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

niworkflows/interfaces/bids.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ class BIDSDataGrabber(SimpleInterface):
265265
_require_funcs = True
266266

267267
def __init__(self, *args, **kwargs):
268-
anat_only = kwargs.pop('anat_only')
268+
anat_only = kwargs.pop('anat_only', None)
269269
anat_derivatives = kwargs.pop('anat_derivatives', None)
270+
require_t1w = kwargs.pop('require_t1w', True)
270271
super().__init__(*args, **kwargs)
271272
if anat_only is not None:
272273
self._require_funcs = not anat_only
273-
self._require_t1w = anat_derivatives is None
274+
self._require_t1w = require_t1w and anat_derivatives is None
274275

275276
def _run_interface(self, runtime):
276277
bids_dict = self.inputs.subject_data

niworkflows/interfaces/tests/test_bids.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,3 +793,16 @@ def test_fsdir_min_version(tmp_path, min_version):
793793
assert not patched_subject_dir.exists()
794794
else:
795795
assert patched_subject_dir.exists()
796+
797+
798+
def test_BIDSDataGrabber():
799+
x = bintfs.BIDSDataGrabber(anat_only=True)
800+
assert x._require_t1w is True
801+
assert x._require_funcs is False
802+
803+
x = bintfs.BIDSDataGrabber(anat_only=False, require_t1w=False)
804+
assert x._require_t1w is False
805+
assert x._require_funcs is True
806+
807+
x = bintfs.BIDSDataGrabber(anat_derivatives='derivatives')
808+
assert x._require_t1w is False

0 commit comments

Comments
 (0)