-
Notifications
You must be signed in to change notification settings - Fork 262
ENH: Update NIfTI header dimensions for CIFTI-2 compliance #929
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #929 +/- ##
==========================================
- Coverage 91.85% 91.71% -0.14%
==========================================
Files 96 96
Lines 12347 12352 +5
Branches 2176 2176
==========================================
- Hits 11341 11329 -12
- Misses 675 686 +11
- Partials 331 337 +6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also explain what we're doing in the docstring. Quoting the bit of spec that requires this would probably make sense.
I would also consider this a bug-fix, not an enhancement.
@@ -1484,8 +1485,14 @@ def update_headers(self): | |||
>>> img.update_headers() | |||
>>> img.nifti_header.get_data_shape() == (2, 3, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> img.nifti_header.get_data_shape() == (2, 3, 4) | |
>>> img.nifti_header.get_data_shape() == (1, 1, 1, 1, 2, 3, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks the current API, is that fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what sense? Does it change img.shape
? If so, we should divorce Cifti2Image.shape
from Cifti2Image.nifti_header.get_data_shape()
.
self._nifti_header.set_data_shape(self._dataobj.shape) | ||
_dims = np.ones((8), dtype=int) | ||
_dims[0] = 7 if len(self._dataobj.shape) == 3 else 6 | ||
_dims[5:8] = (self._dataobj.shape + (1,))[:3] | ||
self._nifti_header['dim'] = _dims |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the input to set_data_shape()
ought to do the trick.
self._nifti_header.set_data_shape(self._dataobj.shape) | |
_dims = np.ones((8), dtype=int) | |
_dims[0] = 7 if len(self._dataobj.shape) == 3 else 6 | |
_dims[5:8] = (self._dataobj.shape + (1,))[:3] | |
self._nifti_header['dim'] = _dims | |
self._nifti_header.set_data_shape((1, 1, 1, 1) + self._dataobj.shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't equivalent though? dim
[0] should be either 6 or 7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dim0
indicates the length of dim[1:8]
. This wlll be determined by this tuple.
Closing in favor of #930, which targets |
Updates the
CiftiImage.update_headers()
method to configure the NIfTI header'sdim
to CIFTI-2 standards brought up in nipreps/fmriprep#2205