MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.4k stars 403 forks source link

[BUG] Z-axis disagreement for stacks taller than they are X or Y #1020

Closed outofculture closed 1 month ago

outofculture commented 2 months ago

Describe the bug Using the GUI, trying to run a model on a z-stack that has more frames than it has pixels (e.g. 266 frames of 200x200px). The model behaves fine on its own, and the GUI is otherwise treating the z-stack just fine, but the drawing the masks results in ERROR: index 200 is out of bounds for axis 0 with size 200 from somewhere inside the if branch at cellpose/gui/io.py:505. I expect this has to do with the decision on cellpose/gui/io.py:169 that chooses the smallest dimension to be Z, but I was unable to figure out how to carry the gui's choice of Z into this layer of the code properly.

To Reproduce Steps to reproduce the behavior:

  1. Load a z-stack with more frames than edge pixels
  2. Click on 'Run Cyto3'
  3. See error in console

Run log

...
2024-09-25 14:57:23,102 [INFO] 44 cells found with model in 8.088 sec
GUI_INFO: 44 masks found
GUI_INFO: plane 0 outlines processed
GUI_INFO: plane 50 outlines processed
GUI_INFO: plane 100 outlines processed
GUI_INFO: plane 150 outlines processed
GUI_INFO: plane 200 outlines processed
ERROR: index 200 is out of bounds for axis 0 with size 200
carsen-stringer commented 1 month ago

thanks for noticing this, it's now fixed