# pytomography/spectpsftoolbox architecture

> Architecture diagram of the GitHub repository pytomography/spectpsftoolbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pytomography/spectpsftoolbox
- Repository: https://github.com/pytomography/spectpsftoolbox

## Overview

SPECT Point Spread Function Toolbox is a Python library for constructing and fitting distance-dependent SPECT point-spread-function models, then using the resulting operators with PyTomography. Its runtime building blocks are 1D and 2D kernel models, image operators that apply or compose those kernels, utilities for operator geometry, and SIMIND readers for simulated projection data and geometry. The README documents model development and PyTomography use, but not a specific fitting orchestrator or the connections between SIMIND import and model fitting; those links are therefore not inferred.

Main entry points: [`src/spectpsftoolbox/operator2d.py`](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py) (Operator composition), [`src/spectpsftoolbox/kernel1d.py`](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel1d.py) (1D kernels), [`src/spectpsftoolbox/kernel2d.py`](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel2d.py) (2D kernels), [`src/spectpsftoolbox/simind_io.py`](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/simind_io.py) (Projection reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Simulation input"]
  node_simind_reader["Projection reader<br/>[simind_io.py]"]
end

subgraph group_models["PSF models"]
  node_kernel1d["1D kernels<br/>[kernel1d.py]"]
  node_kernel2d["2D kernels<br/>[kernel2d.py]"]
end

subgraph group_operations["Image operations"]
  node_operator_base["Operator composition<br/>[operator2d.py]"]
  node_rotated_operator["Rotated 1D operators<br/>[operator2d.py]"]
  node_kernel2d_operator["2D kernel operator<br/>[operator2d.py]"]
  node_psf_operator["Sampled PSF operator<br/>[operator2d.py]"]
  node_gaussian_operator["Gaussian operator<br/>[operator2d.py]"]
end

subgraph group_support["Operator support"]
  node_operator_utils["Padding and grids<br/>[utils.py]"]
end

node_engineer(("Model developer"))
node_simind["SIMIND files"]
node_pytomography["PyTomography"]

node_engineer -->|"loads data"| node_simind_reader
node_simind -->|"provides files"| node_simind_reader
node_engineer -->|"develops models"| node_kernel1d
node_engineer -->|"develops models"| node_kernel2d
node_engineer -->|"uses operators"| node_operator_base
node_operator_base -->|"uses kernels"| node_kernel1d
node_operator_base -->|"uses kernels"| node_kernel2d
node_operator_base -->|"uses padding"| node_operator_utils
node_rotated_operator -->|"evaluates kernel"| node_kernel1d
node_kernel2d_operator -->|"evaluates kernel"| node_kernel2d
node_psf_operator -->|"uses padding"| node_operator_utils
node_gaussian_operator -->|"uses kernel"| node_kernel1d
node_operator_base -->|"models load into"| node_pytomography

click node_simind_reader "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/simind_io.py"
click node_kernel1d "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel1d.py"
click node_kernel2d "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel2d.py"
click node_operator_base "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py"
click node_rotated_operator "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py"
click node_kernel2d_operator "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py"
click node_psf_operator "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py"
click node_gaussian_operator "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py"
click node_operator_utils "https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_simind_reader toneBlue
class node_kernel1d,node_kernel2d toneAmber
class node_operator_base,node_rotated_operator,node_kernel2d_operator,node_psf_operator,node_gaussian_operator toneMint
class node_operator_utils toneRose
class node_engineer,node_simind,node_pytomography toneIndigo
```

## Components

### Simulation input

- [Projection reader](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/simind_io.py): `src/spectpsftoolbox/simind_io.py`

### PSF models

- [1D kernels](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel1d.py): `src/spectpsftoolbox/kernel1d.py`
- [2D kernels](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/kernel2d.py): `src/spectpsftoolbox/kernel2d.py`

### Image operations

- [Operator composition](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py): `src/spectpsftoolbox/operator2d.py`
- [Rotated 1D operators](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py): `src/spectpsftoolbox/operator2d.py`
- [2D kernel operator](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py): `src/spectpsftoolbox/operator2d.py`
- [Sampled PSF operator](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py): `src/spectpsftoolbox/operator2d.py`
- [Gaussian operator](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/operator2d.py): `src/spectpsftoolbox/operator2d.py`

### Operator support

- [Padding and grids](https://github.com/pytomography/spectpsftoolbox/blob/main/src/spectpsftoolbox/utils.py): `src/spectpsftoolbox/utils.py`

### Other components

- **Model developer**
- **SIMIND files**
- **PyTomography**

## Connections

- Model developer → Projection reader: loads data (evidence: `src/spectpsftoolbox/simind_io.py`)
- SIMIND files → Projection reader: provides files (evidence: `src/spectpsftoolbox/simind_io.py`)
- Model developer → 1D kernels: develops models (evidence: `README.md`)
- Model developer → 2D kernels: develops models (evidence: `README.md`)
- Model developer → Operator composition: uses operators (evidence: `README.md`)
- Operator composition → 1D kernels: uses kernels (evidence: `src/spectpsftoolbox/operator2d.py`)
- Operator composition → 2D kernels: uses kernels (evidence: `src/spectpsftoolbox/operator2d.py`)
- Operator composition → Padding and grids: uses padding (evidence: `src/spectpsftoolbox/operator2d.py`)
- Rotated 1D operators → 1D kernels: evaluates kernel (evidence: `src/spectpsftoolbox/operator2d.py`)
- 2D kernel operator → 2D kernels: evaluates kernel (evidence: `src/spectpsftoolbox/operator2d.py`)
- Sampled PSF operator → Padding and grids: uses padding (evidence: `src/spectpsftoolbox/operator2d.py`)
- Gaussian operator → 1D kernels: uses kernel (evidence: `src/spectpsftoolbox/operator2d.py`)
- Operator composition → PyTomography: models load into (evidence: `README.md`)
