Skip to main content

A light-weight python-native implementation of pyradiomics

Project description

NumpyRadiomics

A lightweight, pure-Python implementation of radiomic shape features, fully compatible with PyRadiomics definitions. Built on top of numpy, scipy, and skimage to minimize heavy dependencies while maintaining accuracy.

Features

  • Standard Compliance: Implements the official PyRadiomics definitions for 2D and 3D shape features.
  • Lightweight: No heavy C++ extensions or SimpleITK dependencies required—just standard scientific Python stacks.

Installation

pip install numpyradiomics

Usage

1. Basic Shape Extraction

The shape() function automatically dispatches to 2D or 3D logic based on the input mask dimensions.

import numpy as np
from numpyradiomics import shape, dro

# 1. Create a synthetic 3D mask (e.g., a 20x10x5 mm cuboid)
spacing = (1.0, 1.0, 1.0)
mask = dro.cuboid(radii_mm=(10.0, 5.0, 2.5), spacing=spacing)

# 2. Extract features
# extend=True (default) adds advanced metrics like Solidity and ConvexHullVolume
features = shape(mask, spacing, extend=True)

print(f"Volume:     {features['VoxelVolume']} mm^3")
print(f"Sphericity: {features['Sphericity']:.4f}")
print(f"Solidity:   {features['Solidity']:.4f}")

2. Working with Units

You can retrieve a dictionary mapping every feature to its physical unit (e.g., mm, mm^2, mm^3 or dimensionless).

from numpyradiomics import shape_units

# Get units for 3D features in centimeters
units = shape_units(dim=3, base_unit='cm')

print(f"MeshVolume unit: {units['MeshVolume']}")    # Output: cm^3
print(f"Elongation unit: {units['Elongation']}")    # Output: (empty string for dimensionless)

Supported Features

3D Shape (Standard)

  • Volume: Mesh Volume, Voxel Volume
  • Surface: Surface Area, Surface-to-Volume Ratio
  • Dimensions: Max 3D Diameter, Max 2D Diameter (Slice, Column, Row)
  • Shape Descriptors: Sphericity, Elongation, Flatness
  • Axes: Major, Minor, and Least Axis Lengths

3D Shape (Extended)

  • Advanced Volume: Convex Hull Volume, Bounding Box Volume
  • Ratios: Solidity, Extent
  • Inertia: Moments of Inertia, Fractional Anisotropy
  • Other: Maximum Depth (Chebyshev Radius), Longest Caliper Diameter

2D Shape

  • Area: Mesh Surface, Pixel Surface
  • Perimeter: Perimeter, Perimeter-Surface Ratio
  • Shape Descriptors: Sphericity, Spherical Disproportion, Elongation
  • Axes: Major Axis, Minor Axis, Max Diameter

Texture

All standard texture metrics are available:

  • GLCM: Gray Level Co-occurrence Matrix
  • GLRLM: Gray Level Run Length Matrix
  • GLSZM: Gray Level Size Zone Matrix
  • GLDM: Gray Level Dependence Matrix
  • NGTDM: Neighbouring Gray Tone Difference Matrix

License

Apache 2.0 License

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

numpyradiomics-0.0.4.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpyradiomics-0.0.4-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numpyradiomics-0.0.4.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for numpyradiomics-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9b9f6d1d9c60a6b7f23d0e2adbbea0cdc5aabe2a930bbc839096f7a9d0ae9a65
MD5 d3efb5c0be81b3aada5a6f9ff263b4e1
BLAKE2b-256 fa0634f5458fce08d18ca32a55bdc14e83aab19926f12bc283e573c3e2c14d9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numpyradiomics-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for numpyradiomics-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 34e4947a6f8d878f48ba23ce07326f4d56524f2a6658c5b0a3c4b1209cb15a6d
MD5 e3b7a005a62fce70709040c4525cc733
BLAKE2b-256 00967ec11a5e2b94bd23603ce2df43dcaaf0e6c12fcc0d5ab0254d3bebea1fd2

See more details on using hashes here.

Supported by

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