|
19 | 19 | import re
|
20 | 20 | from collections.abc import MutableSequence, MutableMapping, Iterable
|
21 | 21 | from collections import OrderedDict
|
22 |
| -import numpy as np |
23 | 22 | from .. import xmlutils as xml
|
24 | 23 | from ..filebasedimages import FileBasedHeader
|
25 | 24 | from ..dataobj_images import DataobjImage
|
@@ -1483,16 +1482,12 @@ def update_headers(self):
|
1483 | 1482 | >>> img.shape == (2, 3, 4)
|
1484 | 1483 | True
|
1485 | 1484 | >>> 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) |
1487 | 1486 | True
|
1488 |
| - >>> np.array_equal(img.nifti_header['dim'], [7, 1, 1, 1, 1, 2, 3, 4]) |
| 1487 | + >>> img.shape == (2, 3, 4) |
1489 | 1488 | True
|
1490 | 1489 | '''
|
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) |
1496 | 1491 |
|
1497 | 1492 | def get_data_dtype(self):
|
1498 | 1493 | return self._nifti_header.get_data_dtype()
|
|
0 commit comments