Skip to content

Commit 9a67e76

Browse files
committed
Merge pull request #364 from bcipolli/filebasedimage
RF: Move load/save logic out of SpatialImage into FileBasedImage Prepares for XML-based images that do not store data as binary arrays. Spatial{Image,Header} now subclass FileBased{Image,Header} Header is a deprecated alias for SpatialHeader
2 parents 63f9ef2 + 975495e commit 9a67e76

11 files changed

+615
-384
lines changed

doc/source/old/examples.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ and we have made a temporary directory for the files we are going to write:
3232
and we've got the path to the nifti example data:
3333

3434
>>> from nibabel.testing import data_path as example_data_path
35-
35+
3636
Loading and saving NIfTI files
3737
==============================
3838

@@ -77,7 +77,7 @@ The relevant header information is extracted from the NumPy array. If you
7777
query the header information about the dimensionality of the image, it returns
7878
the desired values:
7979

80-
>>> print nim.get_header()['dim']
80+
>>> print nim.header['dim']
8181
[ 4 32 32 16 100 1 1 1]
8282

8383
First value shows the number of dimensions in the datset: 4 (good, that's what
@@ -110,8 +110,8 @@ preserving as much header information as possible
110110

111111
>>> nim2 = nib.Nifti1Image(nim.get_data()[..., :10],
112112
... nim.get_affine(),
113-
... nim.get_header())
114-
>>> print nim2.get_header()['dim']
113+
... nim.header)
114+
>>> print nim2.header['dim']
115115
[ 4 32 32 16 10 1 1 1]
116116
>>> # a filename in our temporary directory
117117
>>> fname = pjoin(tmpdir, 'part.hdr.gz')
@@ -136,7 +136,7 @@ will first create a NIfTI image with just a single voxel and 50 timepoints
136136
>>> nim = nib.Nifti1Image(
137137
... (np.linspace(0,100) + np.random.randn(50)).reshape(1,1,1,50),
138138
... np.eye(4))
139-
>>> print nim.get_header()['dim']
139+
>>> print nim.header['dim']
140140
[ 4 1 1 1 50 1 1 1]
141141

142142
Depending on the datatype of the input image the detrending process might
@@ -154,4 +154,4 @@ source image.
154154

155155
>>> nim_detrended = nib.Nifti1Image(data_detrended,
156156
... nim.get_affine(),
157-
... nim.get_header())
157+
... nim.header)

doc/source/old/orientation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Every image in ``nibabel`` has an orientation. The orientation is the
88
relationship between the voxels in the image array, and millimeters in
9-
some space.
9+
some space.
1010

1111
Affines as orientation
1212
----------------------
@@ -85,7 +85,7 @@ the affine after loading, as in::
8585
img = nibabel.load('some_image.img')
8686
aff = img.get_affine()
8787
x_flipper = np.diag([-1,1,1,1])
88-
lr_img = nibabel.Nifti1Image(img.get_data, np.dot(x_flipper, aff), img.get_header())
88+
lr_img = nibabel.Nifti1Image(img.get_data, np.dot(x_flipper, aff), img.header)
8989

9090
Affines for Analyze, SPM analyze, and NIFTI
9191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

nibabel/ecat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def to_file_map(self, file_map=None):
929929
# It appears to be necessary to load the data before saving even if the
930930
# data itself is not used.
931931
self.get_data()
932-
hdr = self.get_header()
932+
hdr = self.header
933933
mlist = self._mlist
934934
subheaders = self.get_subheaders()
935935
dir_pos = 512
@@ -944,7 +944,7 @@ def to_file_map(self, file_map=None):
944944
hdr.write_to(hdrf)
945945

946946
# Write every frames
947-
for index in range(0, self.get_header()['num_frames']):
947+
for index in range(0, self.header['num_frames']):
948948
# Move to subheader offset
949949
frame_offset = subheaders._get_frame_offset(index) - 512
950950
imgf.seek(frame_offset)

0 commit comments

Comments
 (0)