From 1310767369607de065f6be8894a794a01e1f7bea Mon Sep 17 00:00:00 2001 From: rhoadesScholar Date: Tue, 5 Nov 2024 02:44:13 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20writing=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested via the cellmap-segmentation-challenge repo. --- src/cellmap_data/dataset_writer.py | 2 +- src/cellmap_data/image.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cellmap_data/dataset_writer.py b/src/cellmap_data/dataset_writer.py index 59116f5..1a45304 100644 --- a/src/cellmap_data/dataset_writer.py +++ b/src/cellmap_data/dataset_writer.py @@ -381,7 +381,7 @@ def __setitem__( for c, label in enumerate(self.classes): self.target_array_writers[array_name][label][ self._current_center - ] = array[c] + ] = array[:, c, ...] def __repr__(self) -> str: """Returns a string representation of the dataset.""" diff --git a/src/cellmap_data/image.py b/src/cellmap_data/image.py index 0685432..fdf30ee 100644 --- a/src/cellmap_data/image.py +++ b/src/cellmap_data/image.py @@ -933,7 +933,10 @@ def __setitem__( f"Writing to center {center} in image {self.path} failed. Coordinates: are not all within the image's bounds. Will drop out of bounds data." ) # Crop data to match the number of coordinates matched in the image - slices = [slice(None, len(coord)) for coord in coords.values()] + slices = [] + for coord in coords.values(): + if len(coord) > 1: + slices.append(slice(None, len(coord))) data = data[*slices] self.array.loc[coords] = data