Description
I have been trying to write out a dseg
-suffixed CIFTI file with the .dlabel.nii
extension with DerivativesDataSink
, but it raises the following exception:
Traceback:
Traceback (most recent call last):
File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 398, in run
runtime = self._run_interface(runtime)
File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/bids.py", line 712, in _run_interface
new_header.set_data_dtype(data_dtype)
AttributeError: 'Cifti2Header' object has no attribute 'set_data_dtype'
In the following section, DerivativesDataSink checks to see if an output file is a NIFTI by looking at the extension. However, it only counts .dtseries.nii[.gz]
files as CIFTIs, and assumes any other files ending in .nii[.gz]
are NIFTIs.
niworkflows/niworkflows/interfaces/bids.py
Lines 651 to 653 in 1555d2b
After that, DerivativesDataSink attempts to coerce the in_file's datatype to a target type for that suffix. However, this step only works for NIFTIs, so any CIFTIs mislabeled as NIFTIs above will cause an error.
I can't think of a great general-purpose solution, but two ideas I had were:
-
Hardcode the full list of CIFTI extensions in the check. The extensions might need to be updated from time to time though.
-
In the following section, check for a
nii.nifti_header
attribute, and set the datatype for that attribute instead ofnii.header
when it is present.niworkflows/niworkflows/interfaces/bids.py
Lines 697 to 712 in 1555d2b