imctoolkit.MultichannelImage

class MultichannelImage(data, channel_names=None)

Functionality for processing multi-channel images

Variables

data – raw image data, as xarray.DataArray with dimensions (c, y, x) and, optionally, channel names as coordinate for the c dimension

__init__(data, channel_names=None)
Parameters
  • data (DataArray-like) – raw image data, shape: (c, y, x)

  • channel_names (Optional[Sequence[str]]) – channel names

property width

Image width in pixels

Return type

int

property height

Image height in pixels

Return type

int

property num_channels

Number of channels

Return type

int

property channel_names

Channel names

Return type

List[str]

copy()

Creates a copy of the current instance

Return type

MultichannelImage

Returns

a deep copy of the current instance

write_ome_tiff(path, **kwargs)

Writes an OME-TIFF file using xtiff.to_tiff()

Note that the written OME-TIFF file will not be identical to any OME-TIFF file from which the current instance was potentially created initially.

Parameters
  • path (Union[str, Path]) – path to the .ome.tiff file to be written

  • kwargs – other arguments passed to xtiff.to_tiff()

classmethod read(path, **kwargs)

Creates a new MultichannelImage from the specified file

The file type is determined based on the file extension.

Parameters
  • path (Union[str, Path]) – path to the file

  • kwargs – optional keyword arguments passed to the respective read_* function

Return type

MultichannelImage

Returns

a new MultichannelImage instance

static read_imc_txt(path, channel_names_attr='channel_names')

Creates a new MultichannelImage from the specified Fluidigm(TM) TXT file

Uses imctools.io.txt.txtparser.TxtParser for reading .txt files.

Parameters
  • path (Union[str, Path]) – path to the .txt file

  • channel_names_attr (str) – imctools.data.AcquisitionData attribute from which the channel names will be taken, e.g. 'channel_labels'

Return type

MultichannelImage

Returns

a new MultichannelImage instance

static read_imc_mcd(path, acquisition_id, channel_names_attr='channel_names')

Creates a new MultichannelImage from the specified Fluidigm(TM) MCD file

Uses imctools.io.txt.mcdparser.McdParser for reading .mcd files.

Parameters
  • path (Union[str, Path]) – path to the .mcd file

  • acquisition_id (int) – acquisition ID to read (unique across slides)

  • channel_names_attr (str) – imctools.data.AcquisitionData attribute from which the channel names will be taken, e.g. 'channel_labels'

Return type

MultichannelImage

Returns

a new MultichannelImage instance

static read_tiff(path, panel=None, panel_channel_index_col=None, panel_channel_name_col='channel_name', channel_names=None, ome_channel_name_attr='Name')

Creates a new MultichannelImage from the specified TIFF/OME-TIFF file

Uses tifffile.TiffFile for reading .tiff files. When reading an OME-TIFF file and panel is not specified, the channel names are taken from the embedded OME-XML.

Parameters
  • path (tifffile.TiffFile path-argument) – path to the .tiff file

  • panel (None, pandas.DataFrame or pandas.read_csv path-argument) – panel that maps channel indices to channel names. If specified, overrides channel names extracted from OME-XML and acts as a channel selector.

  • panel_channel_index_col (Optional[str]) – channel index column in panel, or None for defaulting to range(n_channels)

  • panel_channel_name_col (str) – channel name column in panel

  • channel_names (Optional[Sequence[str]]) – channel names, matching the number of image channels. If specified for OME-TIFFs or together with panel, acts as a channel selector.

  • ome_channel_name_attr (str) – name of the OME-XML Channel element attribute from which the channel names will be taken, see https://www.openmicroscopy.org/Schemas/Documentation/Generated/OME-2016-06/ome.html.

Return type

MultichannelImage

Returns

a new MultichannelImage instance