Skip to content

Commit

Permalink
ENH: Parse kwargs to allow no T1w
Browse files Browse the repository at this point in the history
Also, adds a default to the expected kwarg `anat_only` to allow bare initialization
  • Loading branch information
mgxd committed Jan 9, 2025
1 parent 2ec6b23 commit 343cdb3
Showing 1 changed file with 10 additions and 2 deletions.
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
"""

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

0 comments on commit 343cdb3

Please sign in to comment.