Skip to main content

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.15. If you have installed Qt<5.15 or >=6.0, 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.15.2\msvc2019_64\bin). Make sure the CMAKE_PREFIX_PATH environment variable is set accordingly (e.g. C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5).
    • Qt Charts
  • Install OpenCL 1.1/1.2:
    • Install latest NVIDIA driver.
    • Install CUDA. Make sure the CUDA_PATH and PATH environment variable are set accordingly.
  • Install Python 3 + pip. Recommended: use a virtual conda environment.
  • cd into the cloned PyCTL directory and run pip install .

On Ubuntu

  • 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 Qt 3D plugins: sudo apt install qt3d-assimpsceneimport-plugin qt3d-defaultgeometryloader-plugin qt3d-gltfsceneio-plugin qt3d-scene2d-plugin
  • 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 NVIDIA OpenCL installable client driver: sudo apt install nvidia-opencl-icd-340
    • 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 run pip 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 ctl.gui
from matplotlib import pyplot as plt


def main():
    # create a cylinder as a volume
    volume = ctl.VoxelVolumeF.cylinder_x(radius=60.0,
                                         height=100.0,
                                         voxel_size=0.5,
                                         fill_value=0.03)

    # 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
    source_to_isocenter = 750.0  # mm is the standard unit for length dimensions
    start_angle = ctl.deg2rad(42.0)  # rad is the standard unit for angles
    my_carm_setup.apply_preparation_protocol(ctl.protocols.WobbleTrajectory(source_to_isocenter,
                                                                            start_angle))

    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)

    # plot the projections
    ctl.gui.plot(projections)
    ctl.gui.show()

    # show the 20th projection of detector module 0 using numpy
    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: example-projection

This and more example scripts can be found in the 'examples' folder of this repository.

If you have any problems or questions regarding the CTL or PyCTL, please contact us:
sw4g.production@gmail.com.

Metadata

Release files for pyctl 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyctl 0.1.4
File
pyctl-0.1.4-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
pyctl-0.1.4-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
pyctl-0.1.4-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
pyctl-0.1.4-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details

Total release size: 4.2 MB

Release files / pyctl-0.1.4-cp39-cp39-win_amd64.whl

Download URL pyctl-0.1.4-cp39-cp39-win_amd64.whl
Size 1.1 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
46d477037102acf65b38acb7863618f135ab639847aff9a0b4995488bb349ca5
BLAKE2b-256 checksum
How to use checksums
21860be5c2574097040ed687178eeea8f91c28fa15e7035db9318c6aa1bfc29e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / pyctl-0.1.4-cp38-cp38-win_amd64.whl

Download URL pyctl-0.1.4-cp38-cp38-win_amd64.whl
Size 1.0 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
241c4d951d0887d005aa64c209dffdb0559aad733e095fbbb1935326d953e6af
BLAKE2b-256 checksum
How to use checksums
01d27afc8fe080bed77254fb6602c403581d83a5488c331d51906f2cafc0dd25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / pyctl-0.1.4-cp37-cp37m-win_amd64.whl

Download URL pyctl-0.1.4-cp37-cp37m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
9050204394d34a9bf2add4e2d25e66743c76c3896e1266a8328a2bc517e685a2
BLAKE2b-256 checksum
How to use checksums
7ae3d1eabd7b551b7fbc0000ad8b5300cbd6862b57a70ad11b098993cacb6fe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / pyctl-0.1.4-cp36-cp36m-win_amd64.whl

Download URL pyctl-0.1.4-cp36-cp36m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
136ecfdfe06f8899dd3f6228010f9dbfbed34f52cb23b0e518ad5e94a5ed5f5b
BLAKE2b-256 checksum
How to use checksums
8fc1788aa3344bd6b03e6ae85bcde2391f2f061af2b2d7f6327cd21b622f026a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.1.4 This release

4 release files

0.1.3

3 release files

0.1.2

3 release files

0.1.1

3 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page