NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.nifti1.Nifti1Image

Next topic

nibabel.nifti1.Nifti1PairHeader

Reggie -- the one

nibabel.nifti1.Nifti1Pair

digraph inheritance5815df6a85 { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "SpatialImage" [shape=ellipse,URL="nibabel.spatialimages.SpatialImage.html#nibabel.spatialimages.SpatialImage",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "AnalyzeImage" [shape=ellipse,URL="nibabel.analyze.AnalyzeImage.html#nibabel.analyze.AnalyzeImage",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "SpatialImage" -> "AnalyzeImage" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Nifti1Pair" [shape=ellipse,URL="#nibabel.nifti1.Nifti1Pair",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "AnalyzeImage" -> "Nifti1Pair" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

class nibabel.nifti1.Nifti1Pair(data, affine, header=None, extra=None, file_map=None)

Initialize image

Parameters :

data : array-like

image data. It should be some object that retuns an array from np.asanyarray

affine : (4,4) array

homogenous affine giving relationship between voxel coordinates and world coordinates

header : None or mapping or header instance, optional

metadata for this image format

extra : None or mapping, optional

metadata to associate with image that cannot be stored in the metadata of this image type

file_map : mapping, optional

mapping giving file information for this image format

classmethod from_file_map(klass, file_map)
header_class

alias of Nifti1PairHeader

update_header()

Harmonize header with image data and affine

See AnalyzeImage.update_header for more examples

Examples

>>> data = np.zeros((2,3,4))
>>> affine = np.diag([1.0,2.0,3.0,1.0])
>>> img = Nifti1Image(data, affine)
>>> hdr = img.get_header()
>>> np.all(hdr.get_qform() == affine)
True
>>> np.all(hdr.get_sform() == affine)
True