Skip to main content

mlx-radiomics

Extract radiomics features and voxel maps on the Apple Silicon GPU with native MLX.

PyPI Python License Apple Silicon MedMLX

Getting started · Python API · Feature catalog · Preprint

CT tumor ROI and six radiomics feature-map overlays
Input Output
Aligned image + integer label mask ROI features (JSON/CSV) or one float32 NIfTI map per feature

PyRadiomics feature names and parameter files, with configurable IBSI conventions. No model weights to download.

Install

uv venv --python 3.13
source .venv/bin/activate
uv pip install "mlxradiomics>=1.3.0"
Extra Adds
mlxradiomics[lbp] LBP3D derived images
mlxradiomics[viz] Static feature-map figures: mlxradiomics.viz provides five perceptually uniform palettes with reversed variants, ROI overlays, whole-ROI histograms, and PNG/PDF/SVG export

See the visualization guide and runnable example.

Python API

Start with image and mask files to preserve their physical geometry. Arrays use the same settings and result contract:

from mlxradiomics import Settings, extract_files

result = extract_files(
    "image.nii.gz", "mask.nii.gz",
    settings=Settings(label=1, bin_width=25, features=("firstorder_Mean", "glcm_Contrast")),
)
mean = result.features["original_firstorder_Mean"]

Add mode="voxel" for maps in memory. Use export_files to write voxel maps without retaining every map in memory. export and export_files write maps, not ROI tables; the file runner below writes ROI JSON/CSV.

Conventions: defaults follow IBSI, even when using PyRadiomics feature names or parameter files. Select alternative definitions through individual Settings fields.

Arrays and maps

from mlxradiomics import Settings, extract, extract_files, export_files

settings = Settings(label=2, features=("firstorder_Mean", "glcm_Contrast"))

roi = extract(image, mask, spacing=(3.0, 1.0, 1.0), settings=settings)
mean = roi.features["original_firstorder_Mean"]  # float

voxel = extract_files("image.nii.gz", "mask.nii.gz", settings=settings, mode="voxel")
mean_map = voxel.features["original_firstorder_Mean"]  # float64 NumPy array

saved = export_files(
    "image.nii.gz", "mask.nii.gz", "outputs/maps", settings=settings,
)
saved.report                                 # pathlib.Path to features.json
saved.maps["original_firstorder_Mean"]        # pathlib.Path to a float32 NIfTI
saved.metadata["settings"]                   # effective extraction settings
Operation Arrays NIfTI/NRRD files Result
ROI features extract(image, mask) extract_files(image_path, mask_path) Result[float]
Voxel maps in memory extract(image, mask, mode="voxel") extract_files(image_path, mask_path, mode="voxel") Result[NDArray[np.float64]]
Voxel maps on disk export(image, mask, output_dir) export_files(image_path, mask_path, output_dir) MapExport(report, maps, metadata)

Options are keyword-only:

Option Sets
settings= Features and binning
transforms= Derived images
spacing= Array voxel sizes in NumPy axis order
  • Geometry: file operations read geometry from the image. Array extraction warns when spacing is omitted and assumes 1 mm on each axis. Array export writes zero origin and identity direction; use file operations for scanner-aligned output, or explicitly acknowledge synthetic coordinates with allow_synthetic_geometry=True.
  • Precision: feature arithmetic is float32. In-memory float64 maps hold those float32 results, not higher-precision calculations. Pass map_dtype="float32" to extract or extract_files to halve retained map storage. Saved maps and streamed batches are float32.

Extraction results expose .features and .metadata; exports expose .report, .maps and .metadata. The Python guide covers settings, per-lesion extraction, streaming voxel batches and multi-case studies. The visualization guide covers figure export.

Parameter files

The supported PyRadiomics sections are setting, imageType and featureClass. Unsupported keys, image types and per-image overrides raise InvalidInputError.

setting:
  binWidth: 25
  label: 1
  resampledPixelSpacing: [1.0, 1.0, 1.0]
  interpolator: sitkLinear
  padDistance: 1
imageType:
  Original: {}
  Wavelet:
    level: 1
featureClass:
  firstorder: [Mean, Entropy]
  glcm: [Contrast, JointEntropy]

imageType keys: Original, Square, SquareRoot, Logarithm, Exponential, Gradient, Wavelet, LoG, LBP2D, LBP3D, Mean, Laws, Gabor, SeparableWavelet, Simoncelli (alias NonseparableWavelet) and Riesz.

See parameter files for filter options and conventions for definition settings.

Features

Use list_features("firstorder", "glcm") to select whole families, or list_features(mode="voxel", ndim=3) to discover names supported in that mode. Pass its result as Settings(features=...). Selecting a family does not change binning or numerical conventions.

mlxradiomics.FEATURES lists all 200 names, including all 116 non-deprecated PyRadiomics features. Without a features selection, extraction returns the 93 PyRadiomics intensity and texture features; request shape and the other families by name.

Family Count Modes
firstorder 21 ROI, voxel
intensityhistogram 23 ROI, voxel
glcm 26 ROI, voxel
gldm (NGLDM) 17 ROI, voxel
ngtdm 5 ROI, voxel
glrlm 16 ROI, voxel
glszm 16 ROI, voxel
gldzm 16 ROI, voxel
ivh 7 ROI, voxel
localintensity 2 3D ROI
shape 32 3D ROI
momentinvariant 10 3D ROI
shape2D 9 2D ROI, or one slice of a 3D ROI

Calculation conventions such as kurtosis, shape covariance divisor, NGTDM singular cases and fixed-bin-size origin are independent Settings fields with IBSI defaults. Select each alternative explicitly; see Conventions. The feature catalog lists public names and their IBSI identifiers.

MedMLX and automation

The MedMLX MCP server installs this runtime and lets an AI agent describe, check and run mlxradiomics.

uv tool install --python 3.13 "medmlx[vision,mcp]"
MEDMLX="$(uv tool dir --bin --color never)/medmlx"
mkdir -p "$HOME/medmlx-work"
claude mcp add --scope user medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"

For Codex, use codex mcp add medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work". Other MCP clients take the same command and arguments. The same install provides the medmlx CLI, for example medmlx describe mlxradiomics.

The MCP run_model tool takes the arguments of mlxradiomics.medmlx.run below.

File runner

from mlxradiomics.medmlx import run

result = run(image_path="image.nii.gz", mask_path="mask.nii.gz", output_dir="features")
result["outputs"]["features"]  # path to the report

Inputs and outputs

Use a 2D or 3D NIfTI/NRRD image and an integer label mask on the same grid. label defaults to 1. Set overwrite=True to replace existing outputs.

Mode Writes
ROI (default) features.json (role features) and features.csv (role features_table)
voxel=True float32 NIfTI maps under maps/, zero outside the ROI

Feature keys include image, family and name, such as original_glcm_Contrast. The result contains outputs, artifacts and details. See the runner guide for all arguments, report fields, geometry and error handling.

Limits

  • Shape, local intensity and moment invariants are ROI-only; local intensity and moment invariants need 3D input.
  • Feature arithmetic is float32. Undefined values are NaN; overflow is infinity.
  • Read voxel maps with NiBabel; SimpleITK reads stored NaN voxels as zero.
  • Detached inputs such as .nhdr require a new output directory, even with overwrite=True.

See the environment guide for development.

License

Apache-2.0. See third-party notices, including CC BY 4.0 attribution for adapted IBSI manifest definitions.

Metadata

Release files for mlxradiomics 1.3.0

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

Source distribution (sdist)

Source distribution for mlxradiomics 1.3.0
File Size Uploaded Provenance Actions
mlxradiomics-1.3.0.tar.gz 370.5 kB Without provenance Details for mlxradiomics-1.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 797.5 kB

Release files / mlxradiomics-1.3.0.tar.gz

Download URL mlxradiomics-1.3.0.tar.gz
Size 370.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3adc617ba81a05e88dee31a4ff181e4a2e4f7ade4306ee0ca006ea97b13f1e35
BLAKE2b-256 checksum
How to use checksums
ed21f6e26c3d5e118d0fe80ed46e6077bd5d1b0d2b8593b75d19c0be10c0f4b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mlxradiomics-1.3.0-py3-none-any.whl

Download URL mlxradiomics-1.3.0-py3-none-any.whl
Size 427.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc64680c5e0cb87bc7eb1776cc319a68337637e6ac8b2561c3162b537b847f90
BLAKE2b-256 checksum
How to use checksums
f43760ddb97e2e2041b4b0189f8043eb2deac5563a38353243d2f51a3fca2554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mlxradiomics 1.3.0

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