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. We can read and write Freesurfer geometry, and read Freesurfer morphometry and annotation files. 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.
Current information can always be found at the NIPY nibabel website:
Please see the developer’s list here:
You can find our sources and single-click downloads:
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.
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.