NiBabel

Access a cacophony of neuro-imaging file formats

Table Of Contents

Previous topic

minc1

Next topic

nicom

Reggie -- the one

minc2

Preliminary MINC2 support

Use with care; I haven’t tested this against a wide range of MINC files.

If you have a file that isn’t read correctly, please send an example.

Test reading with something like:

import nibabel as nib
img = nib.load('my_funny.mnc')
data = img.get_data()
print(data.mean())
print(data.max())
print(data.min())

and compare against command line output of:

mincstats my_funny.mnc
Hdf5Bunch(var) Make object for accessing attributes of variable
Minc2File(mincfile) Class to wrap MINC2 format file
Minc2Image(dataobj, affine[, header, extra, ...]) Class for MINC2 images

Hdf5Bunch

class nibabel.minc2.Hdf5Bunch(var)

Bases: object

Make object for accessing attributes of variable

__init__(var)

Minc2File

class nibabel.minc2.Minc2File(mincfile)

Bases: nibabel.minc1.Minc1File

Class to wrap MINC2 format file

Although it has some of the same methods as a Header, we use this only when reading a MINC2 file, to pull out useful header information, and for the method of reading the data out

__init__(mincfile)
get_data_dtype()
get_data_shape()
get_scaled_data(sliceobj=())

Return scaled data for slice definition sliceobj

Parameters:

sliceobj : tuple, optional

slice definition. If not specified, return whole array

Returns:

scaled_arr : array

array from minc file with scaling applied

Minc2Image

class nibabel.minc2.Minc2Image(dataobj, affine, header=None, extra=None, file_map=None)

Bases: nibabel.minc1.Minc1Image

Class for MINC2 images

The MINC2 image class uses the default header type, rather than a specific MINC header type - and reads the relevant information from the MINC file on load.

Initialize image

The image is a combination of (array, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.

Parameters:

dataobj : object

Object containg image data. It should be some object that retuns an array from np.asanyarray. It should have a shape attribute or property

affine : None or (4,4) array-like

homogenous affine giving relationship between voxel coordinates and world coordinates. Affine can also be None. In this case, obj.affine also returns None, and the affine as written to disk will depend on the file format.

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

__init__(dataobj, affine, header=None, extra=None, file_map=None)

Initialize image

The image is a combination of (array, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.

Parameters:

dataobj : object

Object containg image data. It should be some object that retuns an array from np.asanyarray. It should have a shape attribute or property

affine : None or (4,4) array-like

homogenous affine giving relationship between voxel coordinates and world coordinates. Affine can also be None. In this case, obj.affine also returns None, and the affine as written to disk will depend on the file format.

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)