Skip to content

Require explicit --mag/--patch_size when defaults differ from encoder preferences - #254

Open
VishalJ99 wants to merge 1 commit into
mahmoodlab:mainfrom
VishalJ99:require-preferred-patch-args
Open

VishalJ99 wants to merge 1 commit into
mahmoodlab:mainfrom
VishalJ99:require-preferred-patch-args

Conversation

@VishalJ99

Copy link
Copy Markdown
Contributor

Follows up on #45, where the suggestion was to avoid silently applying parser defaults for magnification and patch size during feature extraction while keeping preferred settings documented in the README.

Both CLIs now stop with an error only when an omitted --mag or --patch_size would give the chosen encoder something other than its preferred value, printing both copyable flag options (preferred and default). Explicit flags are always honoured, so multi-magnification and non-preferred runs remain possible.

Changes

  • trident/patch_encoder_models/load.py: add PREFERRED_MAG_AND_PATCH_SIZE next to RESIZE_SUPPORTED_PATCH_ENCODERS (matching the README encoder table) and resolve_patching_defaults to fill omitted flags or error on mismatch.
  • run_batch_of_slides.py and run_single_slide.py: run the check for feature extraction while leaving the parsers' numeric defaults unchanged. Slide encoders are checked against their patch encoder, except madeleine (which uses its documented 10x / 256 grid). --task feat --coords_dir is exempt because the coordinate file decides the grid; --task all still checks since it can generate a grid.
  • README.md, .claude/skills/trident/SKILL.md, and .claude/skills/trident/reference.md: document the check and rename the README column to Preferred args.
  • tests/test_run_batch_of_slides.py, tests/test_run_single_slide.py, and tests/test_patch_encoder_resize.py: cover registry alignment, unchanged numeric defaults, matching defaults, explicit overrides, slide-encoder/Madeleine handling, --coords_dir, and error messages.

Behaviour change

  • Flagless batch feature runs (--task all, or --task feat without --coords_dir) with an encoder whose preferred pair differs from 20x/512 (e.g. uni_v1, madeleine) now stop and ask you to pass the mismatched flag(s) explicitly.
  • Flagless run_single_slide.py with its default conch_v15 now stops and asks for --patch_size 512 or --patch_size 256, because the script's default (256) differs from CONCH v1.5's preferred 512.

Verification

34 focused CLI tests pass; all 35 preferred pairs checked against the README and the encoder registry.

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