{"id":28465341,"url":"https://github.com/frankkramer-lab/miseval","last_synced_at":"2025-06-30T19:31:35.039Z","repository":{"id":40641755,"uuid":"443767021","full_name":"frankkramer-lab/miseval","owner":"frankkramer-lab","description":"a metric library for Medical Image Segmentation EVALuation","archived":false,"fork":false,"pushed_at":"2024-10-10T19:19:15.000Z","size":681,"stargazers_count":116,"open_issues_count":5,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-07T05:12:30.004Z","etag":null,"topics":["evaluaton","medical-image-segmentation","metrics","pip","python","reproducibility","segmentation","statistics"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frankkramer-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-02T13:01:26.000Z","updated_at":"2025-05-17T03:23:32.000Z","dependencies_parsed_at":"2022-08-09T23:50:48.776Z","dependency_job_id":null,"html_url":"https://github.com/frankkramer-lab/miseval","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frankkramer-lab/miseval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankkramer-lab%2Fmiseval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankkramer-lab%2Fmiseval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankkramer-lab%2Fmiseval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankkramer-lab%2Fmiseval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frankkramer-lab","download_url":"https://codeload.github.com/frankkramer-lab/miseval/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankkramer-lab%2Fmiseval/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262838095,"owners_count":23372469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["evaluaton","medical-image-segmentation","metrics","pip","python","reproducibility","segmentation","statistics"],"created_at":"2025-06-07T05:11:14.824Z","updated_at":"2025-06-30T19:31:34.982Z","avatar_url":"https://github.com/frankkramer-lab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# miseval: a metric library for Medical Image Segmentation EVALuation\n\n[![shield_python](https://img.shields.io/pypi/pyversions/miseval?style=flat-square)](https://www.python.org/)\n[![shield_build](https://img.shields.io/github/actions/workflow/status/frankkramer-lab/miseval/python-package.yml?branch=master\u0026style=flat-square)](https://github.com/frankkramer-lab/miseval)\n[![shield_pypi_version](https://img.shields.io/pypi/v/miseval?style=flat-square)](https://pypi.org/project/miseval/)\n[![shield_pypi_downloads](https://img.shields.io/pypi/dm/miseval?style=flat-square)](https://pypistats.org/packages/miseval)\n[![shield_license](https://img.shields.io/github/license/frankkramer-lab/miseval?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0.en.html)\n\nThe open-source and free to use Python package miseval was developed to establish a standardized medical image segmentation evaluation procedure. We hope that our this will help improve evaluation quality, reproducibility, and comparability in future studies in the field of medical image segmentation.\n\n#### Guideline on Evaluation Metrics for \tMedical Image Segmentation\n\n1. Use DSC as main metric for validation and performance interpretation.\n2. Use AHD for interpretation on point position sensitivity (contour) if needed.\n3. Avoid any interpretations based on high pixel accuracy scores.\n4. Provide next to DSC also IoU, Sensitivity, and Specificity for method comparability.\n5. Provide sample visualizations, comparing the annotated and predicted segmentation, for visual evaluation as well as to avoid statistical bias.\n6. Avoid cherry-picking high-scoring samples.\n7. Provide histograms or box plots showing the scoring distribution across the dataset.\n8. For multi-class problems, provide metric computations for each class individually.\n9. Avoid confirmation bias through macro-averaging classes which is pushing scores via background class inclusion.\n10. Provide access to evaluation scripts and results with journal data services or third-party services like GitHub and Zenodo for easier reproducibility.\n\n## Implemented Metrics\n\n| Metric      | Index in miseval | Function in miseval |\n| ----------- | ----------- | ----------- |\n| Dice Similarity Index | \"DSC\", \"Dice\", \"DiceSimilarityCoefficient\" | miseval.calc_DSC() |\n| Intersection-Over-Union | \"IoU\", \"Jaccard\", \"IntersectionOverUnion\" | miseval.calc_IoU() |\n| Sensitivity | \"SENS\", \"Sensitivity\", \"Recall\", \"TPR\", \"TruePositiveRate\" | miseval.calc_Sensitivity() |\n| Specificity | \"SPEC\", \"Specificity\", \"TNR\", \"TrueNegativeRate\" | miseval.calc_Specificity() |\n| Precision | \"PREC\", \"Precision\" | miseval.calc_Precision() |\n| Accuracy | \"ACC\", \"Accuracy\", \"RI\", \"RandIndex\" | miseval.calc_Accuracy() |\n| Balanced Accuracy | \"BACC\", \"BalancedAccuracy\" | miseval.calc_BalancedAccuracy() |\n| Adjusted Rand Index | \"ARI\", \"AdjustedRandIndex\" | miseval.calc_AdjustedRandIndex() |\n| AUC | \"AUC\", \"AUC_trapezoid\" | miseval.calc_AUC() |\n| Cohen's Kappa | \"KAP\", \"Kappa\", \"CohensKappa\" | miseval.calc_Kappa() |\n| Hausdorff Distance | \"HD\", \"HausdorffDistance\" | miseval.calc_SimpleHausdorffDistance() |\n| Average Hausdorff Distance | \"AHD\", \"AverageHausdorffDistance\" | miseval.calc_AverageHausdorffDistance() |\n| Volumetric Similarity | \"VS\", \"VolumetricSimilarity\" | miseval.calc_VolumetricSimilarity() |\n| Matthews Correlation Coefficient | \"MCC\", \"MatthewsCorrelationCoefficient\" | miseval.calc_MCC() |\n| Normalized Matthews Correlation Coefficient | \"nMCC\", \"MCC_normalized\" | miseval.calc_MCC_Normalized() |\n| Absolute Matthews Correlation Coefficient | \"aMCC\", \"MCC_absolute\" | miseval.calc_MCC_Absolute() |\n| Boundary Distance | \"BD\", \"Distance\", \" BoundaryDistance\" | miseval.calc_Boundary_Distance() |\n| Hinge Loss | \"Hinge\", \"HingeLoss\" | miseval.calc_Hinge() |\n| Cross-Entropy | \"CE\", \"CrossEntropy\" | miseval.calc_CrossEntropy() |\n| True Positive | \"TP\", \"TruePositive\" | miseval.calc_TruePositive() |\n| False Positive | \"FP\", \"FalsePositive\" | miseval.calc_FalsePositive() |\n| True Negative | \"TN\", \"TrueNegative\" | miseval.calc_TrueNegative() |\n| False Negative | \"FN\", \"FalseNegative\" | miseval.calc_FalseNegative() |\n\n#### Options for Boundary Distance computation\n\n```\nList of available distances:\n  Bhattacharyya distance              bhattacharyya\n  Bhattacharyya coefficient           bhattacharyya_coefficient\n  Canberra distance                   canberra\n  Chebyshev distance                  chebyshev\n  Chi Square distance                 chi_square\n  Cosine Distance                     cosine\n  Euclidean distance                  euclidean\n  Hamming distance                    hamming\n  Jensen-Shannon divergence           jensen_shannon\n  Kullback-Leibler divergence         kullback_leibler\n  Mean absolute error                 mae\n  Taxicab geometry                    manhattan, cityblock, total_variation\n  Minkowski distance                  minkowsky\n  Mean squared error                  mse\n  Pearson's distance                  pearson\n  Squared deviations from the mean    squared_variation\n\nDistance Pooling (how to combine computed distances to a single value):\n  Distance Sum                        sum\n  Distance Averaging                  mean\n  Minimum Distance                    amin\n  Maximum Distance                    amax\n```\n\n## How to Use\n\n#### Example\n\n```python\n# load libraries\nimport numpy as np\nfrom miseval import evaluate\n\n# Get some ground truth / annotated segmentations\nnp.random.seed(1)\nreal_bi = np.random.randint(2, size=(64,64))  # binary (2 classes)\nreal_mc = np.random.randint(5, size=(64,64))  # multi-class (5 classes)\n# Get some predicted segmentations\nnp.random.seed(2)\npred_bi = np.random.randint(2, size=(64,64))  # binary (2 classes)\npred_mc = np.random.randint(5, size=(64,64))  # multi-class (5 classes)\n\n# Run binary evaluation\ndice = evaluate(real_bi, pred_bi, metric=\"DSC\")    \n  # returns single np.float64 e.g. 0.75\n\n# Run multi-class evaluation\ndice_list = evaluate(real_mc, pred_mc, metric=\"DSC\", multi_class=True,\n                     n_classes=5)   \n  # returns array of np.float64 e.g. [0.9, 0.2, 0.6, 0.0, 0.4]\n  # for each class, one score\n```\n\n#### Core function: Evaluate()\n\nEvery metric in miseval can be called via our core function `evaluate()`.\n\nThe miseval eavluate function can be run with different metrics as backbone.  \nYou can pass the following options to the metric parameter:\n- String naming one of the metric labels, for example \"DSC\"\n- Directly passing a metric function, for example calc_DSC_Sets (from dice.py)\n- Passing a custom metric function\n\nList of metrics : See `miseval/__init__.py` under section \"Access Functions to Metric Functions\"\n\nThe classes in a segmentation mask must be ongoing starting from 0 (integers from 0 to n_classes-1).\n\nA segmentation mask is allowed to have either no channel axis or just 1 (e.g. 512x512x1),\nwhich contains the annotation.  \n\n```python\n\"\"\"\nArguments:\n    truth (NumPy Matrix):            Ground Truth segmentation mask.\n    pred (NumPy Matrix):             Prediction segmentation mask.\n    metric (String or Function):     Metric function. Either a function directly or encoded as\n                                     String from miseval or a custom function.\n    multi_class (Boolean):           Boolean parameter, if segmentation is a binary or multi-class\n                                     problem. By default False -\u003e Binary mode.\n    n_classes (Integer):             Number of classes. By default 2 -\u003e Binary\n    kwargs (arguments):              Additional arguments for passing down to metric functions.\n\nOutput:\n    score (Float) or scores (List of Float)\n\n    The multi_class parameter defines the output of this function.\n    If n_classes \u003e 2, multi_class is automatically True.\n    If multi_class == False \u0026 n_classes == 2, only a single score (float) is returned.\n    If multi_class == True, multiple scores as a list are returned (for each class one score).\n\"\"\"\ndef evaluate(truth, pred, metric, multi_class=False, n_classes=2, **kwargs)\n```\n\n## Installation\n\n\n- **Install miseval from PyPI (recommended):**\n\n```sh\npip install miseval\n```\n\n- **Alternatively: install miseval from the GitHub source:**\n\nFirst, clone miseval using git:\n\n```sh\ngit clone https://github.com/frankkramer-lab/miseval\n```\n\nThen, go into the miseval folder and run the install command:\n\n```sh\ncd miseval\npython setup.py install\n```\n\n## Author\n\nDominik Müller\\\nEmail: dominik.mueller@informatik.uni-augsburg.de\\\nIT-Infrastructure for Translational Medical Research\\\nUniversity Augsburg\\\nBavaria, Germany\n\n## How to cite / More information\n\nDominik Müller, Dennis Hartmann, Philip Meyer, Florian Auer, Iñaki Soto-Rey, Frank Kramer. (2022)   \nMISeval: a Metric Library for Medical Image Segmentation Evaluation.  \nPubMed: https://pubmed.ncbi.nlm.nih.gov/35612011/    \nDOI: https://doi.org/10.3233/shti220391  \narXiv e-print: https://arxiv.org/abs/2201.09395  \n\n```\n@Article{misevalMUELLER2022,\n  title={MISeval: a Metric Library for Medical Image Segmentation Evaluation},\n  author={Dominik Müller, Dennis Hartmann, Philip Meyer, Florian Auer, Iñaki Soto-Rey, Frank Kramer},\n  year={2022},\n  journal={Studies in health technology and informatics},\n  volume={294},\n  number={},\n  pages={33-37},\n  doi={10.3233/shti220391},\n  eprint={2201.09395},\n  archivePrefix={arXiv},\n  primaryClass={cs.CV}\n}\n```\n\nThank you for citing our work.\n\n## License\n\nThis project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.\\\nSee the LICENSE.md file for license rights and limitations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankkramer-lab%2Fmiseval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankkramer-lab%2Fmiseval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankkramer-lab%2Fmiseval/lists"}