Skip to content

Commit

Permalink
Set process_3D checkbox based on image_layer.ndim (#34)
Browse files Browse the repository at this point in the history
* set process_3D based on image_layer.ndim

* have 3D test check process_3D value

---------

Co-authored-by: Talley Lambert <[email protected]>
  • Loading branch information
psobolewskiPhD and tlambert03 authored Oct 27, 2024
1 parent c129834 commit b2a2331
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cellpose_napari/_dock_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,15 @@ def update_masks(masks):
widget.masks_orig = masks
logger.debug('masks updated')


@widget.image_layer.changed.connect
def check_dims(image_layer):
if image_layer.ndim == 4 and not image_layer.rgb:
widget.process_3D.value = True
elif image_layer.ndim==3 and not image_layer.rgb:
widget.process_3D.value = True
else:
widget.process_3D.value = False

@widget.compute_masks_button.changed.connect
def _compute_masks(e: Any):

Expand Down
7 changes: 5 additions & 2 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ def test_compute_diameter(qtbot, viewer_widget):

def test_3D_segmentation(qtbot, viewer_widget):
viewer, widget = viewer_widget
# by default the widget loads with `process_3D` set to False
assert widget.process_3D.value == False
viewer.open_sample(PLUGIN_NAME, 'rgb_3D')

# set 3D processing
widget.process_3D.value = True
# check that 3D processing is set correctly after opening a 3D image
assert widget.process_3D.value == True

widget.model_type.value = "cyto3"
widget() # run segmentation with all default parameters

Expand Down

0 comments on commit b2a2331

Please sign in to comment.