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.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.
  • 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 the CMAKE_PREFIX_PATH environment variable is set accordingly (e.g. C:\Qt\5.14.1\msvc2017_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 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.
  • 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 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 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: example-projection

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyctl-0.1.1-cp38-cp38-win_amd64.whl (715.5 kB view details)

Uploaded CPython 3.8Windows x86-64

pyctl-0.1.1-cp37-cp37m-win_amd64.whl (701.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

pyctl-0.1.1-cp36-cp36m-win_amd64.whl (701.4 kB view details)

Uploaded CPython 3.6mWindows x86-64

File details

Details for the file pyctl-0.1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyctl-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 715.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for pyctl-0.1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 48770ddc579491707991678f33c492f4debbb4bddace19e84bf92070df153fe8
MD5 af233f4d73bca2234560a28fb3331bb1
BLAKE2b-256 7ff1476489f517756b0045222c54aaac7c4fc5d1424f4a2e58aa3cb22a5994c6

See more details on using hashes here.

File details

Details for the file pyctl-0.1.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyctl-0.1.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 701.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for pyctl-0.1.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b13e90329f26033f0d0c886c838b043e339920ed9e040aa37695782b8089405f
MD5 a3f7ea8a354f9fffd515b2c8c2f1d614
BLAKE2b-256 2821aae1299d71281b790f83bfb3221ebbbcd0e1155550751248c267d90cab24

See more details on using hashes here.

File details

Details for the file pyctl-0.1.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyctl-0.1.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 701.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for pyctl-0.1.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 21b8bd6b9f0c32d4422a0aadda3a48e5c9b100d767c78cc60905d0b1e73fb8f0
MD5 3855cfc9ed309025078a79c38baf913a
BLAKE2b-256 0d949fd5cb0e2bcff45ea283d0aa1c67f1ea7373e60957a38ac4e77619ec9821

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page