Metadata-Version: 2.5
Name: fdg-pet-ct-mlx
Version: 0.2.2
Summary: Native MLX FDG PET image synthesis
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: medmlx-core==0.2.4
Requires-Dist: mlx<1,>=0.32.4
Requires-Dist: numpy<3,>=2.0
Provides-Extra: conversion
Requires-Dist: torch<2.14,>=2.13; extra == 'conversion'
Provides-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; extra == 'dev'
Requires-Dist: scipy<2,>=1.13; extra == 'dev'
Description-Content-Type: text/markdown

# fdg-pet-ct-mlx

Generate synthetic FDG PET activity from CT and organ labels with native MLX. Includes scanner blur, scatter and count noise.

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

![Real CT anatomy → simulated PET, with controllable focal uptake.](https://raw.githubusercontent.com/MedMLX/fdg-pet-ct-mlx/main/docs/showcase.png)

*Real CT anatomy → simulated PET, with controllable focal uptake.*

| Input | Output |
| :--- | :--- |
| Aligned CT + organ labels | Synthetic PET SUV array |

**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 fdg-pet-ct-mlx
```

A synthetic example with organ and scanner profiles:

```python
from collections.abc import Mapping
from dataclasses import dataclass

import mlx.core as mx

from fdg_pet_ct_mlx.acquisition import apply_acquisition_model
from fdg_pet_ct_mlx.activity import synthesize_activity_map


@dataclass(frozen=True)
class Tissue:
    suv_mean: float
    suv_std: float
    maisi_labels: tuple[int, ...]


@dataclass(frozen=True)
class Organs:
    tissues: Mapping[str, Tissue]

    def lookup_table(self, size: int) -> tuple[float, ...]:
        table = [self.tissues["unclassified_soft_tissue"].suv_mean] * size
        for tissue in self.tissues.values():
            for label in tissue.maisi_labels:
                if label < size:
                    table[label] = tissue.suv_mean
        return tuple(table)


@dataclass(frozen=True)
class Scanner:
    scatter_fraction: float = 0.05
    randoms_fraction: float = 0.02
    fwhm_mm: tuple[float, float, float] = (5.0, 5.0, 5.0)
    counts_per_suv: float = 100.0


organ = Organs({
    "background": Tissue(0.0, 0.0, (0,)),
    "unclassified_soft_tissue": Tissue(1.0, 0.1, (1,)),
})
labels = mx.ones((16, 16, 16), dtype=mx.int32)
ct_hu = mx.zeros(labels.shape, dtype=mx.float32)
activity = synthesize_activity_map(labels, organ, seed=7, mx=mx)
pet = apply_acquisition_model(
    activity,
    ct_hu,
    scanner=Scanner(),
    count_level=1.0,
    spacing_mm=(2.0, 2.0, 2.0),
    seed=8,
    mx=mx,
)
mx.eval(pet)
print(pet.shape, pet.dtype)  # (16, 16, 16), float32
```

No model weights are needed. This is image-space synthesis; it does not simulate projection physics or reconstruction.

## License

[Apache-2.0](https://github.com/MedMLX/fdg-pet-ct-mlx/blob/main/LICENSE). See [third-party notices](https://github.com/MedMLX/fdg-pet-ct-mlx/blob/main/THIRD_PARTY_NOTICES.md).

For research and education. Outputs require human review.
