NIPY logo

Site Navigation

NIPY Community

Table Of Contents

Previous topic

io.imageformats.binaryheaders

Next topic

io.imageformats.eulerangles

This Page

io.imageformats.compat

Module: io.imageformats.compat

Inheritance diagram for nipy.io.imageformats.compat:

The module provides the NiftiImage interface, which is backward-compatible to the previous C-based implementation.

NiftiImage

class nipy.io.imageformats.compat.NiftiImage(source, header=None, loadmeta=False)

Bases: nipy.io.imageformats.nifti1.Nifti1Image

__init__(source, header=None, loadmeta=False)
asDict()
asarray(copy=True)
copy()
data
extent
static filespec_to_files(filespec)
classmethod from_filename(klass, filename)
classmethod from_files(klass, files)
classmethod from_filespec(klass, img, filespec)
classmethod from_image(klass, img)

Create new instance of own class from img

This is a class method

Parameters :

img : spatialimage instance

In fact, an object with the API of spatialimage - specifically get_data, get_affine, get_header and extra.

Returns :

cimg : spatialimage instance

Image, of our own class

getDataArray()
getExtent()
getFilename()
getInverseQForm()
getInverseSForm()
getPixDims()
getQForm()
getQFormCode(as_string=False)
getQOffset()
getQOrientation(as_string=False)
getQuaternion()
getRepetitionTime()
getSForm()
getSFormCode(as_string=False)
getSOrientation(as_string=False)
getScaledData()
getTimeUnit(as_string=False)
getTimepoints()
getVolumeExtent()
getVoxDims()
getXYZUnit(as_string=False)
get_affine()
get_data()

Lazy load of data

get_data_dtype()
get_header()

Return header

Update header to match data, affine etc in object

get_shape()
get_unscaled_data()

Return image data without image scaling applied

Summary: please use the get_data method instead of this method unless you are sure what you are doing, and that you will only be using image formats for which this method exists and returns sensible results.

Use this method with care; the modified Analyze-type formats such as SPM formats, and nifti1, specify that the image data array, as they are expecting to return it, is given by the raw data on disk, multiplied by a scalefactor and maybe with the addition of a constant. This method returns the data on the disk, without these format-specific scalings applied. Please use this method only if you absolutely need the unscaled data, and the magnitude of the data, as given by the scalefactor, is not relevant to your application. The Analyze-type formats have a single scalefactor +/- offset per image on disk. If you do not care about the absolute values, and will be removing the mean from the data, then the unscaled values will have preserved intensity ratios compared to the mean-centered scaled data. However, this is not necessarily true of other formats with more complicated scaling - such as MINC.

Note that - unlike the scaled get_data method, we do not cache the array, to minimize the memory taken by the object.

header
classmethod instance_to_filename(klass, img, filename)

Save img in our own format, to name implied by filename

This is a class method

Parameters :

img : spatialimage instance

In fact, an object with the API of spatialimage - specifically get_data, get_affine, get_header and extra.

filename : str

Filename, implying name to which to save image.

load()
pixdim
rtime
save(filename=None, filetype='NIFTI', update_minmax=True)
setDataArray(data)
setDescription(value)
setFilename(filename, filetype='NIFTI')
setIntercept(value)
setPixDims(value)
setQFac(value, code='scanner')
setQForm(m, code='scanner')
setQFormCode(code)
setQOffset(value, code='scanner')
setQuaternion(value, code='scanner')
setRepetitionTime(value)
setSForm(m, code='mni152')
setSFormCode(code)
setSlope(value)
setTimeUnit(value)
setVoxDims(value)
setXFormCode(xform, code)
setXYZUnit(value)
set_data_dtype(dtype)
to_filename(filename)

Write image to files implied by filename string

Returns :None :
to_files(files=None)

Write image to files passed, or self._files

to_filespec(filename)
unload()
updateCalMinMax()
updateFromDict(hdrdict)
updateHeader(hdrdict)
voxdim
vx2q(coord)
vx2s(coord)