Package: pyctl
PyCTL - Python bindings for the Computed Tomography Library (CTL)A Python package for simple and interactive use of theCTL.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.2534517Simple installationInstall via pip:pip install pyctlNote: 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 thePATHenvironment variable or compile and install the package from sources.Compiling from sourcesThe following compilation guide has been tested on Windows 10 with MSVC 2019, CUDA 10.1, Python>=3.6.On WindowsInstallMS Visual Studio Build Toolswith Windows SDK.InstallCMake. Make sure thePATHenvironment variable is set accordingly.InstallGit. Clone this repository:git clone --recursive https://github.com/phernst/pyctl.git.InstallQt>=5.12. During installation, you need to set at least:Prebuilt components for MSVC 64-bit. Make sure thePATHenvironment variable is set accordingly
(e.g.C:\Qt\5.15.2\msvc2019_64\bin). Make sure theCMAKE_PREFIX_PATHenvironment variable
is set accordingly (e.g.C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5).Qt ChartsInstall OpenCL 1.1/1.2:Install latest NVIDIA driver.InstallCUDA. Make sure theCUDA_PATHandPATHenvironment variable are set accordingly.Install Python 3 + pip. Recommended: use a virtualconda environment.cdinto the cloned PyCTL directory and runpip install .On UbuntuInstall build tools:sudo apt install build-essentialInstall 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-devInstall Qt 3D plugins:sudo apt install qt3d-assimpsceneimport-plugin qt3d-defaultgeometryloader-plugin qt3d-gltfsceneio-plugin qt3d-scene2d-pluginInstall OpenCL 1.1/1.2:Install official NVIDIA driver using Driver Manager --> rebootInstall NVIDIA OpenCL development package:sudo apt install nvidia-opencl-devInstall NVIDIA OpenCL installable client driver:sudo apt install nvidia-opencl-icd-340Install OpenCL headers:sudo apt install opencl-headersInstall Python 3:sudo apt install python3. Recommended: use a virtual environment.cdinto the cloned PyCTL directory and runpip install .Teaser: Making projectionsThe 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.importsysimportctlimportctl.guifrommatplotlibimportpyplotaspltdefmain():# create a cylinder as a volumevolume=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.blueprintssystem=ctl.CTSystemBuilder.create_from_blueprint(ctl.blueprints.GenericCarmCT())# create an acquisition setupnb_views=100my_carm_setup=ctl.AcquisitionSetup(system,nb_views)# add a predefined trajectory to the setup from ctl.protocolssource_to_isocenter=750.0# mm is the standard unit for length dimensionsstart_angle=ctl.deg2rad(42.0)# rad is the standard unit for anglesmy_carm_setup.apply_preparation_protocol(ctl.protocols.WobbleTrajectory(source_to_isocenter,start_angle))ifnotmy_carm_setup.is_valid():sys.exit(-1)# configure a projector and project volumemy_projector=ctl.ocl.RayCasterProjector()# an ideal projector with default settingsprojections=my_projector.configure_and_project(my_carm_setup,volume)# plot the projectionsctl.gui.plot(projections)ctl.gui.show()# show the 20th projection of detector module 0 using numpyproj20=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: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.