Metadata-Version: 2.5
Name: synthseg-mlx
Version: 0.2.1
Summary: Native MLX implementation of SynthSeg for Apple Silicon (macOS arm64, Metal)
Author: Joseph Sandoval, Alfredo Sandoval Jr.
License-Expression: Apache-2.0
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Classifier: Operating System :: MacOS :: MacOS X
Requires-Python: <3.15,>=3.13
Requires-Dist: h5py<4,>=3.12
Requires-Dist: medmlx-core==0.2.3
Requires-Dist: mlx<0.33,>=0.32.4
Requires-Dist: nibabel<6,>=5.3
Requires-Dist: numpy<3,>=2.0
Requires-Dist: scipy<2,>=1.14
Provides-Extra: dev
Requires-Dist: h5py-stubs<0.2,>=0.1.2; extra == 'dev'
Requires-Dist: hypothesis<7,>=6.100; extra == 'dev'
Requires-Dist: pyright==1.1.414; extra == 'dev'
Requires-Dist: pytest<10,>=8.4; extra == 'dev'
Requires-Dist: ruff<1,>=0.13; extra == 'dev'
Requires-Dist: scipy-stubs<1.19,>=1.18.1; extra == 'dev'
Description-Content-Type: text/markdown

# synthseg-mlx

Segment brain MRI or CT with SynthSeg in native MLX. Includes cortical parcellation, structure volumes and QC scores.

[Docs](docs/technical.md) · [MedMLX](https://github.com/MedMLX)

![synthseg-mlx example output](https://raw.githubusercontent.com/MedMLX/synthseg-mlx/main/docs/example.png)

*SynthSeg 2.0 parcellation of an NV-Generate synthetic T1 MR.*

| Input | Output |
| :--- | :--- |
| 3D brain MRI or CT · NIfTI | Brain labels, volumes and QC |

**Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)

## Quick start

```bash
uv venv --python 3.13
source .venv/bin/activate
repo="https://github.com/MedMLX/synthseg-mlx"
uv pip install "synthseg-mlx @ git+$repo"
```

Download and unzip the author’s [SynthSeg models](https://github.com/BBillot/SynthSeg#installation), then run:

```python
from synthseg_mlx.medmlx import run

result = run(image_path="brain.nii.gz", weights_path="SynthSeg_models", output_dir="out")
print(result["outputs"]["mask"])
```

Reads the original Keras checkpoints without TensorFlow. Output masks use the resampled 1 mm grid, rather than the original voxel grid.

## License

[Apache-2.0](LICENSE). See [third-party notices](THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.

For research and education. Outputs require human review.
