Skip to content

fix: autoload _cp_masks and escape glob metacharacters in paths#1421

Open
skpalan wants to merge 1 commit intoMouseLand:mainfrom
skpalan:fix/gui-autoload-cp-masks
Open

fix: autoload _cp_masks and escape glob metacharacters in paths#1421
skpalan wants to merge 1 commit intoMouseLand:mainfrom
skpalan:fix/gui-autoload-cp-masks

Conversation

@skpalan
Copy link
Copy Markdown

@skpalan skpalan commented Mar 29, 2026

Summary

  • Mask auto-load fix: The GUI's autoloadMasks checkbox only searched for _masks.{ext} and _masks.tif, but cellpose itself saves masks as _cp_masks.png / _cp_masks.tif. Added _cp_masks patterns to the search candidates so saved masks are found on reload.
  • Glob escape fix: get_image_files() passes folder paths directly to glob.glob(), which interprets [, ], ?, and * as pattern metacharacters. Directories containing these characters (e.g. data[condition1]) silently return zero matches, raising ValueError: ERROR: no files in --dir folder. Now uses glob.escape() on the folder portion before appending wildcards.

Test plan

  • Open GUI, load a .tif image that has a corresponding _cp_masks.png → mask auto-loads
  • Open GUI, load image from a directory with [brackets] in the path → A/D navigation works
  • Verify _masks.tif and _masks.png patterns still auto-load (backward compat)

…racters in paths

Two fixes:

1. The GUI's mask auto-load (autoloadMasks checkbox) only searched for
   `_masks.{ext}` and `_masks.tif`, but cellpose saves masks as
   `_cp_masks.png`/`_cp_masks.tif`. Add `_cp_masks` patterns to the
   search candidates so saved masks are found on reload.

2. `get_image_files()` passes folder paths directly to `glob.glob()`,
   which interprets `[`, `]`, `?`, and `*` as pattern metacharacters.
   Directories with these characters (e.g. `data[condition1]`) return
   zero matches, raising ValueError. Use `glob.escape()` on the folder
   portion before appending wildcards.
@skpalan skpalan force-pushed the fix/gui-autoload-cp-masks branch from ad35da7 to 775a4b6 Compare March 29, 2026 02:50
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.

1 participant