insitupy.spatialdata.convert_from_spatialdata

insitupy.spatialdata.convert_from_spatialdata#

insitupy.spatialdata.convert_from_spatialdata(sdata, verbose=True, strict=False)#

Convert an InSituPy-dialect SpatialData object back into an InSituData or InSituExperiment.

A true inverse of convert_to_spatialdata(): the dialect and every modality-naming detail (pixel sizes, RGB-ness, per-cell-layer boundaries, per-unit-layer tables, …) are auto-detected from the store itself and sdata.attrs["insitupy_spatialdata_dialect"] - no caller-supplied keys or pixel sizes are needed. Returns a bare InSituData for a single-sample store (no SAMPLE.<uid>.. prefix in any element key), or an InSituExperiment of InSituData objects for a multi-sample store.

The returned object has no backing project directory - call .saveas(path) to persist it as a .insitupy project before .save() can be used.

Parameters:
  • sdata (SpatialData) – A SpatialData object written by convert_to_spatialdata().

  • verbose (bool (default: True)) – If True, log progress for each modality.

  • strict (bool (default: False)) – If True, raise on an incompletely-written store (a cell/units layer present but missing its table, or a cell layer with boundaries but no recorded _insitupy_seg_mask_value) instead of warning and skipping it (SD-B7). Default False preserves the lenient warn-and-skip behaviour.

Returns:

The reconstructed object(s).

Return type:

InSituData | InSituExperiment

Raises:

ValueError – If sdata.attrs carries no InSituPy dialect descriptor (i.e. this is a foreign/labels-native store InSituPy did not write - see insitupy.spatialdata.convert_from_foreign_spatialdata()) or if the descriptor’s version is not one this InSituPy version supports.