-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fix deepseg threshold (again) #2490
Conversation
@@ -548,7 +548,7 @@ def deep_segmentation_spinalcord(im_image, contrast_type, ctr_algo='cnn', ctr_fi | |||
# Binarize the resampled image (except for soft segmentation, defined by threshold_seg=-1) | |||
if threshold_seg >= 0: | |||
logger.info("Binarizing the resampled segmentation...") | |||
im_seg_r.data = im_seg_r.data.astype(np.uint8) | |||
im_seg_r.data = (im_seg_r.data > 0.5).astype(np.uint8) |
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.
Sorry to change my mind but: was thinking of setting 0 instead of 0.5 so that "no voxel are threshold" during this step and everything is controlled by the "optimised threshold" just after the prediction (ie "everything is controlled by only one threshold"). Does that make sense? or it does not really matter?
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.
actually, to have a proper (i.e. unbiased) thresholding, after resampling, it should be set to 0.5 (equivalent to nearest neighbor). Setting to 0 will introduce a bias in the partial volume cutoff.
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.
Right! Thanks for clarifying, makes sense!
And here are the results of the optimal threshold calculation (commit 845ee14d1b8fc8911585d44bbf9f9e972df98229):
For comparison, here are optimization results from the previous PR:
So, our current results make much more sense, because the T1 and T1w are now very close 👍 |
Make much more sense! 👍 |
c697eaf
to
cb0b3cb
Compare
jca/2488-deepseg-thr (cb0b3cb)
master (d1cdb30)
|
This reverts commit d5d903a.
* deepseg_sc/core: Fixed binarization after resampling * batch_processing.sh: Now outputtting T1 seg in QC * deepseg_sc/core: Updated optimal thresholds Former-commit-id: 1b2501b61b54e73c92ecfc0251c48e3a2f8926c5 [formerly fc6b564 [formerly d5d903a]] Former-commit-id: e5b619f3e07a431d75fb63e99de53e695686e086 Former-commit-id: ffcc4b2
* deepseg_sc/core: Fixed binarization after resampling * batch_processing.sh: Now outputtting T1 seg in QC * deepseg_sc/core: Updated optimal thresholds Former-commit-id: d5d903a
The recently-merged PR (#2479), which consisted in finding the optimal threshold per contrast, by minimizing the STD of CSA across contrasts, was implemented with a flaw: the binarization after resampling was not done properly. This PR fixes it, and updated the optimal threshold per contrast using this repository (commit a482d205120d76893c4f21c76e4535cc45bbce11).
Fixes #2488