From 4a6308424d1c9d9dbe20b4e885587a88baa9ad63 Mon Sep 17 00:00:00 2001 From: Nora Koreuber Date: Fri, 16 Oct 2026 16:09:28 +0200 Subject: [PATCH 1/4] make nuclei mask default --- src/bio_image_datasets/pathocell2_dataset.py | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/bio_image_datasets/pathocell2_dataset.py b/src/bio_image_datasets/pathocell2_dataset.py index 61d78c1..ef748bc 100644 --- a/src/bio_image_datasets/pathocell2_dataset.py +++ b/src/bio_image_datasets/pathocell2_dataset.py @@ -179,31 +179,31 @@ def get_class_mapping(self): return coarse_mapping def get_instance_mask(self, idx): - """Return the cell instance mask at the given index. + """Return the nuclei instance mask at the given index. In this dataset, instance files can be provided as separate cell and nuclei masks, - so the cell mask is treated as the primary instance mask and the nuclei mask is - exposed separately via get_nuclei_mask(). + so the nuclei mask is treated as the primary instance mask and the cell mask is + exposed separately via get_cell_mask(). """ if idx >= len(self): raise IndexError("Index out of bounds.") sample_name = self.sample_names[idx] - cell_path, _ = self._get_instance_mask_paths(sample_name) - if cell_path is not None: - return self._load_mask_from_path(cell_path) + _, nuclei_path = self._get_instance_mask_paths(sample_name) + if nuclei_path is not None: + return self._load_mask_from_path(nuclei_path) return self._load_mask(self.instance_dir, idx) - def get_nuclei_mask(self, idx): - """Return the nuclei instance mask at the given index if it exists.""" + def get_cell_mask(self, idx): + """Return the cell instance mask at the given index if it exists.""" if idx >= len(self): raise IndexError("Index out of bounds.") sample_name = self.sample_names[idx] - _, nuclei_path = self._get_instance_mask_paths(sample_name) - if nuclei_path is None: + cell_path, _ = self._get_instance_mask_paths(sample_name) + if cell_path is None: return None - return self._load_mask_from_path(nuclei_path) + return self._load_mask_from_path(cell_path) def _load_mask_from_path(self, path): """Load a single mask from a TIFF path and sanitize its dimensionality.""" From 8c80b55b7670e8c23bedfd4c6be0f70ff30d0a7b Mon Sep 17 00:00:00 2001 From: Nora Koreuber Date: Fri, 16 Oct 2026 16:22:10 +0200 Subject: [PATCH 2/4] update test of pathocell2 --- tests/test_pathocell2_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pathocell2_dataset.py b/tests/test_pathocell2_dataset.py index f2bc1d1..dc78629 100644 --- a/tests/test_pathocell2_dataset.py +++ b/tests/test_pathocell2_dataset.py @@ -102,11 +102,11 @@ def test_get_semantic_mask(): assert semantic_mask.shape == (32, 32) -def test_get_nuclei_mask(): +def test_get_cell_mask(): with tempfile.TemporaryDirectory() as tmp_dir: prepare_pathocell2_samples(tmp_dir, num_samples=4) dataset = PathoCell2Dataset(local_path=tmp_dir) - assert dataset.get_nuclei_mask(0) is None + assert dataset.get_cell_mask(0) is None def test_get_sample_name(): From a03256e09b109362467d189b98df17aa6eb6de68 Mon Sep 17 00:00:00 2001 From: Nora Koreuber Date: Fri, 16 Oct 2026 16:28:33 +0200 Subject: [PATCH 3/4] fix getting cell mask for getitem in pathocell2 --- src/bio_image_datasets/pathocell2_dataset.py | 2 +- tests/test_pathocell2_dataset.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bio_image_datasets/pathocell2_dataset.py b/src/bio_image_datasets/pathocell2_dataset.py index 659ac96..a6bd14d 100644 --- a/src/bio_image_datasets/pathocell2_dataset.py +++ b/src/bio_image_datasets/pathocell2_dataset.py @@ -158,7 +158,7 @@ def __getitem__(self, idx): 'if_image': self.get_if(idx), 'semantic_mask': self.get_semantic_mask(idx), 'instance_mask': self.get_instance_mask(idx), - 'nuclei_mask': self.get_nuclei_mask(idx), + 'cell_mask': self.get_cell_mask(idx), 'sample_name': sample_name, } diff --git a/tests/test_pathocell2_dataset.py b/tests/test_pathocell2_dataset.py index dc78629..434a3ac 100644 --- a/tests/test_pathocell2_dataset.py +++ b/tests/test_pathocell2_dataset.py @@ -58,7 +58,7 @@ def test_getitem(): assert "if_image" in sample assert "semantic_mask" in sample assert "instance_mask" in sample - assert "nuclei_mask" in sample + assert "cell_mask" in sample assert "sample_name" in sample From 1096391443ee4eb3ab1581c9e0362027d656cbf4 Mon Sep 17 00:00:00 2001 From: Nora Koreuber Date: Fri, 16 Oct 2026 16:43:59 +0200 Subject: [PATCH 4/4] fix test for retrieving cell mask --- tests/test_pathocell2_dataset.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_pathocell2_dataset.py b/tests/test_pathocell2_dataset.py index 434a3ac..978ea03 100644 --- a/tests/test_pathocell2_dataset.py +++ b/tests/test_pathocell2_dataset.py @@ -106,7 +106,9 @@ def test_get_cell_mask(): with tempfile.TemporaryDirectory() as tmp_dir: prepare_pathocell2_samples(tmp_dir, num_samples=4) dataset = PathoCell2Dataset(local_path=tmp_dir) - assert dataset.get_cell_mask(0) is None + cell_mask = dataset.get_cell_mask(0) + assert cell_mask is not None + assert cell_mask.shape == (32, 32) def test_get_sample_name():