aicsimageio.readers package¶
Submodules¶
aicsimageio.readers.arraylike_reader module¶
-
class
aicsimageio.readers.arraylike_reader.
ArrayLikeReader
(data: Union[numpy.ndarray, dask.array.core.Array], **kwargs)[source]¶ Bases:
aicsimageio.readers.reader.Reader
A catch all for numpy ndarray and dask array reading.
- Parameters
data (Union[numpy.ndarray, da.core.Array]) – An in memory numpy ndarray or preconfigured dask array.
Notes
Because this is simply a wrapper around numpy ndarray, no metadata is returned. However, dimension order is returned with dimensions assumed in order but with extra dimensions removed depending on image shape.
-
property
dims
¶
-
property
metadata
¶
aicsimageio.readers.czi_reader module¶
-
class
aicsimageio.readers.czi_reader.
CziReader
[source]¶ Bases:
aicsimageio.readers.reader.Reader
CziReader wraps aicspylibczi to provide the same reading capabilities but abstracts the specifics of using the backend library to create a unified interface. This enables higher level functions to duck type the File Readers.
- Parameters
data (types.FileLike) – A string or path to the CZI file to be read.
chunk_by_dims (List[str]) – The dimensions to use as the for mapping the chunks / blocks. Default: [Dimensions.SpatialZ, Dimensions.SpatialY, Dimensions.SpatialX] Note: SpatialY and SpatialX will always be added to the list if not present.
S (int) – If the image has different dimensions on any scene from another, the dask array construction will fail. In that case, use this parameter to specify a specific scene to construct a dask array for. Default: 0 (select the first scene)
-
ZEISS_10BYTE
= b'ZISRAWFILE'¶
-
ZEISS_2BYTE
= b'ZI'¶
-
property
dims
¶
-
get_channel_names
(scene: int = 0)[source]¶ Attempts to use the image’s metadata to get the image’s channel names.
- Parameters
scene (int) – The index of the scene for which to return channel names.
- Returns
channels_names – List of strings representing the channel names. If channel dimension not present in file, return None.
- Return type
Optional[List[str]]
-
get_physical_pixel_size
()[source]¶ Attempts to retrieve physical pixel size for the specified scene. If none available, returns 1.0 for each spatial dimension.
- Parameters
scene (int) – The index of the scene for which to return physical pixel sizes.
- Returns
sizes – Tuple of floats representing the pixel sizes for X, Y, Z, in that order.
- Return type
Tuple[float]
-
property
metadata
¶ Load and return the metadata from the CZI file
- Returns
- Return type
The lxml Element Tree of the metadata
aicsimageio.readers.default_reader module¶
-
class
aicsimageio.readers.default_reader.
DefaultReader
[source]¶ Bases:
aicsimageio.readers.reader.Reader
A catch all for image file reading that uses imageio for reading.
- Parameters
file (types.ImageLike) – String with path to file.
-
property
dims
¶
-
get_channel_names
()[source]¶ Attempts to use the image’s metadata to get the image’s channel names.
- Parameters
scene (int) – The index of the scene for which to return channel names.
- Returns
channels_names – List of strings representing the channel names. If channel dimension not present in file, return None.
- Return type
Optional[List[str]]
-
property
metadata
¶
aicsimageio.readers.lif_reader module¶
-
class
aicsimageio.readers.lif_reader.
LifReader
[source]¶ Bases:
aicsimageio.readers.reader.Reader
LifReader wraps readlif.reader to provide the same reading capabilities but abstracts the specifics of using the backend library to create a unified interface. This enables higher level functions to duck type the File Readers.
- Parameters
data (types.FileLike) – A string or path to the LIF file to be read.
chunk_by_dims (List[str]) – The dimensions to use as the for mapping the chunks / blocks. Default: [Dimensions.SpatialZ, Dimensions.SpatialY, Dimensions.SpatialX] Note: SpatialY and SpatialX will always be added to the list if not present.
S (int) – If the image has different dimensions on any scene from another, the dask array construction will fail. In that case, use this parameter to specify a specific scene to construct a dask array for. Default: 0 (select the first scene)
-
LIF_MAGIC_BYTE
= 112¶
-
LIF_MEMORY_BYTE
= 42¶
-
property
dims
¶ The dimensions for a lif file.
- Returns
“STCZYX”
- Return type
str
-
dtype
() → numpy.dtype[source]¶ The data type of the underlying numpy ndarray, ie uint8, uint16, uint32 etc.
- Returns
The data format used to store the data in the Leica lif file and the read numpy.ndarray.
- Return type
numpy.dtype
-
get_channel_names
()[source]¶ Get the channel names for the scene
- Parameters
scene (int) – The index of the scene from which to retrieve the channel names
- Returns
A list of descriptive names of the channels of the form “Gray–TL-BF–EMP_BF” and “Green–FLUO–GFP”
- Return type
List[str]
-
get_physical_pixel_size
()[source]¶ Get the (X, Y, Z) pixel size. If the value is not set it returns 1.0.
- Parameters
scene (int) – The scene to retrieve the dimensions from
- Returns
- Return type
(X, Y, Z) in m.
-
static
get_pixel_type
(meta: xml.etree.ElementTree.Element, scene: int = 0) → numpy.dtype[source]¶ This function parses the metadata to assign the appropriate numpy.dtype
- Parameters
meta (xml.etree.ElementTree.Element) – The root Element of the metadata etree
scene (int) – The index of the scene, scenes could have different storage data types.
- Returns
The appropriate data type to construct the matrix with.
- Return type
numpy.dtype
-
property
metadata
¶ Load and return the metadata from the LIF file
- Returns
- Return type
The xml Element Tree of the metadata
aicsimageio.readers.ome_tiff_reader module¶
-
class
aicsimageio.readers.ome_tiff_reader.
OmeTiffReader
(data: Union[str, pathlib.Path, bytes, io.BufferedIOBase], **kwargs)[source]¶ Bases:
aicsimageio.readers.tiff_reader.TiffReader
Opening and processing the contents of an OME Tiff file
-
get_channel_names
(scene: int = 0)[source]¶ Attempts to use the image’s metadata to get the image’s channel names.
- Parameters
scene (int) – The index of the scene for which to return channel names.
- Returns
channels_names – List of strings representing the channel names. If channel dimension not present in file, return None.
- Return type
Optional[List[str]]
-
get_physical_pixel_size
()[source]¶ Attempts to retrieve physical pixel size for the specified scene. If none available, returns 1.0 for each spatial dimension.
- Parameters
scene (int) – The index of the scene for which to return physical pixel sizes.
- Returns
sizes – Tuple of floats representing the pixel sizes for X, Y, Z, in that order.
- Return type
Tuple[float]
-
property
metadata
¶
-
aicsimageio.readers.reader module¶
-
class
aicsimageio.readers.reader.
Reader
[source]¶ Bases:
abc.ABC
-
property
client
¶
-
close
()[source]¶ Always close the Dask Client connection. If connected to strictly a LocalCluster, close it down as well.
-
property
cluster
¶
-
property
dask_data
¶
-
property
data
¶
-
abstract property
dims
¶
-
get_channel_names
()[source]¶ Attempts to use the image’s metadata to get the image’s channel names.
- Parameters
scene (int) – The index of the scene for which to return channel names.
- Returns
channels_names – List of strings representing the channel names. If channel dimension not present in file, return None.
- Return type
Optional[List[str]]
-
get_image_dask_data
(out_orientation: Optional[str] = None, **kwargs) → dask.array.core.Array[source]¶ Get specific dimension image data out of an image as a dask array.
- Parameters
out_orientation (Optional[str]) – A string containing the dimension ordering desired for the returned ndarray. Default: The current image dimensions. i.e. self.dims
kwargs –
C=1: specifies Channel 1
T=3: specifies the fourth index in T
D=n: D is Dimension letter and n is the index desired. D should not be present in the out_orientation.
D=[a, b, c]: D is Dimension letter and a, b, c is the list of indicies desired. D should be present in the out_orientation.
D=(a, b, c): D is Dimension letter and a, b, c is the tuple of indicies desired. D should be present in the out_orientation.
D=range(…): D is Dimension letter and range is the standard Python range function. D should be present in the out_orientation.
D=slice(…): D is Dimension letter and slice is the standard Python slice function. D should be present in the out_orientation.
- Returns
data – The read data with the dimension ordering that was specified with out_orientation.
- Return type
dask array
Examples
Specific index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... c1 = img.get_image_dask_data("ZYX", C=1)
List of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_and_second = img.get_image_dask_data("CZYX", C=[0, 1])
Tuple of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_and_last = img.get_image_dask_data("CZYX", C=(0, -1))
Range of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_three = img.get_image_dask_data("CZYX", C=range(3))
Slice selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... every_other = img.get_image_dask_data("CZYX", C=slice(0, -1, 2))
Notes
If a requested dimension is not present in the data the dimension is added with a depth of 1.
See aicsimageio.transforms.reshape_data for more details.
-
get_image_data
(out_orientation: Optional[str] = None, **kwargs) → numpy.ndarray[source]¶ Read the image as a numpy array then return specific dimension image data.
- Parameters
out_orientation (Optional[str]) – A string containing the dimension ordering desired for the returned ndarray. Default: The current image dimensions. i.e. self.dims
kwargs –
C=1: specifies Channel 1
T=3: specifies the fourth index in T
D=n: D is Dimension letter and n is the index desired. D should not be present in the out_orientation.
D=[a, b, c]: D is Dimension letter and a, b, c is the list of indicies desired. D should be present in the out_orientation.
D=(a, b, c): D is Dimension letter and a, b, c is the tuple of indicies desired. D should be present in the out_orientation.
D=range(…): D is Dimension letter and range is the standard Python range function. D should be present in the out_orientation.
D=slice(…): D is Dimension letter and slice is the standard Python slice function. D should be present in the out_orientation.
Examples
Specific index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... c1 = img.get_image_data("ZYX", C=1)
List of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_and_second = img.get_image_data("CZYX", C=[0, 1])
Tuple of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_and_last = img.get_image_data("CZYX", C=(0, -1))
Range of index selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... first_three = img.get_image_data("CZYX", C=range(3))
Slice selection
>>> img = Reader("s_1_t_1_c_10_z_20.ome.tiff") ... every_other = img.get_image_data("CZYX", C=slice(0, -1, 2))
- Returns
data – The read data with the dimension ordering that was specified with out_orientation.
- Return type
np.ndarray
Notes
If a requested dimension is not present in the data the dimension is added with a depth of 1.
This will preload the entire image before returning the requested data.
See aicsimageio.transforms.reshape_data for more details.
-
get_physical_pixel_size
()[source]¶ Attempts to retrieve physical pixel size for the specified scene. If none available, returns 1.0 for each spatial dimension.
- Parameters
scene (int) – The index of the scene for which to return physical pixel sizes.
- Returns
sizes – Tuple of floats representing the pixel sizes for X, Y, Z, in that order.
- Return type
Tuple[float]
-
classmethod
is_this_type
(data: Union[str, pathlib.Path, bytes, io.BufferedIOBase, numpy.ndarray, dask.array.core.Array]) → bool[source]¶
-
abstract property
metadata
¶
-
property
shape
¶ - Returns
shape – A tuple with the size of all dimensions.
- Return type
Tuple[int]
-
property
-
aicsimageio.readers.reader.
use_dask
(setting: bool)[source]¶ Enable or disable Dask for image reading. When True, image reads are first attempted to be handled by a distributed cluster. When False, image reads are never routed to a distributed cluster and are instead read immediately in the running process.
aicsimageio.readers.tiff_reader module¶
-
class
aicsimageio.readers.tiff_reader.
TiffReader
(data: Union[str, pathlib.Path, bytes, io.BufferedIOBase], S: int = 0, **kwargs)[source]¶ Bases:
aicsimageio.readers.reader.Reader
TiffReader wraps tifffile to provide the same reading capabilities but abstracts the specifics of using the backend library to create a unified interface. This enables higher level functions to duck type the File Readers.
- Parameters
data (types.FileLike) – A string or path to the TIFF file to be read.
S (int) – If the image has different dimensions on any scene from another, the dask array construction will fail. In that case, use this parameter to specify a specific scene to construct a dask array for. Default: 0 (select the first scene)
-
property
dims
¶
-
static
get_image_description
(buffer: io.BufferedIOBase) → Optional[bytearray][source]¶ Retrieve the image description as one large string.
-
property
metadata
¶