Skip to main content

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

Metadata

Release files for numpyradiomics 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for numpyradiomics 0.0.5
File Size Uploaded Provenance Actions
numpyradiomics-0.0.5.tar.gz 47.9 kB Without provenance Details for numpyradiomics-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for numpyradiomics 0.0.5
File Interpreter ABI Platform Actions
numpyradiomics-0.0.5-py3-none-any.whl Python 3 none any Details for numpyradiomics-0.0.5-py3-none-any.whl

Total release size: 95.4 kB

Release files / numpyradiomics-0.0.5.tar.gz

Download URL numpyradiomics-0.0.5.tar.gz
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f6060d790797f681f494ebe2398687108c4f115e28804e7c046a86e64e7c2e90
BLAKE2b-256 checksum
How to use checksums
b0733ca3b05087c41a54b8702f5765d5e09aa4fe54be2a11373d2b63682f2d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / numpyradiomics-0.0.5-py3-none-any.whl

Download URL numpyradiomics-0.0.5-py3-none-any.whl
Size 47.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37617d209511dd4ff8504131b51b439ee4e28dcfc91df77a5a746c0a2c36b78a
BLAKE2b-256 checksum
How to use checksums
800376fc7053732040423999cb56b232a01a658f3cf6f0005cbb028ce6a8225a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for numpyradiomics 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page