Metadata-Version: 2.4
Name: ToolsFor302
Version: 0.3.4
Summary: some tools for 302
Home-page: 
Author: zengkeyao
Author-email: cengkeyao186@Gmail.com
License: MIT License
Requires-Python: >=3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: ipywidgets
Requires-Dist: SimpleITK
Requires-Dist: pymedphys
Requires-Dist: pydicom
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# ToolsFor302

ToolsFor302 provides Python helpers for dose grid loading, plotting, and gamma
analysis.

## Installation

```powershell
pip install ToolsFor302
```

Runtime dependencies are installed by default: `numpy`, `matplotlib`,
`ipywidgets`, `SimpleITK`, `pymedphys`, and `pydicom`.

## Usage

ToolsFor302 0.3.4 uses `DoseVolume` as the common dose data container.

```python
from ToolsFor302 import (
    DoseVolume,
    read_mhd_dose,
    read_bin_dose,
    read_dicom_dose,
    calculate_gamma,
    plot_slice,
    plot_gamma_histogram,
)
```

Read dose files:

```python
mhd_volume = read_mhd_dose("dose.mhd")

bin_volume = read_bin_dose(
    "dose.bin",
    dtype="float",
    shape=(128, 256, 256),
    spacing_mm=(2.5, 1.0, 1.0),
)

dicom_volume = read_dicom_dose("rt_dose.dcm")
```

Create a volume directly:

```python
import numpy as np

volume = DoseVolume(
    array=np.zeros((16, 64, 64)),
    axes_mm=(
        np.arange(16) * 2.5,
        np.arange(64) * 1.0,
        np.arange(64) * 1.0,
    ),
    metadata={"source": "example"},
)
```

Calculate gamma:

```python
result = calculate_gamma(
    reference=mhd_volume,
    evaluation=dicom_volume,
    dose_percent_threshold=3,
    distance_mm_threshold=3,
    lower_percent_dose_cutoff=10,
)

print(result.pass_rate_percent)
```

Plot dose and gamma data:

```python
slice_plot = plot_slice(mhd_volume, slice_index=20, show=True)
gamma_plot = plot_gamma_histogram(result, show=True)

slice_plot.fig.savefig("dose_slice.png")
```

## Project structure

```text
ToolsFor302_pypi/
├── ToolsFor302/          # Package source code
│   ├── __init__.py       # Public API exports
│   ├── dlTools.py        # Placeholder download/helper tools
│   └── doseTools.py      # Dose volume, I/O, plotting, and gamma tools
├── tests/                # Public API and doseTools tests
├── dist/                 # Built release artifacts
├── LICENSE
├── README.md
├── setup.py
└── .gitignore
```

## API note

Version 0.3.4 is a breaking API cleanup. Old functions such as
`load_mhd_dose`, `load_bin_dose`, `cal_gamma`, and `show_gamma` are no longer
exported. Use `read_mhd_dose`, `read_bin_dose`, `calculate_gamma`, and the
`plot_*` functions instead.
