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

The ProjectionPipeline class is a convenience class to manage a composition of a projector and additional extensions in a simple manner. More...

#include <projectionpipeline.h>

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

Public Types

enum  { Type = 200 }
 
using ProjectorPtr = std::unique_ptr< AbstractProjector >
 Alias name for std::unique_ptr<AbstractProjector>.
 
using ExtensionPtr = std::unique_ptr< ProjectorExtension >
 Alias name for std::unique_ptr<ProjectorExtension>.
 
- Public Types inherited from CTL::AbstractProjector
enum  { Type = 0 }
 
- Public Types inherited from CTL::SerializationInterface
enum  { Type = -1, UserType = 65536 }
 

Public Member Functions

int type () const override
 
void configure (const AcquisitionSetup &setup) override
 Sets the acquisition setup for the simulation to setup. More...
 
ProjectionData project (const VolumeData &volume) override
 Creates projection data from volume. More...
 
ProjectionData projectComposite (const CompositeVolume &volume) override
 Creates projection data from the composite volume volume. More...
 
ProjectionData projectSparse (const SparseVoxelVolume &volume) override
 Creates projection data from the sparse volume volume. More...
 
bool isLinear () const override
 
void fromVariant (const QVariant &variant) override
 Sets the contents of the object based on the QVariant variant. More...
 
QVariant toVariant () const override
 Stores the contents of this instance in a QVariant. More...
 
ProjectorNotifiernotifier () override
 Returns a pointer to the notifier of the projector. More...
 
 ProjectionPipeline (AbstractProjector *projector=nullptr)
 
 ProjectionPipeline (ProjectorPtr projector)
 
void appendExtension (ExtensionPtr extension)
 
void appendExtension (ProjectorExtension *extension)
 
void insertExtension (uint pos, ExtensionPtr extension)
 
void insertExtension (uint pos, ProjectorExtension *extension)
 
ProjectorExtensionreleaseExtension (uint pos)
 
void removeExtension (uint pos)
 
void setProjector (ProjectorPtr projector)
 
void setProjector (AbstractProjector *projector)
 
ExtensionPtr takeExtension (uint pos)
 
ProjectorExtensionextension (uint pos) const
 
AbstractProjectorprojector () const
 
uint nbExtensions () const
 
- Public Member Functions inherited from CTL::AbstractProjector
 AbstractProjector (const AbstractProjector &)=delete
 
 AbstractProjector (AbstractProjector &&)=default
 
AbstractProjectoroperator= (const AbstractProjector &)=delete
 
AbstractProjectoroperator= (AbstractProjector &&)=default
 
 ~AbstractProjector () override=default
 
ProjectionData configureAndProject (const AcquisitionSetup &setup, const VolumeData &volume)
 Performs a forward projection with a precedent configuration of the projector. More...
 
ProjectionData configureAndProject (const AcquisitionSetup &setup, const CompositeVolume &volume)
 Performs a forward projection with a precedent configuration of the projector. More...
 
ProjectionData configureAndProject (const AcquisitionSetup &setup, const SparseVoxelVolume &volume)
 Performs a forward projection with a precedent configuration of the projector. More...
 
virtual QVariant parameter () const
 Returns the parameters of this instance as QVariant. More...
 
virtual void setParameter (const QVariant &parameter)
 Sets the parameters of this instance based on the passed QVariant parameter. Parameters need to follow the naming convention as described in parameter(). More...
 
void connectNotifierToMessageHandler (bool includeProgress=false)
 Connects the notifier to the CTL's MessageHandler. More...
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Private Member Functions

void stashExtensions (uint nbExt)
 
void restoreExtensions (uint nbExt)
 

Private Attributes

std::vector< ProjectorExtension * > _extensions
 (Ordered) list of pointers to all extensions.
 
ExtensionPtr _finalProjector
 The fully-assembled projector (incl. all extensions).
 
AbstractProjector_projector
 Pointer to the actual projector object.
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- 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 ProjectionPipeline class is a convenience class to manage a composition of a projector and additional extensions in a simple manner.

This class provides a simple means to manage a projector along with an arbitrary number of ProjectorExtension objects. It allows for manipulations of the processing pipeline in a list-like fashion.

Use appendExtension() to add another extension to the end of the current pipeline. Extensions can also be inserted at arbitrary positions within the pipeline with insertExtension() as well as removed with removeExtension(). The actual projector to be used can be set using setProjector() or directly in the constructor. All methods take ownership of the objects passed to them and destroy any previous object, in case they replace or remove it. To take extensions out of the pipeline without destroying the object, use releaseExtension() or takeExtension().

All manipulations on the pipeline are executed immediately. That means each call to either of the above mentioned methods can throw an exeption in case the pipeline that would result from the manipulation is not possible (i.e. if it internally throws an exception during use()).

To modify any settings of individual extensions (or the actual projector), pointers to the corresponding objects can be accessed with extension() and projector(). Note that the ownership remains at the ProjectionPipeline object and you need to cast the pointer to the correct type of extension or projector in order to access its full interface. Best practice is to fully prepare all settings of the extensions before adding them to the pipeline.

The ProjectorPipeline object itself can be used in the same way as any projector; use configure() to pass the AcquisitionSetup for the simulation and then call project() (or projectComposite()) with the volume dataset that shall be projected to create the simulated projections using the full processing pipeline that is managed your ProjectorPipeline object.

The following code example demonstrates the usage of a ProjectionPipeline for creating projections of a bone ball phantom. The simulation shall be done using the OCL::RayCasterProjector class as forward projector and the processing chain shall consider spectral effects followed by addition of Poisson noise.

// create ball phantom made of cortical bone
auto volume = SpectralVolumeData::ball(50.0f, 0.5f, 1.0f,
database::attenuationModel(database::Composite::Bone_Cortical));
// create a C-arm CT system and a short scan protocol with 10 views
auto system = CTSystemBuilder::createFromBlueprint(blueprints::GenericCarmCT());
auto setup = AcquisitionSetup(system, 10);
setup.applyPreparationProtocol(protocols::ShortScanTrajectory(750.0));
// create the pipeline with a ray caster projector
ProjectionPipeline pipe(new OCL::RayCasterProjector);
// alternatively:
// ProjectionPipeline pipe;
// pipe.setProjector(new OCL::RayCasterProjector);
// create a SpectralEffectsExtension and set the energy resolution to 7.5 keV
auto spectralExt = new SpectralEffectsExtension;
spectralExt->setSpectralSamplingResolution(7.5f);
// add the spectral effects extension and a Poisson noise extension to the pipeline
pipe.appendExtension(spectralExt);
pipe.appendExtension(new PoissonNoiseExtension);
// pass the acquisition setup and run the simulation
pipe.configure(setup);
auto projections = pipe.project(volume);

Constructor & Destructor Documentation

◆ ProjectionPipeline() [1/2]

CTL::ProjectionPipeline::ProjectionPipeline ( AbstractProjector projector = nullptr)

Constructs a ProjectionPipeline object and sets the projector to projector.

This object takes ownership of projector.

◆ ProjectionPipeline() [2/2]

CTL::ProjectionPipeline::ProjectionPipeline ( ProjectorPtr  projector)

Convenience overload of ProjectionPipeline(AbstractProjector*) for unique_ptr arguments.

Member Function Documentation

◆ appendExtension() [1/2]

void CTL::ProjectionPipeline::appendExtension ( ExtensionPtr  extension)

Appends the extension extension to the end of the pipeline.

This object takes ownership of extension.

◆ appendExtension() [2/2]

void CTL::ProjectionPipeline::appendExtension ( ProjectorExtension extension)

Appends the extension extension to the end of the pipeline.

This object takes ownership of extension.

◆ configure()

void CTL::ProjectionPipeline::configure ( const AcquisitionSetup setup)
overridevirtual

Sets the acquisition setup for the simulation to setup.

Sets the acquisition setup for the simulation to setup. This needs to be done prior to calling project().

Implements CTL::AbstractProjector.

◆ extension()

ProjectorExtension * CTL::ProjectionPipeline::extension ( uint  pos) const

Returns a (base-class) pointer to the extension at position pos in the current pipeline.

Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).

Ownership remains at this instance.

◆ fromVariant()

void CTL::ProjectionPipeline::fromVariant ( const QVariant &  variant)
overridevirtual

Sets the contents of the object based on the QVariant variant.

Implementation of the deserialization interface. This method uses setParameter() to deserialize class members.

Reimplemented from CTL::AbstractProjector.

◆ insertExtension() [1/2]

void CTL::ProjectionPipeline::insertExtension ( uint  pos,
ExtensionPtr  extension 
)

Inserts the extension extension at position pos into the pipeline. If pos >= nbExtensions(), the extension is appended.

Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).

This object takes ownership of extension.

◆ insertExtension() [2/2]

void CTL::ProjectionPipeline::insertExtension ( uint  pos,
ProjectorExtension extension 
)

Inserts the extension extension at position pos into the pipeline. If pos >= nbExtensions(), the extension is appended.

Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).

This object takes ownership of extension.

◆ isLinear()

bool CTL::ProjectionPipeline::isLinear ( ) const
overridevirtual

Returns true if the application of the full processing pipeline is linear.

Reimplemented from CTL::AbstractProjector.

◆ nbExtensions()

uint CTL::ProjectionPipeline::nbExtensions ( ) const

Returns the number of extensions in the pipeline.

Note that the actual projector does not count towards the number of extensions, i.e. for a pipeline consisting solely of a projector, nbExtensions() is zero.

◆ notifier()

ProjectorNotifier * CTL::ProjectionPipeline::notifier ( )
overridevirtual

Returns a pointer to the notifier of the projector.

The notifier object can be used to emit the signal ProjectorNotifier::projectionFinished(int) when the calculation of the viewNb'th view has been done.

To receive emitted signals, use Qt's connect() method to connect the notifier object to any receiver object of choice. The notifier can also conveniently be connected to the MessageHandler of the CTL using connectToMessageHandler() or directly from the projector through AbstractProjector::connectNotifierToMessageHandler().

Example - sending simulation progress information to a QProgressBar:

AbstractProjector* myProjector /* = new ActualProjector */;
QProgressBar* myProgressBar = new QProgressBar();
// ... e.g. add the progress bar somewhere in your GUI
connect(myProjector->notifier(), SIGNAL(projectionFinished(int)),
myProgressBar, SLOT(setValue(int)));

/// Example 2 - forwarding the information text to a QStatusBar

AbstractProjector* myProjector /* = new ActualProjector */;
QStatusBar* myStatusBar = new QStatusBar;
// ... e.g. add the status bar somewhere in your GUI (or take a pointer to an existing one)
QObject::connect(myProjector->notifier(), SIGNAL(information(QString)),
myStatusBar, SLOT(showMessage(QString)));

Reimplemented from CTL::AbstractProjector.

◆ project()

ProjectionData CTL::ProjectionPipeline::project ( const VolumeData volume)
overridevirtual

Creates projection data from volume.

Creates projection data from volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().

Implements CTL::AbstractProjector.

◆ projectComposite()

ProjectionData CTL::ProjectionPipeline::projectComposite ( const CompositeVolume volume)
overridevirtual

Creates projection data from the composite volume volume.

Creates projection data from the composite volume volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().

Reimplemented from CTL::AbstractProjector.

◆ projector()

AbstractProjector * CTL::ProjectionPipeline::projector ( ) const

Returns a (base-class) pointer to the projector that is currently set in the pipeline.

Ownership remains at this instance.

◆ projectSparse()

ProjectionData CTL::ProjectionPipeline::projectSparse ( const SparseVoxelVolume volume)
overridevirtual

Creates projection data from the sparse volume volume.

Creates projection data from the sparse volume volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().

Reimplemented from CTL::AbstractProjector.

◆ releaseExtension()

ProjectorExtension * CTL::ProjectionPipeline::releaseExtension ( uint  pos)

Removes the extension at position pos from the pipeline. Throws an std::domain_error if pos >= nbExtensions().

Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).

The ownership of the released object is transfered to the caller.

◆ removeExtension()

void CTL::ProjectionPipeline::removeExtension ( uint  pos)

Removes the extension at position pos from the pipeline. Throws an std::domain_error if pos >= nbExtensions().

The removed extension object is destroyed.

◆ restoreExtensions()

void CTL::ProjectionPipeline::restoreExtensions ( uint  nbExt)
private

Restores nbExt extensions at the end of the pipeline.

Extensions must have been removed before by stashExtensions().

◆ setProjector() [1/2]

void CTL::ProjectionPipeline::setProjector ( ProjectorPtr  projector)

Sets the projector to projector. Destroys any previous projector object managed by this instance.

This object takes ownership of projector.

◆ setProjector() [2/2]

void CTL::ProjectionPipeline::setProjector ( AbstractProjector projector)

Sets the projector to projector. Destroys any previous projector object managed by this instance.

This object takes ownership of projector.

◆ stashExtensions()

void CTL::ProjectionPipeline::stashExtensions ( uint  nbExt)
private

Temporarily removes nbExt extensions from the end of the pipeline.

The removed objects are not deleted and need to be restored later using restoreExtensions() to avoid memory leaks.

◆ takeExtension()

ProjectionPipeline::ExtensionPtr CTL::ProjectionPipeline::takeExtension ( uint  pos)

Removes the extension at position pos from the pipeline. The extension object is wrapped into a unique pointer and returned to the caller. Throws an std::domain_error if pos >= nbExtensions().

Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).

◆ toVariant()

QVariant CTL::ProjectionPipeline::toVariant ( ) const
overridevirtual

Stores the contents of this instance in a QVariant.

Implementation of the serialization interface. Stores the object's type-id (from SerializationInterface::toVariant()).

This method uses parameter() to serialize class members.

Reimplemented from CTL::AbstractProjector.

◆ type()

int CTL::ProjectionPipeline::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::AbstractProjector.


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