NRRD#

IO interface to NRRD volumetric image data files.

Note

The interface is based on nrrd.py for reading and writing nrrd files. See ‘this link <http://teem.sourceforge.net/nrrd/format.html>`_ for specifications.

exception NrrdError[source]#

Bases: Exception

Exceptions for Nrrd class.

class Source(location)[source]#

Bases: Source

Nrrd array source.

as_buffer()[source]#
as_memmap()[source]#
as_real()[source]#
as_virtual()[source]#

Return virtual source without array data to pass in parallel processing.

Returns

sourceSource class

The source class without array data.

metadata(info=None)[source]#

Returns metadata from this nrrd file.

Arguments

infolist or all

Optional list of keywords, if all return full tif metadata, if None return default set info.

Returns

metadatadict

Dictionary with the meta data.

property array#

The underlying data array.

Returns

arrayarray

The underlying data array of this source.

property dtype#

The data type of the source.

Returns

dtypedtype

The data type of the source.

property element_strides#

The strides of the array elements.

Returns

stridestuple

Strides of the array elements.

Note

The strides of the elements module itemsize instead of bytes.

property location#

The location where the data of the source is stored.

Returns

locationstr or None

Returns the location of the data source or None if this source lives in memory only.

property name#

The name of this source.

Returns

namestr

Name of this source.

property offset#

The offset of the memory map in the file.

Returns

offsetint

Offset of the memeory map in the file.

property order#

The order of how the data is stored in the source.

Returns

orderstr

Returns ‘C’ for C contigous and ‘F’ for fortran contigous, None otherwise.

property shape#

The shape of the source.

Returns

shapetuple

The shape of the source.

class VirtualSource(source=None, shape=None, dtype=None, order=None, location=None, name=None)[source]#

Bases: VirtualSource

as_buffer()[source]#
as_real()[source]#
as_virtual()[source]#

Return virtual source without array data to pass in parallel processing.

Returns

sourceSource class

The source class without array data.

property name#

The name of this source.

Returns

namestr

Name of this source.

create(location=None, shape=None, dtype=None, order=None, mode=None, array=None, as_source=True, **kwargs)[source]#
is_nrrd(source)[source]#

Checks if this source is a NRRD source

read(source, slicing=None, **kwargs)[source]#

Read data from a nrrd file.

Arguments

sourcestr

The name of the nrrd file.

slicingslice, Slice or None

An optional sub-slice to consider.

Returns

arrayarray

The image data in the tif file as a buffer.

write(sink, data, slicing=None, **kwargs)[source]#