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

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
    • Sources
  • 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()      # the projector (uses its default settings)
    my_projector.configure(my_carm_setup)            # configure the projector
    projections = my_projector.project(volume)       # project

    # show the 20th projection of detector module 0
    proj20 = projections.to_numpy()[20, 0]
    # alternatively: proj20 = projections.view(20).module(0).to_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 Distribution

pyctl-0.1.0.tar.gz (63.0 kB view details)

Uploaded Source

Built Distributions

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

pyctl-0.1.0-cp38-cp38-win_amd64.whl (696.4 kB view details)

Uploaded CPython 3.8Windows x86-64

pyctl-0.1.0-cp37-cp37m-win_amd64.whl (683.2 kB view details)

Uploaded CPython 3.7mWindows x86-64

pyctl-0.1.0-cp36-cp36m-win_amd64.whl (683.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

File details

Details for the file pyctl-0.1.0.tar.gz.

File metadata

  • Download URL: pyctl-0.1.0.tar.gz
  • Upload date:
  • Size: 63.0 kB
  • Tags: Source
  • 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.0.tar.gz
Algorithm Hash digest
SHA256 bc65fad286cdbed6e870f2e0cdd6f636d40824b79fd649c7d6725a481242edfb
MD5 57d08fc0b9985805f79794d4d83fec3c
BLAKE2b-256 63bb28be53af7bc73e14bb288b273b120d38e044de81fef858dcc03cb38909ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyctl-0.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 696.4 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.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 82fabf90464bebbe5d0e43b3ea7689843f63ac8faea6e7e2ad5811a4173bbe23
MD5 7a867073c006057fb1ebca21f05fb6f7
BLAKE2b-256 630d9b9b9e83482d158a81bb143f8c98a07d3fa7fd22309f3014c372dc969660

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyctl-0.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 683.2 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.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 83a634228423885a7939d4963dd6a0443e2f739f514c210572ade2b7019b1753
MD5 535f786ff1b8b969085ee4059a89a6f0
BLAKE2b-256 ab87332b9d54425108c7f6aa17ad50c5ea4525454cca8f35fde064b22dab8b8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyctl-0.1.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 683.2 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.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f38d9bcc2abc265b245d454144445fbf043adecd0421a2aeaa50a8f6216821c1
MD5 06799ddf55522cf39e9f3512a8586003
BLAKE2b-256 a458762741af94fe04e189845771277a221e03c46249d47240d87ac23abf3dac

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 Pingdom Monitoring Sentry Error logging StatusPage Status page