Skip to content

Commit

Permalink
Merge pull request #922 from mgxd/fix/t2w-only-bidsdatagrabber
Browse files Browse the repository at this point in the history
ENH: Parse kwargs to allow no T1w
  • Loading branch information
mgxd authored Jan 10, 2025
2 parents 2ec6b23 + 83b887e commit 7337fb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,13 @@ class BIDSDataGrabber(SimpleInterface):
_require_funcs = True

def __init__(self, *args, **kwargs):
anat_only = kwargs.pop('anat_only')
anat_only = kwargs.pop('anat_only', None)
anat_derivatives = kwargs.pop('anat_derivatives', None)
require_t1w = kwargs.pop('require_t1w', True)
super().__init__(*args, **kwargs)
if anat_only is not None:
self._require_funcs = not anat_only
self._require_t1w = anat_derivatives is None
self._require_t1w = require_t1w and anat_derivatives is None

def _run_interface(self, runtime):
bids_dict = self.inputs.subject_data
Expand Down
13 changes: 13 additions & 0 deletions niworkflows/interfaces/tests/test_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,16 @@ def test_fsdir_min_version(tmp_path, min_version):
assert not patched_subject_dir.exists()
else:
assert patched_subject_dir.exists()


def test_BIDSDataGrabber():
x = bintfs.BIDSDataGrabber(anat_only=True)
assert x._require_t1w is True
assert x._require_funcs is False

x = bintfs.BIDSDataGrabber(anat_only=False, require_t1w=False)
assert x._require_t1w is False
assert x._require_funcs is True

x = bintfs.BIDSDataGrabber(anat_derivatives='derivatives')
assert x._require_t1w is False

0 comments on commit 7337fb1

Please sign in to comment.