-
Notifications
You must be signed in to change notification settings - Fork 265
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ | |||||||||||||
import re | ||||||||||||||
from collections.abc import MutableSequence, MutableMapping, Iterable | ||||||||||||||
from collections import OrderedDict | ||||||||||||||
import numpy as np | ||||||||||||||
from .. import xmlutils as xml | ||||||||||||||
from ..filebasedimages import FileBasedHeader | ||||||||||||||
from ..dataobj_images import DataobjImage | ||||||||||||||
|
@@ -1484,8 +1485,14 @@ def update_headers(self): | |||||||||||||
>>> img.update_headers() | ||||||||||||||
>>> img.nifti_header.get_data_shape() == (2, 3, 4) | ||||||||||||||
True | ||||||||||||||
>>> np.array_equal(img.nifti_header['dim'], [7, 1, 1, 1, 1, 2, 3, 4]) | ||||||||||||||
True | ||||||||||||||
""" | ||||||||||||||
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 | ||||||||||||||
Comment on lines
1491
to
+1495
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating the input to
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't equivalent though? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
|
||||||||||||||
def get_data_dtype(self): | ||||||||||||||
return self._nifti_header.get_data_dtype() | ||||||||||||||
|
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.
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 divorceCifti2Image.shape
fromCifti2Image.nifti_header.get_data_shape()
.