{"id":14982717,"url":"https://github.com/phernst/pyctl","last_synced_at":"2025-08-19T14:22:39.147Z","repository":{"id":62579690,"uuid":"247075902","full_name":"phernst/pyctl","owner":"phernst","description":"Python bindings for Computed Tomography Library (CTL)","archived":false,"fork":false,"pushed_at":"2022-08-30T07:45:08.000Z","size":351,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T22:54:57.922Z","etag":null,"topics":["computed-tomography","gpu","interactive","opencl","projection","python","python-bindings","qt5","radon","xray"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phernst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-13T13:20:02.000Z","updated_at":"2025-01-06T06:55:49.000Z","dependencies_parsed_at":"2022-11-03T21:00:59.295Z","dependency_job_id":null,"html_url":"https://github.com/phernst/pyctl","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/phernst/pyctl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phernst%2Fpyctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phernst%2Fpyctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phernst%2Fpyctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phernst%2Fpyctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phernst","download_url":"https://codeload.github.com/phernst/pyctl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phernst%2Fpyctl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271166807,"owners_count":24710573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computed-tomography","gpu","interactive","opencl","projection","python","python-bindings","qt5","radon","xray"],"created_at":"2024-09-24T14:05:54.421Z","updated_at":"2025-08-19T14:22:39.109Z","avatar_url":"https://github.com/phernst.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyCTL - Python bindings for the Computed Tomography Library (CTL)\n\nA Python package for simple and interactive use of the [CTL](https://gitlab.com/tpfeiffe/ctl).\n\nReference publication:  \nTim Pfeiffer, Robert Frysch, Richard N. K. Bismark, and Georg Rose\n\"CTL: modular open-source C++-library for CT-simulations\",\nProc. SPIE 11072,\n15th International Meeting on Fully Three-Dimensional Image Reconstruction in Radiology and Nuclear Medicine,\n110721L (28 May 2019);\n[doi:10.1117/12.2534517](https://doi.org/10.1117/12.2534517)\n\n# Simple installation\nInstall via pip:\n```\npip install pyctl\n```\nNote: This package was compiled with Qt 5.15. If you have installed Qt\u003c5.15 or \u003e=6.0, please remove any reference\nto Qt directories from the `PATH` environment variable or compile and install the package from sources.\n\n# Compiling from sources\nThe following compilation guide has been tested on Windows 10 with MSVC 2019, CUDA 10.1, Python\u003e=3.6.\n\n## On Windows\n* Install [MS Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/) with Windows SDK.\n* Install [CMake](https://cmake.org/download/). Make sure the `PATH` environment variable is set accordingly.\n* Install [Git](https://git-scm.com/). Clone this repository: `git clone --recursive https://github.com/phernst/pyctl.git`.\n* Install [Qt](https://www.qt.io/)\u003e=5.12. During installation, you need to set at least:\n    * Prebuilt components for MSVC 64-bit. Make sure the `PATH` environment variable is set accordingly\n      (e.g. `C:\\Qt\\5.15.2\\msvc2019_64\\bin`). Make sure the `CMAKE_PREFIX_PATH` environment variable\n      is set accordingly (e.g. `C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5`).\n    * Qt Charts\n* Install OpenCL 1.1/1.2:\n    * Install latest NVIDIA driver.\n    * Install [CUDA](https://developer.nvidia.com/cuda-downloads). Make sure the `CUDA_PATH` and\n      `PATH` environment variable are set accordingly.\n* Install Python 3 + pip. Recommended: use a virtual [conda environment](https://www.anaconda.com/).\n* `cd` into the cloned PyCTL directory and run `pip install .`\n\n## On Ubuntu\n* Install build tools: `sudo apt install build-essential`\n* Install CMake: `sudo apt install cmake`.\n* Install Git: `sudo apt install git`. Clone this repository: `git clone --recursive https://github.com/phernst/pyctl.git`.\n* Install Qt: `sudo apt install qt5-default qt3d5-dev libqt5charts5-dev`\n* Install Qt 3D plugins: `sudo apt install qt3d-assimpsceneimport-plugin qt3d-defaultgeometryloader-plugin qt3d-gltfsceneio-plugin qt3d-scene2d-plugin`\n* Install OpenCL 1.1/1.2:\n    * Install official NVIDIA driver using Driver Manager --\u003e reboot\n    * Install NVIDIA OpenCL development package: `sudo apt install nvidia-opencl-dev`\n    * Install NVIDIA OpenCL installable client driver: `sudo apt install nvidia-opencl-icd-340`\n    * Install OpenCL headers: `sudo apt install opencl-headers`\n* Install Python 3: `sudo apt install python3`. Recommended: use a virtual environment.\n* `cd` into the cloned PyCTL directory and run `pip install .`\n\n# Teaser: Making projections\n\nThe following example code uses a predefined C-arm system and a predefined\ntrajectory (a trajectory is a specific acquisition protocol) in order to\nproject a volume, which is read from a file. This serves to show how the CTL\nmay work out of the box. However, CT systems or acquisition protocols (or even\npreparations of single views) can be freely configured. Moreover, certain\nprojector extensions can \"decorate\" the used forward projector in order to\ninclude further geometric/physical/measuring effects.\n\n```python\nimport sys\n\nimport ctl\nimport ctl.gui\nfrom matplotlib import pyplot as plt\n\n\ndef main():\n    # create a cylinder as a volume\n    volume = ctl.VoxelVolumeF.cylinder_x(radius=60.0,\n                                         height=100.0,\n                                         voxel_size=0.5,\n                                         fill_value=0.03)\n\n    # alternatively:\n    # volume = ctl.VoxelVolumeF.from_numpy(np.ones((128, 128, 128)))\n    # volume.set_voxel_size((1.0, 1.0, 1.0))\n\n    # use of a predefined system from ctl.blueprints\n    system = ctl.CTSystemBuilder.create_from_blueprint(ctl.blueprints.GenericCarmCT())\n\n    # create an acquisition setup\n    nb_views = 100\n    my_carm_setup = ctl.AcquisitionSetup(system, nb_views)\n\n    # add a predefined trajectory to the setup from ctl.protocols\n    source_to_isocenter = 750.0  # mm is the standard unit for length dimensions\n    start_angle = ctl.deg2rad(42.0)  # rad is the standard unit for angles\n    my_carm_setup.apply_preparation_protocol(ctl.protocols.WobbleTrajectory(source_to_isocenter,\n                                                                            start_angle))\n\n    if not my_carm_setup.is_valid():\n        sys.exit(-1)\n\n    # configure a projector and project volume\n    my_projector = ctl.ocl.RayCasterProjector()  # an ideal projector with default settings\n    projections = my_projector.configure_and_project(my_carm_setup, volume)\n\n    # plot the projections\n    ctl.gui.plot(projections)\n    ctl.gui.show()\n\n    # show the 20th projection of detector module 0 using numpy\n    proj20 = projections.numpy()[20, 0]\n    # alternatively: proj20 = projections.view(20).module(0).numpy()\n    _ = plt.imshow(proj20, cmap='gray'), plt.show()\n\n\nif __name__ == '__main__':\n    main()\n\n```\n\nIf everything works well, you should see this projection:\n![example-projection](examples/readme_example.png?raw=true)\n\nThis and more example scripts can be found in the 'examples' folder of this repository.\n\nIf you have any problems or questions regarding the CTL or PyCTL, please contact us:  \n\u003csw4g.production@gmail.com\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphernst%2Fpyctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphernst%2Fpyctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphernst%2Fpyctl/lists"}