Skip to main content

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.

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

Usage

Only two extra keyword arguments:

  1. device: str or torch.device, default: "cuda"
  2. 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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorchradiomics-0.0.4.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

pytorchradiomics-0.0.4-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file pytorchradiomics-0.0.4.tar.gz.

File metadata

  • Download URL: pytorchradiomics-0.0.4.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for pytorchradiomics-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ca6404ceabb724942473ade02cdd935f3242b4cb5020e79278eddd8d2e1e1a87
MD5 ec920845aa3c9be9a61a205bec984961
BLAKE2b-256 a7ee6dfad51d922fd46f5588cc3db89bff20666fa60aa496407c77a0529cc106

See more details on using hashes here.

File details

Details for the file pytorchradiomics-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pytorchradiomics-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3f977ab5678f8dfe43ed9b4e10c7232d356d8d75f09927d47e8769c08861b597
MD5 902dd4d27e020ddea0ac6cf020a92284
BLAKE2b-256 4c0b59a9557dc13b6d65c67c27e87a4e224032794b46cc06a89bf327014682ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page