Metadata-Version: 2.5
Name: lung-nodule-mlx
Version: 0.2.2
Summary: MONAI 3D RetinaNet lung nodule detector for Apple Silicon (macOS arm64, Metal)
Author: Joseph Sandoval, Alfredo Sandoval Jr.
License-Expression: Apache-2.0 AND BSD-3-Clause
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: <3.15,>=3.13
Requires-Dist: medmlx-core==0.2.4
Requires-Dist: nibabel<6,>=5.3
Requires-Dist: numpy<3,>=2.0
Provides-Extra: conversion
Requires-Dist: torch<3,>=2.13; extra == 'conversion'
Provides-Extra: dev
Requires-Dist: hypothesis<7,>=6.140; extra == 'dev'
Requires-Dist: monai==1.6.1; 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: torch<2.14,>=2.13; extra == 'dev'
Requires-Dist: torchvision<0.29,>=0.28; extra == 'dev'
Description-Content-Type: text/markdown

# lung-nodule-mlx

Detect lung nodule candidates in 3D chest CT with MONAI RetinaNet and native MLX.

[Docs](https://github.com/MedMLX/lung-nodule-mlx/blob/main/docs/technical.md) · [MedMLX](https://github.com/MedMLX)

![A 3D nodule candidate localized in axial, coronal and sagittal CT views.](https://raw.githubusercontent.com/MedMLX/lung-nodule-mlx/main/docs/showcase.png)

*A 3D nodule candidate localized in axial, coronal and sagittal CT views.*

| Input | Output |
| :--- | :--- |
| 3D chest CT · NIfTI | Candidate boxes and scores in RAS mm |

**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
uv pip install "lung-nodule-mlx[conversion]" huggingface-hub
```

Download and convert the checkpoint once, then run:

```bash
python -c 'from pathlib import Path; from huggingface_hub import hf_hub_download; import lung_nodule_mlx as m; m.convert_weights(Path(hf_hub_download("MONAI/lung_nodule_ct_detection", "models/model.pt")), Path("network.safetensors"))'

c++ -std=c++17 -O2 -dynamiclib \
  "$(python -c 'import lung_nodule_mlx, pathlib; print(pathlib.Path(lung_nodule_mlx.__file__).with_name("selection.cpp"))')" \
  -o selection.dylib
```

```python
from lung_nodule_mlx.medmlx import run

result = run(
    image_path="ct.nii.gz",
    weights_path="network.safetensors",
    selector_path="selection.dylib",
    output_dir="out",
    resample_raw_input=True,
)
print(result["outputs"]["detections"])
```

Requires Apple’s command-line developer tools for box selection. Keep `resample_raw_input=True` for ordinary CT.

## License

[Apache-2.0](https://github.com/MedMLX/lung-nodule-mlx/blob/main/LICENSE). See [third-party notices](https://github.com/MedMLX/lung-nodule-mlx/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.

For research and education. Outputs require human review.
