mlx-radiomics
Extract radiomics features and voxel maps on the Apple Silicon GPU with native MLX.
Getting started · Python API · Feature catalogue
| Input | Output |
|---|---|
| Aligned image + integer label mask | ROI features (JSON/CSV) or one float32 NIfTI map per feature |
No model weights to download.
PyRadiomics feature names and parameter files, with configurable IBSI conventions. Requires Apple Silicon with Metal.
Install
uv venv --python 3.13
source .venv/bin/activate
uv pip install "mlxradiomics>=1.0.1"
Install mlxradiomics[lbp] for LBP3D derived images.
Install mlxradiomics[viz] for 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. Use settings= for features and binning,
transforms= for derived images, and spacing= for array voxel sizes in
NumPy axis order. 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.
Feature arithmetic is float32. In-memory float64 maps hold those float32 results, not higher-precision calculations; saved maps and streamed batches are float32.
Extraction results expose .features and .metadata; exports expose .report,
.maps and .metadata. The Python guide
covers settings, 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
are recognized but cannot run on this release; see Limits.
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 190 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 |
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 catalogue 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["files"]["features_json"] # 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. ROI mode writes features.json and features.csv;
voxel=True writes float32 NIfTI maps under maps/, zero outside the ROI.
Set overwrite=True to replace existing outputs.
Feature keys include image, family and name, such as original_glcm_Contrast.
The result contains outputs, files and details. See the
runner guide
for all arguments, report fields, geometry and error handling.
Limits
- Shape and local intensity are ROI-only; local intensity needs 3D input.
- Simoncelli and Riesz filters are unavailable on this release; see the limits guide.
- 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
.nhdrrequire a new output directory, even withoverwrite=True.
See limits for filter requirements and supported inputs, and 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.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mlxradiomics-1.0.1.tar.gz | 334.1 kB | Without provenance | Details for mlxradiomics-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlxradiomics-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for mlxradiomics-1.0.1-py3-none-any.whl |
Total release size: 720.5 kB
Release files / mlxradiomics-1.0.1.tar.gz
| Download URL | mlxradiomics-1.0.1.tar.gz |
|---|---|
| Size | 334.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9412c450787b93871be9153e53f4b4413fd97ca06b9dbcec6de75f95d98680db
|
|
BLAKE2b-256 checksum How to use checksums |
fe58ff0a5db3a4a87f74260ea0dd940e4e339befa80b2497aab9777f2a26b796
|
| 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.0.1-py3-none-any.whl
| Download URL | mlxradiomics-1.0.1-py3-none-any.whl |
|---|---|
| Size | 386.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
525a825cb1b6da4f221798b8959a588f28835805f5ad208cb92f68f946199ed8
|
|
BLAKE2b-256 checksum How to use checksums |
af514cb8a844dc6b4b50ce4a5ff0b9c5779c3eb34e9ca7782c5e6f4466862ae2
|
| 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.0.1
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.