# Additional functions: the functions module¶

astra.functions.add_noise_to_sino(sinogram_in, I0, seed=None)[source]

Adds Poisson noise to a sinogram.

Parameters
• sinogram_in (numpy.ndarray) – Sinogram to add noise to.

• I0 (float) – Background intensity. Lower values lead to higher noise.

Returns

numpy.ndarray – the sinogram with added noise.

astra.functions.clear()[source]

Clears all used memory of the ASTRA Toolbox.

Note

This is irreversible.

astra.functions.data_op(op, data, scalar, gpu_core, mask=None)[source]

Perform data operation on data.

Parameters
• op – Operation to perform.

• data – Data to perform operation on.

• scalar – Scalar argument to data operation.

• gpu_core – GPU core to perform operation on.

astra.functions.geom_2vec(proj_geom)[source]

Returns a vector-based projection geometry from a basic projection geometry.

Parameters

proj_geom (dict) – Projection geometry to convert

astra.functions.geom_postalignment(proj_geom, factor)[source]

Apply a postalignment to a vector-based projection geometry. Can be used to model the rotation axis offset.

For 2D geometries, the argument factor is a single float specifying the distance to shift the detector (measured in detector pixels).

For 3D geometries, factor can be a pair of floats specifying the horizontal resp. vertical distances to shift the detector. If only a single float is specified, this is treated as a horizontal shift.

Parameters
• proj_geom (dict) – input projection geometry

• factor (float) – number of pixels to shift the detector

astra.functions.geom_size(geom, dim=None)[source]

Returns the size of a volume or sinogram, based on the projection or volume geometry.

Parameters
• geom – Geometry to calculate size from

• dim (int) – Optional axis index to return

astra.functions.move_vol_geom(geom, pos, is_relative=False)[source]

Moves center of volume geometry to new position.

Parameters
• geom (dict) – Input volume geometry

• pos (tuple) – Tuple (x,y[,z]) for new position, with the center of the image at (0,0[,0])

• is_relative (bool) – Whether new position is relative to the old position

Returns

dict – Volume geometry with the new center