Skip to content

RF: move load/save logic out of SpatialImage #364

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

Merged
merged 10 commits into from
Oct 23, 2015
12 changes: 6 additions & 6 deletions doc/source/old/examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ and we have made a temporary directory for the files we are going to write:
and we've got the path to the nifti example data:

>>> from nibabel.testing import data_path as example_data_path

Loading and saving NIfTI files
==============================

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

>>> print nim.get_header()['dim']
>>> print nim.header['dim']
[ 4 32 32 16 100 1 1 1]

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

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

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

>>> nim_detrended = nib.Nifti1Image(data_detrended,
... nim.get_affine(),
... nim.get_header())
... nim.header)
4 changes: 2 additions & 2 deletions doc/source/old/orientation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Every image in ``nibabel`` has an orientation. The orientation is the
relationship between the voxels in the image array, and millimeters in
some space.
some space.

Affines as orientation
----------------------
Expand Down Expand Up @@ -85,7 +85,7 @@ the affine after loading, as in::
img = nibabel.load('some_image.img')
aff = img.get_affine()
x_flipper = np.diag([-1,1,1,1])
lr_img = nibabel.Nifti1Image(img.get_data, np.dot(x_flipper, aff), img.get_header())
lr_img = nibabel.Nifti1Image(img.get_data, np.dot(x_flipper, aff), img.header)

Affines for Analyze, SPM analyze, and NIFTI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions nibabel/ecat.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def to_file_map(self, file_map=None):
# It appears to be necessary to load the data before saving even if the
# data itself is not used.
self.get_data()
hdr = self.get_header()
hdr = self.header
mlist = self._mlist
subheaders = self.get_subheaders()
dir_pos = 512
Expand All @@ -944,7 +944,7 @@ def to_file_map(self, file_map=None):
hdr.write_to(hdrf)

# Write every frames
for index in range(0, self.get_header()['num_frames']):
for index in range(0, self.header['num_frames']):
# Move to subheader offset
frame_offset = subheaders._get_frame_offset(index) - 512
imgf.seek(frame_offset)
Expand Down
Loading