dice-score-3d


Namedice-score-3d JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryUtility for calculating the Dice Similarity Coefficient (DSC) for 3D segmentation masks.
upload_time2024-07-15 08:39:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2024 ancestor-mithril Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords image segmentation dice similarity coefficient dice score
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dice-score-3d
Utility for calculating the Dice Similarity Coefficient (DSC) for 3D segmentation masks. Writes the results in a csv or json file and can be used both from the terminal or from a Python script. 
Calculates per-case mean Dice and weighted mean Dice, and per-label mean Dice, weighted mean Dice and Union Dice. The Union Dice for a label is the Dice Score calculated as if all the cases are concatenated into a single big case, aiming to balance out cases in which the Dice Score is 0 but have very few FP voxels or cases in which the Dice Score is 1 but have no positive voxels.

## Installation

```
pip install --upgrade dice-score-3d
```

## Usage

Simple usage (Python):
```py
from dice_score_3d import dice_metrics

results_dict = dice_metrics(gt_dir, pred_dir, output_path=None, indices={'lung': 1, 'heart': 2}, suffix='.nii.gz')
# Write to csv: 
dice_metrics(gt_dir, pred_dir, output_path='results.csv',  indices={'lung': 1, 'heart': 2}, suffix='.nii.gz', num_workers=8)
```

Simple usage (terminal):
```
dice_score_3d GT.nii.gz PRED.nii.gz -output results.json -indices "{'lung': 1, 'heart': 2}" --console
dice_score_3d GT.nii.gz PRED.nii.gz -output results.json -indices indices.json
```

Complete documentation:
```
usage: dice_score_3d [-h] -output OUTPUT -indices INDICES [--reorient] [-dtype {uint8,uint16}] [-prefix PREFIX] [-suffix SUFFIX] [-num_workers NUM_WORKERS] [--console]
                     ground_truths predictions

DICE Score 3D

positional arguments:
  ground_truths         Path to Ground Truth. Can be a single file or a folder with all the GT volumes. The number of GT files must match the number of predictions. When passing a     
                        folder of GT files, the name of the GT files must match the name of the predictions. This is not applicable when passing a single file. Supported file
                        formats: .nii, .nii.gz, .nrrd, .mha, .gipl.
  predictions           Path to Ground Truth. Can be a single file or a folder with all the predicted volumes. The number of prediction files must match the number of GT files. When   
                        passing a folder of prediction files, the name of the prediction files must match the name of the GT files. This is not applicable when passing a single file.  
                        Supported file formats: .nii, .nii.gz, .nrrd, .mha, .gipl.

options:
  -h, --help            show this help message and exit
  -output OUTPUT        The output path to write the computed metrics. Can be a csv or json file, depending on extension. Example: "results.csv", "results.json".
  -indices INDICES      Path to the json file describing the indices used for calculating the Dice Similarity Coefficient. Can also be a json string. Only the indices present in the   
                        json are considered when evaluating the Dice Score. Example: "{"lung_left": 1, "lung_right": 2}".
  --reorient            Reorients both the GT and the prediction to the default "LPS" orientation before calculating the Dice Score.
  -dtype {uint8,uint16}
                        Must be either "uint8" when having less than 255 classes, or "uint16" otherwise. Default: uint8.
  -prefix PREFIX        This parameter is used when the ground truth path is a folder. It filters all the files in the folder and selects only the files with this prefix.
  -suffix SUFFIX        This parameter is used when the ground truth path is a folder. It filters all the files in the folder and selects only the files with this suffix. Default: .nii.gz.
  -num_workers NUM_WORKERS
                        Number of parallel processes to be used to calculate the Dice Score in parallel. Default: 0.
  --console             Also prints the Dice metrics to console.
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dice-score-3d",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "George Stoica <george.stoica@senticlab.com>",
    "keywords": "image segmentation, dice similarity coefficient, dice score",
    "author": null,
    "author_email": "George Stoica <george.stoica@senticlab.com>",
    "download_url": "https://files.pythonhosted.org/packages/2c/8c/0545507c8fbd29c9fb90d836192f539c18ce563d6e84b2114e032b4957f0/dice_score_3d-1.0.2.tar.gz",
    "platform": null,
    "description": "# dice-score-3d\nUtility for calculating the Dice Similarity Coefficient (DSC) for 3D segmentation masks. Writes the results in a csv or json file and can be used both from the terminal or from a Python script. \nCalculates per-case mean Dice and weighted mean Dice, and per-label mean Dice, weighted mean Dice and Union Dice. The Union Dice for a label is the Dice Score calculated as if all the cases are concatenated into a single big case, aiming to balance out cases in which the Dice Score is 0 but have very few FP voxels or cases in which the Dice Score is 1 but have no positive voxels.\n\n## Installation\n\n```\npip install --upgrade dice-score-3d\n```\n\n## Usage\n\nSimple usage (Python):\n```py\nfrom dice_score_3d import dice_metrics\n\nresults_dict = dice_metrics(gt_dir, pred_dir, output_path=None, indices={'lung': 1, 'heart': 2}, suffix='.nii.gz')\n# Write to csv: \ndice_metrics(gt_dir, pred_dir, output_path='results.csv',  indices={'lung': 1, 'heart': 2}, suffix='.nii.gz', num_workers=8)\n```\n\nSimple usage (terminal):\n```\ndice_score_3d GT.nii.gz PRED.nii.gz -output results.json -indices \"{'lung': 1, 'heart': 2}\" --console\ndice_score_3d GT.nii.gz PRED.nii.gz -output results.json -indices indices.json\n```\n\nComplete documentation:\n```\nusage: dice_score_3d [-h] -output OUTPUT -indices INDICES [--reorient] [-dtype {uint8,uint16}] [-prefix PREFIX] [-suffix SUFFIX] [-num_workers NUM_WORKERS] [--console]\n                     ground_truths predictions\n\nDICE Score 3D\n\npositional arguments:\n  ground_truths         Path to Ground Truth. Can be a single file or a folder with all the GT volumes. The number of GT files must match the number of predictions. When passing a     \n                        folder of GT files, the name of the GT files must match the name of the predictions. This is not applicable when passing a single file. Supported file\n                        formats: .nii, .nii.gz, .nrrd, .mha, .gipl.\n  predictions           Path to Ground Truth. Can be a single file or a folder with all the predicted volumes. The number of prediction files must match the number of GT files. When   \n                        passing a folder of prediction files, the name of the prediction files must match the name of the GT files. This is not applicable when passing a single file.  \n                        Supported file formats: .nii, .nii.gz, .nrrd, .mha, .gipl.\n\noptions:\n  -h, --help            show this help message and exit\n  -output OUTPUT        The output path to write the computed metrics. Can be a csv or json file, depending on extension. Example: \"results.csv\", \"results.json\".\n  -indices INDICES      Path to the json file describing the indices used for calculating the Dice Similarity Coefficient. Can also be a json string. Only the indices present in the   \n                        json are considered when evaluating the Dice Score. Example: \"{\"lung_left\": 1, \"lung_right\": 2}\".\n  --reorient            Reorients both the GT and the prediction to the default \"LPS\" orientation before calculating the Dice Score.\n  -dtype {uint8,uint16}\n                        Must be either \"uint8\" when having less than 255 classes, or \"uint16\" otherwise. Default: uint8.\n  -prefix PREFIX        This parameter is used when the ground truth path is a folder. It filters all the files in the folder and selects only the files with this prefix.\n  -suffix SUFFIX        This parameter is used when the ground truth path is a folder. It filters all the files in the folder and selects only the files with this suffix. Default: .nii.gz.\n  -num_workers NUM_WORKERS\n                        Number of parallel processes to be used to calculate the Dice Score in parallel. Default: 0.\n  --console             Also prints the Dice metrics to console.\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 ancestor-mithril  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Utility for calculating the Dice Similarity Coefficient (DSC) for 3D segmentation masks.",
    "version": "1.0.2",
    "project_urls": {
        "Issues": "https://github.com/ancestor-mithril/dice-score-3d/issues",
        "Repository": "https://github.com/ancestor-mithril/dice-score-3d"
    },
    "split_keywords": [
        "image segmentation",
        " dice similarity coefficient",
        " dice score"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21af8c11e0976f28849752c11381a773f8b8ff2cca4e2c48e149acf328e3ef0c",
                "md5": "757f2a122aa608e762e729df24bbaf0d",
                "sha256": "9950955e07a97de1ac43a6593dc479c35d6ff549b8287684d54fa8f4b3a24434"
            },
            "downloads": -1,
            "filename": "dice_score_3d-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "757f2a122aa608e762e729df24bbaf0d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9461,
            "upload_time": "2024-07-15T08:39:32",
            "upload_time_iso_8601": "2024-07-15T08:39:32.930367Z",
            "url": "https://files.pythonhosted.org/packages/21/af/8c11e0976f28849752c11381a773f8b8ff2cca4e2c48e149acf328e3ef0c/dice_score_3d-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2c8c0545507c8fbd29c9fb90d836192f539c18ce563d6e84b2114e032b4957f0",
                "md5": "ff41c402845fde99c1299bd6933be2fb",
                "sha256": "2ee041bfb4ba196aecda69de54d60e9a77883850d03111518168ace294136a76"
            },
            "downloads": -1,
            "filename": "dice_score_3d-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ff41c402845fde99c1299bd6933be2fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9774,
            "upload_time": "2024-07-15T08:39:34",
            "upload_time_iso_8601": "2024-07-15T08:39:34.161408Z",
            "url": "https://files.pythonhosted.org/packages/2c/8c/0545507c8fbd29c9fb90d836192f539c18ce563d6e84b2114e032b4957f0/dice_score_3d-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-15 08:39:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ancestor-mithril",
    "github_project": "dice-score-3d",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dice-score-3d"
}
        
Elapsed time: 0.30931s