Neuroimaging in Python — NiBabel 5.4.0.dev1+g3b1c7b37 documentation (original) (raw)

analyze

Read / write access to the basic Mayo Analyze format

AnalyzeHeader([binaryblock, endianness, check]) Class for basic analyze header
AnalyzeImage(dataobj, affine[, header, ...]) Class for basic Analyze format image

AnalyzeImage

class nibabel.analyze.AnalyzeImage(dataobj, affine, header=None, extra=None, file_map=None, dtype=None)

Bases: SpatialImage

Class for basic Analyze format image

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 containing image data. It should be some object that returns an array from np.asanyarray. It should have a shape attribute or property

affineNone or (4,4) array-like

homogeneous 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, dtype=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 containing image data. It should be some object that returns an array from np.asanyarray. It should have a shape attribute or property

affineNone or (4,4) array-like

homogeneous 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 ArrayProxy

files_types_: tuple[tuple[str, str], ...]_ = (('image', '.img'), ('header', '.hdr'))

classmethod from_file_map(file_map, *, mmap=True, keep_file_open=None)

Class method to create image from mapping in file_map

Parameters:

file_mapdict

Mapping with (key, 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. Ammap 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. IfTrue, 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 ofnibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT being used.

Returns:

imgAnalyzeImage instance

get_data_dtype()

alias of AnalyzeHeader

makeable_: bool_ = True

rw_: bool_ = True

set_data_dtype(dtype)

to_file_map(file_map=None, dtype=None)

Write image to file_map or contained self.file_map

Parameters:

file_mapNone or mapping, optional

files mapping. If None (default) use object’s file_mapattribute instead

dtypedtype-like, optional

The on-disk data type to coerce the data array.

valid_exts_: tuple[str, ...]_ = ('.img', '.hdr')