boa-contrast


Nameboa-contrast JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/UMEssen/BOA-Contrast
Summary
upload_time2023-08-04 11:45:15
maintainer
docs_urlNone
authorGiulia Baldini
requires_python>=3.8,<3.11
licenseMIT
keywords python contrast intravenous gastrointestinal tract ct machine learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
             # BOA::Contrast

Package to compute contrast information from a CT image, part of the [BOA](https://github.com/UMEssen/Body-and-Organ-Analyzer) (soon online!). The package uses the open-source software [TotalSegmentator](https://github.com/wasserth/TotalSegmentator) to compute segmentations of important anatomical landmarks, which are then used to create features for a machine learning model to predict the contrast information.

## Install

```bash
pip install boa-contrast
```

will install only the basic package (without the TotalSegmentator), if you also want to install the TotalSegmentator you can

```bash
pip install "boa-contrast[totalsegmentator]"
```

However, the TotalSegmentator can also be used together with docker, and in such case it is not needed to install it.

## Command Line
```
constrast-recognition --help
```
Once a CT and a folder where to store the TotalSegmentator segmentations is given, you can run it using the following command
```
contrast-recognition [-h] --ct-path CT_PATH --segmentation-folder SEGMENTATION_FOLDER [--docker] [--user-id USER_ID] [--device-id DEVICE_ID] [-v]
```

You can run it using docker by using the `--docker` flag. If you are using docker, you need to specify your user ID using the `--user-id` flag, otherwise you will have to change the ownership of the segmentations afterwards.

If you are using a GPU, you can specify the device ID using the `--device-id` flag.

You can enable verbosity with the `-v` flag.

To not download the TotalSegmentator weights all the time, you can specify their location using the `TOTALSEG_WEIGHTS_PATH` environment variable.

A sample output looks as follows:
```
IV Phase: NON_CONTRAST
Contrast in GIT: NO_CONTRAST_IN_GI_TRACT
```

## From Python
Compute the segmentation with the TotalSegmentator with docker

```python
from boa_contrast import compute_segmentation

compute_segmentation(
    ct_path=...,  # The path to the CT
    segmentation_folder=...,  # The root where the segmentation should be stored
    device_id=...,  # The ID of the GPU device or -1
    user_id=...,  # Your user ID for docker to run in user mode
    compute_with_docker=False,  # Whether to use docker or not
)
```

Once the segmentation is computed

```python
from boa_contrast import predict

predict(
    ct_path=...,  # path to the CT
    segmentation_folder=...,  # path to this CT's segmentation
)
```

Output:
```
{
    "phase_ensemble_prediction": 0,
    "phase_ensemble_predicted_class": "NON_CONTRAST",
    "phase_ensemble_probas": array(
        [
            9.89733540e-01,
            3.60637282e-04,
            4.79974664e-04,
            5.55973168e-04,
            8.86987492e-03,
        ]
    ),
    "git_ensemble_prediction": 0,
    "git_ensemble_predicted_class": "NO_CONTRAST_IN_GI_TRACT",
    "git_ensemble_probas": array(
        [
            9.99951577e-01,
            4.84187825e-05,
        ]
    ),
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/UMEssen/BOA-Contrast",
    "name": "boa-contrast",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.11",
    "maintainer_email": "",
    "keywords": "python,contrast,intravenous,gastrointestinal tract,CT,machine learning",
    "author": "Giulia Baldini",
    "author_email": "Giulia.Baldini@uk-essen.de",
    "download_url": "https://files.pythonhosted.org/packages/0c/f2/5e176422a8ea891eb315e0de0fccf3320bae9483e41666f62c3c87956a93/boa_contrast-0.1.3.tar.gz",
    "platform": null,
    "description": " # BOA::Contrast\n\nPackage to compute contrast information from a CT image, part of the [BOA](https://github.com/UMEssen/Body-and-Organ-Analyzer) (soon online!). The package uses the open-source software [TotalSegmentator](https://github.com/wasserth/TotalSegmentator) to compute segmentations of important anatomical landmarks, which are then used to create features for a machine learning model to predict the contrast information.\n\n## Install\n\n```bash\npip install boa-contrast\n```\n\nwill install only the basic package (without the TotalSegmentator), if you also want to install the TotalSegmentator you can\n\n```bash\npip install \"boa-contrast[totalsegmentator]\"\n```\n\nHowever, the TotalSegmentator can also be used together with docker, and in such case it is not needed to install it.\n\n## Command Line\n```\nconstrast-recognition --help\n```\nOnce a CT and a folder where to store the TotalSegmentator segmentations is given, you can run it using the following command\n```\ncontrast-recognition [-h] --ct-path CT_PATH --segmentation-folder SEGMENTATION_FOLDER [--docker] [--user-id USER_ID] [--device-id DEVICE_ID] [-v]\n```\n\nYou can run it using docker by using the `--docker` flag. If you are using docker, you need to specify your user ID using the `--user-id` flag, otherwise you will have to change the ownership of the segmentations afterwards.\n\nIf you are using a GPU, you can specify the device ID using the `--device-id` flag.\n\nYou can enable verbosity with the `-v` flag.\n\nTo not download the TotalSegmentator weights all the time, you can specify their location using the `TOTALSEG_WEIGHTS_PATH` environment variable.\n\nA sample output looks as follows:\n```\nIV Phase: NON_CONTRAST\nContrast in GIT: NO_CONTRAST_IN_GI_TRACT\n```\n\n## From Python\nCompute the segmentation with the TotalSegmentator with docker\n\n```python\nfrom boa_contrast import compute_segmentation\n\ncompute_segmentation(\n    ct_path=...,  # The path to the CT\n    segmentation_folder=...,  # The root where the segmentation should be stored\n    device_id=...,  # The ID of the GPU device or -1\n    user_id=...,  # Your user ID for docker to run in user mode\n    compute_with_docker=False,  # Whether to use docker or not\n)\n```\n\nOnce the segmentation is computed\n\n```python\nfrom boa_contrast import predict\n\npredict(\n    ct_path=...,  # path to the CT\n    segmentation_folder=...,  # path to this CT's segmentation\n)\n```\n\nOutput:\n```\n{\n    \"phase_ensemble_prediction\": 0,\n    \"phase_ensemble_predicted_class\": \"NON_CONTRAST\",\n    \"phase_ensemble_probas\": array(\n        [\n            9.89733540e-01,\n            3.60637282e-04,\n            4.79974664e-04,\n            5.55973168e-04,\n            8.86987492e-03,\n        ]\n    ),\n    \"git_ensemble_prediction\": 0,\n    \"git_ensemble_predicted_class\": \"NO_CONTRAST_IN_GI_TRACT\",\n    \"git_ensemble_probas\": array(\n        [\n            9.99951577e-01,\n            4.84187825e-05,\n        ]\n    ),\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/UMEssen/BOA-Contrast",
        "Repository": "https://github.com/UMEssen/BOA-Contrast"
    },
    "split_keywords": [
        "python",
        "contrast",
        "intravenous",
        "gastrointestinal tract",
        "ct",
        "machine learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d036f17ac762a09a0fc4e1b67d0eca8fe15383325f70a43e66e8e2cf3cd7120f",
                "md5": "68b9c99d59fa566b3783666ff9336ed6",
                "sha256": "82f8973dfd64ac49dc0fd752d27d4f88ab85e13f5b11fa272fc8abe92deb9fb5"
            },
            "downloads": -1,
            "filename": "boa_contrast-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "68b9c99d59fa566b3783666ff9336ed6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.11",
            "size": 78440901,
            "upload_time": "2023-08-04T11:45:09",
            "upload_time_iso_8601": "2023-08-04T11:45:09.739474Z",
            "url": "https://files.pythonhosted.org/packages/d0/36/f17ac762a09a0fc4e1b67d0eca8fe15383325f70a43e66e8e2cf3cd7120f/boa_contrast-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0cf25e176422a8ea891eb315e0de0fccf3320bae9483e41666f62c3c87956a93",
                "md5": "afd6ddd2d2023cb99f1be8f04e966665",
                "sha256": "77010a8f2ee2319a13bb7e317890ec49875301ceb2ef0fb809859627da423326"
            },
            "downloads": -1,
            "filename": "boa_contrast-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "afd6ddd2d2023cb99f1be8f04e966665",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.11",
            "size": 78437884,
            "upload_time": "2023-08-04T11:45:15",
            "upload_time_iso_8601": "2023-08-04T11:45:15.621442Z",
            "url": "https://files.pythonhosted.org/packages/0c/f2/5e176422a8ea891eb315e0de0fccf3320bae9483e41666f62c3c87956a93/boa_contrast-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-04 11:45:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "UMEssen",
    "github_project": "BOA-Contrast",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "boa-contrast"
}
        
Elapsed time: 0.09570s