PyTorch implementation of PyRadiomics Extractor
Project description
PyTorchRadiomics
PyTorch implementation of 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:
device:strortorch.device, default:"cuda"dtype:torch.dtype, default:torch.float64
Direct usage:
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:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorchradiomics-0.0.5.tar.gz.
File metadata
- Download URL: pytorchradiomics-0.0.5.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72d75d4faba96d5d9f90b383944e87774275955ef855f6c79da3f201f0dd720e
|
|
| MD5 |
a579f75788dcec0af3855a33cc1f1b2f
|
|
| BLAKE2b-256 |
a02d462ee778a99a19f9be904a7f3f97cdd90f3ce49ebca9a70c3217f5aa419e
|
File details
Details for the file pytorchradiomics-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pytorchradiomics-0.0.5-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
217b890755545c6f64980767d52b6d0d56f32de813b269fff4b5f3c1732f85fe
|
|
| MD5 |
8ceab26abc9178ee1ee97626def76c1f
|
|
| BLAKE2b-256 |
4c3a09b407489d741333796abd272eda1a1e250917154fe3ccb57cfc360c357c
|