Skip to main content

About

Description

aprict is a Python module for simulating transmission experiments in X-ray Computed Tomography, and for performing reconstructions from real and simulated data. In addition to the Python API, there is a commandline interface for some common operations.

Disclaimer

This software is provided with no warranty or guarantee of correctness. This is my research code sandbox, subject to breaking changes on a whim. This is not mature software. So, if you like it and wish to use it, then it is best to download a fixed version and use that. Updates are very likely to break things.

Hardware Requirements

This software requires at least one relatively recent CUDA-capable GPU. An RTX 3090 is recent enough. The relevant drivers will also need to be installed. You may need up-to-date drivers, depending on when the code was last updated.

It is strongly recommended to use high-speed mass storage, such as an NVMe drive. The software has not been tested on slower mass storage, and is not expected to perform well without it.

Known limitations

  • Lack of documentation:

    • The Python API is not yet documented.
    • The way that geometry is encoded in *.json files is not yet documented.
    • The encoding of projection data and volume data is not yet documented. (Numpy arrays; memory-mapped in the case of projections.)
  • Implementation-related issues which could be alleviated in the future:

    • The FORBILD shape Tetrahedron is not yet implemented, and no primitive shape can is permitted to have more than 3 clipping planes applied, due to internal limitations. All other FORBILD phantoms should be supported.
    • Only one GPU is utilised by this module, at the present time. There is no defined behaviour for which GPU will be chosen.
    • Not fully optimised: among other issues, this library currently requires that the whole volume (or more) can fit in the GPU VRAM.
    • CPU and GPU work not completely asynchronous: due to unresolved bugs, various asynchronous GPU operations have been disabled. This may not have much impact on large reconstructions, but could result in poor GPU utilisation for smaller reconstructions.
    • No smart batching of (back)projections: smarter code would analyse the geometry of projections, and batch together (back)projections that involve similar regions of the volume. Currently, the code does not do any kind of clever batching like this, and so the (back)projection code is not as performant as it could be.

Features

  • Works efficiently with projection datasets of any size. (Requires high-speed mass storage for rapid reading/writing, e.g. an NVMe drive.)

  • High-accuracy simulation of projection data for almost any flat-panel geometry, with almost any FORBILD phantom. Also supports voxelised volumes. The projection code computes exact line integrals (including through voxelised volumes composed of voxels of uniform attenuation coefficient), and can accept arbtirary phantoms defined in *.pha files using the FORBILD format. The accuracy can be further increased by averaging multiple line integrals for each pixel. The source and detector can even be placed inside the object, and projection will still be accurately computed from the source point to the detector pixels.

  • Several built-in phantoms included for the user's convenience.

  • Analytic reconstruction from:

    • Fan-beam data with circular scan
    • Cone-beam data with cylindrical scan

Setup

Installation

You can install aprict like you would any python package, using pip install. It is recommended to install it with the [gui] extra if possible, as this will enable plotting capabilities. This may require PyQt6 or pyside or some other GUI backend to be installed on your system. Try installing with [gui] first, if you can. This README will assume that the [gui] extra is installed.

Example installation using uv:

$ uv venv -p 3.14
$ uv pip install ~/downloads/aprict-0.0.9.tar.gz[gui]
$ source .venv/bin/activate

You should now have several executables available on $PATH. Try aprict-cli --help to see the polished commandline interface.

If you're using Windows, then it's recommended to install this inside the Windows Subsystem for Linux (WSL).

Example usage with the Commandline Interface (CLI)

Commandline interface (CLI)

Activate the environment:

source .venv/bin/activate

Now, try the shell command aprict-cli --help. Here is the output as at v0.0.9:

Usage: aprict-cli [OPTIONS] COMMAND [ARGS]...

  Entry point for aprict CLI.

Options:
  --version   Show the version and exit.
  --tree      Show the tree of nested subcommands and exit.
  -h, --help  Show this message and exit.

Commands:
  help       Show help for a command.
  make-geom  Make a geometry object.
  project    Generate projection data.
  recon      Tomographic reconstruction routines.

You can use the --help option with any command to see its detailed usage information.

Example A: cone-beam; cylindrical source distribution

Here's an example where we will use the CLI to simulate data from the FORBILD Head phantom, and reconstruct a tomogram from that data.

Start by creating a clean directory to work in:

mkdir headtest
cd headtest

Now, the first step is to create a .json file representing the experiment geometry. This can be done like so:

aprict-cli make-geom cone-cyl \
    --num 2000 \
    --R 250 --L-minus-R 250 --h 700 \
    --detwid 600 --dethei 600 \
    --pixwid-isoc 0.25 --pixhei-isoc 0.25 \
    --output projgeom.json

You might like to open this file in a text editor, to get a feel for what's inside. It describes an experiment geometry with a flat-panel trajectory.

Now, let's generate accurate, noiseless projection data from this geometry. We can specify any FORBILD file, assumed to have a file suffix of .pha, using the --phantom file.pha option. However, there are also a few built-in presets for convenience. Let's use --phantom-preset HEAD, which refers to the FORBILD Head phantom, with distances specified in units of millimeters.

aprict-cli project cbfp \
    --geom projgeom.json \
    --phantom-preset HEAD \
    --ssu 3 \
    --ssv 3 \
    --output projs \
    --plot-mode PYQTGRAPH

The option --plot-mode PYQTGRAPH will display a plot window of the projection data after it is created. (This will not be available if the module was not installed with the [gui] option.)

Now, let's reconstruct with three different algorithms:

  1. Global Backprojection-Convolution (GBC)
  2. Filtered backprojection (FBP)
  3. Filtered backprojection with volumetric weightings (FBP-VW)

To perform a GBC reconstruction, we do:

aprict-cli recon gbc-cone-cyl \
    --geom projs/projgeom.json \
    --projs projs/projs.npy \
    --voxwid 0.5 \
    --volshape '(525,525,525)' \
    --alg GREWAR \
    --output recon_gbc \
    --plot-mode PYQTGRAPH

(Time on my machine: ~03m10s)

To perform an FBP reconstruction, we do:

aprict-cli recon fbp-cone-cyl \
    --geom projs/projgeom.json \
    --projs projs/projs.npy \
    --voxwid 0.5 \
    --volshape '(525,525,525)' \
    --alg STANDARD \
    --output recon_fbp \
    --plot-mode PYQTGRAPH

(Time on my machine: ~00m33s)

To perform an FBP-VM reconstruction, we change --alg to NOOGREWAR:

aprict-cli recon fbp-cone-cyl \
    --geom projs/projgeom.json \
    --projs projs/projs.npy \
    --voxwid 0.5 \
    --volshape '(525,525,525)' \
    --alg NOOGREWAR \
    --output recon_fbp-vw \
    --plot-mode PYQTGRAPH

(Time on my machine: ~01m03s)

Example B: fan-beam; circular source distribution

Here's an example where we will use the CLI to simulate data from a FORBILD phantom resembling a double-chambered aluminium rock canister phantom.

Start by creating a clean directory to work in:

mkdir rockcantest
cd rockcantest

The first step is to create a .json file representing the fan-beam experiment geometry. This can be done like so:

aprict-cli make-geom fan-circ \
    --num 300 \
    --R 4 --L-minus-R 4 \
    --detwid 17.5 --nv 1 \
    --pixwid-isoc 0.002 --pixhei-isoc 0.002 \
    --output projgeom.json

Note the option --nv 1, which specifies that the detector height should be 1 pixel, which is appropriate for a fan-beam experiment, where we only intend to reconstruct a single z slice of the phantom. This is an alternative to supplying the --dethei option. Some options, such as these, are mutually exclusive. Use aprict-cli make-geom fan-circ --help to see detailed information about this.

Now, let's generate projection data from the phantom preset called ROCK_CAN. The z=0 layer of the phantom is not all that interesting, so we'll also translate the input phantom down along the z axis by -2.7 units (millimeters, in this case). Additionally, since we intend on simulating a 2D phantom here, we only want to sample rays at the vertical centre of each pixel. So, we will supply --ssv 1 to ensure that only the middle of each pixel is used for ray end-points. The option --ssu 100 ensures that 100 fanning rays are averaged to compute the projected attenuation at each pixel. This ensures greater accuracy, particularly in the presence of small features which may otherwise be missed by the pixel size.

aprict-cli project cbfp \
    --geom projgeom.json \
    --phantom-preset ROCK_CAN \
    --translate-vol '(0,0,-2.7)' \
    --ssu 100 \
    --ssv 1 \
    --output projs \
    --plot-mode PYQTGRAPH

The option --plot-mode PYQTGRAPH will display a plot window of the projection data (a sinogram) after it is created. (This will not be available if the module was not installed with the [gui] option.)

You will find a copy of the ROCK_CAN phantom in the output directory projs, beside the projection data. The phantom is always copied to the output directory, to ensure a good record of the inputs to the simulation.

Finally, let's perform a reconstruction using a filtered backprojection (FBP) method for this geometry:

aprict-cli recon fbp-fan-circ \
    --geom projs/projgeom.json \
    --projs projs/projs.npy \
    --voxwid 0.002 \
    --volshape '(3000,3000,1)' \
    --alg STANDARD \
    --output recon_standard \
    --plotmin -0.25 \
    --plotmax 2.25 \
    --plot-mode PYQTGRAPH

Once again, the option --plot-mode PYQTGRAPH ensures that a plot window will pop up once the reconstruction is done. Note the --plotmin -0.25 and --plotmax 2.25 options here, which control the plotting range of the saved *.png files in the output directory. The whole volume is stored as a numpy array (*.npy), but it's useful to have some preview PNGs generated as well.

The previous reconstruction contains a lot of undersampling artefacts, due to the small number of projections (300). To a lesser extent, it also contains aliasing artefacts, due to the (de)magnified pixel size subceeding the voxel size. So, let's try an alternative algorithm that better handles this situation, at the expensive of reduced sharpness on the edges. This can be done by specifying --alg NOOGREWAR:

aprict-cli recon fbp-fan-circ \
    --geom projs/projgeom.json \
    --projs projs/projs.npy \
    --voxwid 0.002 \
    --volshape '(3000,3000,1)' \
    --alg NOOGREWAR \
    --output recon_noogrewar \
    --plotmin -0.25 \
    --plotmax 2.25 \
    --plot-mode PYQTGRAPH

Metadata

Release files for aprict 0.0.15

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

Source distribution (sdist)

Source distribution for aprict 0.0.15
File Size Uploaded Provenance
aprict-0.0.15.tar.gz 6.0 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aprict 0.0.15
File Interpreter ABI Platform
aprict-0.0.15-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 MB

Release files / aprict-0.0.15.tar.gz

Download URL aprict-0.0.15.tar.gz
Size 6.0 MB
Tags Source
SHA-256 checksum
How to use checksums
7ec67ba201102bf98dd51468e160e7e4a8c94fbe5e230b8b9869b1f9a8f2484b
BLAKE2b-256 checksum
How to use checksums
4d71c9b1500f781943a3e71b20ef28b70c9936e45a6426675302a48cacb494a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / aprict-0.0.15-py3-none-any.whl

Download URL aprict-0.0.15-py3-none-any.whl
Size 6.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
66cf7adfc803c6c1a15c463a8be317627e96f820afa3c21c1ed04dff6adc5523
BLAKE2b-256 checksum
How to use checksums
f81eb27f9b5731de9414abb78710fb2cf000e701ce85160bb7ab2ccd7049b822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for aprict 0.0.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aprict-0.0.15.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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