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 typeintype.
- astra.creators.create_backprojection(data, proj_id, returnData=True)[source]
Create a backprojection of a sinogram (2D).
- Parameters:
data (
numpy.ndarrayorint) – 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:
intor (int,numpy.ndarray) – IfreturnData=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.ndarrayorint) – 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:
intor (int,numpy.ndarray) – IfreturnData=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('cyl_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 with cylindrical detector.
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.
Added in version 2.4: Support for cylindrical detectors (‘cyl_cone_vec’ type).
- 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.ndarrayorint) – Sinogram data or ID.iterations (
int) – Number of iterations to run.use_mask (
'yes'or'no') – Whether to use a mask.mask (
numpy.ndarrayorint) – Mask data or IDuse_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:
intor (int,numpy.ndarray) – IfreturnData=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.ndarrayorint) – 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:
intor (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.ndarrayorint) – 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:
intor (int,numpy.ndarray) – IfreturnData=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 x N.
create_vol_geom((n_rows, n_cols)):- Returns:
A 2D volume geometry of size n_rows x n_cols.
create_vol_geom(n_rows, n_cols):- Returns:
A 2D volume geometry of size n_rows x n_cols.
create_vol_geom(n_rows, n_cols, min_x, max_x, min_y, max_y):- Returns:
A 2D volume geometry of size n_rows x n_cols, windowed as min_x <= x <= max_x and min_y <= y <= max_y. Note that rows are oriented along the Y axis, and columns along the X axis.
create_vol_geom((n_rows, n_cols, n_slices)):- Returns:
A 3D volume geometry of size n_rows x n_cols x n_slices.
create_vol_geom(n_rows, n_cols, n_slices):- Returns:
A 3D volume geometry of size n_rows x n_cols x n_slices.
create_vol_geom(n_rows, n_cols, n_slices, min_x, max_x, min_y, max_y, min_z, max_z):- Returns:
A 3D volume geometry of size n_rows x n_cols x n_slices, windowed as min_x <= x <= max_x, min_y <= y <= max_y, and min_z <= z <= max_z. Note that rows are oriented along the Y axis, columns along the X axis, and slices along the Z axis.