minc1

Read MINC1 format images

Minc1File(mincfile)

Class to wrap MINC1 format opened netcdf object

Minc1Header([data_dtype, shape, zooms])

Minc1Image(dataobj, affine[, header, extra, …])

Class for MINC1 format images

MincError

Error when reading MINC files

MincFile(*args, **kwargs)

Deprecated alternative name for Minc1File

MincHeader([data_dtype, shape, zooms])

Class to contain header for MINC formats

MincImage(*args, **kwargs)

Deprecated alternative name for Minc1Image

MincImageArrayProxy(minc_file)

MINC implementation of array proxy protocol

Minc1File

class nibabel.minc1.Minc1File(mincfile)

Bases: object

Class to wrap MINC1 format opened netcdf object

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

__init__(mincfile)

Initialize self. See help(type(self)) for accurate signature.

get_affine()
get_data_dtype()
get_data_shape()
get_scaled_data(sliceobj=())

Return scaled data for slice definition sliceobj

Parameters
sliceobjtuple, optional

slice definition. If not specified, return whole array

Returns
scaled_arrarray

array from minc file with scaling applied

get_zooms()

Get real-world sizes of voxels

Minc1Header

class nibabel.minc1.Minc1Header(data_dtype=<class 'numpy.float32'>, shape=(0, ), zooms=None)

Bases: nibabel.minc1.MincHeader

__init__(data_dtype=<class 'numpy.float32'>, shape=(0, ), zooms=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod may_contain_header(binaryblock)

Minc1Image

class nibabel.minc1.Minc1Image(dataobj, affine, header=None, extra=None, file_map=None)

Bases: nibabel.spatialimages.SpatialImage

Class for MINC1 format images

The MINC1 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-like, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.

Parameters
dataobjobject

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

affineNone 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.

headerNone or mapping or header instance, optional

metadata for this image format

extraNone or mapping, optional

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

file_mapmapping, 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-like, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.

Parameters
dataobjobject

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

affineNone 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.

headerNone or mapping or header instance, optional

metadata for this image format

extraNone or mapping, optional

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

file_mapmapping, optional

mapping giving file information for this image format

ImageArrayProxy

alias of MincImageArrayProxy

files_types = (('image', '.mnc'),)
classmethod from_file_map(file_map, mmap=True, keep_file_open=None)

Class method to create image from mapping in file_map

Deprecated since version 2.4.1: keep_file_open='auto' is redundant with False and has been deprecated. It will raise an error in nibabel 3.0.

Parameters
file_mapdict

Mapping with (kay, value) pairs of (file_type, FileHolder instance giving file-likes for each file needed for this image type.

mmap{True, False, ‘c’, ‘r’}, optional, keyword only

mmap controls the use of numpy memory mapping for reading image array data. If False, do not try numpy memmap for data array. If one of {‘c’, ‘r’}, try numpy memmap with mode=mmap. A mmap value of True gives the same behavior as mmap='c'. If image data file cannot be memory-mapped, ignore mmap value and read array from file.

keep_file_open{ None, True, False }, optional, keyword only

keep_file_open controls whether a new file handle is created every time the image is accessed, or a single file handle is created and used for the lifetime of this ArrayProxy. If True, a single file handle is created and used. If False, a new file handle is created every time the image is accessed. If file_map refers to an open file handle, this setting has no effect. The default value (None) will result in the value of nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT being used.

Returns
imgDataobjImage instance
header_class

alias of Minc1Header

makeable = True
rw = False
valid_exts = ('.mnc',)

MincError

class nibabel.minc1.MincError

Bases: Exception

Error when reading MINC files

__init__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

MincFile

class nibabel.minc1.MincFile(*args, **kwargs)

Bases: nibabel.deprecated.FutureWarningMixin, nibabel.minc1.Minc1File

Deprecated alternative name for Minc1File

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

warn_message = 'MincFile is deprecated; please use Minc1File instead'

MincHeader

class nibabel.minc1.MincHeader(data_dtype=<class 'numpy.float32'>, shape=(0, ), zooms=None)

Bases: nibabel.spatialimages.SpatialHeader

Class to contain header for MINC formats

__init__(data_dtype=<class 'numpy.float32'>, shape=(0, ), zooms=None)

Initialize self. See help(type(self)) for accurate signature.

data_from_fileobj(fileobj)

See Header class for an implementation we can’t use

data_layout = 'C'
data_to_fileobj(data, fileobj, rescale=True)

See Header class for an implementation we can’t use

MincImage

class nibabel.minc1.MincImage(*args, **kwargs)

Bases: nibabel.deprecated.FutureWarningMixin, nibabel.minc1.Minc1Image

Deprecated alternative name for Minc1Image

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

warn_message = 'MincImage is deprecated; please use Minc1Image instead'

MincImageArrayProxy

class nibabel.minc1.MincImageArrayProxy(minc_file)

Bases: object

MINC implementation of array proxy protocol

The array proxy allows us to freeze the passed fileobj and header such that it returns the expected data array.

__init__(minc_file)

Initialize self. See help(type(self)) for accurate signature.

is_proxy
ndim
shape