Package nifti :: Module niftiimage :: Class MemMappedNiftiImage
[hide private]
[frames] | no frames]

Class MemMappedNiftiImage

source code


Memory mapped access to uncompressed NIfTI files.

This access mode might be the prefered one whenever whenever only a small part of the image data has to be accessed or the memory is not sufficient to load the whole dataset. Please note, that memory-mapping is not required when exclusively header information shall be accessed. By default the NiftiImage class does not load any image data into memory.

Instance Methods [hide private]
 
__init__(self, source)
Create a NiftiImage object.
source code
call graph 
 
__del__(self)
Do all necessary cleanups by calling __close().
source code
call graph 
 
save(self)
Save the image.
source code
 
load(self)
Does nothing for memory mapped images.
source code
call graph 
 
unload(self)
Does nothing for memory mapped images.
source code
 
setFilename(self, filename, filetype='NIFTI')
Does not work for memory mapped images and therefore raises an exception.
source code

Inherited from NiftiImage: asarray, getBoundingBox, getDataArray, getScaledData, updateCalMinMax, updateHeader

Inherited from niftiformat.NiftiFormat: asDict, getExtent, getFilename, getInverseQForm, getInverseSForm, getPixDims, getQForm, getQOffset, getQOrientation, getQuaternion, getRepetitionTime, getSForm, getSOrientation, getTimepoints, getVolumeExtent, getVoxDims, setDescription, setIntercept, setPixDims, setQFac, setQForm, setQOffset, setQuaternion, setRepetitionTime, setSForm, setSlope, setVoxDims, setXFormCode, updateFromDict, updateQFormFromQuaternion

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from NiftiImage: bbox, data

Inherited from niftiformat.NiftiFormat: description, extent, filename, header, intercept, max, min, nvox, pixdim, qfac, qform, qform_inv, qoffset, quatern, raw_nimg, rtime, sform, sform_inv, slope, timepoints, volextent, voxdim

Inherited from object: __class__

Method Details [hide private]

__init__(self, source)
(Constructor)

source code 
call graph 

Create a NiftiImage object.

This method decides whether to load a nifti image from file or create one from ndarray data, depending on the datatype of source.

Parameters:
  • source, str, |, ndarray - If source is a string, it is assumed to be a filename and an attempt will be made to open the corresponding NIfTI file. In case of an ndarray the array data will be used for the to be created nifti image and a matching nifti header is generated. If an object of a different type is supplied as 'source' a ValueError exception will be thrown.
Overrides: object.__init__

__del__(self)
(Destructor)

source code 
call graph 
Do all necessary cleanups by calling __close().
Overrides: niftiformat.NiftiFormat.__del__

save(self)

source code 

Save the image.

This methods does nothing except for syncing the file on the disk.

Please note that the NIfTI header might not be completely up-to-date. For example, the min and max values might be outdated, but this class does not automatically update them, because it would require to load and search through the whole array.

Parameters:
  • filename, str, |, None - Calling save() with filename equal None on a NiftiImage loaded from a file, it will overwrite the original file.

    Usually setting the filename also determines the filetype (NIfTI/ANALYZE). Please see the documentation of the setFilename() method for some more details.

  • filetype, str - Override filetype. Please see the documentation of the setFilename() method for some more details.
Overrides: NiftiImage.save

load(self)

source code 
call graph 
Does nothing for memory mapped images.
Overrides: NiftiImage.load

unload(self)

source code 
Does nothing for memory mapped images.
Overrides: NiftiImage.unload

setFilename(self, filename, filetype='NIFTI')

source code 
Does not work for memory mapped images and therefore raises an exception.
Overrides: NiftiImage.setFilename