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

The DefaultSubsetGenerator class is a convenience class combining the capabilities of multiple CTL subset generators. More...

#include <defaultsubsetgenerator.h>

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

Public Types

enum  { Type = 1200 }
 
enum  Order {
  Random, Adjacent, Orthogonal180, Orthogonal360,
  RealOrthogonal
}
 
- Public Types inherited from CTL::TransitionSchemeExtension
enum  { Type = 1100 }
 
- 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
 
void setFixedNumberOfSubsets (uint nbSubsets)
 Sets the number of subsets in each iteration to nbSubsets; disables size transition. More...
 
void setOrder (DefaultSubsetGenerator::Order order)
 Sets the selection order (creation pattern) for the creation of subsets to order. More...
 
- Public Member Functions inherited from CTL::TransitionSchemeExtension
int type () const override
 
 TransitionSchemeExtension (AbstractFixedSizeSubsetGenerator *nestedGenerator)
 Creates a TransitionSchemeExtension using nestedGenerator as actual subset generator. More...
 
 TransitionSchemeExtension (std::unique_ptr< AbstractFixedSizeSubsetGenerator > nestedGenerator)
 Creates a TransitionSchemeExtension using nestedGenerator as actual subset generator. More...
 
virtual void setSetup (const AcquisitionSetup &setup) override
 Sets the AcquisitionSetup that belongs to the projection data to setup. More...
 
virtual void setProjections (ProjectionDataView projections) override
 Sets the projections that this instance shall operate on to projections. More...
 
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
void setTransitionPeriod (uint transitionEveryNIterations)
 Sets the transition period (i.e. the number of iterations after which the subset count is cut in half) to transitionEveryNIterations. More...
 
void setMaximumNbSubsets (uint maxNbSubsets)
 Sets the maximum number of subsets generated to maxNbSubsets. More...
 
void setMinimumNbSubsets (uint minNbSubsets)
 Sets the minimum number of subsets generated to minNbSubsets. More...
 
void setSubsetBounds (uint initialNbSubsets, uint finalNbSubsets)
 Sets the number of subsets in the beginning (early iterations) and at the end of transitions (late iterations) to initialNbSubsets and finalNbSubsets, respectively. More...
 
void setSubsetGenerator (AbstractFixedSizeSubsetGenerator *nestedGenerator)
 Sets the nested subset generator to nestedGenerator; deleted previous one. More...
 
void setSubsetGenerator (std::unique_ptr< AbstractFixedSizeSubsetGenerator > nestedGenerator)
 Sets the nested subset generator to nestedGenerator; deleted previous one. More...
 
- Public Member Functions inherited from CTL::AbstractSubsetGenerator
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
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- Protected Member Functions inherited from CTL::TransitionSchemeExtension
std::vector< ProjectionDataViewgenerateSubsetsImpl (uint iteration) const override
 Implementation of the wrapper for the subset generation routine. More...
 
virtual uint numberOfSubsets (uint iteration) const
 Computes the number of subsets that shall be generated for iteration nb. \iteration. More...
 
void shuffleSubsets (std::vector< ProjectionDataView > &subsets) const override
 Randomly permutes the order of the subsets in subsets. More...
 
- 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
 
- 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 inherited from CTL::TransitionSchemeExtension
std::unique_ptr< AbstractFixedSizeSubsetGenerator_nestedGen
 
uint _minNbSubsets = 1u
 
uint _maxNbSubsets = 0u
 
uint _transitionPeriod = 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 DefaultSubsetGenerator class is a convenience class combining the capabilities of multiple CTL subset generators.

The DefaultSubsetGenerator provides the capabilities of a TransitionSchemeExtension with predefined nested subset generators to make its use more convenient. This includes the SimpleSubsetGenerator as well as the OrthogonalSubsetGenerator. The corresponding generator type will be selected automatically based on the chosen subset order (or generation pattern) by means of setOrder().

By default, this class creates a subset size transition with progressing iteration count. Refer to the documentation of TransitionSchemeExtension for more details on all possible settings and and explanation of the transition pattern. In case a fixed number of subsets is desired, this can be done conveniently using setFixedNumberOfSubsets().

In total, this generator supports the following generation patterns:

Note that when using Order::RealOrthogonal, subset generation depends on the actual acquisition geometry, thus the corresponding AcquisitionSetup needs to be set in advance of generating the subsets (see setSetup()).

It is also possible to use TransitionSchemeExtension::setSubsetGenerator() to install a custom nested subset generator. However, a call to setOrder() will replace any previously installed custom generator by either SimpleSubsetGenerator or OrthogonalSubsetGenerator (depending on the selected order).

Example:

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
DefaultSubsetGenerator subsetGen;
// we choose the 'Orthogonal180' pattern and want to transition between 6 and 2 subsets:
subsetGen.setSubsetBounds(6, 2);
// pass projection data to the generator
subsetGen.setProjections(dummyProjections);
// NOTE: except for DefaultSubsetGenerator::RealOrthogonal, we don't need to pass the setup
// However, it would also be ok to do so, without additional cost:
// subsetGen.setData(dummyProjections, setup);
// generate (and inspect) subsets for the first 4 iterations
for(uint it = 0; it < 4; ++it)
{
const auto subsets = subsetGen.generateSubsets(it);
qInfo() << "Iteration" << it << "with" << subsets.size() << "subset(s)";
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
}
// output:
// Iteration 0 with 6 subset(s)
// std::vector(8, 17, 5)
// std::vector(2, 11, 3)
// std::vector(0, 9, 4)
// std::vector(14, 6, 15)
// std::vector(13, 7, 16)
// std::vector(12, 1, 10)
// Iteration 1 with 3 subset(s)
// std::vector(0, 9, 4, 13, 7, 16)
// std::vector(2, 11, 3, 12, 1, 10)
// std::vector(8, 17, 5, 14, 6, 15)
// Iteration 2 with 2 subset(s)
// std::vector(12, 1, 10, 8, 17, 5, 14, 6, 15)
// std::vector(0, 9, 4, 13, 7, 16, 2, 11, 3)
// Iteration 3 with 2 subset(s)
// std::vector(0, 9, 4, 13, 7, 16, 2, 11, 3)
// std::vector(12, 1, 10, 8, 17, 5, 14, 6, 15)

We now want to use the RealOrthogonal pattern to generate our subsets. We can do so as follows:

// since this generation pattern relies on the real acquisition geometry,
// we need to also pass 'setup' to 'subsetGen', this time.
subsetGen.setData(dummyProjections, setup);
// NOTE: we need to pass the projections again after changing the order!
// we repeat the generation of subsets for the first 4 iterations
for(uint it = 0; it < 4; ++it)
{
const auto subsets = subsetGen.generateSubsets(it);
qInfo() << "Iteration" << it << "with" << subsets.size() << "subset(s)";
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
}
// output:
// Iteration 0 with 6 subset(s)
// std::vector(15, 2, 1)
// std::vector(0, 8, 4)
// std::vector(14, 6, 10)
// std::vector(17, 9, 13)
// std::vector(16, 5, 12)
// std::vector(11, 3, 7)
// Iteration 1 with 3 subset(s)
// std::vector(0, 8, 4, 12, 6, 14)
// std::vector(7, 15, 10, 2, 16, 1)
// std::vector(17, 9, 13, 5, 11, 3)
// Iteration 2 with 2 subset(s)
// std::vector(17, 10, 5, 13, 3, 11, 2, 16, 1)
// std::vector(0, 8, 4, 12, 6, 14, 7, 15, 9)
// Iteration 3 with 2 subset(s)
// std::vector(17, 10, 5, 13, 3, 11, 2, 16, 1)
// std::vector(0, 8, 4, 12, 6, 14, 7, 15, 9)

Member Enumeration Documentation

◆ Order

Enumeration for subset selection orders.

The selection order decides which views will end up in a particular subset.

Implemented through SimpleSubsetGenerator.

Enumerator
Random 

Randomly selects views for a subset.

Implemented through SimpleSubsetGenerator.

Adjacent 

Puts adjacent views into a subset.

Implemented through SimpleSubsetGenerator.

Orthogonal180 

Selects sets of most orthogonal views, assuming a circular scan orbit with an agular range of 180 degrees.

Implemented through SimpleSubsetGenerator.

Orthogonal360 

Selects sets of most orthogonal views, assuming a circular scan orbit with an agular range of 360 degrees.

Implemented through SimpleSubsetGenerator.

RealOrthogonal 

Selects sets of most orthogonal views based on the actual acquisition geometry.

Implemented through OrthogonalSubsetGenerator.

Member Function Documentation

◆ setFixedNumberOfSubsets()

void CTL::DefaultSubsetGenerator::setFixedNumberOfSubsets ( uint  nbSubsets)

Sets the number of subsets in each iteration to nbSubsets; disables size transition.

If nbSubsets is larger than the number of projections in the data that has been set, the number of subsets is reduced to the total count of available projections (i.e. subsets with a single view each will be generated).

Same as:

Example: generating a fixed number of 3 subsets

// create some dummy projections (the actual dimensions are irrelevant here)
ProjectionData dummyProjections(1,1,1);
dummyProjections.allocateMemory(20); // dummyProjections now contains 20 views
// create our subset generator
DefaultSubsetGenerator subsetGen;
// we choose the 'Random' pattern ...
subsetGen.setOrder(DefaultSubsetGenerator::Random);
// ... and set our desired fixed number of 3 subsets
subsetGen.setFixedNumberOfSubsets(3);
// pass projection data to the generator
subsetGen.setProjections(dummyProjections);
// generate (and inspect) subsets for the first 4 iterations
for(uint it = 0; it < 4; ++it)
{
const auto subsets = subsetGen.generateSubsets(it);
qInfo() << "Iteration" << it << "with" << subsets.size() << "subset(s)";
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
}
// output:
// Iteration 0 with 3 subset(s)
// std::vector(2, 17, 11, 3, 18, 12, 0)
// std::vector(16, 7, 14, 4, 13, 10)
// std::vector(15, 9, 5, 19, 1, 6, 8)
// Iteration 1 with 3 subset(s)
// std::vector(9, 7, 17, 12, 16, 13)
// std::vector(5, 11, 18, 3, 19, 8, 6)
// std::vector(1, 4, 15, 0, 2, 10, 14)
// Iteration 2 with 3 subset(s)
// std::vector(7, 3, 11, 15, 14, 12, 5)
// std::vector(13, 16, 10, 4, 6, 17, 19)
// std::vector(18, 8, 9, 2, 1, 0)
// Iteration 3 with 3 subset(s)
// std::vector(9, 0, 17, 4, 5, 8)
// std::vector(19, 13, 12, 16, 10, 2, 6)
// std::vector(11, 15, 1, 14, 3, 18, 7)

◆ setOrder()

void CTL::DefaultSubsetGenerator::setOrder ( DefaultSubsetGenerator::Order  order)

Sets the selection order (creation pattern) for the creation of subsets to order.

The following generation patterns are supported:

  • Random - randomly selects views for a subset
  • Adjacent - puts adjacent views into a subset
  • Orthogonal180 - selects sets of most orthogonal views, assuming the total scan range was 180 degrees
  • Orthogonal360 - selects sets of most orthogonal views, assuming the total scan range was 360 degrees
  • RealOrthogonal - selection based on orthogonality between real view directions (i.e. the source-to-detector vector)

All patterns except RealOrthogonal are provided by a SimpleSubsetGenerator. These cases do not require an AcquisitionSetup being set for the generation of subsets. The case RealOrthogonal uses OrthogonalSubsetGenerator and is based on the actual acquisition geometry; thus, requiring the corresponding setup (see setSetup()).

Calling this method always results in a reset of the nested subset generator. This might be important in case a custom generator has been installed previously through TransitionSchemeExtension::setSubsetGenerator().

Example: see detailed class description

◆ type()

int CTL::DefaultSubsetGenerator::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::AbstractSubsetGenerator.


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