Skip to content

Commit 1ff35d4

Browse files
Merge pull request #21 from LaboratoryOpticsBiosciences/value_filter
2 parents 499287c + 3e5cd25 commit 1ff35d4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/napari_brainbow_diagnose/_utils_channel_space.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_channels_ranges(a: np.ndarray) -> np.ndarray:
6767

6868

6969
def image_mask_of_wheel_selection(
70-
image: np.ndarray, wheel_selection: np.ndarray
70+
image: np.ndarray, wheel_selection: np.ndarray, value_threshold: float
7171
):
7272
"""
7373
Returns a boolean mask of the wheel selection.
@@ -79,6 +79,9 @@ def image_mask_of_wheel_selection(
7979
Shape: (c, z, y, x) or (c, y, x)
8080
wheel_selection : np.ndarray
8181
The wheel selection to apply.
82+
value_threshold : float
83+
The value threshold to apply to the image voxel.
84+
Only voxels with a value above the threshold will be selected.
8285
8386
Returns
8487
-------
@@ -103,6 +106,9 @@ def image_mask_of_wheel_selection(
103106
selection_mask = selected_points.reshape(image.shape[1:])
104107
selection_mask = selection_mask.astype(bool)
105108

109+
print(selection_mask.shape, (hsv[2] < value_threshold).shape)
110+
selection_mask[hsv[2] < value_threshold] = False
111+
106112
return selection_mask
107113

108114

src/napari_brainbow_diagnose/_widget.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ def create_mask_on_image(self):
9797
bool
9898
)
9999
mask_corrected = self.density_figure.selection_mask.astype(bool)
100-
mask_on_image = image_mask_of_wheel_selection(channels, mask_corrected)
100+
101+
value_threshold = self.density_resolution_widget.value_threshold.value
102+
103+
mask_on_image = image_mask_of_wheel_selection(
104+
channels, mask_corrected, value_threshold
105+
)
101106

102107
self.viewer.add_labels(mask_on_image, name="mask_on_image")
103108

0 commit comments

Comments
 (0)