Skip to content

Imagedraw fixes & update logging#1431

Merged
carsen-stringer merged 7 commits into
mainfrom
imagedraw_fixes
Apr 30, 2026
Merged

Imagedraw fixes & update logging#1431
carsen-stringer merged 7 commits into
mainfrom
imagedraw_fixes

Conversation

@mrariden
Copy link
Copy Markdown
Collaborator

@mrariden mrariden commented Apr 9, 2026

Should fix the bug where drawing fails because the scatter was removed but drawing didn't end. Also added a try/catch block to end the GUI when a drawing error occurs.

Migrated print statements to logs and set up logging to behave different for stdout vs log file, with the log file setting to debug mode by default. Adding logging debug statements won't affect the GUI output behavior but will get caught in the log file. This should be helpful for debugging.

Need to

  • GUI testing protocol
  • Test --verbose flag in CLI
  • Test logging in scripts/notebooks
  • verify passing tests

@mrariden mrariden requested a review from carsen-stringer April 9, 2026 21:29
@mrariden
Copy link
Copy Markdown
Collaborator Author

mrariden commented Apr 9, 2026

Example cellpose GUI stdout:

[GUI INFO] : WRITING LOG OUTPUT TO /home/raridenm/.cellpose/run.log

cellpose version:       4.0.10.dev27+g74b6ba06c.d20260320 
platform:               linux 
python version:         3.13.3 
torch version:          2.8.0+cu128
GUI_INFO: image shape: (600, 600, 3)
GUI_INFO: normalization checked: computing saturation levels (and optionally filtered image)
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
[0, 255.0]
(1, 600, 600, 3)
2026-04-09 17:16:54,652 [io INFO] 53 masks found
2026-04-09 17:16:54,654 [io INFO] creating cellcolors and drawing masks
2026-04-09 17:16:54,660 [io INFO] loaded in previous changes
2026-04-09 17:17:01,886 [io INFO] 54 ROIs saved to /mnt/stringerlab/janelia_images/fromMark_Shaohe_SG/G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x.czi - G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x#09-crop1-slice_seg.npy
2026-04-09 17:17:02,972 [io INFO] 55 ROIs saved to /mnt/stringerlab/janelia_images/fromMark_Shaohe_SG/G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x.czi - G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x#09-crop1-slice_seg.npy
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
2026-04-09 17:17:09,785 [gui INFO] 53 cells found with model in 1.724 sec
2026-04-09 17:17:09,788 [io INFO] 53 masks found
2026-04-09 17:17:09,790 [io INFO] creating cellcolors and drawing masks

Example logfile output for same session:

2026-04-09 17:16:53,454 INFO [io.py:109 -         logger_setup()] WRITING LOG OUTPUT TO /home/raridenm/.cellpose/run.log
2026-04-09 17:16:53,454 INFO [io.py:110 -         logger_setup()]
cellpose version:       4.0.10.dev27+g74b6ba06c.d20260320
platform:               linux
python version:         3.13.3
torch version:          2.8.0+cu128
2026-04-09 17:16:53,670 INFO [core.py:50 -       _use_gpu_torch()] ** TORCH CUDA version installed and working. **
2026-04-09 17:16:54,652 INFO [io.py:435 -        _masks_to_gui()] 53 masks found
2026-04-09 17:16:54,654 INFO [io.py:473 -        _masks_to_gui()] creating cellcolors and drawing masks
2026-04-09 17:16:54,660 INFO [io.py:322 -            _load_seg()] loaded in previous changes
2026-04-09 17:17:01,886 INFO [io.py:632 -           _save_sets()] 54 ROIs saved to /mnt/stringerlab/janelia_images/fromMark_Shaohe_SG/G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x.czi - G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x#09-crop1-slice_seg.npy
2026-04-09 17:17:02,972 INFO [io.py:632 -           _save_sets()] 55 ROIs saved to /mnt/stringerlab/janelia_images/fromMark_Shaohe_SG/G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x.czi - G4_SG2_3XEx_Ribo_647_nDAPI_RLS_6x6_05x#09-crop1-slice_seg.npy
2026-04-09 17:17:08,067 INFO [core.py:50 -       _use_gpu_torch()] ** TORCH CUDA version installed and working. **
2026-04-09 17:17:08,067 INFO [core.py:84 -        assign_device()] >>>> using GPU (CUDA)
2026-04-09 17:17:08,888 INFO [models.py:147 -             __init__()] >>>> loading model /home/raridenm/.cellpose/models/cpsam
2026-04-09 17:17:09,785 INFO [gui.py:1997 - compute_segmentation()] 53 cells found with model in 1.724 sec
2026-04-09 17:17:09,788 INFO [io.py:435 -        _masks_to_gui()] 53 masks found
2026-04-09 17:17:09,790 INFO [io.py:473 -        _masks_to_gui()] creating cellcolors and drawing masks

@mrariden
Copy link
Copy Markdown
Collaborator Author

mrariden commented Apr 29, 2026

Tests passing on

  • Mac
  • Ubuntu

GUI manual testing:

Image loading

  • Drop image into GUI
  • Load from menu
  • Right/left arrow keys to load next image in folder

Network

  • 'run CPSAM' button works
  • Adjusting parameters & hit return to re-run dynamics
    • Diameter
    • Flow threshold
    • cell probability threshold
    • normalization percentiles
    • niter dynamics
  • User models work

GUI: display

  • Image colors work with drop down and arrow key up/down
  • Display data cycles through flows/cellprob/image/restored with drop down and pg up/down
  • Auto adjust saturation checkbox and sliders work

GUI: mouse/ROIs

  • Right click and draw cell
  • Command/ctrl and click to delete cell
  • Left click and drag to pan
  • Scroll to zoom
  • Number of ROIs updates correctly when add/delete cell
  • Masks/outline can be turned on/off with checkbox and (Z & X)
  • Delete multiple ROIs using region selection works
  • Esc to escape drawing (future PR)

GUI: menus

  • All File > saving functions work
  • All Edit > functions work
  • Models >
    • Add model and remove model works
    • Train new model, adjusting training params/name works
  • Help menu items appear when clicked

Filtering

  • Sharpen and smooth radius appear correct and make a 'restored' viewer image
  • tile_norm blocksize normalizes images per block
  • Smoothing in 3D works

@mrariden mrariden changed the title Imagedraw fixes Imagedraw fixes & update logging Apr 29, 2026
@carsen-stringer carsen-stringer merged commit 94ae120 into main Apr 30, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants