Comparing with DukeSim

In order to perform validation of the code, some classes and functions were created to compare the results of the DukeSim with the results of the code.

Classes

duke_sensor

Purpose

This class is used to replicate the behavior of the DukeSim sensor, using the same data. This class inherits from the class sensor.

Properties

electronic_std

(double) The standard deviation of the electronic noise of the sensor. Currently not used, but it is a property of the DukeSim sensor, and could be implemented for better comparison.

mean_det_response

(Nx1 double) The mean detector response at each energy.

var_det_response

(Nx1 double) The variance of the detector response at each energy. Currently not used, but it is a property of the DukeSim sensor, and could be implemented for better comparison.

Functions

duke_sensor(num_energies, detector_response_file, electronic_std)

Constructor of the class. It receives the number of energies, the file with the detector response and the electronic standard deviation to create the list of mean detector responses and variance at each energy.

Parameters:
  • num_energies (double) – The number of energies in the detector response file.

  • detector_response_file (string) – The file with the detector response.

  • electronic_std (double) – The electronic standard deviation of the sensor.

Returns:

obj - An instance of the class.

Return type:

duke_sensor

Methods

duke_sensor.detector_response(obj, nrj_bin, count_array)

Multiplies the count array by the mean detector response at the energy bin.

Parameters:
  • nrj_bin (double) – A single value representing the index of the energy bin.

  • count_array (MxNxP double) – An array of dimensions [ny_pix, nz_pix, nrotation] representing the number of photons in each pixel and rotation in the energy bin.

Returns:

signal – The detector response at the energy bin.

Return type:

MxNxP double

Potential Future Changes

The DukeSim sensor has a standard deviation of the electronic noise and a variance of the detector response at each energy. These properties could be implemented in the class to make the comparison more accurate.

duke_source

Purpose

This class is used to replicate the behavior of the DukeSim source, using the same data. This class inherits from the class source.

Properties

ebins

(1xN double) The energy bins of the source.

spectrum

(NxM double) The spectrum of the source for each energy at each pixel.

Functions

duke_source(filename, num_energies, num_ypixels, msecs_per_frame)

Constructor of the class. It receives the file with the source spectrum and splits it into the energy bins and the spectrum using the number of energies, number of pixels in the y direction. Then the spectrum is multiplied by the msecs_per_frame to get the number of photons per pixel per frame.

Parameters:
  • filename (string) – The file with the source spectrum.

  • num_energies (double) – The number of energies in the source spectrum.

  • num_ypixels (double) – The number of pixels in the y direction.

  • msecs_per_frame (double) – The number of milliseconds per frame.

Returns:

obj - An instance of the class.

Return type:

duke_source

Methods

duke_source.get_energies(obj, range)

This method returns the energies of the xrays if they are within the range. If they are not, it errors, as it is up to the user to give the correct sensor to the source.

Parameters:

range (Nx2 double) – A vector with N rows of [min_energy, max_energy) indicating the range of energies that the source should generate.

Returns:

energies - The weighted mean of the energies within the range.

Return type:

1xN double

duke_source.get_fluences(obj, range, ypixels)

This method returns the fluences of the xrays if they are within the range for each pixel. If they are not, it returns 0.

Parameters:
  • range (Nx2 double) – A vector with N rows of [min_energy, max_energy) indicating the range of energies that the source should generate.

  • ypixels (1xM double) – The index of the pixels in the y direction.

Returns:

fluences – The sum of the fluences of the xrays within the range in units of photons/cm^2 at 1m.

Return type:

MxN double

duke_source.get_nrj_range(obj)

This method returns the range of energies of the source spectrum.

Returns:

  • min (double) – The minimum energy bin of the spectrum file.

  • max (double) – The maximum energy bin of the spectrum file.

Functions

duke_parser(path_to_duke_out)

This function returns the simulated sinogram and parameters from the DukeSim output folder. The argument path_to_duke_out is the path to the DukeSim output folder, and equivalent to the MainDir parameter in the DukeSim input file.

Parameters:

path_to_duke_out (string) – The path to the DukeSim output folder.

Returns:

  • sinogram (MxNxP double) – The simulated sinogram with dimensions [ny_pix, nz_pix, nrotation].

  • params (dict) – A dictionary with the parameters of the simulation.

get_duke_source(path_to_duke_out)

This function returns a duke_source by calling duke_parser() with the path to the DukeSim output folder and using the resultant parameters to create the source. A file that is necessary for the source is the Spectrum_Duke1_120kV_900_1mAs_1ms_calibrated.bin file, which can be found in the DukeSim input folder when running the DukeSim simulation. In the future, this function could be modified to receive the path to the source spectrum file.

Parameters:

path_to_duke_out (string) – The path to the DukeSim output folder.

Returns:

the_source - The source created from the DukeSim output folder.

Return type:

duke_source

get_duke_detector(path_to_duke_out)

This function returns a detector object containing a gantry, a curved_detector or a flat_detector and a duke_sensor by calling duke_parser() with the path to the DukeSim output folder and using the resultant parameters to create the detector. A file that is necessary for the detector is the DetResponse_Duke1_120kV_final.bin file, which can be found in the DukeSim input folder when running the DukeSim simulation. In the future, this function could be modified to receive the path to the detector response file.

Parameters:

path_to_duke_out (string) – The path to the DukeSim output folder.

Returns:

the_detector - The detector created from the DukeSim output folder.

Return type:

detector

Files

dukesim_voxel_creator()

This file creates the phantom for the DukeSim simulation. It uses the voxel_array within this package to define the phantom and then saves it in the format required by DukeSim. Currently it is doing a specific phantom, but it could be modified to create any phantom, as long as it can be defined by the voxel_array.