Command-line applications¶
RTK provides command line applications which can be built from the C++ code by turning ON
the RTK_BUILD_APPLICATIONS
CMake option. A few of these applications have also been translated to Python and integrated in the Pypi package. The options of each command line application can be listed with the --help option
.
The following are examples using RTK applications:
- 3D, 2D and motion-compensated FDK
- Conjugate gradient
- Forward Projection
- Create gammex phantom
- Amsterdam Shroud
- Elekta Reconstruction
- Varian Reconstruction
- Total Variation Regularized Reconstruction
- Daubechies Wavelets Regularized Reconstruction
- 4DROOSTER: Total variation-regularized 3D + time reconstruction
- Geometry viewer
In applications/rtktutorialapplication/, you will find a very basic RTK application that can be used as a starting point for building your own new application.
Using RTK applications in Python¶
RTK applications which have been translated to Python can also be called from Python in addition to the command line, thus avoiding reloading the RTK package (which is slow) and enabling the flexibility of Python scripting. The Python interface dynamically maps the RTK applications to Python functions. You can use help(rtk.<application_name>)
to see all required and optional arguments. Note that only file paths are supported as input, ITK images or RTK geometry objects cannot be passed directly.
Each Python application accepts either:
A single positional string argument: This mimics the command-line usage.
A list of keyword arguments: This provides a more Pythonic interface.
rtk.<application_name>(<arguments>)
For example,
rtkfdk -p . -r projections.mha -o fdk.mha -g geometry.xml --spacing 2 --dimension 256
is equivalent to execute from Python
from itk import RTK as rtk
rtk.rtkfdk(
"-p . -r projections.mha -o fdk.mha -g geometry.xml --spacing 2 --dimension 256"
)
or
from itk import RTK as rtk
rtk.rtkfdk(
path=".",
regexp="projections.mha",
output="fdk.mha",
geometry="geometry.xml",
spacing="2,2,2",
dimension=[256,256,256] # You can use a string or a list
)