segmentationmetrics
Generate segmentation accuracy metrics based on binary masks
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.7%) to scientific vocabulary
Repository
Generate segmentation accuracy metrics based on binary masks
Basic Info
- Host: GitHub
- Owner: alexdaniel654
- License: apache-2.0
- Language: Python
- Default Branch: main
- Size: 163 KB
Statistics
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 4
- Releases: 7
Metadata Files
README.md
Segmentation Metrics
Volumetric binary mask segmentation accuracy metrics
Scope
A small package for assessing the accuracy of binary segmentations. There are lots of metrics that can be used to compare how close two segmentations are, here voxel overlap, surface and volume based metrics are all calculated at once and returned either as individual metrics, a dictionary or a Pandas DataFrame.
The surface based metrics in this package are calculated using code from deepmind's surface-distance repository, however as this is not available as a PyPI package, the code has been included as a submodule here.
Installation
Segmentation Metrics is available on PyPI and can be installed using pip:
bash
pip install segmentationmetrics
or if you're a conda user:
bash
conda install segmentationmetrics -c conda-forge
Alternatively, you can install from source:
bash
git clone https://github.com/alexdaniel654/Segmentation_Metrics.git
cd Segmentation_Metrics
pip install -e .
Calculated Metrics
Voxel overlap based metrics
Surface based metrics
- Mean Surface Distance (in mm) - The symmetric mean surface distance is returned by default i.e. the mean of the distance from surface A to surface B and surface B to surface A.
- Hausdorff Distance (in mm) - Computes the robust distance based on the percentile of distances rather than the maximum distance.
Volume based metrics
- Volume Difference (in millilitres)
Example Usage
```python import nibabel as nib # Package for reading MRI data import segmentationmetrics as sm
imgmanual = nib.load('maskmanuallysegmented.nii.gz') # Load manually generated ground truth mask imgautomatic = nib.load('maskautomaticallysegmented.nii.gz') # Load automatically generated mask
Get voxel data from image object
maskmanual = imgmanual.getfdata() maskautomatic = imgautomatic.getfdata()
Get zoom from header
zoom = imgmanual.header.getzooms()
Generate metrics
metrics = sm.SegmentationMetrics(maskautomatic, maskmanual, zoom)
Print the dice score
print(f'The Dice score is {metrics.dice:.2f}') ```
The Dice score is 0.85
```python
Get and print a DataFrame containing all the scores for this mask pair
df = metrics.get_df() print(df) ```
Metric Score
dice Dice 0.844512
jaccard Jaccard 0.730870
sensitivity Sensitivity 0.732352
specificity Specificity 0.999926
precision Precision 0.997239
accuracy Accuracy 0.990492
mean_surface_distance Mean Surface Distance 1.459697
hausdorff_distance Hausdorff Distance 7.027224
volume_difference Volume Difference -107.212906
true_volume True Volume 403.632624
predicted_volume Predicted Volume 296.419718
```python
As above but with asymmetric mean surface distance and Hausdorff distance defined by the 99th percentil rather than the 95th percentile.
metrics = sm.SegmentationMetrics(maskautomatic, maskmanual, zoom, symmetric=False, percentile=99) df = metrics.get_df() print(df) ```
Metric Score
dice Dice 0.844512
jaccard Jaccard 0.73087
sensitivity Sensitivity 0.732352
specificity Specificity 0.999926
precision Precision 0.997239
accuracy Accuracy 0.990492
mean_surface_distance Mean Surface Distance (1.6603182056644057, 1.259075931110695)
hausdorff_distance Hausdorff Distance 9.335755
volume_difference Volume Difference -107.212906
true_volume True Volume 403.632624
predicted_volume Predicted Volume 296.419718
Owner
- Name: Alex Daniel
- Login: alexdaniel654
- Kind: user
- Location: Nottingham
- Company: The University of Nottingham @SPMIC-UoN
- Website: alexdaniel.info
- Repositories: 21
- Profile: https://github.com/alexdaniel654
Computational physicist working on renal MRI at The University of Nottingham.
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Daniel" given-names: "Alexander J" orcid: "https://orcid.org/0000-0003-2353-3283" title: "Segmentation Metrics" version: 1.1.1 doi: 10.5281/zenodo.6576199 date-released: 2024-07-22 url: "https://github.com/alexdaniel654/Segmentation_Metrics"
GitHub Events
Total
- Watch event: 1
- Delete event: 3
- Issue comment event: 3
- Pull request event: 8
- Create event: 5
Last Year
- Watch event: 1
- Delete event: 3
- Issue comment event: 3
- Pull request event: 8
- Create event: 5
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 99
- Average time to close issues: N/A
- Average time to close pull requests: about 1 month
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.46
- Merged pull requests: 48
- Bot issues: 0
- Bot pull requests: 94
Past Year
- Issues: 0
- Pull requests: 22
- Average time to close issues: N/A
- Average time to close pull requests: 21 days
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.32
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 20
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (127)
- alexdaniel654 (5)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 45 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 7
- Total maintainers: 1
pypi.org: segmentationmetrics
Binary segmentation accuracy metrics
- Homepage: https://github.com/alexdaniel654/Segmentation_Metrics
- Documentation: https://segmentationmetrics.readthedocs.io/
- License: Apache-2.0
-
Latest release: 1.1.1
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- absl-py ==1.1.0
- numpy ==1.22.4
- pandas ==1.4.2
- pytest ==7.1.2
- scikit-image ==0.19.2
- scipy ==1.8.1
- actions/checkout v2 composite
- actions/setup-python v2 composite
- docker://antonyurchenko/git-release v4 composite
- pypa/gh-action-pypi-publish master composite
- actions/checkout v2 composite
- actions/setup-python v2 composite