Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Parse kwargs to allow no T1w #922

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading