Skip to content
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 overwriting of prediction for multiple thresholds #115

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pytorch3dunet/unet3d/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ def input_to_segm(self, input):
for predictions in input:
for th in self.thresholds:
# threshold probability maps
predictions = predictions > th
predictions_th = predictions > th

if self.invert_pmaps:
# for connected component analysis we need to treat boundary signal as background
# assign 0-label to boundary mask
predictions = np.logical_not(predictions)
predictions_th = np.logical_not(predictions_th)

predictions = predictions.astype(np.uint8)
predictions_th = predictions_th.astype(np.uint8)
# run connected components on the predicted mask; consider only 1-connectivity
seg = measure.label(predictions, background=0, connectivity=1)
seg = measure.label(predictions_th, background=0, connectivity=1)
segs.append(seg)

return np.stack(segs)
Expand Down