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, as well as PAR/REC. 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.

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()