Creation of objects: the creators module

astra.creators.astra_dict(intype)[source]

Creates a dict to use with the ASTRA Toolbox.

Parameters:

intype (string) – Type of the ASTRA object.

Returns:

dict – An ASTRA dict of type intype.

astra.creators.create_backprojection(data, proj_id, returnData=True)[source]

Create a backprojection of a sinogram (2D).

Parameters:
  • data (numpy.ndarray or int) – Sinogram data or ID.

  • proj_id (int) – ID of the projector to use.

  • returnData (bool) – If False, only return the ID of the backprojection.

Returns:

int or (int, numpy.ndarray) – If returnData=False, returns the ID of the backprojection. Otherwise, returns a tuple containing the ID of the backprojection and the backprojection itself, in that order.

astra.creators.create_backprojection3d_gpu(data, proj_geom, vol_geom, returnData=True)[source]

Create a backprojection of a sinogram (3D) using CUDA.

Parameters:
  • data (numpy.ndarray or int) – Sinogram data or ID.

  • proj_geom (dict) – Projection geometry.

  • vol_geom (dict) – Volume geometry.

  • returnData (bool) – If False, only return the ID of the backprojection.

Returns:

int or (int, numpy.ndarray) – If returnData=False, returns the ID of the backprojection. Otherwise, returns a tuple containing the ID of the backprojection and the backprojection itself, in that order.

astra.creators.create_proj_geom(intype, *args)[source]

Create a projection geometry.

This method can be called in a number of ways:

create_proj_geom('parallel', detector_spacing, det_count, angles):

Parameters:
  • detector_spacing (float) – Distance between two adjacent detector pixels.

  • det_count (int) – Number of detector pixels.

  • angles (numpy.ndarray) – Array of angles in radians.

Returns:

A parallel projection geometry.

create_proj_geom('parallel_vec', det_count, V):

Parameters:
  • det_count (int) – Number of detector pixels.

  • V (numpy.ndarray) – Vector array.

Returns:

A parallel-beam projection geometry.

create_proj_geom('fanflat', det_width, det_count, angles, source_origin, origin_det):

Parameters:
  • det_width (float) – Size of a detector pixel.

  • det_count (int) – Number of detector pixels.

  • angles (numpy.ndarray) – Array of angles in radians.

  • source_origin – Position of the source.

  • origin_det – Position of the detector

Returns:

A fan-beam projection geometry.

create_proj_geom('fanflat_vec', det_count, V):

Parameters:
  • det_count (int) – Number of detector pixels.

  • V (numpy.ndarray) – Vector array.

Returns:

A fan-beam projection geometry.

create_proj_geom('parallel3d', detector_spacing_x, detector_spacing_y, det_row_count, det_col_count, angles):

Parameters:
  • detector_spacing_* (float) – Distance between two adjacent detector pixels.

  • det_row_count (int) – Number of detector pixel rows.

  • det_col_count (int) – Number of detector pixel columns.

  • angles (numpy.ndarray) – Array of angles in radians.

Returns:

A parallel projection geometry.

create_proj_geom('cone', detector_spacing_x, detector_spacing_y, det_row_count, det_col_count, angles, source_origin, origin_det):

Parameters:
  • detector_spacing_* (float) – Distance between two adjacent detector pixels.

  • det_row_count (int) – Number of detector pixel rows.

  • det_col_count (int) – Number of detector pixel columns.

  • angles (numpy.ndarray) – Array of angles in radians.

  • source_origin (float) – Distance between point source and origin.

  • origin_det (float) – Distance between the detector and origin.

Returns:

A cone-beam projection geometry.

create_proj_geom('cone_vec', det_row_count, det_col_count, V):

Parameters:
  • det_row_count (int) – Number of detector pixel rows.

  • det_col_count (int) – Number of detector pixel columns.

  • V (numpy.ndarray) – Vector array.

Returns:

A cone-beam projection geometry.

create_proj_geom('parallel3d_vec', det_row_count, det_col_count, V):

Parameters:
  • det_row_count (int) – Number of detector pixel rows.

  • det_col_count (int) – Number of detector pixel columns.

  • V (numpy.ndarray) – Vector array.

Returns:

A parallel projection geometry.

create_proj_geom('sparse_matrix', det_width, det_count, angles, matrix_id):

Parameters:
  • det_width (float) – Size of a detector pixel.

  • det_count (int) – Number of detector pixels.

  • angles (numpy.ndarray) – Array of angles in radians.

  • matrix_id (int) – ID of the sparse matrix.

Returns:

A projection geometry based on a sparse matrix.

astra.creators.create_projector(proj_type, proj_geom, vol_geom, options=None)[source]

Create a 2D or 3D projector.

Parameters:
  • proj_type (string) – Projector type, such as 'line', 'linear', …

  • proj_geom (dict) – Projection geometry.

  • vol_geom (dict) – Volume geometry.

  • options (dict) – Projector options structure defining 'VoxelSuperSampling', 'DetectorSuperSampling'.

Returns:

int – The ID of the projector.

astra.creators.create_reconstruction(rec_type, proj_id, sinogram, iterations=1, use_mask='no', mask=array([], dtype=float64), use_minc='no', minc=0, use_maxc='no', maxc=255, returnData=True, filterType=None, filterData=None)[source]

Create a reconstruction of a sinogram (2D).

Parameters:
  • rec_type (string) – Name of the reconstruction algorithm.

  • proj_id (int) – ID of the projector to use.

  • sinogram (numpy.ndarray or int) – Sinogram data or ID.

  • iterations (int) – Number of iterations to run.

  • use_mask ('yes' or 'no') – Whether to use a mask.

  • mask (numpy.ndarray or int) – Mask data or ID

  • use_minc ('yes' or 'no') – Whether to force a minimum value on the reconstruction pixels.

  • minc (float) – Minimum value to use.

  • use_maxc ('yes' or 'no') – Whether to force a maximum value on the reconstruction pixels.

  • maxc (float) – Maximum value to use.

  • returnData (bool) – If False, only return the ID of the reconstruction.

  • filterType (string) – Which type of filter to use for filter-based methods.

  • filterData (numpy.ndarray) – Optional filter data for filter-based methods.

Returns:

int or (int, numpy.ndarray) – If returnData=False, returns the ID of the reconstruction. Otherwise, returns a tuple containing the ID of the reconstruction and reconstruction itself, in that order.

astra.creators.create_sino(data, proj_id, returnData=True, gpuIndex=None)[source]

Create a forward projection of an image (2D).

Parameters:
  • data (numpy.ndarray or int) – Image data or ID.

  • proj_id (int) – ID of the projector to use.

  • returnData (bool) – If False, only return the ID of the forward projection.

  • gpuIndex (int) – Optional GPU index.

Returns:

int or (int, numpy.ndarray)

If returnData=False, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order.

astra.creators.create_sino3d_gpu(data, proj_geom, vol_geom, returnData=True, gpuIndex=None)[source]

Create a forward projection of an image (3D).

Parameters:
  • data (numpy.ndarray or int) – Image data or ID.

  • proj_geom (dict) – Projection geometry.

  • vol_geom (dict) – Volume geometry.

  • returnData (bool) – If False, only return the ID of the forward projection.

  • gpuIndex (int) – Optional GPU index.

Returns:

int or (int, numpy.ndarray) – If returnData=False, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order.

astra.creators.create_vol_geom(*varargin)[source]

Create a volume geometry structure.

This method can be called in a number of ways:

create_vol_geom(N):
returns:

A 2D volume geometry of size \(N \times N\).

create_vol_geom((Y, X)):
returns:

A 2D volume geometry of size \(Y \times X\).

create_vol_geom(Y, X):
returns:

A 2D volume geometry of size \(Y \times X\).

create_vol_geom(Y, X, minx, maxx, miny, maxy):
returns:

A 2D volume geometry of size \(Y \times X\), windowed as \(minx \leq x \leq maxx\) and \(miny \leq y \leq maxy\).

create_vol_geom((Y, X, Z)):
returns:

A 3D volume geometry of size \(Y \times X \times Z\).

create_vol_geom(Y, X, Z):
returns:

A 3D volume geometry of size \(Y \times X \times Z\).

create_vol_geom(Y, X, Z, minx, maxx, miny, maxy, minz, maxz):
returns:

A 3D volume geometry of size \(Y \times X \times Z\), windowed as \(minx \leq x \leq maxx\) and \(miny \leq y \leq maxy\) and \(minz \leq z \leq maxz\) .