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

The SimpleSubsetGenerator class provides an implementation of subset generation featuring a few simple options. More...

#include <simplesubsetgenerator.h>

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

Public Types

enum  { Type = 1010 }
 
enum  Order { Random, Adjacent, Orthogonal180, Orthogonal360 }
 
- 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
 
 SimpleSubsetGenerator (uint nbSubsets=1, Order subsetOrder=Random)
 Creates a SimpleSubsetGenerator that generates nbSubsets subsets according to the creation pattern subsetOrder. More...
 
void setOrder (Order order)
 Sets the order used for selecting views for a subset to order. More...
 
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
- 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.
 
- Public Member Functions inherited from CTL::AbstractSubsetGenerator
virtual void setSetup (const AcquisitionSetup &)
 Sets the AcquisitionSetup that belongs to the projection data to setup. More...
 
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

std::vector< ProjectionDataViewmakeRandomSubsets (const std::vector< uint > &subsetSizes) const
 Creates subsets based on random selection of views. More...
 
std::vector< ProjectionDataViewmakeAdjacentSubsets (const std::vector< uint > &subsetSizes) const
 Creates subsets taking adjacent blocks of views into a subset. More...
 
std::vector< ProjectionDataViewmakeOrthogonalSubsets (const std::vector< uint > &subsetSizes) const
 Creates subsets based on the assumption of a circular scan orbit. More...
 

Static Private Member Functions

static QMetaEnum metaEnum ()
 QMetaEnum object used to decode/encode subset order enum values.
 

Private Attributes

Order _order = Random
 

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 SimpleSubsetGenerator class provides an implementation of subset generation featuring a few simple options.

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().

All provided subset generation routines in this class are independent of the acquisition geometry. Instead, simple strategies (such as random selection) or basic assumptions on the geometry (e.g. 360 degree circle) are used. Four different 'creation patterns' are available for the generation of subsets:

The creation pattern (or the order in which views are selected for participation in a subset) can be specified in the constructor or later on through setOrder(). All creation patterns ensure that each view appears only once in the entire set of subsets.

Example:

// create dummy projection data (sizes entirely arbitrary, and irrelevant here)
ProjectionData dummy(1,1,1);
dummy.allocateMemory(36); // 'dummy' now contains 36 views
// create a subset generator; set the number of subsets to 4 and the pattern to 'Orthogonal360'
subsetGen.setNbSubsets(4);
// pass the dummy projection data (note: it contains 36 views)
subsetGen.setProjections(dummy);
// generate subsets (note: iteration '0' is arbitrary and has no effect here)
const auto subsets = subsetGen.generateSubsets(0);
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
// output:
// std::vector(18, 27, 22, 31, 25, 34, 20, 29, 21)
// std::vector(30, 19, 28, 26, 35, 23, 32, 24, 33)
// std::vector(0, 9, 4, 13, 7, 16, 2, 11, 3)
// std::vector(12, 1, 10, 8, 17, 5, 14, 6, 15)

Member Enumeration Documentation

◆ Order

Enumeration for subset selection orders.

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

Enumerator
Random 

Randomly selects views for a subset.

Adjacent 

Puts adjacent views into a subset.

Orthogonal180 

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

Orthogonal360 

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

Constructor & Destructor Documentation

◆ SimpleSubsetGenerator()

CTL::SimpleSubsetGenerator::SimpleSubsetGenerator ( uint  nbSubsets = 1,
Order  subsetOrder = Random 
)
explicit

Creates a SimpleSubsetGenerator that generates nbSubsets subsets according to the creation pattern subsetOrder.

Example:

// create dummy projection data (sizes entirely arbitrary, and irrelevant here)
ProjectionData dummy(1,1,1);
dummy.allocateMemory(10); // 'dummy' now contains 10 views
// create a subset generator with 3 subsets and the pattern to 'Adjacent'
// pass the dummy projection data (note: it contains 36 views)
subsetGen.setProjections(dummy);
// generate subsets (note: iteration '0' is arbitrary and has no effect here)
const auto subsets = subsetGen.generateSubsets(0);
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
// output:
// std::vector(18, 27, 22, 31, 25, 34, 20, 29, 21)
// std::vector(30, 19, 28, 26, 35, 23, 32, 24, 33)
// std::vector(0, 9, 4, 13, 7, 16, 2, 11, 3)
// std::vector(12, 1, 10, 8, 17, 5, 14, 6, 15)

Member Function Documentation

◆ fromVariant()

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

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::AbstractFixedSizeSubsetGenerator.

◆ generateSubsetsImpl()

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

Implementation of the subset generation routine.

This generates the subsets for the data that have been set through setProjections() (or setData()). Generates the same subsets independent of the iteration input.

The generation pattern used depends on the mode selected in the constructor or through setOrder():

  • Order::Random - randomly selects views for a subset
  • Order::Adjacent - puts adjacent views into a subset
  • Order::Orthogonal180 - selects sets of most orthogonal views, assuming the total scan range was 180 degrees
  • Order::Orthogonal360 - selects sets of most orthogonal views, assuming the total scan range was 360 degrees

Example:

// create dummy projection data (sizes entirely arbitrary, and irrelevant here)
ProjectionData dummy(1,1,1);
dummy.allocateMemory(10); // 'dummy' now contains 10 views
// create a subset generator and set the number of subsets to 2
subsetGen.setNbSubsets(2);
// pass the dummy projection data (note: it contains 10 views)
subsetGen.setProjections(dummy);
// we use a simple function to try out the different generation patterns
const auto runGeneration = [&subsetGen] (const SimpleSubsetGenerator::Order& order)
{
// set the subset order
subsetGen.setOrder(order);
// generate subsets (note: iteration '0' is arbitrary and has no effect here)
const auto subsets = subsetGen.generateSubsets(0);
// print the ids of the views included in the two subsets
for(const auto& subset : subsets)
qInfo() << subset.viewIds();
};
// order: Random
// output:
// std::vector(6, 2, 1, 0, 3)
// std::vector(8, 7, 9, 4, 5)
// order: Adjacent
// output:
// std::vector(0, 1, 2, 3, 4)
// std::vector(5, 6, 7, 8, 9)
// order: Orthogonal180
// output:
// std::vector(9, 1, 6, 2, 7)
// std::vector(0, 5, 3, 8, 4)
// order: Orthogonal360
// output:
// std::vector(0, 3, 1, 4, 2)
// std::vector(5, 8, 6, 9, 7)

Implements CTL::AbstractSubsetGenerator.

◆ makeAdjacentSubsets()

std::vector< ProjectionDataView > CTL::SimpleSubsetGenerator::makeAdjacentSubsets ( const std::vector< uint > &  subsetSizes) const
private

Creates subsets taking adjacent blocks of views into a subset.

Ensures that each view appears only once in the entire set of subsets.

◆ makeOrthogonalSubsets()

std::vector< ProjectionDataView > CTL::SimpleSubsetGenerator::makeOrthogonalSubsets ( const std::vector< uint > &  subsetSizes) const
private

Creates subsets based on the assumption of a circular scan orbit.

Assumes a total scan range of either 180 or 360 degrees, depending on what has been specified as order for the subsets (see setOrder()).

Ensures that each view appears only once in the entire set of subsets.

◆ makeRandomSubsets()

std::vector< ProjectionDataView > CTL::SimpleSubsetGenerator::makeRandomSubsets ( const std::vector< uint > &  subsetSizes) const
private

Creates subsets based on random selection of views.

Ensures that each view appears only once in the entire set of subsets.

◆ setOrder()

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

Sets the order used for selecting views for a subset to order.

The following options of subset generation patterns are available:

  • Order::Random - randomly selects views for a subset
  • Order::Adjacent - puts adjacent views into a subset
  • Order::Orthogonal180 - selects sets of most orthogonal views, assuming the total scan range was 180 degrees
  • Order::Orthogonal360 - selects sets of most orthogonal views, assuming the total scan range was 360 degrees

Examples: see generateSubsetsImpl().

◆ toVariant()

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

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::AbstractFixedSizeSubsetGenerator.

◆ type()

int CTL::SimpleSubsetGenerator::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: