TIF

TIF module provides interface to read and write tif image files.

Note

This modules relies onf the tifffile library.

class Source(location, series=0, multi_file=False)[source]

Bases: ClearMap.IO.Source.Source

Class to handle a tif file source

Note

Its assumed that the image data is stored in a serregionies of the tif file.

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 tif file.

Arguments

sourcestr or Source

The filename or data source.

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

series

Attribute whose value is computed on first access.

property shape

The shape of the source.

Returns

shapetuple

The shape of the source.

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

Bases: ClearMap.IO.Source.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.

array_from_tif(array)[source]
array_to_tif(array)[source]
create(location=None, shape=None, dtype=None, mode=None, as_source=True, **kwargs)[source]

Create a memory map.

Arguments

locationstr

The filename of the memory mapped array.

shapetuple or None

The shape of the memory map to create.

dtypedtype

The data type of the memory map.

mode‘r’, ‘w’, ‘w+’, None

The mode to open the memory map.

as_sourcebool

If True, return as Source class.

Returns

memmapnp.memmap

The memory map.

Note

By default memmaps are initialized as fortran contiguous if order is None.

is_tif(source)[source]

Checks if this source a TIF source

read(source, slicing=None, sink=None, **args)[source]

Read data from a tif file.

Arguments

sourcestr or TIF class

The name of the tif file or a TIF class.

slicingslice, Slice or None

An optional sub-slice to consider.

Returns

dataarray

The image data in the tif file.

shape_from_tif(shape)[source]
shape_to_tif(shape)[source]
write(sink, data, **args)[source]

Write data to a tif file

Arguments

sinkstr

The name of the tif file.

Returns

sinkstr

The name of the tif file.