Beam Hardening

xrayphysics.xrayPhysics.setBHlookupTable(self, spectralResponse, gammas, Z, referenceEnergy=0.0, T_atten=0.0, N_atten=0)

Calculate a beam hardening transfer function of a given material

This function can be used to model beam hardening. The model is given by

\[\begin{split}\begin{eqnarray*} a_{poly} &=& -\log\left( \int \widehat{s}(\gamma) e^{-a_{mono}\widehat{\sigma}(\gamma)} \, d\gamma \right) \\ \widehat{\sigma}(\gamma) &:=& \frac{\sigma(\gamma)}{\sigma(\gamma_{ref})} \\ \widehat{s}(\gamma) &:=& \frac{s(\gamma)}{\int s(\gamma') \, d\gamma'} \end{eqnarray*}\end{split}\]

where \(a_{poly}\) is the polychromatic attenuation, \(a_{mono}\) is the monochromatic attenuation at the reference energy, \(\gamma_{ref}\), \(\gamma\) is the x-ray energy (keV), \(\sigma\) is the mass cross section of the material, and \(s\) is the x-ray spectra. Note that this function returns \(a_{poly}\) from a uniform sampling of \(a_{mono}\).

Parameters:
  • spectralResponse (numpy array) – spectra model (if 2D, assumes multiple spectra are given and will generate a table to each spectra)

  • gammas (numpy array) – energies at which the spectra model is defined

  • Z (scalar or string) – atomic number, chemical formula, mixture of compounds with mass fractions, or member of the material library

  • referenceEnergy (scalar) – the energy (keV) of the monochromatic attenuation (if not specified uses the mean energy of the spectra)

  • T_atten (scalar) – the sampling rate of the monochromatic attenuation

  • N_atten (int) – the number of samples of the monochromatic attenuation

Returns:

A 1D numpy array that maps monochromatic attenuation to polychromatic attenuation, the sampling rate of the monochromatic attenuation

xrayphysics.xrayPhysics.setBHClookupTable(self, spectralResponse, gammas, Z, referenceEnergy=0.0, T_atten=0.0, N_atten=0)

Calculate a beam hardening correction transfer function of a given material

This function can be used to correct for single-material beam hardening. It calculates the inverse of the setBHlookupTable function, i.e., it returns \(a_{mono}\) from a uniform sampling of \(a_{poly}\).

Parameters:
  • spectralResponse (numpy array) – spectra model (if 2D, assumes multiple spectra are given and will generate a table to each spectra)

  • gammas (numpy array) – energies at which the spectra model is defined

  • Z (scalar or string) – atomic number, chemical formula, mixture of compounds with mass fractions, or member of the material library

  • referenceEnergy (scalar) – the energy (keV) of the monochromatic attenuation (if not specified uses the mean energy of the spectra)

  • T_atten (scalar) – the sampling rate of the polychromatic attenuation

  • N_atten (int) – the number of samples of the polychromatic attenuation

Returns:

A 1D numpy array that maps polychromatic attenuation to monochromatic attenuation, the sampling rate of the polychromatic attenuation

xrayphysics.xrayPhysics.polynomialBHC(self, spectralResponse, gammas, Z, density, referenceEnergy=0.0, maxThickness=10.0, order=2)

Calculate the coefficients of a polynomial-based beam hardening correction transfer function of a given material

This function can be used to approximately correct for single-material beam hardening; it serves the same purpose as the setBHClookupTable except the correction is approximated by a polynomial which is convenient for some purposes. Applying this correction is done as follows:

\[\begin{eqnarray*} a_{mono} &=& \sum_n c_n a_{poly}^n \end{eqnarray*}\]

where \(c_n\) are the polynomial coefficients calculated by this function, \(a_{poly}\) is the polychromatic attenuation, \(a_{mono}\) is the monochromatic attenuation at the reference energy.

Parameters:
  • spectralResponse (numpy array) – spectra model

  • gammas (numpy array) – energies at which the spectra model is defined

  • Z (scalar or string) – atomic number, chemical formula, mixture of compounds with mass fractions, or member of the material library

  • density (scalar) – the mass density (g/cm^3) of the matial

  • referenceEnergy (scalar) – the energy (keV) of the monochromatic attenuation (if not specified uses the mean energy of the spectra)

  • maxThickness (scalar) – the maximum thickness (cm) that one expects to penetrate of this material (defines the range of values for the polynomial fit)

  • order (int) – the order of the polynomial

Returns:

A numpy array of the coefficients of the BHC polynomial

xrayphysics.xrayPhysics.setTwoMaterialBHClookupTable(self, spectralResponse, gammas, sigma_1, sigma_2, referenceEnergy=None, T_atten=0.0, N_atten=0)

Calculate a two-material beam hardening correction transfer function of the two given materials

Parameters:
  • spectralResponse (numpy array) – spectra model

  • gammas (numpy array) – energies at which the spectra model is defined

  • sigma_1 (numpy array) – the mass cross section of the lower attenuating material

  • sigma_2 (numpy array) – the mass cross section of the higher attenuating material

  • referenceEnergy (scalar) – the energy (keV) of the monochromatic attenuation (if not specified uses the mean energy of the spectra)

  • T_atten (scalar) – the sampling rate of the polychromatic attenuation (if unspecified, uses default values)

  • N_atten (int) – the number of samples of the polychromatic attenuation (if unspecified, uses default values)

Returns:

A 2D numpy array that maps polychromatic attenuation to monochromatic attenuation