Skip to content

Commit

Permalink
[FIX] ensure channel names are preserved when reading input images fr…
Browse files Browse the repository at this point in the history
…om spatialdata object
  • Loading branch information
sophiamaedler committed Feb 10, 2025
1 parent 4c482d4 commit 088bf42
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/scportrait/pipeline/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,17 +888,22 @@ def load_input_from_sdata(

if isinstance(image, xarray.DataTree):
image_c, image_x, image_y = image.scale0.image.shape

# ensure chunking is correct
for scale in image:
self._check_chunk_size(image[scale].image, chunk_size=self.DEFAULT_CHUNK_SIZE_3D)

# get channel names
channel_names = image.scale0.image.c.values

elif isinstance(image, xarray.DataArray):
(
image_c,
image_x,
image_y,
) = image.shape
image_c, image_x, image_y = image.shape

# ensure chunking is correct
self._check_chunk_size(image, chunk_size=self.DEFAULT_CHUNK_SIZE_3D)

channel_names = image.c.values

# Reset all transformations
if image.attrs.get("transform"):
self.log("Image contained transformations which which were removed.")
Expand All @@ -907,7 +912,7 @@ def load_input_from_sdata(
# check coordinate system of input image
### PLACEHOLDER

self.filehandler._write_image_sdata(image, self.DEFAULT_INPUT_IMAGE_NAME)
self.filehandler._write_image_sdata(image, self.DEFAULT_INPUT_IMAGE_NAME, channel_names=channel_names)

# check if a nucleus segmentation exists and if so add it to the sdata object
if nucleus_segmentation_name is not None:
Expand Down

0 comments on commit 088bf42

Please sign in to comment.