CTL  0.6.1
Computed Tomography Library
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
CTL::AbstractSource Class Referenceabstract

Base class for source components. More...

#include <abstractsource.h>

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

Public Types

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

Public Member Functions

int type () const override
 
virtual EnergyRange nominalEnergyRange () const =0
 
virtual IntervalDataSeries spectrum (uint nbSamples) const
 Returns the (relative) emitted radiation spectrum sampled with nbSamples bins covering the energy range of [energyRange().start(), energyRange().end()] keV. More...
 
virtual uint spectrumDiscretizationHint () const
 
virtual void setSpectrumModel (AbstractXraySpectrumModel *model)
 
QString info () const override
 
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
EnergyRange energyRange () const
 
float meanEnergy () const
 
double photonFlux () const
 
double fluxModifier () const
 
const QSizeF & focalSpotSize () const
 
const Vector3x1focalSpotPosition () const
 
const AbstractXraySpectrumModelspectrumModel () const
 
void setFluxModifier (double modifier)
 
void setFocalSpotSize (const QSizeF &size)
 
void setFocalSpotSize (double width, double height)
 
void setFocalSpotPosition (const Vector3x1 &position)
 
void setFocalSpotPosition (double x, double y, double z)
 
void setEnergyRangeRestriction (const EnergyRange &window)
 
IntervalDataSeries spectrum (EnergyRange range, uint nbSamples) const
 
bool hasSpectrumModel () const
 
void setSpectrumModel (std::unique_ptr< AbstractXraySpectrumModel > model)
 
std::unique_ptr< GenericSourcetoGeneric () const
 
- Public Member Functions inherited from CTL::SystemComponent
int type () const override
 
 SystemComponent (const QString &name=defaultName())
 
virtual int elementalType () const
 
virtual SystemComponentclone () const
 
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
const QString & name () const
 
void rename (QString name)
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Static Public Attributes

static const uint DEFAULT_SPECTRUM_RESOLUTION_HINT = 10
 

Protected Member Functions

virtual double nominalPhotonFlux () const =0
 
 AbstractSource (const QString &name)
 
 AbstractSource (const QSizeF &focalSpotSize, const QString &name)
 
 AbstractSource (const QSizeF &focalSpotSize, const Vector3x1 &focalSpotPosition, const QString &name)
 
 AbstractSource (const QSizeF &focalSpotSize, const Vector3x1 &focalSpotPosition, AbstractXraySpectrumModel *spectumModel, const QString &name)
 
 AbstractSource (const AbstractSource &)=default
 
 AbstractSource (AbstractSource &&)=default
 
AbstractSourceoperator= (const AbstractSource &)=default
 
AbstractSourceoperator= (AbstractSource &&)=default
 
- Protected Member Functions inherited from CTL::SerializationInterface
 SerializationInterface ()=default
 
 SerializationInterface (const SerializationInterface &)=default
 
 SerializationInterface (SerializationInterface &&)=default
 
SerializationInterfaceoperator= (const SerializationInterface &)=default
 
SerializationInterfaceoperator= (SerializationInterface &&)=default
 

Protected Attributes

QSizeF _focalSpotSize = QSizeF(0.0, 0.0)
 Size of the focal spot (in mm).
 
Vector3x1 _focalSpotPosition = Vector3x1(0.0)
 Position of the focal spot (relative to source center).
 
double _fluxModifier = 1.0
 Global (multiplicative) modifier for the photon flux.
 
DataModelPtr< AbstractXraySpectrumModel_spectrumModel
 Data model for the emitted radiation spectrum.
 
EnergyRange _restrictedEnergyWindow = { 0.0f, 0.0f }
 Windowed energy range.
 
bool _hasRestrictedEnergyWindow = false
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Related Functions

(Note that these are not member functions.)

 EnergyRange
 Alias name for CTL::Range<float>. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CTL::SystemComponent
static QString defaultName ()
 
- Static Protected Member Functions inherited from CTL::SystemComponent
static QString typeInfoString (const std::type_info &type)
 

Detailed Description

Base class for source components.

This is the base class for all source components. A source component is characterized by the size and position (optional) of its focal spot (i.e. the area from which radiation is emitted), the emitted X-ray spectrum (relative intensity contribution for each photon energy) and the overall photon flux that is emitted by the source.

The AbstractSource class has two abstract interface methods: energyRange() and nominalPhotonFlux(). The energyRange() method must provide the energy boundaries within which all radiation from the source is contained. This range will be used whenenver the source's radiation spectrum is queried using spectrum() in order to determine the required interval for a sampled representation of the spectrum. The nominalPhotonFlux() method shall return the (unmodified) flux of photons emitted by the source. This is used whithin the actual getter method photonFlux(), which returns the nominal flux multiplied by an (optional, defaults to 1.0) modifier (see fluxModifier() and setFluxModifier()).

Spectrum computation is based on an AbstractXraySpectrumModel, which can be set using the corresponding setter method setSpectrumModel(). To query the current spectrum, use the spectrum() method, passing the number of desired sampling points as an input.

Definition of the focal spot geometry, i.e. both size and position, refers to CT coordinates. The focal spot size is specified in the x-y-plane. Hence, a focal spot with size QSizeF(1.0, 2.0) would, for example, have an extension of 1mm in x-direction and 2mm in y-direction. The position of the focal spot can be defined in all three directions (in the CT coordinate system). This can be used to describe shifted focal spot positions. The zero position (i.e. Vector3x1(0.0, 0.0, 0.0)) corresponds to an unshifted focal spot. Example: A source with focal spot position Vector3x1(0.0, 10.0, -50.0), would have its focal spot shifted by 10mm in y-direction and 50mm in negative z-direction (the latter would, for example, mean that the point of radiation emission is 50mm further away from the detector compared to an unshifed focal spot).

When creating a sub-class of AbstractSource, make sure to register the new component in the enumeration using the CTL_TYPE_ID(newIndex) macro. It is required to specify a value for newIndex that is not already in use. This can be easily achieved by use of values starting from SerializationInterface::UserType, as these are reserved for user-defined types.

To enable de-/serialization of objects of the new sub-class, reimplement the toVariant() and fromVariant() methods. These should take care of all newly introduced information of the sub-class. Additionally, call the macro DECLARE_SERIALIZABLE_TYPE(YourNewClassName) within the .cpp file of your new class (substitute "YourNewClassName" with the actual class name). Objects of the new class can then be de-/serialized with any of the serializer classes (see also AbstractSerializer).

Constructor & Destructor Documentation

◆ AbstractSource() [1/4]

CTL::AbstractSource::AbstractSource ( const QString &  name)
inlineprotected

Constructs an AbstractSource object named name.

Focal spot size defaults to QSizeF(0.0, 0.0) and the focal spot position is initialized with Vector3x1(0.0).

◆ AbstractSource() [2/4]

CTL::AbstractSource::AbstractSource ( const QSizeF &  focalSpotSize,
const QString &  name 
)
inlineprotected

Constructs an AbstractSource object named name with a focal spot size of focalSpotSize.

The focal spot position is initialized with Vector3x1(0.0).

◆ AbstractSource() [3/4]

CTL::AbstractSource::AbstractSource ( const QSizeF &  focalSpotSize,
const Vector3x1 focalSpotPosition,
const QString &  name 
)
inlineprotected

Constructs an AbstractSource object named name with a focal spot size of focalSpotSize and its focal spot position at focalSpotPosition.

◆ AbstractSource() [4/4]

CTL::AbstractSource::AbstractSource ( const QSizeF &  focalSpotSize,
const Vector3x1 focalSpotPosition,
AbstractXraySpectrumModel spectumModel,
const QString &  name 
)
inlineprotected

Constructs an AbstractSource object named name with a focal spot size of focalSpotSize and its focal spot position at focalSpotPosition. This constructor also sets the spectrum model to spectrumModel. This instance manages ownership of spectrumModel as a std::shared_ptr.

Member Function Documentation

◆ energyRange()

EnergyRange CTL::AbstractSource::energyRange ( ) const
inline

Abstract interface method. Returns the energy range that contains all radiation from the source.

◆ fluxModifier()

double CTL::AbstractSource::fluxModifier ( ) const
inline

Returns the flux modifier.

The flux modifier is a multiplicative factor that modifies the total photon flux returned by photonFlux().

◆ focalSpotPosition()

const Vector3x1 & CTL::AbstractSource::focalSpotPosition ( ) const
inline

Returns the focal spot position of this instance.

Definition of the focal spot position is in CT coordinates.

◆ focalSpotSize()

const QSizeF & CTL::AbstractSource::focalSpotSize ( ) const
inline

Returns the focal spot size of this instance.

Definition of the focal spot size is in CT coordinates. In particular, it is specified as the dimension in the x-y-plane.

◆ fromVariant()

void CTL::AbstractSource::fromVariant ( const QVariant &  variant)
inlineoverridevirtual

Interface to read all member variables from the QVariant variant.

Reimplement this method such that it reads all newly introduced content when sub-classing. A typical reimplementation in sub-classes might look like this:

DirectBaseClass::fromVariant(variant);
// assuming our class has a member "double _myMemberVariable"
_myMemberVariable = variant.toMap().value("my member variable").toDouble();

Reimplemented from CTL::SerializationInterface.

Reimplemented in CTL::XrayLaser, CTL::GenericSource, and CTL::XrayTube.

◆ hasSpectrumModel()

bool CTL::AbstractSource::hasSpectrumModel ( ) const
inline

Returns true if a spectrum model is available in this instance.

See also
setSpectrumModel().

◆ info()

QString CTL::AbstractSource::info ( ) const
inlineoverridevirtual

Returns a formatted string with information about the object.

In addition to the information from the base class, the info string contains the following details:

  • Focal spot size
  • Focal spot position
  • Flux modifier.

Reimplemented from CTL::SystemComponent.

Reimplemented in CTL::GenericSource, CTL::XrayLaser, and CTL::XrayTube.

◆ meanEnergy()

float CTL::AbstractSource::meanEnergy ( ) const
inline

Returns the mean energy (in keV) of the spectrum emitted by this instance. Spectrum sampling is performed using the number of samples returned by spectrumDiscretizationHint(). Note that, in general, this is only an approximative mean.

◆ nominalPhotonFlux()

CTL::AbstractSource::nominalPhotonFlux ( ) const
protectedpure virtual

Abstract interface method. Returns the nominal photon flux (i.e. photons per cm²) of the source in a distance of one meter.

To query the actual photon flux of the source component, use photonFlux().

Implemented in CTL::XrayLaser, CTL::GenericSource, and CTL::XrayTube.

◆ photonFlux()

double CTL::AbstractSource::photonFlux ( ) const
inline

Returns the photon flux (i.e. photons per cm²) emitted by the source in a distance of one meter.

This method returns the nominal photon flux (as returned by nominalPhotonFlux()) multiplied with the flux modifier.

So far, the emitted flux cannot be direction-dependent (planned for future releases). However, direction-dependency can be introduced using a beam modifier (see AbstractBeamModifier).

◆ setFluxModifier()

void CTL::AbstractSource::setFluxModifier ( double  modifier)
inline

Sets the flux modifier to modifier.

The flux modifier is a multiplicative factor considered when querying the photon flux of the source component. This value can be used to describe global variation of the emitted photon flux. However, local solutions in sub-classes of AbstractSource are recommended when trying to model intensity variation. Best practice is to realize this within the (re-)implementation of nominalPhotonFlux() by utilization of dedicated class members (e.g. tube emission current).

See also
photonFlux().

◆ setFocalSpotPosition() [1/2]

void CTL::AbstractSource::setFocalSpotPosition ( const Vector3x1 position)
inline

Sets the focal spot position to position.

Definition of the focal spot position is in CT coordinates.

◆ setFocalSpotPosition() [2/2]

void CTL::AbstractSource::setFocalSpotPosition ( double  x,
double  y,
double  z 
)
inline

Sets the focal spot position to the point (x, y, z).

Convenience alternative. Same as setFocalSpotPosition(Vector3x1({ x, y, z })).

◆ setFocalSpotSize() [1/2]

void CTL::AbstractSource::setFocalSpotSize ( const QSizeF &  size)
inline

Sets the focal spot size size.

Definition of the focal spot size is in CT coordinates. In particular, it is specified as the dimension in the x-y-plane.

◆ setFocalSpotSize() [2/2]

void CTL::AbstractSource::setFocalSpotSize ( double  width,
double  height 
)
inline

Sets the focal spot size to a rectangle with dimensions width x height.

Convenience alternative. Same as setFocalSpotSize(QSizeF(width, height)).

◆ setSpectrumModel() [1/2]

void CTL::AbstractSource::setSpectrumModel ( AbstractXraySpectrumModel model)
inlinevirtual

Sets the spectrum model to model.

This instance manages ownership of model as a std::shared_ptr.

◆ setSpectrumModel() [2/2]

void CTL::AbstractSource::setSpectrumModel ( std::unique_ptr< AbstractXraySpectrumModel model)
inline

Sets the spectrum model to model.

◆ spectrum()

IntervalDataSeries CTL::AbstractSource::spectrum ( uint  nbSamples) const
inlinevirtual

Returns the (relative) emitted radiation spectrum sampled with nbSamples bins covering the energy range of [energyRange().start(), energyRange().end()] keV.

The method spectrumDiscretizationHint() can provide a hint for a reasonable number of samples.

Each energy bin in the returned data series is defined to represent the integral over the contribution to the total number of emitted photons of all energies within that particular bin. The individual contributions are extracted from the AbstractXraySpectrumModel set to the component.

The returned spectrum contains relative photon flux, i.e. the sum over all bins equals to one. To get quantitative energy-dependent photon flux values, multiply this (relative) spectrum with the photon flux constant (see photonFlux()).

Throws std::runtime_error if no spectrum model is available.

See also
energyRange(), spectrumModel(), setSpectrumModel().

Example: this example is based on the derived class 'XrayTube'

// create an XrayTube object, set the tube voltage to 100 kV
XrayTube tube;
tube.setTubeVoltage(100.0f);
auto sampledSpectrum = tube.spectrum(10); // sample 10 values
// we print the sampled values - these provide the relative photon flux
for(uint i = 0; i < sampledSpectrum.nbSamples(); ++i)
qInfo() << sampledSpectrum.binBounds(i).toPair() << "\t" << sampledSpectrum.value(i);
// output:
// std::pair(0,10) 8.3238e-06
// std::pair(10,20) 0.0253859
// std::pair(20,30) 0.159632
// std::pair(30,40) 0.220303
// std::pair(40,50) 0.193801
// std::pair(50,60) 0.183763
// std::pair(60,70) 0.117172
// std::pair(70,80) 0.0579733
// std::pair(80,90) 0.0319659
// std::pair(90,100) 0.00999621
// we now scale the spectrum by the photon flux constant of the tube...
// (note that this constant depends on several things, such as mAs and the tube voltage)
sampledSpectrum.scaleValues(tube.photonFlux());
// ...and print again - this now shows the actual photon flux (photons per area) for each energy bin
for(uint i = 0; i < sampledSpectrum.nbSamples(); ++i)
qInfo() << sampledSpectrum.binBounds(i).toPair() << "\t" << sampledSpectrum.value(i);
// output:
// std::pair(0,10) 1975.2
// std::pair(10,20) 6.02396e+06
// std::pair(20,30) 3.78799e+07
// std::pair(30,40) 5.22769e+07
// std::pair(40,50) 4.5988e+07
// std::pair(50,60) 4.36061e+07
// std::pair(60,70) 2.78044e+07
// std::pair(70,80) 1.37568e+07
// std::pair(80,90) 7.58536e+06
// std::pair(90,100) 2.37205e+06

Reimplemented in CTL::XrayLaser.

◆ spectrumDiscretizationHint()

uint CTL::AbstractSource::spectrumDiscretizationHint ( ) const
inlinevirtual

Returns a hint for a reasonable number of sampling points when querying a spectrum of the component. By default, this method returns 10. Re-implement this method in sub-classes to return meaningful hints for your particular source component type.

Reimplemented in CTL::XrayLaser, CTL::GenericSource, and CTL::XrayTube.

◆ spectrumModel()

const AbstractXraySpectrumModel * CTL::AbstractSource::spectrumModel ( ) const
inline

Returns a pointer to the spectrum model of this instance.

◆ toVariant()

QVariant CTL::AbstractSource::toVariant ( ) const
inlineoverridevirtual

Interface to store all member variables in a QVariant.

Stores the object's type-id.

Reimplement this method such that it stores all newly introduced object data when sub-classing. This needs to cover everything that is necessary to fully determine the state of an object. 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::toVariant().toMap();
ret.insert("my member variable", _myMemberVariable);
return ret;

Reimplemented from CTL::SerializationInterface.

Reimplemented in CTL::XrayLaser, CTL::GenericSource, and CTL::XrayTube.

◆ type()

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

Returns the type-id of the serializable object. Used in deserialization to determine the proper object type.

Add derived classes to the enumeration using the CTL_TYPE_ID macro.

Reimplemented from CTL::SerializationInterface.

Reimplemented in CTL::XrayLaser, CTL::GenericSource, and CTL::XrayTube.

Friends And Related Function Documentation

◆ EnergyRange()

EnergyRange
related

Alias name for CTL::Range<float>.

Holds the borders (i.e. minimum to maximum) of the energy range.


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