Skip to content

Commit

Permalink
add workaround for sdata objects with multiple labels
Browse files Browse the repository at this point in the history
supports some labels not being in the scportrait compatible format
  • Loading branch information
sophiamaedler committed Jan 9, 2025
1 parent 62f70fa commit d53eab4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/scportrait/pipeline/_utils/sdata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ def _read_sdata(self) -> SpatialData:
_sdata = SpatialData()
_sdata.write(self.sdata_path, overwrite=True)

allowed_labels = ["seg_all_nucleus", "seg_all_cytosol"]
for key in _sdata.labels:
segmentation_object = _sdata.labels[key]
if not hasattr(segmentation_object.attrs, "cell_ids"):
segmentation_object = spLabels2DModel().convert(segmentation_object, classes=None)
if key in allowed_labels:
segmentation_object = _sdata.labels[key]
if not hasattr(segmentation_object.attrs, "cell_ids"):
segmentation_object = spLabels2DModel().convert(segmentation_object, classes=None)

return _sdata

Expand Down

0 comments on commit d53eab4

Please sign in to comment.