Skip to content

Commit

Permalink
update omero exlcuding it from labels
Browse files Browse the repository at this point in the history
  • Loading branch information
giovp committed Feb 20, 2023
1 parent 4214abc commit f65151e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
10 changes: 6 additions & 4 deletions spatialdata/_io/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ def _read_multiscale(
encoded_ngff_transformations = multiscales[0]["coordinateTransformations"]
transformations = _get_transformations_from_ngff_dict(encoded_ngff_transformations)
node.metadata["name"]
omero = multiscales[0]["omero"]
channels = fmt.channels_from_metadata(omero)
# if image, read channels metadata
if raster_type == "image":
omero = multiscales[0]["omero"]
channels = fmt.channels_from_metadata(omero)
axes = [i["name"] for i in node.metadata["axes"]]
if len(datasets) > 1:
multiscale_image = {}
Expand All @@ -168,7 +170,7 @@ def _read_multiscale(
name="image",
# name=name,
dims=axes,
coords={"c": channels},
coords={"c": channels} if raster_type == "image" else {},
# attrs={"transform": t},
)
msi = MultiscaleSpatialImage.from_dict(multiscale_image)
Expand All @@ -182,7 +184,7 @@ def _read_multiscale(
name="image",
# name=name,
dims=axes,
coords={"c": channels},
coords={"c": channels} if raster_type == "image" else {},
# attrs={TRANSFORM_KEY: t},
)
_set_transformations(si, transformations)
Expand Down
3 changes: 2 additions & 1 deletion spatialdata/_io/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def _get_group_for_writing_transformations() -> zarr.Group:
return group["labels"][name]

# convert channel names to channel metadata
metadata["omero"] = fmt.channels_to_metadata(raster_data, channels_metadata)
if raster_type == "image":
metadata["omero"] = fmt.channels_to_metadata(raster_data, channels_metadata)

if isinstance(raster_data, SpatialImage):
data = raster_data.data
Expand Down
10 changes: 2 additions & 8 deletions tests/_io/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def test_images(self, tmp_path: str, images: SpatialData) -> None:
sdata = SpatialData.read(tmpdir)
assert images.images.keys() == sdata.images.keys()
for k in images.images.keys():
if isinstance(sdata.images[k], SpatialImage):
assert images.images[k].equals(sdata.images[k])
elif isinstance(images.images[k], MultiscaleSpatialImage):
assert images.images[k].equals(sdata.images[k])
assert images.images[k].equals(sdata.images[k])

def test_labels(self, tmp_path: str, labels: SpatialData) -> None:
"""Test read/write."""
Expand All @@ -38,10 +35,7 @@ def test_labels(self, tmp_path: str, labels: SpatialData) -> None:
sdata = SpatialData.read(tmpdir)
assert labels.labels.keys() == sdata.labels.keys()
for k in labels.labels.keys():
if isinstance(sdata.labels[k], SpatialImage):
assert labels.labels[k].equals(sdata.labels[k])
elif isinstance(sdata.labels[k], MultiscaleSpatialImage):
assert labels.labels[k].equals(sdata.labels[k])
assert labels.labels[k].equals(sdata.labels[k])

def test_shapes(self, tmp_path: str, shapes: SpatialData) -> None:
"""Test read/write."""
Expand Down

0 comments on commit f65151e

Please sign in to comment.