Voxel Array
Purpose
This class is creates a 3D array of voxels. It is used to create your phantom from various shapes and materials.
Properties
- array_position
(
3x1 double) The position of the top left corner of the voxel array in the world coordinate system.
- num_planes
(
3x1 double) The number of planes in the voxel array.
- dimensions
(
3x1 double) The dimensions of each voxel in the voxel array.
- voxel_objs
(
1xN cell) A cell array of all the voxel objects in the voxel array (see Voxel Objects).
- nobj
(
double) The number of voxel objects in the array, equivalent tolength(voxel_objs) + 1. The last element is the world material.
- world_material
(
material_attenuation) The material of the world in the array that is not occupied by any voxel objects.
Functions
- voxel_array(centre, object_dims, voxel_size, voxel_objs, world_material=material_attenuation("air"))
The constructor for the voxel array. The arguments are as follows:
- Parameters:
centre (
3x1 double) – The position of the centre of the array in the world coordinate system. Used to calculate the position of the top left corner of the array.object_dims (
3x1 double) – The dimensions of the array in the x, y and z directions.voxel_size (
double) – The dimensions of each voxel in the array in the x, y and z directions, currently must be the same for all voxels, so is given as a single number.voxel_objs (
voxel_objectcell array) – A cell array of all the voxel objects in the array (see Voxel Objects).world_material (
material_attenuation) – The material of the world in the array that is not occupied by any voxel objects, defaults to air.
- Returns:
Voxel array – An instance of the voxel array class.
- Return type:
Methods
- update_voxel_size(obj, new_voxel_size)
Updates the voxel size of the array to
new_voxel_sizeby changing the number of planes and the dimensions of the array.- Parameters:
new_voxel_size (
double) – The new dimensions of each voxel in the array in the x, y and z directions.- Returns:
Voxel array – An instance of the voxel array class with the updated voxel size.
- Return type:
- precalculate_mus(obj, nrj_arr)
Pre-calculates the linear attenuation coefficient for each voxel object in
voxel_objsfor each energy innrjs.- Parameters:
nrj_arr – An array of energies in keV. This is an n-Dimensional array of energies, the output is the same shape as the input.
- Returns:
mu_dict – A PxMxN double with the first dimension representing the index of the voxel object in your array, the other dimensions are the same as the input
nrj_arr. The values are the linear attenuation coefficients for each voxel object invoxel_objsat each energy innrj_arr. P is the number of voxel objects + 1, the last element is the linear attenuation coefficient of the world material.- Return type:
PxMxN double
- precalculate_mfps(obj, nrj_arr)
Pre-calculates the Compton mean free path for each voxel object in
voxel_objsfor each energy innrjs.- Parameters:
nrj_arr – An array of energies in keV. This is an n-Dimensional array of energies, the output is the same shape as the input.
- Returns:
mfp_dict – A PxMxN double with the first dimension representing the index of the voxel object in your array, the other dimensions are the same as the input
nrj_arr. The values are the Compton mean free paths for each voxel object invoxel_objsat each energy innrj_arr. P is the number of voxel objects + 1, the last element is the Compton mean free path of the world material.- Return type:
PxMxN double
- get_object_idxs(obj, indices)
Obtain the indices of the voxel objects at the indices in
indices.- Parameters:
indices (
3xN double) – List of indices of voxels to obtain which voxel object they belong to.- Returns:
iobj – A 1xN array of the identifiers of the voxel objects at the indices in
indices. This is used along with the output ofprecalculate_mus()andprecalculate_mfps()to obtain the linear attenuation coefficients and Compton mean free paths at the indices inindices.- Return type:
1xN double
- get_mu_arr(obj, nrj)
Obtain all the linear attenuation coefficients for each voxel object in
voxel_objsat the energynrj.- Parameters:
nrj (
double) – The photon energy (in \(keV\)).- Returns:
mu_arr – A 1D array of the linear attenuation coefficients for each voxel object in
voxel_objsat the energynrj.- Return type:
1xN double
- get_mfp_arr(obj, nrj)
Obtain all the Compton mean free paths for each voxel object in
voxel_objsat the energynrj.- Parameters:
nrj (
double) – The energy in keV.- Returns:
mfp_arr – A 1D array of the Compton mean free paths for each voxel object in
voxel_objsat the energynrj.- Return type:
1xN double
- get_saved_mu(obj, indices, dict)
Obtain the linear attenuation coefficients at the indices in
indicesfrom the list of linear attenuation coefficients indict.- Parameters:
indices (
3xN double) – List of indices of voxels to obtain the linear attenuation coefficients for.dict (
double) – A list of linear attenuation coefficients, as returned by a single energy from the dictionary returned byprecalculate_mus().
- Returns:
mus – A 1D array of the linear attenuation coefficients at the indices in
indices. It is the same length as the number of indices inindices.- Return type:
1xN double
- get_saved_mfp(obj, indices, dict)
Obtain the Compton mean free paths at the indices in
indicesfrom the list of Compton mean free paths indict.- Parameters:
indices (
3xN double) – List of indices of voxels to obtain the Compton mean free paths for.dict (
double) – A list of Compton mean free paths, as returned by a single energy from the dictionary returned byprecalculate_mfps().
- Returns:
mfps - A 1D array of the Compton mean free paths at the indices in
indices. It is the same length as the number of indices inindices.- Return type:
1xN double