Skip to content

Commit f2f6dc9

Browse files
committed
RF: Set NIfTI-2 header shape through API call
1 parent 582cdfa commit f2f6dc9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

nibabel/cifti2/cifti2.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import re
2020
from collections.abc import MutableSequence, MutableMapping, Iterable
2121
from collections import OrderedDict
22-
import numpy as np
2322
from .. import xmlutils as xml
2423
from ..filebasedimages import FileBasedHeader
2524
from ..dataobj_images import DataobjImage
@@ -1483,16 +1482,12 @@ def update_headers(self):
14831482
>>> img.shape == (2, 3, 4)
14841483
True
14851484
>>> img.update_headers()
1486-
>>> img.nifti_header.get_data_shape() == (2, 3, 4)
1485+
>>> img.nifti_header.get_data_shape() == (1, 1, 1, 1, 2, 3, 4)
14871486
True
1488-
>>> np.array_equal(img.nifti_header['dim'], [7, 1, 1, 1, 1, 2, 3, 4])
1487+
>>> img.shape == (2, 3, 4)
14891488
True
14901489
'''
1491-
self._nifti_header.set_data_shape(self._dataobj.shape)
1492-
_dims = np.ones((8), dtype=int)
1493-
_dims[0] = 7 if len(self._dataobj.shape) == 3 else 6
1494-
_dims[5:8] = (self._dataobj.shape + (1,))[:3]
1495-
self._nifti_header['dim'] = _dims
1490+
self._nifti_header.set_data_shape((1, 1, 1, 1) + self._dataobj.shape)
14961491

14971492
def get_data_dtype(self):
14981493
return self._nifti_header.get_data_dtype()

0 commit comments

Comments
 (0)