Testing the ASTRA installation


This will run quick tests of basic CPU/GPU functionality, and report on the results. As a part of this it will report if GPU functionality is available.

Setting GPU index

astra.set_gpu_index([index1, index2, ...])

This lets ASTRA use the GPU with the specified index or indices. Not all ASTRA functionality supports using multiple GPUs. In that case the GPU specified first will be used.


Various reconstruction algorithms support projection data and reconstruction volume masks. These behave as follows.

The projection data elements corresponding to locations with SinogramMask value 0.0 will be ignored during the reconstruction. Similarly, the reconstruction data elements corresponding to locations with ReconstructionMask value 0.0 will be ignored during the reconstruction, and their values will be preserved. (Mostly, see note on constraints below.)

The algorithm will behave as if the rows and columns corresponding to the masked voxels and projection data elements have been removed from the projection matrix entirely. In other words, it will iteratively try to match the projection of the non-masked voxels to the non-masked projection data elements.

NB: MinConstraint/MaxConstraint will affect even masked voxels.


cfg = astra.astra_dict('NAME')

This is the basic script to create a configuration struct for many astra objects. The returned struct is usually filled with more options after creating it, and then passed to astra functions such as

id = astra.algorithm.create(cfg)
id = astra.projector.create(cfg)

The most common usage is for creating algorithm configuration structs. See the pages on [2D CPU Algorithms], [2D GPU Algorithms], [3D GPU Algorithms] for available algorithms, and the pages for the individual algorithms for the options they support.


astra_mex_matrix is used to manage sparse matrices. These can be created by the ASTRA toolbox itself to obtain explicit weight matrices (see [astra_mex_projector]), or you can create them yourself for use with the sparse_matrix projection geometry.

It is a wrapper around the MEX file astra_mex_matrix_c.

astra_mex_matrix contains the following commands:

  • create

  • get

  • get_size

  • store

  • delete

  • clear

  • info


id = astra.matrix.create(S)

Create an ASTRA sparse matrix object from a Python sparse matrix of type scipy.sparse.csr_matrix or a Matlab sparse matrix.

S = astra.matrix.get(id)

Return an ASTRA sparse matrix object as a Python sparse matrix of type scipy.sparse.csr_matrix or a Matlab sparse matrix.


s = astra.matrix.get_size(id)

Get the size (rows,columns) of the sparse matrix object.


astra.matrix.store(id, S)

Store a new Python or Matlab sparse matrix in an ASTRA sparse matrix object.

NB: This does not re-allocate memory: the number of rows and non-zero entries may not be larger than they were when the object was first created.


astra.matrix.delete([id1, id2, ...])

Free a single sparse matrix.



Free all sparse matrices.



Print basic information about all allocated sparse matrix objects.