CTL  0.6.1
Computed Tomography Library
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
CTL::XraySpectrumTabulatedModel Class Reference

The XraySpectrumTabulatedModel class provides an implementation of an X-ray spectrum model based on tabulated data. More...

#include <xrayspectrummodels.h>

Inheritance diagram for CTL::XraySpectrumTabulatedModel:
Inheritance graph
[legend]
Collaboration diagram for CTL::XraySpectrumTabulatedModel:
Collaboration graph
[legend]

Public Types

enum  { Type = 35 }
 
- Public Types inherited from CTL::AbstractDataModel
enum  { Type = 0 }
 
- Public Types inherited from CTL::SerializationInterface
enum  { Type = -1, UserType = 65536 }
 

Public Member Functions

int type () const override
 
float valueAt (float position) const override
 Returns the value (i.e. photon count per energy) of the model at the given position (in keV). More...
 
float binIntegral (float position, float binWidth) const override
 Returns the integral over model values (i.e. total number of photons) in the (energy) interval [position - 0.5 * binWidth, position + 0.5 * binWidth]. More...
 
XraySpectrumTabulatedModelclone () const override
 
 XraySpectrumTabulatedModel ()
 Creates an empty XraySpectrumTabulatedModel. More...
 
void addLookupTable (float voltage, const TabulatedDataModel &table)
 Inserts table as a lookup table for the energy setting voltage. More...
 
void setLookupTables (const QMap< float, TabulatedDataModel > &tables)
 Sets the lookup tables used by this instance to tables. More...
 
QVariant parameter () const override
 
void setParameter (const QVariant &parameter) override
 Sets the parameters of this instance based in data in parameter. More...
 
bool hasTabulatedDataFor (float voltage) const
 Returns true if this instance can provide data for an energy parameter set to voltage. More...
 
- Public Member Functions inherited from CTL::AbstractIntegrableDataModel
float meanValue (float position, float binWidth) const
 
- Public Member Functions inherited from CTL::AbstractDataModel
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
bool isIntegrable () const
 
void setName (const QString &name)
 
const QString & name () const
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Protected Attributes

QMap< float, TabulatedDataModel_lookupTables
 The spectra lookup tables (key = energy).
 
- Protected Attributes inherited from CTL::AbstractXraySpectrumModel
float _energy = 0.0f
 Control parameter of device setting (usually tube voltage).
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- Protected Member Functions inherited from CTL::AbstractIntegrableDataModel
 AbstractIntegrableDataModel (const AbstractIntegrableDataModel &)=default
 
 AbstractIntegrableDataModel (AbstractIntegrableDataModel &&)=default
 
AbstractIntegrableDataModeloperator= (const AbstractIntegrableDataModel &)=default
 
AbstractIntegrableDataModeloperator= (AbstractIntegrableDataModel &&)=default
 
- Protected Member Functions inherited from CTL::AbstractDataModel
 AbstractDataModel (const AbstractDataModel &)=default
 
 AbstractDataModel (AbstractDataModel &&)=default
 
AbstractDataModeloperator= (const AbstractDataModel &)=default
 
AbstractDataModeloperator= (AbstractDataModel &&)=default
 
- Protected Member Functions inherited from CTL::SerializationInterface
 SerializationInterface ()=default
 
 SerializationInterface (const SerializationInterface &)=default
 
 SerializationInterface (SerializationInterface &&)=default
 
SerializationInterfaceoperator= (const SerializationInterface &)=default
 
SerializationInterfaceoperator= (SerializationInterface &&)=default
 

Detailed Description

The XraySpectrumTabulatedModel class provides an implementation of an X-ray spectrum model based on tabulated data.

This class implements AbstractXraySpectrumModel with a backend of several TabulatedDataModel lookup tables. Each of these tables corresponds to a particular energy of operation (e.g. tube voltage). Lookup tables can be added through addLookupTable(). If an energy parameter is set for which no exact match exists in the lookup tables, interpolation between the tables closest to the requested energy parameter is performed.

Note that for introducing a fixed spectrum to the simulation (e.g. some spectrum pre-generated by an external tool), the class FixedXraySpectrumModel might be a more suitable choice.

Example: creating an XraySpectrumTabulatedModel with two lookup tables for spectra at 40 kV and 70 kV, and setting it to provide (interpolated) data for a 55 kV setting.

// we first create a TabulatedDataModel to hold our spectrum at a 40 kV setting
auto table_40kV = std::make_shared<TabulatedDataModel>();
table_40kV->setName("40 kV Table"); // optional name for visualization
// now, we fill in sampling points of the actual spectrum
table_40kV->insertDataPoint(0.0f, 0.0f);
table_40kV->insertDataPoint(10.0f, 15.0f);
table_40kV->insertDataPoint(20.0f, 4.0f);
table_40kV->insertDataPoint(30.0f, 1.5f);
table_40kV->insertDataPoint(40.0f, 0.0f);
// we create another TabulatedDataModel to hold a spectrum at a 70 kV setting
auto table_70kV = std::make_shared<TabulatedDataModel>();
table_70kV->setName("70 kV Table"); // optional name for visualization
// now, we fill in sampling points of the actual spectrum
table_70kV->insertDataPoint(0.0f, 0.0f);
table_70kV->insertDataPoint(10.0f, 10.0f);
table_70kV->insertDataPoint(20.0f, 9.0f);
table_70kV->insertDataPoint(30.0f, 6.0f);
table_70kV->insertDataPoint(40.0f, 5.0f);
table_70kV->insertDataPoint(50.0f, 3.0f);
table_70kV->insertDataPoint(60.0f, 1.0f);
table_70kV->insertDataPoint(70.0f, 0.0f);
// we now create our XraySpectrumTabulatedModel...
auto tabulatedSpectrum = std::make_shared<XraySpectrumTabulatedModel>();
// ... and add both lookup tables at their corresponding energies (i.e. 40 and 70 kV).
tabulatedSpectrum->addLookupTable(40.0f, *table_40kV);
tabulatedSpectrum->addLookupTable(70.0f, *table_70kV);
// we finally set the energy parameter of the XraySpectrumTabulatedModel to 55 kV
// this means that the model will try to provide a spectrum for a 55 kV setting
// (using interpolation between the two lookup tables)
tabulatedSpectrum->setParameter(55.0f);
// we could now sample values from the model; here we choose to visualize the model
// Note: Visualization requires 'gui_widgets_charts.pri' module
gui::plot(table_40kV);
gui::plot(table_70kV);
gui::plot(tabulatedSpectrum);
Visualization from the example. (left) Tabulated model for 40 kV, (center) Tabulated model for 70 kV, (left) XrayTabulatedDataModel containing both lookup tables (i.e. at 40 and 70 kV) and sampled at energy parameter 55 kV.

Constructor & Destructor Documentation

◆ XraySpectrumTabulatedModel()

CTL::XraySpectrumTabulatedModel::XraySpectrumTabulatedModel ( )

Creates an empty XraySpectrumTabulatedModel.

Use addLookupTable() or setLookupTables() to provide it with actual data.

Member Function Documentation

◆ addLookupTable()

void CTL::XraySpectrumTabulatedModel::addLookupTable ( float  voltage,
const TabulatedDataModel table 
)

Inserts table as a lookup table for the energy setting voltage.

Overrides any already existing table for that particular energy (i.e. voltage).

◆ binIntegral()

float CTL::XraySpectrumTabulatedModel::binIntegral ( float  position,
float  binWidth 
) const
overridevirtual

Returns the integral over model values (i.e. total number of photons) in the (energy) interval [position - 0.5 * binWidth, position + 0.5 * binWidth].

The bin integral is computed using sampled values from the available lookup tables of this instance. If a lookup table is available for the exact energy currently set as parameter of this instance, this call reduces to a call of binIntegral() of that particular table (see also TabulatedDataModel::binIntegral()). In case an energy parameter is set for which no exact match exists in the lookup tables, (linear) interpolation between the tables closest to the requested energy parameter is performed by computing the bin integrals from the corresponding tables and computing the weighted sum.

Requires that either a lookup table for the exact energy (i.e. the current energy parameter of this instance) is available or at least one lookup table for an energy lower as well as higher than the current energy parameter must be present (see also hasTabulatedDataFor()).

Implements CTL::AbstractIntegrableDataModel.

◆ clone()

XraySpectrumTabulatedModel * CTL::XraySpectrumTabulatedModel::clone ( ) const
overridevirtual

Creates a copy of this instance and returns a base class pointer to the new object.

Implements CTL::AbstractXraySpectrumModel.

◆ hasTabulatedDataFor()

bool CTL::XraySpectrumTabulatedModel::hasTabulatedDataFor ( float  voltage) const

Returns true if this instance can provide data for an energy parameter set to voltage.

Data for a particular energy setting can be provided if there exists at least one lookup table for an energy lower and higher than voltage. The only exception is if a table with the exact energy (i.e. energy == voltage) is available, in which case this is sufficient to return true.

Returns true if these conditions are met; returns false otherwise (includes models without any lookup tables).

◆ parameter()

QVariant CTL::XraySpectrumTabulatedModel::parameter ( ) const
overridevirtual

Returns the parameters of this instance as a QVariant.

Re-implement this method within your sub-class such that it encapsulates all necessary information into a QVariant.

Best practice is to invoke the base class version of this method to take care of all content originating from underlying base classes.

A typical reimplementation in sub-classes might look like this:

QVariantMap ret = DirectBaseClass::parameter().toMap();
ret.insert("my new parameter", _myNewParameter);
return ret;

Reimplemented from CTL::AbstractXraySpectrumModel.

◆ setLookupTables()

void CTL::XraySpectrumTabulatedModel::setLookupTables ( const QMap< float, TabulatedDataModel > &  tables)

Sets the lookup tables used by this instance to tables.

Each lookup table (one entry in the QMap) consist of a key-value-pair in which the key refers to the energy the table belongs to (e.g. tube voltage setting) and the value is the actual table (TabulatedDataModel) holding the spectrum data.

Overrides any already existing data.

◆ setParameter()

void CTL::XraySpectrumTabulatedModel::setParameter ( const QVariant &  parameter)
overridevirtual

Sets the parameters of this instance based in data in parameter.

The passed QVariant paramter must be a QVariantMap containing the key-value-pair ("energy", [float] value_to_set) (see also AbstractXraySpectrumModel::setParameter()) and might also contain a key-value-pair with key "lookup tables" and a QVariantList holding the variants for all lookup tables that shall be set. Note that this overrides any already existing lookup tables.

In general, it is not advised to use this method to set lookup table data. Consider using addLookupTable() or setLookupTables() instead.

Reimplemented from CTL::AbstractXraySpectrumModel.

◆ type()

int CTL::XraySpectrumTabulatedModel::type ( ) const
inlineoverridevirtual

Returns the type id of this instance.

Reimplemented from CTL::AbstractDataModel.

◆ valueAt()

float CTL::XraySpectrumTabulatedModel::valueAt ( float  position) const
overridevirtual

Returns the value (i.e. photon count per energy) of the model at the given position (in keV).

The value is computed using sampled values from the available lookup tables of this instance. If a lookup table is available for the exact energy currently set as parameter of this instance, this call reduces to a call of valueAt() of that particular table (see also TabulatedDataModel::valueAt()). In case an energy parameter is set for which no exact match exists in the lookup tables, (linear) interpolation between the tables closest to the requested energy parameter is performed by sampling values from the corresponding tables and computing the weighted sum.

Requires that either a lookup table for the exact energy (i.e. the current energy parameter of this instance) is available or at least one lookup table for an energy lower as well as higher than the current energy parameter must be present (see also hasTabulatedDataFor()).

Implements CTL::AbstractDataModel.


The documentation for this class was generated from the following files: