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
Changes from 1 commit
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
12 changes: 10 additions & 2 deletions niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,24 +253,32 @@ class BIDSDataGrabber(SimpleInterface):
>>> bids_src.inputs.subject_data = bids_collect_data(
... str(datadir / 'ds114'), '01', bids_validate=False)[0]
>>> bids_src.inputs.subject_id = '01'
>>> bids_src._require_t1w
True
>>> bids_src._require_funcs
True
>>> res = bids_src.run()
>>> res.outputs.t1w # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
['.../ds114/sub-01/ses-retest/anat/sub-01_ses-retest_T1w.nii.gz',
'.../ds114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz']

>>> bids_src = BIDSDataGrabber(require_t1w=False)
>>> bids_src._require_t1w
False
mgxd marked this conversation as resolved.
Show resolved Hide resolved
"""

input_spec = _BIDSDataGrabberInputSpec
output_spec = _BIDSDataGrabberOutputSpec
_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
Loading