-
Notifications
You must be signed in to change notification settings - Fork 550
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When masks contains no mask labels, save_rois creates an empty .zip archive.
Expected behaviour: no .zip archive should be created.
To Reproduce
- I don’t have permission to share my data, so instead create an image with no cells and therefore no masks:
import tifffile
import numpy as np
img = np.zeros((256, 256), dtype=np.uint8)
path = “/path/to/image.tif"
tifffile.imwrite(path, img, compression="zlib")- CLI (I have also run this in a notebook and can share this, but the steps to reproduce are longer…)
python -m cellpose --dir /Users/cameron/Downloads/cellpose --save_png --in_folders --save_outlines --save_rois --verbose
Run log
(cellpose) cameron@Camerons-MacBook-Pro ~ % python -m cellpose --dir /Users/cameron/Downloads/cellpose --save_png --save_outlines --save_rois --in_folders --verbose
Welcome to CellposeSAM, cellpose v
cellpose version: 4.0.4
platform: darwin
python version: 3.10.17
torch version: 2.7.0! The neural network component of
CPSAM is much larger than in previous versions and CPU excution is slow.
We encourage users to use GPU/MPS if available.
2025-06-14 23:37:05,221 [INFO] WRITING LOG OUTPUT TO /Users/cameron/.cellpose/run.log
2025-06-14 23:37:05,221 [INFO]
cellpose version: 4.0.4
platform: darwin
python version: 3.10.17
torch version: 2.7.0
2025-06-14 23:37:05,221 [INFO] >>>> using CPU
2025-06-14 23:37:05,221 [INFO] >>>> using CPU
2025-06-14 23:37:05,221 [WARNING] the '--no_resample' flag is deprecated in v4.0.1+ and no longer used
2025-06-14 23:37:05,221 [WARNING] the '--diam_mean' flag is deprecated in v4.0.1+ and no longer used
2025-06-14 23:37:05,226 [INFO] >>>> running cellpose on 1 images using all channels
2025-06-14 23:37:06,131 [INFO] >>>> loading model /Users/cameron/.cellpose/models/cpsam
2025-06-14 23:37:07,891 [INFO] 0%| | 0/1 [00:00<?, ?it/s]
2025-06-14 23:37:15,779 [INFO] No cell pixels found.
2025-06-14 23:37:15,785 [WARNING] no masks found, will not save PNG or outlines
2025-06-14 23:37:15,785 [INFO] 100%|##########| 1/1 [00:07<00:00, 7.89s/it]
2025-06-14 23:37:15,785 [INFO] 100%|##########| 1/1 [00:07<00:00, 7.89s/it]
2025-06-14 23:37:15,785 [INFO] >>>> completed in 10.565 sec
Proposed solution
Add a guard clause to save_rois mirroring the behaviour of save_masks
Alternatives considered
- Attempt to handle this at the notebook level instead
- Clean up empty .zip archives afterwards
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working