opentps.core.data.CTCalibrations package

Subpackages

Module contents

class AbstractCTCalibration

Bases: object

Abstract class for CT calibration. Methods are redefined in mcSquareCTCalibration and rayStationCTCalibration.

abstract convertHU2MassDensity(hu)
abstract convertHU2RSP(hu, energy)
abstract convertMassDensity2HU(density)
abstract convertMassDensity2RSP(density, energy)
abstract convertRSP2HU(rsp)
abstract convertRSP2MassDensity(rsp)
class MCsquareCTCalibration(hu2densityTable=([], []), hu2materialTable=([], []), fromFiles=(None, None, 'default'))

Bases: AbstractCTCalibration, PiecewiseHU2Density, MCsquareHU2Material

Class for the CT calibration for MCsquare. Inherits from AbstractCTCalibration, PiecewiseHU2Density and MCsquareHU2Material.

addEntry(hu: float | None = None, density: float | None = None, material: MCsquareMolecule | None = None)

Add an entry to the HU to mass density and HU to material conversion tables. Either density or material must be None, and the other must be a valid value.

Parameters:
  • hu (float) – The HU value.

  • density (float (optional)) – The mass density value.

  • material (MCsquareMolecule (optional)) – The material.

convertHU2MassDensity(hu)

Convert HU to mass density.

Parameters:

hu (float or array_like) – The HU value(s).

Returns:

The mass density value(s).

Return type:

float or array_like

convertHU2RSP(hu, energy=100)

Convert HU to relative stopping power.

Parameters:
  • hu (float or array_like) – The HU value(s).

  • energy (float (default=100)) – The energy of the proton beam in MeV.

Returns:

The relative stopping power value(s).

Return type:

float or array_like

convertMassDensity2HU(density)

Convert mass density to HU.

Parameters:

density (float or array_like) – The mass density value(s).

Returns:

The HU value(s).

Return type:

float or array_like

convertMassDensity2RSP(density, energy=100)

Convert mass density to relative stopping power.

Parameters:
  • density (float or array_like) – The mass density value(s).

  • energy (float (default=100)) – The energy of the proton beam in MeV.

Returns:

The relative stopping power value(s).

Return type:

float or array_like

convertMaterial2HU(materialID)
convertRSP2HU(rsp, energy=100)

Convert relative stopping power to HU.

Parameters:
  • rsp (float or array_like) – The relative stopping power value(s).

  • energy (float (default=100)) – The energy of the proton beam in MeV.

Returns:

The HU value(s).

Return type:

float or array_like

convertRSP2MassDensity(rsp, energy=100)

Convert relative stopping power to mass density.

Parameters:
  • rsp (float or array_like) – The relative stopping power value(s).

  • energy (float (default=100)) – The energy of the proton beam in MeV.

Returns:

The mass density value(s).

Return type:

float or array_like

classmethod fromCTCalibration(ctCalibration: AbstractCTCalibration)

Create a MCsquareCTCalibration object from a AbstractCTCalibration object (RayStationCalibration).

Parameters:

ctCalibration (AbstractCTCalibration) – The AbstractCTCalibration object.

Returns:

The MCsquareCTCalibration object.

Return type:

MCsquareCTCalibration

Raises:

NotImplementedError – If the conversion is not implemented.

classmethod fromFiles(huDensityFile, huMaterialFile, materialsPath='default')

Create a MCsquareCTCalibration object from files.

Parameters:
  • huDensityFile (str) – Path to the file containing the HU to mass density conversion table.

  • huMaterialFile (str) – Path to the file containing the HU to material conversion table.

  • materialsPath (str (optional, default=’default’)) – Path to the folder containing the material files. Default is ‘default’ which means that the default materials folder of MCsquare will be used.

Returns:

The MCsquareCTCalibration object.

Return type:

MCsquareCTCalibration

waterSP(energy: float = 100.0) float

Get the stopping power of water at a given energy.

Parameters:

energy (float (default=100)) – The energy of the proton beam in MeV.

Returns:

The stopping power of water at the given energy.

Return type:

float

write(scannerPath, materialPath)

Write the HU to mass density and HU to material conversion tables to files.

Parameters:
  • scannerPath (str) – Path to the folder to write the HU to mass density conversion table to.

  • materialPath (str) – Path to the folder to write the HU to material conversion table to.

class PiecewiseHU2Density(piecewiseTable=([], []), fromFile=None)

Bases: object

Class for converting HU to mass density and vice versa. The conversion is done using linear interpolation.

Variables:
  • !! (!! USED ONLY AT INITIALIZATION) –

  • fromFile (str) – Path to the file containing the HU to mass density conversion table.

  • piecewiseTable (tuple) – Tuple containing the HU to mass density conversion table.

addEntry(hu: float, density: float)

Add an entry to the HU to mass density conversion table.

Parameters:
  • hu (float) – The Housnfield unit value.

  • density (float) – The mass density value.

convertHU2MassDensity(hu)

Convert Housnfield unit to mass density.

Parameters:

hu (float or array_like) – The Housnfield unit value(s).

Returns:

The mass density value(s).

Return type:

float or array_like

convertMassDensity2HU(densities)

Convert mass density to Housnfield unit.

Parameters:

densities (float or array_like) – The mass density value(s).

Returns:

The Housnfield unit value(s).

Return type:

float or array_like

classmethod fromFile(huDensityFile)

Create a PiecewiseHU2Density object from a file.

Parameters:

huDensityFile (str) – Path to the file containing the HU to mass density conversion table.

Returns:

The PiecewiseHU2Density object.

Return type:

PiecewiseHU2Density

getPiecewiseHU2MassDensityConversion()

Get the HU to mass density conversion table.

Returns:

The HU to mass density conversion table.

Return type:

tuple

load(scannerFile)

Load the HU to mass density conversion table from a file.

Parameters:

scannerFile (str) – Path to the file containing the HU to mass density conversion table.

setPiecewiseHU2MassDensityConversion(piecewiseTable)

Set the HU to mass density conversion table.

write(scannerFile)

Write the HU to mass density conversion table to a file.

Parameters:

scannerFile (str) – Path to the file to write the HU to mass density conversion table to.

writeHeader()

Return header of HU to density conversion table

writeableTable()

Returns a string containing the HU to mass density conversion table.

Returns:

The HU to mass density conversion table.

Return type:

str

class RayStationCTCalibration(piecewiseTable=(None, None), densities=None, materials=None, fromFiles=(None, None))

Bases: AbstractCTCalibration, PiecewiseHU2Density, RayStationDensity2Material

Class for RayStation CT calibration. Inherits from AbstractCTCalibration, PiecewiseHU2Density and RayStationDensity2Material.

convertHU2MassDensity(hu)

Convert HU to mass density.

Parameters:

hu (float or array_like) – The HU value(s).

Returns:

The mass density value(s).

Return type:

float or array_like

convertHU2RSP(hu, energy=100)

Convert HU to relative stopping power.

Parameters:
  • hu (float or array_like) – The HU value(s).

  • energy (float (default=100)) – The energy of the beam in MeV.

Returns:

The relative stopping power value(s).

Return type:

float or array_like

convertMassDensity2HU(density)

Convert mass density to HU.

Parameters:

density (float or array_like) – The mass density value(s).

Returns:

The HU value(s).

Return type:

float or array_like

convertMassDensity2RSP(density, energy=100)

Convert mass density to relative stopping power.

Parameters:
  • density (float or array_like) – The mass density value(s).

  • energy (float (default=100)) – The energy of the beam in MeV.

Returns:

The relative stopping power value(s).

Return type:

float or array_like

convertRSP2HU(rsp, energy=100)

Convert relative stopping power to HU.

Parameters:
  • rsp (float or array_like) – The relative stopping power value(s).

  • energy (float (default=100)) – The energy of the beam in MeV.

Returns:

The HU value(s).

Return type:

float or array_like

convertRSP2MassDensity(rsp, energy=100)

Convert relative stopping power to mass density.

Parameters:
  • rsp (float or array_like) – The relative stopping power value(s).

  • energy (float (default=100)) – The energy of the beam in MeV.

Returns:

The mass density value(s).

Return type:

float or array_like

toMCSquareCTCalibration(materialsPath='default')

Convert RayStation CT calibration to MCsquare CT calibration.

Returns:

The MCsquare CT calibration.

Return type:

MCsquareCTCalibration