imctools.io

imctools.io.utils

reshape_long_2_cyx(data, is_sorted=True, shape=None, channel_indices=None)

Reshape data from long format into cyx format (channels, y, x).

Parameters
  • data (memmap) – Input data.

  • is_sorted (bool) – Whether data are sorted.

  • shape (Optional[ndarray]) – Custom data shape.

  • channel_indices (Optional[Sequence[int]]) – Channel indices.

get_ome_xml(img, image_name, channel_names, big_endian, pixel_size, pixel_depth, creator=None, acquisition_date=None, channel_fluors=None, xml_metadata=None, **ome_xml_kwargs)

Helper function for xtiff library to get a proper OME-TIFF XML

Return type

ElementTree

sort_acquisition_channels(session)

Sort entries of acquisition channels dictionary by channel order number

imctools.io.imc

class ImcParser(input_dir)

IMC folder parser.

property origin
property session
get_mcd_xml()

Original (raw) metadata from MCD file in XML format.

get_acquisition_data(acquisition_id)

Returns AcquisitionData object with binary image data

class ImcWriter(root_output_folder, mcd_parser, txt_acquisitions_map=None, parse_txt=False)

Write IMC session data to IMC folder structure.

property folder_name
write_imc_folder(create_zip=True, remove_folder=None)

imctools.io.mcd

class McdParser(filepath, file_handle=None, xml_metadata_filepath=None)

Raw MCD file parser.

The McdParser object should be closed using the close method.

property origin
property session
get_mcd_xml()

Original (raw) metadata from MCD file in XML format.

property mcd_filename

Name of the open MCD file

get_acquisition_data(acquisition_id)

Returns AcquisitionData object with binary image data for given acquisition ID

get_slide_image(slide_id)

Get slide image as numpy array

save_slide_image(slide_id, output_folder, output_filename=None)

Save slide image

get_panorama_image(panorama_id)

Get panorama image as numpy array

save_panorama_image(panorama_id, output_folder, output_filename=None)

Save panorama image of the acquisition

get_before_ablation_image(acquisition_id)
save_before_ablation_image(acquisition_id, output_folder, output_filename=None)
get_after_ablation_image(acquisition_id)
save_after_ablation_image(acquisition_id, output_folder, output_filename=None)
close()

Close file handlers.

class McdXmlParser(mcd_xml, source_path, process_namespaces=False)

Converts MCD XML structure into IMC session format.

property origin

Origin of the data

property session

Root session data

get_mcd_xml()

Original (raw) metadata from MCD file in XML format.

Definitions of MCD XML keywords

imctools.io.ometiff

class OmeTiffParser(filepath, slide_id=0, channel_id_offset=0)

Parser of MCD compatible .OME-TIFF files.

Allows to get a single IMC acquisition from a single OME-TIFF file.

property origin
property filepath
get_mcd_xml()

Original (raw) metadata from MCD file in XML format.

Return type

Optional[str]

get_acquisition_data()

Returns AcquisitionData object with binary image data

static extract_acquisition_id(filepath)

Extract acquisition ID from source OME-TIFF filepath.

Filename should end with a numeric symbol!

Parameters

filepath (Union[str, Path]) – Input OME-TIFF filepath

imctools.io.txt

class TxtParser(filepath, slide_id=0, channel_id_offset=0)

Parser of MCD compatible .txt files.

Allows to get a single IMC acquisition from a single TXT file.

property origin
property filepath
get_acquisition_data()

Returns AcquisitionData object with binary image data

static extract_acquisition_id(filepath)

Extract acquisition ID from source TXT filepath.

Filename should end with a numeric symbol!

Parameters

filepath (Union[str, Path]) – Input TXT filepath.