pytorchradiomics


Namepytorchradiomics JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummaryPyTorch implementation of PyRadiomics Extractor
upload_time2024-08-04 16:23:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords radiomics cancerimaging medicalresearch computationalimaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyTorchRadiomics

PyTorch implementation of [PyRadiomics](https://github.com/AIM-Harvard/pyradiomics) Extractor

# Performance Improvement

It can speed up voxel-based features extraction significantly, especially GLCM features.

Using it to extract non-voxel-based features is *NOT* recommended (it is slower).

## Voxel-based Features Extraction Performance Comparison
Intel i9-10900K v.s. RTX 3080 10G (dtype=torch.float64), Size=$16^3$

|Type|CPU Time|Torch Time|Max Abs. Error|Max Rel. Error|
|-|-|-|-|-|
GLCM|636s|23.8s|2.32e-09|7.92e-12|
FirstOrder|4.3s|0.244s|2.84e-14|2.22e-16|
GLRLM|1.71s|0.731s|2.72e-12|8.88e-16|
NGTDM|4.03s|0.398s|3.27e-11|3.99e-15|

# Installation
```
pip install pytorchradiomics
```

# Usage

Only two extra keyword arguments:
1. `device`: `str` or `torch.device`, default: `"cuda"`
2. `dtype`: `torch.dtype`, default: `torch.float64`

Direct usage:
```python
from torchradiomics import (TorchRadiomicsFirstOrder, TorchRadiomicsGLCM,
                            TorchRadiomicsGLRLM, TorchRadiomicsNGTDM,
                            inject_torch_radiomics, restore_radiomics)

ext = TorchRadiomicsGLCM(
    img_norm, mask_norm,
    voxelBased=True, padDistance=kernel,
    kernelRadius=kernel, maskedKernel=False, voxelBatch=512,
    dtype=torch.float64, # it is default
    device="cuda:0",
    **get_default_settings())

features = ext.execute()
```

Or use injection to use `RadiomicsFeatureExtractor`:

```python
from radiomics.featureextractor import RadiomicsFeatureExtractor
from torchradiomics import (TorchRadiomicsFirstOrder, TorchRadiomicsGLCM,
                            TorchRadiomicsGLRLM, TorchRadiomicsNGTDM,
                            inject_torch_radiomics, restore_radiomics)

inject_torch_radiomics() # replace cpu version with torch version

ext = RadiomicsFeatureExtractor(
    voxelBased=True, padDistance=kernel,
    kernelRadius=kernel, maskedKernel=False, voxelBatch=512,
    dtype=torch.float64, # it is default
    device="cuda:0",
    **get_default_settings())
ext.execute(img, mask, voxelBased=True)

restore_radiomics() # restore
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytorchradiomics",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "radiomics, cancerimaging, medicalresearch, computationalimaging",
    "author": null,
    "author_email": "Wingkou <wingkou@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/a0/2d/462ee778a99a19f9be904a7f3f97cdd90f3ce49ebca9a70c3217f5aa419e/pytorchradiomics-0.0.5.tar.gz",
    "platform": null,
    "description": "# PyTorchRadiomics\r\n\r\nPyTorch implementation of [PyRadiomics](https://github.com/AIM-Harvard/pyradiomics) Extractor\r\n\r\n# Performance Improvement\r\n\r\nIt can speed up voxel-based features extraction significantly, especially GLCM features.\r\n\r\nUsing it to extract non-voxel-based features is *NOT* recommended (it is slower).\r\n\r\n## Voxel-based Features Extraction Performance Comparison\r\nIntel i9-10900K v.s. RTX 3080 10G (dtype=torch.float64), Size=$16^3$\r\n\r\n|Type|CPU Time|Torch Time|Max Abs. Error|Max Rel. Error|\r\n|-|-|-|-|-|\r\nGLCM|636s|23.8s|2.32e-09|7.92e-12|\r\nFirstOrder|4.3s|0.244s|2.84e-14|2.22e-16|\r\nGLRLM|1.71s|0.731s|2.72e-12|8.88e-16|\r\nNGTDM|4.03s|0.398s|3.27e-11|3.99e-15|\r\n\r\n# Installation\r\n```\r\npip install pytorchradiomics\r\n```\r\n\r\n# Usage\r\n\r\nOnly two extra keyword arguments:\r\n1. `device`: `str` or `torch.device`, default: `\"cuda\"`\r\n2. `dtype`: `torch.dtype`, default: `torch.float64`\r\n\r\nDirect usage:\r\n```python\r\nfrom torchradiomics import (TorchRadiomicsFirstOrder, TorchRadiomicsGLCM,\r\n                            TorchRadiomicsGLRLM, TorchRadiomicsNGTDM,\r\n                            inject_torch_radiomics, restore_radiomics)\r\n\r\next = TorchRadiomicsGLCM(\r\n    img_norm, mask_norm,\r\n    voxelBased=True, padDistance=kernel,\r\n    kernelRadius=kernel, maskedKernel=False, voxelBatch=512,\r\n    dtype=torch.float64, # it is default\r\n    device=\"cuda:0\",\r\n    **get_default_settings())\r\n\r\nfeatures = ext.execute()\r\n```\r\n\r\nOr use injection to use `RadiomicsFeatureExtractor`:\r\n\r\n```python\r\nfrom radiomics.featureextractor import RadiomicsFeatureExtractor\r\nfrom torchradiomics import (TorchRadiomicsFirstOrder, TorchRadiomicsGLCM,\r\n                            TorchRadiomicsGLRLM, TorchRadiomicsNGTDM,\r\n                            inject_torch_radiomics, restore_radiomics)\r\n\r\ninject_torch_radiomics() # replace cpu version with torch version\r\n\r\next = RadiomicsFeatureExtractor(\r\n    voxelBased=True, padDistance=kernel,\r\n    kernelRadius=kernel, maskedKernel=False, voxelBatch=512,\r\n    dtype=torch.float64, # it is default\r\n    device=\"cuda:0\",\r\n    **get_default_settings())\r\next.execute(img, mask, voxelBased=True)\r\n\r\nrestore_radiomics() # restore\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PyTorch implementation of PyRadiomics Extractor",
    "version": "0.0.5",
    "project_urls": {
        "Github": "https://github.com/lyhyl/pytorchradiomics",
        "Homepage": "https://github.com/lyhyl/pytorchradiomics#readme",
        "Issues": "https://github.com/lyhyl/pytorchradiomics/issues"
    },
    "split_keywords": [
        "radiomics",
        " cancerimaging",
        " medicalresearch",
        " computationalimaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c3a09b407489d741333796abd272eda1a1e250917154fe3ccb57cfc360c357c",
                "md5": "8ceab26abc9178ee1ee97626def76c1f",
                "sha256": "217b890755545c6f64980767d52b6d0d56f32de813b269fff4b5f3c1732f85fe"
            },
            "downloads": -1,
            "filename": "pytorchradiomics-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ceab26abc9178ee1ee97626def76c1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 29099,
            "upload_time": "2024-08-04T16:23:38",
            "upload_time_iso_8601": "2024-08-04T16:23:38.174241Z",
            "url": "https://files.pythonhosted.org/packages/4c/3a/09b407489d741333796abd272eda1a1e250917154fe3ccb57cfc360c357c/pytorchradiomics-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a02d462ee778a99a19f9be904a7f3f97cdd90f3ce49ebca9a70c3217f5aa419e",
                "md5": "a579f75788dcec0af3855a33cc1f1b2f",
                "sha256": "72d75d4faba96d5d9f90b383944e87774275955ef855f6c79da3f201f0dd720e"
            },
            "downloads": -1,
            "filename": "pytorchradiomics-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "a579f75788dcec0af3855a33cc1f1b2f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22681,
            "upload_time": "2024-08-04T16:23:40",
            "upload_time_iso_8601": "2024-08-04T16:23:40.312313Z",
            "url": "https://files.pythonhosted.org/packages/a0/2d/462ee778a99a19f9be904a7f3f97cdd90f3ce49ebca9a70c3217f5aa419e/pytorchradiomics-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-04 16:23:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lyhyl",
    "github_project": "pytorchradiomics",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "pytorchradiomics"
}
        
Elapsed time: 0.43544s