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

The OrthogonalSubsetGenerator class provides an implementation of subset generation considering real geometric orthogonality. More...

#include <orthogonalsubsetgenerator.h>

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

Classes

struct  Candidate
 

Public Types

enum  { Type = 1011 }
 
- Public Types inherited from CTL::AbstractFixedSizeSubsetGenerator
enum  { Type = 1001 }
 
- Public Types inherited from CTL::AbstractSubsetGenerator
enum  { Type = 1000 }
 
- Public Types inherited from CTL::SerializationInterface
enum  { Type = -1, UserType = 65536 }
 

Public Member Functions

int type () const override
 
 OrthogonalSubsetGenerator (uint nbSubsets=1u)
 Creates an OrthogonalSubsetGenerator that generates nbSubsets subsets. More...
 
void setSetup (const AcquisitionSetup &setup) override
 Sets the AcquisitionSetup that belongs to the projection data to setup. More...
 
- Public Member Functions inherited from CTL::AbstractFixedSizeSubsetGenerator
uint nbSubsets () const
 Returns the number of subsets that are generated.
 
void setNbSubsets (uint nbSubsets)
 Sets the number of subsets that will be generated to nbSubsets.
 
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
- Public Member Functions inherited from CTL::AbstractSubsetGenerator
virtual void setProjections (ProjectionDataView projections)
 Sets the projections that this instance shall operate on to projections. More...
 
void setData (ProjectionDataView projections, const AcquisitionSetup &setup)
 Sets the projections to projections and the corresponding acquisition setup to setup. More...
 
std::vector< ProjectionDataViewgenerateSubsets (uint iteration) const
 Generates the subsets for iteration iteration. More...
 
virtual std::vector< std::vector< ProjectionDataView > > generateAllSubsets (uint nbIterations)
 Convenience method to generate subsets for a certain number of iterations. More...
 
bool isSubsetPermutationEnabled () const
 Returns true if subset permutation is enabled; false otherwise.
 
const ProjectionDataViewprojections () const
 Returns the ProjectionDataView that has been set via setProjections().
 
uint randomGeneratorSeed () const
 Returns the seed that has been used to seed the RNG of this instance. More...
 
void setRandomGeneratorSeed (uint seed=std::random_device{}())
 Sets the seed of the RNG to seed and actually seeds the RNG.
 
void setSubsetPermutationEnabled (bool enabled)
 Sets the use of subset permutation to enabled. More...
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Protected Member Functions

std::vector< ProjectionDataViewgenerateSubsetsImpl (uint iteration) const override
 Implementation of the subset generation routine. More...
 
- Protected Member Functions inherited from CTL::AbstractFixedSizeSubsetGenerator
 AbstractFixedSizeSubsetGenerator (uint nbSubsets=1u)
 Creates an AbstractFixedSizeSubsetGenerator and sets the number of subsets to nbSubsets.
 
- Protected Member Functions inherited from CTL::AbstractSubsetGenerator
 AbstractSubsetGenerator ()
 Constructs an AbstractSubsetGenerator. More...
 
 AbstractSubsetGenerator (const AbstractSubsetGenerator &)=default
 
 AbstractSubsetGenerator (AbstractSubsetGenerator &&)=default
 
AbstractSubsetGeneratoroperator= (const AbstractSubsetGenerator &)=default
 
AbstractSubsetGeneratoroperator= (AbstractSubsetGenerator &&)=default
 
virtual void shuffleSubsets (std::vector< ProjectionDataView > &subsets) const
 Randomly permutes the order of the subsets in subsets. More...
 
- Protected Member Functions inherited from CTL::SerializationInterface
 SerializationInterface ()=default
 
 SerializationInterface (const SerializationInterface &)=default
 
 SerializationInterface (SerializationInterface &&)=default
 
SerializationInterfaceoperator= (const SerializationInterface &)=default
 
SerializationInterfaceoperator= (SerializationInterface &&)=default
 

Private Member Functions

ProjectionDataView createSubset (std::vector< Candidate > &candidates, uint subsetSize) const
 Creates a subset from the data managed by this instance. More...
 

Private Attributes

std::vector< mat::Matrix< 3, 1 > > _directionVectors
 source-to-detector vectors of the latest setup set
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- Protected Attributes inherited from CTL::AbstractFixedSizeSubsetGenerator
uint _nbSubsets = 1u
 
- Protected Attributes inherited from CTL::AbstractSubsetGenerator
ProjectionDataView _fullProjections = ProjectionDataView::invalidView()
 The projection data view this instance operates on.
 
std::mt19937 _rng
 random number generator (RNG) instance
 
uint _rngSeed = 42
 value used to seed the RNG
 
bool _permuteSubsets = true
 state variable if subset permutation is enabled
 

Detailed Description

The OrthogonalSubsetGenerator class provides an implementation of subset generation considering real geometric orthogonality.

This class implements the AbstractFixedSizeSubsetGenerator interface. The number of subsets that shall be generated can be specified in the constructor or later on through setNbSubsets().

The subset generation routine implemented by this class depends on the acquisition geometry referring to the projections that shall be divided into subsets. For that reason, the corresponding AcquisitionSetup needs to be set in advance of generating the subsets. This can be done individually through setSetup() or along with setting projection data using setData().

In order to assign individual views to a particular subset, the degree of orthogonality between the view directions (i.e. the source-to-detector vector) of all views already included in the subset and all remaining candidates (i.e. views from the full projection data that are not yet assigned to any subset) is computed. The candidate maximizing the average orthogonality is then subsequnetly added to the subset under construction and the full procedure is repeated until the required number (subject to the requested number of subsets) of views is reached.

Example: creating two subsets for a set of 18 views from a ShortScanTrajectory

constexpr uint nbViews = 18;
// first, we create the AcquisitionSetup with 'nbViews' and a ShortScanTrajectory
AcquisitionSetup setup(makeSimpleCTSystem<blueprints::GenericCarmCT>());
setup.setNbViews(nbViews);
setup.applyPreparationProtocol(protocols::ShortScanTrajectory(700.0));
// create some dummy projections (the actual dimensions are irrelevant here)
ProjectionData dummyProjections(1,1,1);
dummyProjections.allocateMemory(nbViews); // dummyProjections now contains 'nbViews' views
// create our subset generator and set the number of subsets to 2
subsetGen.setNbSubsets(2);
// pass both projection data and the correponding setup to the generator
subsetGen.setData(dummyProjections, setup);
// create the subsets (note: iteration '0' is entirely arbitrary and has no particular effect)
const auto subsets = subsetGen.generateSubsets(0);
// print the ids of the views that have been assigned to our two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
// output:
// std::vector(17, 10, 5, 13, 3, 11, 2, 16, 1)
// std::vector(0, 8, 4, 12, 6, 14, 7, 15, 9)
// out of interest:
// we want to compare that to a SimpleSubsetGenerator that assumes a 180 degree circle
SimpleSubsetGenerator simpleGen(2, SimpleSubsetGenerator::Orthogonal180);
simpleGen.setProjections(dummyProjections); // note that we do not need the AcquisitionSetup here
for(const auto& subset : simpleGen.generateSubsets(0))
qInfo() << subset.viewIds();
// output:
// std::vector(12, 1, 10, 8, 17, 5, 14, 6, 15)
// std::vector(0, 9, 4, 13, 7, 16, 2, 11, 3)

Constructor & Destructor Documentation

◆ OrthogonalSubsetGenerator()

CTL::OrthogonalSubsetGenerator::OrthogonalSubsetGenerator ( uint  nbSubsets = 1u)

Creates an OrthogonalSubsetGenerator that generates nbSubsets subsets.

The number of subsets to create may be changed later on through setNbSubsets(). Please note that this subset generator requires a valid AcquisitionSetup that corresponds to the projections that shall be partitioned into subsets before requesting the subsets.

Example: creating four subsets for a set of 36 views from a WobbleTrajectory

constexpr uint nbViews = 36;
// first, we create the AcquisitionSetup with 'nbViews'
AcquisitionSetup setup(makeSimpleCTSystem<blueprints::GenericCarmCT>(), nbViews);
// here, we decide for a WobbleTrajectory as our acquisition geometry
setup.applyPreparationProtocol(protocols::WobbleTrajectory(700.0));
// create some dummy projections (the actual dimensions are irrelevant here)
ProjectionData dummyProjections(1,1,1);
dummyProjections.allocateMemory(nbViews); // dummyProjections now contains 'nbViews' views
// create our subset generator with four subsets
// pass both projection data and the correponding setup to the generator
subsetGen.setData(dummyProjections, setup);
// create the subsets (note: iteration '0' is entirely arbitrary and has no particular effect)
const auto subsets = subsetGen.generateSubsets(0);
// print the ids of the views that have been assigned to our four subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
// output:
// std::vector(31, 14, 29, 12, 30, 6, 32, 4, 3)
// std::vector(0, 16, 26, 10, 23, 8, 1, 17, 25)
// std::vector(33, 15, 22, 5, 21, 7, 27, 13, 28)
// std::vector(35, 19, 9, 24, 2, 18, 34, 20, 11)

Member Function Documentation

◆ createSubset()

ProjectionDataView CTL::OrthogonalSubsetGenerator::createSubset ( std::vector< Candidate > &  candidates,
uint  subsetSize 
) const
private

Creates a subset from the data managed by this instance.

This selects subsetSize views from the list of available candidates, w.r.t. the maximum orthogonality approach described in generateSubsetsImpl().

◆ generateSubsetsImpl()

std::vector< ProjectionDataView > CTL::OrthogonalSubsetGenerator::generateSubsetsImpl ( uint  iteration) const
overrideprotectedvirtual

Implementation of the subset generation routine.

This generates the subsets for the data that have been set through setData() (or individual calls of setSetup() and setProjections()). Please note that setting a valid AcquisitionSetup that corresponds to the projections is required before this method is called (i.e. before requesting the subsets).

Generates the same subsets independent of the iteration input.

The subset generation routine implemented by this class depends on the acquisition geometry referring to the projections that shall be divided into subsets: In order to assign individual views to a particular subset, the degree of orthogonality between the view directions (i.e. the source-to-detector vector) of all views already included in the subset and all remaining candidates (i.e. views from the full projection data that are not yet assigned to any subset) is computed. The candidate maximizing the average orthogonality is then subsequnetly added to the subset under construction and the full procedure is repeated until the required number (subject to the requested number of subsets) of views is reached.

Note that this procedure is solely based on the orthogonality of the direction vectors. This means, in particular, that shifted view positions are not considered at all when determining their information content for the purpose of their assignment to a subset.

Implements CTL::AbstractSubsetGenerator.

◆ setSetup()

void CTL::OrthogonalSubsetGenerator::setSetup ( const AcquisitionSetup setup)
overridevirtual

Sets the AcquisitionSetup that belongs to the projection data to setup.

setup must be the AcquisitionSetup that describes the acquisition of the projection data passed to setProjections(). Please note that setup must always represent the full ProjectionData that is managed by the view passed to setProjections(). That means if the ProjectionDataView passed to setProjections() is already a subset, the setup passed here must still refer to the full ProjectionData the view belongs to.

This class extracts only the view directions, i.e. the vector pointing from the source position towards the detector position, from setup.

Reimplemented from CTL::AbstractSubsetGenerator.

◆ type()

int CTL::OrthogonalSubsetGenerator::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::AbstractFixedSizeSubsetGenerator.


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