harpy.io.macsima

Contents

harpy.io.macsima#

harpy.io.macsima(path, image_name=None, to_coordinate_system=None, c_subset=None, remove_bleached=True, remove_dapi=True, include_roi_id_in_channel_name=True, imread_kwargs=mappingproxy({}), image_models_kwargs=mappingproxy({}), output=None, overwrite=False)#

Read MACSima formatted dataset.

This function reads images from a MACSima cyclic imaging experiment.

The channel names will follow the following format: cycle_scantype_channelname_roiid_reagent (or cycle_scantype_channelname_reagent if include_roi_id_in_channel_name=False).

The pixel coordinate system is added as either the provided to_coordinate_system or, by default, global_roiid (if ROI metadata is available) or global (if ROI metadata is not available). The micron coordinate system is always added as the pixel coordinate system with suffix _micron.

See also

Parameters:
  • path (str | Path | list[str] | list[Path]) – Path, or list of paths, to the directory/directories containing the data. The function searches recursively for preprocessed .tif files under each path (subdirectories allowed) as generated by MACS IQ VIEW. All files discovered for a single path are expected to belong to the same ROI.

  • c_subset (list[str] (default: None)) – Channel names to consider. Elements of c_subset that are in one of cycle_scantype_channelname_roiid_reagent, will be considered (or cycle_scantype_channelname_reagent if include_roi_id_in_channel_name=False). E.g if c_subset=['DAPI'] and cycle_scantype_channelname_roiid_reagent = 01_B_DAPI_001_DAPI, then channel 01_B_DAPI_001_DAPI will be retained.

  • image_name (str | Iterable[str] | None (default: None)) – Name of the resulting image element. If None, the name is inferred from OME metadata. If path contains multiple entries, image_name must be a list with the same length.

  • to_coordinate_system (str | Iterable[str] | None (default: None)) – Target coordinate system name(s) for the resulting image element(s). If None, defaults to global_<roi_id> when ROI metadata is available, otherwise global. If path contains multiple entries, to_coordinate_system must be a list with the same length.

  • remove_bleached (bool (default: True)) – If set to True will remove all channels of scantype 'B' (=bleached).

  • remove_dapi (bool (default: True)) – If set to True will remove all dapi channels for which cycle number>0.

  • include_roi_id_in_channel_name (bool (default: True)) – If set to False will omit the ROI ID from channel names.

  • imread_kwargs (Mapping[str, Any] (default: mappingproxy({}))) – Keyword arguments passed to bioio.BioImage.

  • image_models_kwargs (Mapping[str, Any] (default: mappingproxy({}))) – Keyword arguments to pass to the image models. E.g. “chunks” or “scale_factors”.

  • output (str | Path | None (default: None)) – The path where the resulting SpatialData object will be backed. If None, it will not be backed to a zarr store.

  • overwrite (bool (default: False)) – If set to True will overwrite the zarr store at output. Ignored if output is None.

Return type:

SpatialData

Returns:

: spatialdata.SpatialData

Examples

>>> sdata = macsima(
...     path="path/to/roi_folder",  # recursively loads all .tif in this ROI, one image element
...     c_subset=["DAPI", "CD43"],
...     image_models_kwargs={"chunks": (1, 3000, 3000)},
... )
>>> sdata = macsima(
...     path=["path/to/roi_folder", "path/to/another_roi_folder"],  # two ROI folders -> two image elements
...     c_subset=["DAPI", "CD43"],
...     image_models_kwargs={"chunks": (1, 3000, 3000)},
... )