NiBabel

Access a cacophony of neuro-imaging file formats

Table Of Contents

Next topic

nibabel.get_info

This Page

Reggie -- the one

nibabel

This package provides read and write access to some common medical and neuroimaging file formats, including: ANALYZE (plain, SPM99, SPM2), GIFTI, NIfTI1, MINC, MGH and ECAT as well as PAR/REC. There is some very limited support for DICOM. NiBabel is the successor of PyNIfTI.

The various image format classes give full or selective access to header (meta) information and access to the image data is made available via NumPy arrays.

Website

Current information can always be found at the NIPY nibabel website:

http://nipy.org/nibabel

Mailing Lists

Please see the developer’s list here:

http://mail.scipy.org/mailman/listinfo/nipy-devel

Code

You can find our sources and single-click downloads:

License

Nibabel is licensed under the terms of the MIT license. Some code included with nibabel is licensed under the BSD license. Please the COPYING file in the nibabel distribution.

Quickstart

import nibabel as nib

img1 = nib.load('my_file.nii')
img2 = nib.load('other_file.nii.gz')
img3 = nib.load('spm_file.img')

data = img1.get_data()
affine = img1.get_affine()

print img1

nib.save(img1, 'my_file_copy.nii.gz')

new_image = nib.Nifti1Image(data, affine)
nib.save(new_image, 'new_image.nii.gz')

For more detailed information see the NiBabel Manual.

Functions

get_info()