New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add checks for empty arrays post-segmentation #4199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These error messages look much better, thanks.
Since they're uncaught exceptions, they'll appear to the user with a possibly-confusing traceback. Could you add a try...except
block in the CLI layer to instead display the associated error message using printv(..., 'error')
? For example:
spinalcordtoolbox/spinalcordtoolbox/scripts/sct_label_vertebrae.py
Lines 426 to 428 in d6aeaef
except ValueError as e: | |
printv(f'Vertebral detection failed: {e}', 1, 'error') | |
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine, thanks! And yes, if we're going to have some general-purpose custom exceptions, types.py
seems like a fine place for them. I think, as time goes on, we'll see whether or not we like this error-handling pattern.
Description
This PR provides more intuitive feedback when
sct_deepseg_sc
produces an empty array. This avoids a more unintuitive error later on in the postprocessing function.Linked issues
Fixes #4197.