Skip to content

Commit 9db7cdd

Browse files
Simon Ritcyrilmory
andcommitted
ENH: Add Python examples and associated documentation
Co-authored-by: Cyril Mory <cyril.mory@gmail.com>
1 parent f6c23fc commit 9db7cdd

12 files changed

Lines changed: 715 additions & 0 deletions

File tree

applications/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ The following are examples using RTK applications:
2020
./rtkfourdconjugategradient/README.md
2121
./rtkfourdsart/README.md
2222
./rtkfourdrooster/README.md
23+
./rtkspectralforwardmodel/README.md
24+
./rtkspectralsimplexdecomposition/README.md
25+
./rtkspectralrooster/README.md
26+
./rtkspectralonestep/README.md
2327
./rtkshowgeometry/README.md
2428
./rtkosem/README.md
2529
./rtksart/README.md
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Two-step spectral CT reconstruction
2+
3+
This page describes an application for two-step spectral CT reconstruction. Please start by reading the [general documentation on spectral CT](../../documentation/docs/multi_energy.md).
4+
5+
# Spectral forward model
6+
7+
RTK provides a command line application to simulate the measured projections in spectral CT from the decomposed projections, the incident spectrum, the material attenuations and the detector response.
8+
It is the "forward operator" in the [inverse problem](https://en.wikipedia.org/wiki/Inverse_problem) that RTK solves to obtain the decomposed projections from the measured projections.
9+
10+
## Dataset
11+
12+
The data used in this documentation page can be downloaded using [Girder](https://data.kitware.com/#collection/5a7706878d777f0649e04776/folder/69a005bdf94d0dc14645a412).
13+
It is a simulation through a cylinder of water with two inserts, one empty, the other filled with cortical bone.
14+
15+
## Command line application
16+
17+
```
18+
# Simulate the measured projections (photon counts on the spectral detector)
19+
# from the decomposed projections, the incident spectrum,
20+
# the material attenuations and the detector response.
21+
22+
rtkspectralforwardmodel \
23+
-o cl_counts.mha \
24+
-i decomposed.mha \
25+
-d drm.mha \
26+
--incident no_vector_spectrum.mha \
27+
-a mat_basis.mha \
28+
-t 20,40,60,80,100
29+
```
30+
31+
`cl_counts.mha` should be identical to `counts.mha`. You can check it with [VV](http://vv.creatis.insa-lyon.fr/) using the overlay feature.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# One-step spectral CT reconstruction
2+
3+
Please start by reading the [general documentation on spectral CT](../../documentation/docs/multi_energy.md).
4+
5+
RTK provides a command line application to perform one-step reconstruction. It uses the measured projections, the incident spectrum, the material attenuations and the detector response for the spectral part, and the geometry and an initial reconstructed volume for the tomographic part.
6+
Providing a mask of the region of the reconstructed volume where the image object is expected to be found, and outside of which there should be nothing, helps the algorithm converge.
7+
The method is described in [this paper](https://ieeexplore.ieee.org/document/7979598).
8+
9+
## Dataset
10+
11+
The data used in this documentation page can be downloaded using [Girder](https://data.kitware.com/#collection/5a7706878d777f0649e04776/folder/69a005bdf94d0dc14645a412).
12+
It is a simulation through a cylinder of water with two inserts, one empty, the other filled with cortical bone.
13+
14+
## Command line application
15+
16+
```
17+
# One-step spectral reconstruction
18+
19+
rtkspectralonestep \
20+
-s counts.mha \
21+
--incident spectrum.mha \
22+
-a mat_basis.mha \
23+
-d drm.mha \
24+
-g geometry.xml \
25+
-i decomposed_init.mha \
26+
-o cl_onestep.mha \
27+
-t 20,40,60,80,100 \
28+
--mask mask.mha \
29+
-n 20
30+
```
31+
32+
`cl_onestep.mha` should look similar to `recon_ref.mha`. You can check it with [VV](http://vv.creatis.insa-lyon.fr/) using the overlay feature. Note that `recon_ref.mha` is a 4D image, while `cl_onestep.mha` is a VectorImage, so their data is not organized the same way on disk, but VV will open both a 4D images and overlay them correctly.
33+
34+
To speed things up, it is recommended to use the CUDA version of the forward and back projectors by running this command instead:
35+
36+
```
37+
# One-step spectral reconstruction using CUDA accelerations
38+
39+
rtkspectralonestep \
40+
-s counts.mha \
41+
--incident spectrum.mha \
42+
-a mat_basis.mha \
43+
-d drm.mha \
44+
-g geometry.xml \
45+
-i decomposed_init.mha \
46+
-o cl_onestep.mha \
47+
-t 20,40,60,80,100 \
48+
--mask mask.mha \
49+
-n 20 \
50+
-f CudaRayCast \
51+
-b CudaVoxelBased
52+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Two-step spectral CT reconstruction
2+
3+
This page describes an application for two-step spectral CT reconstruction. Please start by reading the [general documentation on spectral CT](../../documentation/docs/multi_energy.md).
4+
5+
Once measured projections have been decomposed into material projections, any reconstruction algorithm can be used to reconstruct each material. In RTK, simply splitting the material projections file (saved as an `itkVectorImage`) into one set of projections per material, and then using `rtkfdk`, `rtksart` or `rtkconjugategradient` will work.
6+
7+
# Spectral ROOSTER
8+
9+
RTK provides a command line application to jointly reconstruct all materials at once, allowing to apply spatial regularization in each material, but also regularization along the material dimension, as reconstructed material volumes sometimes share the same spatial structure.
10+
Since `rtkspectralrooster` uses the [ROOSTER filter](https://www.openrtk.org/Doxygen/classrtk_1_1FourDROOSTERConeBeamReconstructionFilter.html), originally designed to reconstruct 3D+time volume sequences, the material dimension is referred to as time in the command-line help and parameter names.
11+
12+
## Dataset
13+
14+
The data used in this documentation page can be downloaded using [Girder](https://data.kitware.com/#collection/5a7706878d777f0649e04776/folder/69a005bdf94d0dc14645a412).
15+
It is a simulation through a cylinder of water with two inserts, one empty, the other filled with cortical bone.
16+
17+
## Command line application
18+
19+
```
20+
# Reconstruct a set of material volumes from all material projections,
21+
# applying Total Nuclear Variation regularization
22+
23+
rtkspectralrooster \
24+
-o cl_spectralrooster.mha \
25+
-i mat_recon.mha \
26+
-p decomposed.mha \
27+
-g geometry.xml \
28+
--niter 4 \
29+
--cgiter 2 \
30+
--tviter 2 \
31+
--gamma_tnv 1
32+
```
33+
34+
`cl_spectralrooster.mha` should look similar to `recon_ref.mha`. You can check it with [VV](http://vv.creatis.insa-lyon.fr/) using the overlay feature. Note that `recon_ref.mha` is a 4D image, while `cl_spectralrooster.mha` is a VectorImage, so their data is not organized the same way on disk, but VV will open both a 4D images and overlay them correctly.
35+
To speed things up, it is recommended to use the CUDA version of the forward and back projectors, and by using CUDA in the conjugate gradient descent algorithm, by running this command instead:
36+
37+
```
38+
# Reconstruct a set of material volumes from all material projections,
39+
# applying Total Nuclear Variation regularization, using CUDA accelerations
40+
41+
rtkspectralrooster \
42+
-o cl_spectralrooster.mha \
43+
-i mat_recon.mha \
44+
-p decomposed.mha \
45+
-g geometry.xml \
46+
--niter 4 \
47+
--cgiter 2 \
48+
--tviter 2 \
49+
--gamma_tnv 1
50+
--cudacg \
51+
--fp CudaRayCast \
52+
--bp CudaVoxelBased
53+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Two-step spectral CT reconstruction
2+
3+
This page describes an application for two-step spectral CT reconstruction. Please start by reading the [general documentation on spectral CT](../../documentation/docs/multi_energy.md).
4+
5+
# Spectral simplex decomposition
6+
7+
RTK provides a command line application to decompose the measured projections into one set of projections per material assumed compose the imaged object. It uses the incident spectrum, the material attenuations and the detector response.
8+
The method is described in [this paper](https://iopscience.iop.org/article/10.1088/0031-9155/53/15/002).
9+
10+
## Dataset
11+
12+
The data used in this documentation page can be downloaded using [Girder](https://data.kitware.com/#collection/5a7706878d777f0649e04776/folder/69a005bdf94d0dc14645a412).
13+
It is a simulation through a cylinder of water with two inserts, one empty, the other filled with cortical bone.
14+
15+
## Command line application
16+
17+
```
18+
# Decompose the measured projections (photon counts on the spectral detector)
19+
# into material projections, using the incident spectrum,
20+
# the material attenuations and the detector response.
21+
22+
rtkspectralsimplexdecomposition \
23+
-o cl_decomposed.mha \
24+
-i zero_decomposed.mha \
25+
-s counts.mha \
26+
-d drm.mha \
27+
--incident no_vector_spectrum.mha \
28+
-a mat_basis.mha \
29+
-t 20,40,60,80,100
30+
31+
```
32+
33+
`cl_decomposed.mha` should be identical to `decomposed.mha`. You can check it with [VV](http://vv.creatis.insa-lyon.fr/) using the overlay feature.

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ providing efficient implementations for high-performance applications.
2222
./InlineReconstruction/README.md
2323
./AddNoise/README.md
2424
./GeometricPhantom/README.md
25+
./SpectralOneStep/README.md
26+
./SpectralTwoStep/README.md
2527
```

examples/SpectralOneStep/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# One-step spectral reconstruction
2+
3+
This example shows how to generate simulated spectral x-ray projections of an in silico phantom, and then perform a one-step reconstruction using [Mechlem *et al*'s reconstruction](https://doi.org/10.1109/TMI.2017.2726687) (ordered subset separable quadratic surrogate using [Weidinger *et al*'s surrogate](https://doi.org/10.1155/2016/5871604)).
4+
5+
`````{tab-set}
6+
7+
````{tab-item} Python
8+
9+
```{literalinclude} ./SpectralOneStep.py
10+
:language: python
11+
```
12+
````
13+
`````

0 commit comments

Comments
 (0)