torchtomo 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torchtomo-0.1.0/LICENSE +12 -0
- torchtomo-0.1.0/PKG-INFO +152 -0
- torchtomo-0.1.0/README.md +112 -0
- torchtomo-0.1.0/pyproject.toml +64 -0
- torchtomo-0.1.0/setup.cfg +4 -0
- torchtomo-0.1.0/src/torchtomo/__init__.py +35 -0
- torchtomo-0.1.0/src/torchtomo/base.py +89 -0
- torchtomo-0.1.0/src/torchtomo/fanbeam.py +383 -0
- torchtomo-0.1.0/src/torchtomo/filters.py +102 -0
- torchtomo-0.1.0/src/torchtomo/parallel.py +217 -0
- torchtomo-0.1.0/src/torchtomo/phantom.py +186 -0
- torchtomo-0.1.0/src/torchtomo.egg-info/PKG-INFO +152 -0
- torchtomo-0.1.0/src/torchtomo.egg-info/SOURCES.txt +19 -0
- torchtomo-0.1.0/src/torchtomo.egg-info/dependency_links.txt +1 -0
- torchtomo-0.1.0/src/torchtomo.egg-info/requires.txt +16 -0
- torchtomo-0.1.0/src/torchtomo.egg-info/top_level.txt +1 -0
- torchtomo-0.1.0/tests/test_batch.py +43 -0
- torchtomo-0.1.0/tests/test_fanbeam.py +72 -0
- torchtomo-0.1.0/tests/test_filters.py +46 -0
- torchtomo-0.1.0/tests/test_parallel.py +44 -0
- torchtomo-0.1.0/tests/test_skimage_consistency.py +321 -0
torchtomo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
This work is licensed under the Creative Commons Attribution–NonCommercial
|
|
2
|
+
4.0 International License (CC BY-NC 4.0).
|
|
3
|
+
|
|
4
|
+
You are free to use, share, and adapt this software for non-commercial
|
|
5
|
+
research and educational purposes, provided that appropriate attribution
|
|
6
|
+
is given to the authors and the source.
|
|
7
|
+
|
|
8
|
+
Commercial use by third parties is prohibited without prior written
|
|
9
|
+
permission from the authors. The authors retain all commercial rights.
|
|
10
|
+
|
|
11
|
+
To view a copy of this license, visit:
|
|
12
|
+
https://creativecommons.org/licenses/by-nc/4.0/
|
torchtomo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: torchtomo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Differentiable CT Reconstruction in Pure PyTorch
|
|
5
|
+
Author: BIAI Lab
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/itu-biai/torchtomo
|
|
8
|
+
Project-URL: Repository, https://github.com/itu-biai/torchtomo
|
|
9
|
+
Project-URL: Issues, https://github.com/itu-biai/torchtomo/issues
|
|
10
|
+
Keywords: ct,tomography,reconstruction,pytorch,differentiable,deep-learning
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: torch>=1.10
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest; extra == "test"
|
|
29
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
30
|
+
Requires-Dist: scikit-image; extra == "test"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: build; extra == "dev"
|
|
33
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff; extra == "dev"
|
|
37
|
+
Requires-Dist: scikit-image; extra == "dev"
|
|
38
|
+
Requires-Dist: twine; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# TorchTomo
|
|
42
|
+
|
|
43
|
+
[](https://pypi.org/project/torchtomo/)
|
|
44
|
+
[](https://github.com/itu-biai/torchtomo/releases)
|
|
45
|
+
[](https://github.com/itu-biai/torchtomo/actions/workflows/test.yml)
|
|
46
|
+
[](https://github.com/itu-biai/torchtomo/blob/main/LICENSE)
|
|
47
|
+
|
|
48
|
+
Differentiable CT reconstruction primitives in pure PyTorch.
|
|
49
|
+
|
|
50
|
+
TorchTomo provides forward projection, adjoint backprojection, and filtered backprojection for parallel-beam and fan-beam geometries, with support for CPU, CUDA, and Apple Silicon (MPS).
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- Pure PyTorch implementation with no custom CUDA build step
|
|
55
|
+
- Autograd-friendly operators for learned reconstruction pipelines
|
|
56
|
+
- Parallel-beam and fan-beam (flat detector) projectors
|
|
57
|
+
- Built-in FBP filters: `ramp`, `shepp-logan`, `cosine`, `hamming`, `hann`, `none`
|
|
58
|
+
- Built-in phantom generators for quick experiments
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install torchtomo
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start (Parallel Beam)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import torch
|
|
70
|
+
from torchtomo import ParallelBeam, shepp_logan
|
|
71
|
+
|
|
72
|
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
73
|
+
|
|
74
|
+
phantom = shepp_logan(size=256, device=device) # [1, 1, 256, 256]
|
|
75
|
+
projector = ParallelBeam(img_size=256, n_angles=180, n_det=256).to(device)
|
|
76
|
+
|
|
77
|
+
sinogram = projector.forward(phantom) # [1, 1, 180, 256]
|
|
78
|
+
recon = projector.fbp(sinogram, filter_name="ramp") # [1, 1, 256, 256]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Fan-Beam Example
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from torchtomo import FanBeam, shepp_logan
|
|
85
|
+
|
|
86
|
+
phantom = shepp_logan(size=256)
|
|
87
|
+
projector = FanBeam(
|
|
88
|
+
img_size=256,
|
|
89
|
+
n_angles=360,
|
|
90
|
+
n_det=400,
|
|
91
|
+
src_dist=500.0,
|
|
92
|
+
det_dist=500.0,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
sinogram = projector.forward(phantom)
|
|
96
|
+
recon = projector.fbp(sinogram, filter_name="hann")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Differentiable Optimization Example
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import torch
|
|
103
|
+
import torch.nn.functional as F
|
|
104
|
+
from torchtomo import ParallelBeam
|
|
105
|
+
|
|
106
|
+
projector = ParallelBeam(img_size=256, n_angles=180)
|
|
107
|
+
x = torch.zeros(1, 1, 256, 256, requires_grad=True)
|
|
108
|
+
y = torch.randn(1, 1, 180, 256)
|
|
109
|
+
|
|
110
|
+
loss = F.mse_loss(projector.forward(x), y)
|
|
111
|
+
loss.backward() # gradients flow through projection operators
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## API Snapshot
|
|
115
|
+
|
|
116
|
+
- `ParallelBeam(...)`
|
|
117
|
+
- `FanBeam(...)`
|
|
118
|
+
- `projector.forward(image)`
|
|
119
|
+
- `projector.backward(sinogram)`
|
|
120
|
+
- `projector.fbp(sinogram, filter_name="ramp")`
|
|
121
|
+
- `apply_filter(sinogram, filter_name=...)`
|
|
122
|
+
- `shepp_logan(size=..., device=...)`
|
|
123
|
+
- `circle_phantom(size=..., n_circles=..., device=...)`
|
|
124
|
+
- `torchtomo.phantom.forbild(size=..., device=...)`
|
|
125
|
+
|
|
126
|
+
## Tensor Shapes
|
|
127
|
+
|
|
128
|
+
- Image: `[B, 1, H, W]`
|
|
129
|
+
- Sinogram: `[B, 1, n_angles, n_det]`
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git clone https://github.com/itu-biai/torchtomo.git
|
|
135
|
+
cd torchtomo
|
|
136
|
+
pip install -e ".[dev]"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
make test
|
|
141
|
+
make lint
|
|
142
|
+
make build
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## CI/CD
|
|
146
|
+
|
|
147
|
+
- `.github/workflows/test.yml`: Python test matrix on `push` and `pull_request`
|
|
148
|
+
- `.github/workflows/publish.yml`: release-triggered test matrix and PyPI publish step
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# TorchTomo
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/torchtomo/)
|
|
4
|
+
[](https://github.com/itu-biai/torchtomo/releases)
|
|
5
|
+
[](https://github.com/itu-biai/torchtomo/actions/workflows/test.yml)
|
|
6
|
+
[](https://github.com/itu-biai/torchtomo/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Differentiable CT reconstruction primitives in pure PyTorch.
|
|
9
|
+
|
|
10
|
+
TorchTomo provides forward projection, adjoint backprojection, and filtered backprojection for parallel-beam and fan-beam geometries, with support for CPU, CUDA, and Apple Silicon (MPS).
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Pure PyTorch implementation with no custom CUDA build step
|
|
15
|
+
- Autograd-friendly operators for learned reconstruction pipelines
|
|
16
|
+
- Parallel-beam and fan-beam (flat detector) projectors
|
|
17
|
+
- Built-in FBP filters: `ramp`, `shepp-logan`, `cosine`, `hamming`, `hann`, `none`
|
|
18
|
+
- Built-in phantom generators for quick experiments
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install torchtomo
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start (Parallel Beam)
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import torch
|
|
30
|
+
from torchtomo import ParallelBeam, shepp_logan
|
|
31
|
+
|
|
32
|
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
33
|
+
|
|
34
|
+
phantom = shepp_logan(size=256, device=device) # [1, 1, 256, 256]
|
|
35
|
+
projector = ParallelBeam(img_size=256, n_angles=180, n_det=256).to(device)
|
|
36
|
+
|
|
37
|
+
sinogram = projector.forward(phantom) # [1, 1, 180, 256]
|
|
38
|
+
recon = projector.fbp(sinogram, filter_name="ramp") # [1, 1, 256, 256]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Fan-Beam Example
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from torchtomo import FanBeam, shepp_logan
|
|
45
|
+
|
|
46
|
+
phantom = shepp_logan(size=256)
|
|
47
|
+
projector = FanBeam(
|
|
48
|
+
img_size=256,
|
|
49
|
+
n_angles=360,
|
|
50
|
+
n_det=400,
|
|
51
|
+
src_dist=500.0,
|
|
52
|
+
det_dist=500.0,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
sinogram = projector.forward(phantom)
|
|
56
|
+
recon = projector.fbp(sinogram, filter_name="hann")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Differentiable Optimization Example
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import torch
|
|
63
|
+
import torch.nn.functional as F
|
|
64
|
+
from torchtomo import ParallelBeam
|
|
65
|
+
|
|
66
|
+
projector = ParallelBeam(img_size=256, n_angles=180)
|
|
67
|
+
x = torch.zeros(1, 1, 256, 256, requires_grad=True)
|
|
68
|
+
y = torch.randn(1, 1, 180, 256)
|
|
69
|
+
|
|
70
|
+
loss = F.mse_loss(projector.forward(x), y)
|
|
71
|
+
loss.backward() # gradients flow through projection operators
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API Snapshot
|
|
75
|
+
|
|
76
|
+
- `ParallelBeam(...)`
|
|
77
|
+
- `FanBeam(...)`
|
|
78
|
+
- `projector.forward(image)`
|
|
79
|
+
- `projector.backward(sinogram)`
|
|
80
|
+
- `projector.fbp(sinogram, filter_name="ramp")`
|
|
81
|
+
- `apply_filter(sinogram, filter_name=...)`
|
|
82
|
+
- `shepp_logan(size=..., device=...)`
|
|
83
|
+
- `circle_phantom(size=..., n_circles=..., device=...)`
|
|
84
|
+
- `torchtomo.phantom.forbild(size=..., device=...)`
|
|
85
|
+
|
|
86
|
+
## Tensor Shapes
|
|
87
|
+
|
|
88
|
+
- Image: `[B, 1, H, W]`
|
|
89
|
+
- Sinogram: `[B, 1, n_angles, n_det]`
|
|
90
|
+
|
|
91
|
+
## Development
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/itu-biai/torchtomo.git
|
|
95
|
+
cd torchtomo
|
|
96
|
+
pip install -e ".[dev]"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
make test
|
|
101
|
+
make lint
|
|
102
|
+
make build
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## CI/CD
|
|
106
|
+
|
|
107
|
+
- `.github/workflows/test.yml`: Python test matrix on `push` and `pull_request`
|
|
108
|
+
- `.github/workflows/publish.yml`: release-triggered test matrix and PyPI publish step
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "torchtomo"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Differentiable CT Reconstruction in Pure PyTorch"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "BIAI Lab" }]
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
keywords = ["ct", "tomography", "reconstruction", "pytorch", "differentiable", "deep-learning"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Image Processing",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Medical Science Apps.",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"torch>=1.10",
|
|
30
|
+
"numpy",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
test = [
|
|
35
|
+
"pytest",
|
|
36
|
+
"pytest-cov",
|
|
37
|
+
"scikit-image",
|
|
38
|
+
]
|
|
39
|
+
dev = [
|
|
40
|
+
"build",
|
|
41
|
+
"matplotlib",
|
|
42
|
+
"pytest",
|
|
43
|
+
"pytest-cov",
|
|
44
|
+
"ruff",
|
|
45
|
+
"scikit-image",
|
|
46
|
+
"twine",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/itu-biai/torchtomo"
|
|
51
|
+
Repository = "https://github.com/itu-biai/torchtomo"
|
|
52
|
+
Issues = "https://github.com/itu-biai/torchtomo/issues"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
where = ["src"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 88
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = ["E", "F", "I"]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TorchTomo: Differentiable CT Reconstruction in Pure PyTorch
|
|
3
|
+
|
|
4
|
+
A lightweight library for CT forward and back projection that works
|
|
5
|
+
on any device (CPU, CUDA, MPS) without compilation.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
>>> from torchtomo import ParallelBeam, FanBeam
|
|
9
|
+
>>>
|
|
10
|
+
>>> # Parallel beam
|
|
11
|
+
>>> projector = ParallelBeam(img_size=256, n_angles=180, n_det=256)
|
|
12
|
+
>>> sinogram = projector.forward(image)
|
|
13
|
+
>>> recon = projector.fbp(sinogram)
|
|
14
|
+
>>>
|
|
15
|
+
>>> # Fan beam
|
|
16
|
+
>>> projector = FanBeam(img_size=256, n_angles=360, n_det=400,
|
|
17
|
+
... src_dist=500, det_dist=500)
|
|
18
|
+
>>> sinogram = projector.forward(image)
|
|
19
|
+
>>> recon = projector.fbp(sinogram)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from .fanbeam import FanBeam
|
|
23
|
+
from .filters import apply_filter, get_filter
|
|
24
|
+
from .parallel import ParallelBeam
|
|
25
|
+
from .phantom import circle_phantom, shepp_logan
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
__all__ = [
|
|
29
|
+
"ParallelBeam",
|
|
30
|
+
"FanBeam",
|
|
31
|
+
"apply_filter",
|
|
32
|
+
"get_filter",
|
|
33
|
+
"shepp_logan",
|
|
34
|
+
"circle_phantom",
|
|
35
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Base class for CT projectors."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
import torch
|
|
6
|
+
import torch.nn as nn
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseProjector(nn.Module, ABC):
|
|
10
|
+
"""
|
|
11
|
+
Abstract base class for CT projectors.
|
|
12
|
+
|
|
13
|
+
All projectors support:
|
|
14
|
+
- forward(): Image -> Sinogram (Radon transform)
|
|
15
|
+
- backward(): Sinogram -> Image (Adjoint/back-projection)
|
|
16
|
+
- fbp(): Filtered back-projection reconstruction
|
|
17
|
+
|
|
18
|
+
All operations are differentiable.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
img_size: int,
|
|
24
|
+
n_angles: int,
|
|
25
|
+
n_det: int,
|
|
26
|
+
angle_range: tuple[float, float] = (0, torch.pi),
|
|
27
|
+
):
|
|
28
|
+
super().__init__()
|
|
29
|
+
self.img_size = img_size
|
|
30
|
+
self.n_angles = n_angles
|
|
31
|
+
self.n_det = n_det
|
|
32
|
+
self.angle_range = angle_range
|
|
33
|
+
|
|
34
|
+
angles = torch.linspace(
|
|
35
|
+
angle_range[0], angle_range[1], n_angles, dtype=torch.float32
|
|
36
|
+
)
|
|
37
|
+
self.register_buffer("angles", angles)
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
41
|
+
"""
|
|
42
|
+
Forward projection: image -> sinogram.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
x: Image tensor of shape [B, 1, H, W]
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
Sinogram of shape [B, 1, n_angles, n_det]
|
|
49
|
+
"""
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
@abstractmethod
|
|
53
|
+
def backward(self, sinogram: torch.Tensor) -> torch.Tensor:
|
|
54
|
+
"""
|
|
55
|
+
Back projection (adjoint): sinogram -> image.
|
|
56
|
+
|
|
57
|
+
Note: This is NOT the inverse, just the adjoint operator.
|
|
58
|
+
For reconstruction, use fbp().
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
sinogram: Sinogram of shape [B, 1, n_angles, n_det]
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Back-projected image of shape [B, 1, H, W]
|
|
65
|
+
"""
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
@abstractmethod
|
|
69
|
+
def fbp(self, sinogram: torch.Tensor, filter_name: str = "ramp") -> torch.Tensor:
|
|
70
|
+
"""
|
|
71
|
+
Filtered back-projection reconstruction.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
sinogram: Sinogram of shape [B, 1, n_angles, n_det]
|
|
75
|
+
filter_name: Filter type ('ramp', 'shepp-logan', 'cosine',
|
|
76
|
+
'hamming', 'hann')
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Reconstructed image of shape [B, 1, H, W]
|
|
80
|
+
"""
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
def __repr__(self) -> str:
|
|
84
|
+
return (
|
|
85
|
+
f"{self.__class__.__name__}("
|
|
86
|
+
f"img_size={self.img_size}, "
|
|
87
|
+
f"n_angles={self.n_angles}, "
|
|
88
|
+
f"n_det={self.n_det})"
|
|
89
|
+
)
|