From 0083e99307e3b55694a6efb259cb9cfc78737a85 Mon Sep 17 00:00:00 2001 From: Cyril Achard <94955160+C-Achard@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:21:35 +0100 Subject: [PATCH] Hotfix : v0.1.1 (#62) * Fix shape >3 issues in sliding_window * Fix artefact removal widget visibility --- napari_cellseg3d/code_models/instance_segmentation.py | 2 +- napari_cellseg3d/code_plugins/plugin_model_inference.py | 5 ++++- napari_cellseg3d/dev_scripts/sliding_window_voronoi.py | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/napari_cellseg3d/code_models/instance_segmentation.py b/napari_cellseg3d/code_models/instance_segmentation.py index 05fd4667..e4a6b38a 100644 --- a/napari_cellseg3d/code_models/instance_segmentation.py +++ b/napari_cellseg3d/code_models/instance_segmentation.py @@ -209,7 +209,7 @@ def sliding_window(volume, func, patch_size=512, increment_labels=True): """ result = np.zeros(volume.shape, dtype=np.uint32) max_label_id = 0 - x, y, z = volume.shape + x, y, z = volume.shape[-3:] pbar_total = (x // patch_size) * (y // patch_size) * (z // patch_size) pbar = tqdm(total=pbar_total) for i in range(0, x, patch_size): diff --git a/napari_cellseg3d/code_plugins/plugin_model_inference.py b/napari_cellseg3d/code_plugins/plugin_model_inference.py index 69e42239..88effabc 100644 --- a/napari_cellseg3d/code_plugins/plugin_model_inference.py +++ b/napari_cellseg3d/code_plugins/plugin_model_inference.py @@ -387,6 +387,9 @@ def _toggle_display_instance(self): def _toggle_artifact_removal_widgets(self): """Shows or hides the options for instance segmentation based on current user selection.""" ui.toggle_visibility(self.use_instance_choice, self.artifact_container) + ui.toggle_visibility( + self.use_instance_choice, self.attempt_artifact_removal_box + ) def _toggle_display_window_size(self): """Show or hide window size choice depending on status of self.window_infer_box.""" @@ -513,7 +516,7 @@ def _build(self): self.artifact_removal_size, ], ) - # self.attempt_artifact_removal_box.setVisible(False) + self.attempt_artifact_removal_box.setVisible(False) self.remove_artifacts_label.setVisible(False) self.artifact_removal_size.setVisible(False) diff --git a/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py b/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py index f8ed4303..e644cd8d 100644 --- a/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py +++ b/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py @@ -1,12 +1,13 @@ +"""Test script for sliding window Voronoi-Otsu segmentation."".""" import numpy as np import pyclesperanto_prototype as cle from tqdm import tqdm def sliding_window_voronoi_otsu(volume, spot_sigma, outline_sigma, patch_size): - """Given a volume of dimensions HxWxD, a spot_sigma and an outline_sigma, - perform Voronoi-Otsu segmentation on the volume using a sliding window of - size patch_size. If the edge has been reached, the patch size is reduced + """Given a volume of dimensions HxWxD, a spot_sigma and an outline_sigma, perform Voronoi-Otsu segmentation on the volume using a sliding window of size patch_size. + + If the edge has been reached, the patch size is reduced to fit the remaining space. The result is a segmentation of the same size as the input volume. @@ -18,7 +19,7 @@ def sliding_window_voronoi_otsu(volume, spot_sigma, outline_sigma, patch_size): """ result = np.zeros(volume.shape, dtype=np.uint32) max_label_id = 0 - x, y, z = volume.shape + x, y, z = volume.shape[-3:] for i in tqdm(range(0, x, patch_size)): for j in range(0, y, patch_size): for k in range(0, z, patch_size):