Clean up cell detection and fail fast on invalid input#2026
Merged
petebankhead merged 4 commits intoqupath:mainfrom Oct 29, 2025
Merged
Clean up cell detection and fail fast on invalid input#2026petebankhead merged 4 commits intoqupath:mainfrom
petebankhead merged 4 commits intoqupath:mainfrom
Conversation
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.
qupath-core-processing/src/main/java/qupath/imagej/detect/cells/WatershedCellDetection.java
Outdated
Show resolved
Hide resolved
alanocallaghan
approved these changes
Oct 29, 2025
Contributor
alanocallaghan
left a comment
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This firstly (conservatively) cleans up
WatershedCellDetectionwhile 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: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
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.