Python bindings for CTL
Project description
PyCTL - Python bindings for the Computed Tomography Library (CTL)
A Python package for simple and interactive use of the CTL.
Reference publication:
Tim Pfeiffer, Robert Frysch, Richard N. K. Bismark, and Georg Rose
"CTL: modular open-source C++-library for CT-simulations",
Proc. SPIE 11072,
15th International Meeting on Fully Three-Dimensional Image Reconstruction in Radiology and Nuclear Medicine,
110721L (28 May 2019);
doi:10.1117/12.2534517
Simple installation
Install via pip:
pip install pyctl
Note: This package was compiled with Qt 5.12. If you have installed Qt<5.12 or >=5.15, please remove any reference
to Qt directories from the PATH
environment variable or compile and install the package from sources.
Compiling from sources
The following compilation guide has been tested on Windows 10 with MSVC 2019, CUDA 10.1, Python>=3.6.
On Windows
- Install MS Visual Studio Build Tools with Windows SDK.
- Install CMake. Make sure the
PATH
environment variable is set accordingly. - Install Git. Clone this repository:
git clone --recursive https://github.com/phernst/pyctl.git
. - Install Qt>=5.12. During installation, you need to set at least:
- Prebuilt components for MSVC 64-bit. Make sure the
PATH
environment variable is set accordingly (e.g.C:\Qt\5.14.1\msvc2017_64\bin
). Make sure theCMAKE_PREFIX_PATH
environment variable is set accordingly (e.g.C:\Qt\5.14.1\msvc2017_64\lib\cmake\Qt5
). - Qt Charts
- Prebuilt components for MSVC 64-bit. Make sure the
- Install OpenCL 1.1/1.2:
- Install latest NVIDIA driver.
- Install CUDA. Make sure the
CUDA_PATH
andPATH
environment variable are set accordingly.
- Install Python 3 + pip. Recommended: use a virtual conda environment.
cd
into the cloned PyCTL directory and runpip install .
On Linux (not tested)
- Install build tools:
sudo apt install build-essential
- Install CMake:
sudo apt install cmake
. - Install Git:
sudo apt install git
. Clone this repository:git clone --recursive https://github.com/phernst/pyctl.git
. - Install Qt:
sudo apt install qt5-default qt3d5-dev libqt5charts5-dev
- Install OpenCL 1.1/1.2:
- Install official NVIDIA driver using Driver Manager --> reboot
- Install NVIDIA OpenCL development package:
sudo apt install nvidia-opencl-dev
- Install OpenCL headers:
sudo apt install opencl-headers
- Install Python 3:
sudo apt install python3
. Recommended: use a virtual environment. cd
into the cloned PyCTL directory and runpip install .
Teaser: Making projections
The following example code uses a predefined C-arm system and a predefined trajectory (a trajectory is a specific acquisition protocol) in order to project a volume, which is read from a file. This serves to show how the CTL may work out of the box. However, CT systems or acquisition protocols (or even preparations of single views) can be freely configured. Moreover, certain projector extensions can "decorate" the used forward projector in order to include further geometric/physical/measuring effects.
import sys
import ctl
import numpy as np
from matplotlib import pyplot as plt
def main():
# create a volume of size 128x128x128px with a voxel size of 1x1x1mm
volume = ctl.VoxelVolumeF((128, 128, 128), (1.0, 1.0, 1.0))
volume.fill(1.0)
# alternatively:
# volume = ctl.VoxelVolumeF.from_numpy(np.ones((128, 128, 128)))
# volume.set_voxel_size((1.0, 1.0, 1.0))
# use of a predefined system from ctl.blueprints
system = ctl.CTSystemBuilder.create_from_blueprint(ctl.blueprints.GenericCarmCT())
# create an acquisition setup
nb_views = 100
my_carm_setup = ctl.AcquisitionSetup(system, nb_views)
# add a predefined trajectory to the setup from ctl.protocols
angle_span = np.deg2rad(200.0) # rad is the standard unit for angles
source_to_isocenter = 750.0 # mm is the standard unit for length dimensions
my_carm_setup.apply_preparation_protocol(ctl.protocols.WobbleTrajectory(angle_span,
source_to_isocenter))
if not my_carm_setup.is_valid():
sys.exit(-1)
# configure a projector and project volume
my_projector = ctl.ocl.RayCasterProjector() # an ideal projector with default settings
projections = my_projector.configure_and_project(my_carm_setup, volume)
# show the 20th projection of detector module 0
proj20 = projections.numpy()[20, 0]
# alternatively: proj20 = projections.view(20).module(0).numpy()
_ = plt.imshow(proj20, cmap='gray'), plt.show()
if __name__ == '__main__':
main()
If everything works well, you should see this projection:
If you have any problems or questions regarding the CTL or PyCTL, please contact us:
sw4g.production@gmail.com.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pyctl-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa0f7c686f08dd981da1f670bc6f54a8884c9bead12fb580446433fe807d2967 |
|
MD5 | f25803356e8f62b43b2c5c772ec32107 |
|
BLAKE2b-256 | c7645743220720487dbb7f4ffee4713bb378ed997f66aac199ef0aacaebee0be |
Hashes for pyctl-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a47d7a497d69f7108e7abbe2c13bfeb217d1a0f4a48776518f04ef2feaa30c72 |
|
MD5 | 9c477e288824c4ba65884ba84c942a66 |
|
BLAKE2b-256 | 157758c1c1e8bdb051218b18610493d232fe9bc856677153f43f3d8bce768422 |
Hashes for pyctl-0.1.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 798c74b19539455d302df0e1673cf20ea16aec302a462a998ee7d198d1084b78 |
|
MD5 | 0108995e7feed5ef0f563c282d3a7784 |
|
BLAKE2b-256 | 97d47665c7e7795f0a60f41ac8778d553ebe670f484980159676262a743e4728 |