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 QC for soft segmentations that have light regions close to 1.0 (e.g. 0.999) #4193

Merged
merged 2 commits into from Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion spinalcordtoolbox/reports/slice.py
Expand Up @@ -60,7 +60,7 @@ def __init__(self, images, p_resample=0.6):
# Check if image is a segmentation (binary or soft) by making sure:
# - 0/1 are the two most common voxel values
# - 0/1 account for >95% of voxels (to allow for some soft voxels)
unique, counts = np.unique(img.data, return_counts=True)
unique, counts = np.unique(np.round(img.data, decimals=1), return_counts=True)
unique, counts = unique[np.argsort(counts)[::-1]], counts[np.argsort(counts)[::-1]] # Sort by counts
binary_most_common = set(unique[0:2].astype(float)) == {0.0, 1.0}
binary_percentage = np.sum(counts[0:2]) / np.sum(counts)
Expand Down