Skip to content

Commit 6d77bb9

Browse files
authored
Merge pull request #889 from fractal-analytics-platform/779_deactivate_cellpose_overlap_check
Remove Cellpose ROI overlap check
2 parents 5c5ccaf + 66f3be1 commit 6d77bb9

File tree

4 files changed

+34
-53
lines changed

4 files changed

+34
-53
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
**Note**: Numbers like (\#123) point to closed Pull Requests on the fractal-tasks-core repository.
22

3+
# 1.4.1
4+
5+
* Tasks:
6+
* Remove overlap checking for output ROIs in Cellpose task to address performance issues (\#889).
37

48
# 1.4.0
59

fractal_tasks_core/tasks/cellpose_segmentation.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
from fractal_tasks_core.roi import (
4545
find_overlaps_in_ROI_indices,
4646
)
47-
from fractal_tasks_core.roi import get_overlapping_pairs_3D
4847
from fractal_tasks_core.roi import is_ROI_table_valid
4948
from fractal_tasks_core.roi import load_region
5049
from fractal_tasks_core.tables import write_table
@@ -561,15 +560,6 @@ def cellpose_segmentation(
561560

562561
bbox_dataframe_list.append(bbox_df)
563562

564-
overlap_list = get_overlapping_pairs_3D(
565-
bbox_df, full_res_pxl_sizes_zyx
566-
)
567-
if len(overlap_list) > 0:
568-
logger.warning(
569-
f"ROI {indices} has "
570-
f"{len(overlap_list)} bounding-box pairs overlap"
571-
)
572-
573563
# Compute and store 0-th level to disk
574564
da.array(new_label_img).to_zarr(
575565
url=mask_zarr,

tests/tasks/test_workflows_cellpose_segmentation.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -602,49 +602,6 @@ def test_workflow_bounding_box(
602602
assert "encoding-version" in table_group.attrs.asdict().keys()
603603

604604

605-
def test_workflow_bounding_box_with_overlap(
606-
tmp_path: Path,
607-
zenodo_zarr: list[str],
608-
caplog: pytest.LogCaptureFixture,
609-
monkeypatch: MonkeyPatch,
610-
):
611-
monkeypatch.setattr(
612-
"fractal_tasks_core.tasks.cellpose_segmentation.cellpose.core.use_gpu",
613-
patched_cellpose_core_use_gpu,
614-
)
615-
616-
monkeypatch.setattr(
617-
"fractal_tasks_core.tasks.cellpose_segmentation.segment_ROI",
618-
patched_segment_ROI_overlapping_organoids,
619-
)
620-
621-
# Setup caplog fixture, see
622-
# https://docs.pytest.org/en/stable/how-to/logging.html#caplog-fixture
623-
caplog.set_level(logging.WARNING)
624-
625-
# Use pre-made 3D zarr
626-
zarr_dir = tmp_path / "tmp_out/"
627-
zarr_urls = prepare_3D_zarr(str(zarr_dir), zenodo_zarr)
628-
debug(zarr_dir)
629-
debug(zarr_urls)
630-
631-
# Per-FOV labeling
632-
channel = CellposeChannel1InputModel(
633-
wavelength_id="A01_C01", normalize=CellposeCustomNormalizer()
634-
)
635-
for zarr_url in zarr_urls:
636-
cellpose_segmentation(
637-
zarr_url=zarr_url,
638-
channel=channel,
639-
level=3,
640-
relabeling=True,
641-
diameter_level0=80.0,
642-
output_ROI_table="bbox_table",
643-
)
644-
debug(caplog.text)
645-
assert "bounding-box pairs overlap" in caplog.text
646-
647-
648605
def test_cellpose_within_masked_bb_with_overlap(
649606
tmp_path: Path,
650607
zenodo_zarr: list[str],

tests/test_unit_ROIs.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
find_overlaps_in_ROI_indices,
3131
)
3232
from fractal_tasks_core.roi import get_image_grid_ROIs
33+
from fractal_tasks_core.roi import get_overlapping_pairs_3D
3334
from fractal_tasks_core.roi import get_single_image_ROI
3435
from fractal_tasks_core.roi import is_ROI_table_valid
3536
from fractal_tasks_core.roi import (
@@ -755,3 +756,32 @@ def test_create_roi_table_from_df_list_with_label_repeats():
755756
]
756757
)
757758
np.testing.assert_allclose(output_array, roi_table.X)
759+
760+
761+
def test_get_overlapping_pairs_3D():
762+
common_columns = {
763+
"y_micrometer": [0.0, 0.0],
764+
"z_micrometer": [0.0, 0.0],
765+
"len_x_micrometer": [1.0, 1.0],
766+
"len_y_micrometer": [1.0, 1.0],
767+
"len_z_micrometer": [1.0, 1.0],
768+
"label": [1, 2],
769+
}
770+
df_overlapping = pd.DataFrame(
771+
{"x_micrometer": [0.0, 0.5], **common_columns}
772+
)
773+
full_res_pxl_sizes_zyx = [1.0, 1.0, 1.0]
774+
df_non_overlapping = pd.DataFrame(
775+
{"x_micrometer": [0.0, 2.0], **common_columns}
776+
)
777+
res_overlapping = get_overlapping_pairs_3D(
778+
df_overlapping,
779+
full_res_pxl_sizes_zyx,
780+
)
781+
assert len(res_overlapping) == 1
782+
783+
res_non_overlapping = get_overlapping_pairs_3D(
784+
df_non_overlapping,
785+
full_res_pxl_sizes_zyx,
786+
)
787+
assert len(res_non_overlapping) == 0

0 commit comments

Comments
 (0)