Skip to content

Clean up cell detection and fail fast on invalid input#2026

Merged
petebankhead merged 4 commits intoqupath:mainfrom
petebankhead:cell-detection
Oct 29, 2025
Merged

Clean up cell detection and fail fast on invalid input#2026
petebankhead merged 4 commits intoqupath:mainfrom
petebankhead:cell-detection

Conversation

@petebankhead
Copy link
Member

This firstly (conservatively) cleans up WatershedCellDetection while trying to avoid any change in behavior.

Then it adds new logic to parseArgument(ImageData<BufferedImage> imageData, String arg) that attempts to fail fast with an exception in the following cases:

  • A brightfield image is processed with non-brightfield parameters
  • A non-brightfield image is processed with brightfield parameters
  • A non-brightfield image is processed while requesting a channel that doesn't exist

It is still possible to process a brightfield image while specifying a channel (stain) that doesn't exist, but I think that might be obscure enough to accept - and it will result in a warning being logged.

The main problem this aims to solve is that the user could use completely invalid parameters and still get sensible results because default channels were chosen.

See also #2025


Along the way, I also changed

ParameterList.updateParameterList(ParameterList params, Map<String, String> mapNew, Locale locale)

so that it now throws an exception (rather than only logging a warning) if attempting to set a parameter that doesn't exist. This could potentially impact other commands, but I hope that if it does then its impact is positive.

This change could however be reverted, since in the end the cell detection adjustments don't rely upon it.

Limited changes that should not make any difference in behavior (if I've done them properly).
Again, if I've done this properly then there should be no change in behavior.
@petebankhead petebankhead added this to the v0.7.0 milestone Oct 29, 2025
Copy link
Contributor

@alanocallaghan alanocallaghan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand a lot of the code still but this seems sensible and certainly resolves the worst examples of silently running on a different channel without even logging a warning.

@petebankhead petebankhead merged commit 089ea98 into qupath:main Oct 29, 2025
3 checks passed
@petebankhead petebankhead deleted the cell-detection branch October 29, 2025 15:09
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