Commit 98e877c9 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF,BF: Nifti.header is now protected via property setter - Failure in was resulting in a Nifti without a header.
parent 477a43a5
......@@ -254,7 +254,7 @@ class Nifti(notifier.Notifier, meta.Meta):
self.header = header
self.__header = header
self.__shape = shape
self.__origShape = origShape
self.__pixdim = pixdim
......@@ -492,6 +492,24 @@ class Nifti(notifier.Notifier, meta.Meta):
return ''.join([c for c in val if c in string.printable]).strip()
def header(self):
"""Return a reference to the ``nibabel`` header object. """
return self.__header
def header(self, header):
"""Replace the ``nibabel`` header object managed by this ``Nifti``
with a new header. The new header must have the same dimensions,
voxel size, and orientation as the old one.
new = Nifti(header)
if not (self.sameSpace(new) and self.ndim == new.ndim):
raise ValueError('Incompatible header')
self.__header = new
def niftiVersion(self):
"""Returns the NIFTI file version:
......@@ -1411,12 +1429,6 @@ class Image(Nifti):, tmpfname)
# nibabel should close any old
# file handles when the image/
# header refs are deleted
self.__nibImage = None
self.header = None
# Copy to final destination,
# and reload from there
imcp.imcp(tmpfname, filename, overwrite=True)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment