CTL
0.6.1
Computed Tomography Library
|
The TransitionSchemeExtension class is a decorator for subset generators enabling a transition from many small subsets to a few larger ones with increasing iteration. More...
#include <transitionschemeextension.h>
Public Types | |
enum | { Type = 1100 } |
![]() | |
enum | { Type = 1000 } |
![]() | |
enum | { Type = -1, UserType = 65536 } |
Public Member Functions | |
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... | |
![]() | |
void | setData (ProjectionDataView projections, const AcquisitionSetup &setup) |
Sets the projections to projections and the corresponding acquisition setup to setup. More... | |
std::vector< ProjectionDataView > | generateSubsets (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 ProjectionDataView & | projections () 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... | |
![]() | |
virtual | ~SerializationInterface ()=default |
Protected Member Functions | |
std::vector< ProjectionDataView > | generateSubsetsImpl (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... | |
![]() | |
AbstractSubsetGenerator () | |
Constructs an AbstractSubsetGenerator. More... | |
AbstractSubsetGenerator (const AbstractSubsetGenerator &)=default | |
AbstractSubsetGenerator (AbstractSubsetGenerator &&)=default | |
AbstractSubsetGenerator & | operator= (const AbstractSubsetGenerator &)=default |
AbstractSubsetGenerator & | operator= (AbstractSubsetGenerator &&)=default |
![]() | |
SerializationInterface ()=default | |
SerializationInterface (const SerializationInterface &)=default | |
SerializationInterface (SerializationInterface &&)=default | |
SerializationInterface & | operator= (const SerializationInterface &)=default |
SerializationInterface & | operator= (SerializationInterface &&)=default |
Protected Attributes | |
std::unique_ptr< AbstractFixedSizeSubsetGenerator > | _nestedGen |
uint | _minNbSubsets = 1u |
uint | _maxNbSubsets = 0u |
uint | _transitionPeriod = 1u |
![]() | |
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 | |
Friends | |
template<class > | |
struct | SerializationHelper::RegisterWithSerializationHelper |
The TransitionSchemeExtension class is a decorator for subset generators enabling a transition from many small subsets to a few larger ones with increasing iteration.
This class extends the capabilities of a subset generator (henceforth also referred to as the nested generator) by taking control of the number of subsets the nested generator creates for a particular iteration. In doing so, this extension provides a means to generate subsets of increasing size for consecutive iterations. To be more specific, subset generation starts with a given upper bound for the number of subsets (see setMaximumNbSubsets()) and uses the nested generator to generate that particular amount of subsets for the first iteration. After a defined number of iterations (see setTransitionPeriod()), the number of subsets will be halved, resulting in fewer but larger subsets for the upcoming iteration/s. This procedure of cutting the number of subsets in half is repeated until a defined lower bound of subsets (see setMinimumNbSubsets()) is reached. For convenience, initial and final subset sizes can also be be specified in terms of bounds (see setSubsetsBounds()), offering a combined setter for the number of subsets to be created in the two opposing limits (i.e. largest and smallest number of subsets).
The number of subsets \( N \) generated in a particular iteration \( i \), can be expressed as follows (given the maximum and minimum subset count as \( N_{max}\) and \( N_{min}\), as well as the transition period \( T \)):
\[ \def\lf{\left\lfloor} \def\rf{\right\rfloor} N(i) = \max \left(\lf N_{max} / 2^{\lf i / T \rf} \rf, N_{min} \right) \]
The following special cases exist:
\( \begin{align*} T &== 0 \to T = N_{proj} \\ N_{max} &== 0 \to N_{max} = N_{proj} \end{align*} \)
where \( N_{proj} \) denotes the total number of projections in the data set to this instance.
To be functional, this extension needs an actual subset generator to be set (during construction; exchangeable later on through setSubsetGenerator()). Depending on the requirements of the nested generator, the extension does or does not need the AcquisitionSetup that corresponds to the projections that shall be partitioned (see setSetup()). Please refer to the documentation of the specific generator for details on that aspect.
Example:
|
explicit |
Creates a TransitionSchemeExtension using nestedGenerator as actual subset generator.
This instance takes ownership of nestedGenerator.
Make sure to set projection data (see setProjections()) and - if required by the nested generator
The default subset size parameters are as follows:
|
explicit |
Creates a TransitionSchemeExtension using nestedGenerator as actual subset generator.
Make sure to set projection data (see setProjections()) and - if required by the nested generator
The default subset size parameters are as follows:
|
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:
Reimplemented from CTL::AbstractSubsetGenerator.
|
overrideprotectedvirtual |
Implementation of the wrapper for the subset generation routine.
This wraps the call to generateSubsetsImpl() of the nested subset generator. Before passing the call to the nested generator, its number of subsets is set according to the iteration.
For more details on how the subset sizes for a particular iteration are constructed, please refer to the detailed class description or the related setters.
Implements CTL::AbstractSubsetGenerator.
Computes the number of subsets that shall be generated for iteration nb. \iteration.
The number of subsets \( N \) generated in a particular iteration \( i \), can be expressed as follows (given the maximum and minimum subset count as \( N_{max}\) and \( N_{min}\), as well as the transition period \( T \)):
\[ \def\lf{\left\lfloor} \def\rf{\right\rfloor} N(i) = \max \left(\lf N_{max} / 2^{\lf i / T \rf} \rf, N_{min} \right) \]
The following special cases exist:
\( \begin{align*} T &== 0 \to T = N_{proj} \\ N_{max} &== 0 \to N_{max} = N_{proj} \end{align*} \)
where \( N_{proj} \) denotes the total number of projections in the data set to this instance.
void CTL::TransitionSchemeExtension::setMaximumNbSubsets | ( | uint | maxNbSubsets | ) |
Sets the maximum number of subsets generated to maxNbSubsets.
The maximum number of subsets refers to the amount of subsets generated in the first iterations (i.e. before the first transition takes place). If maxNbSubsets = 0, the maximum number of subsets that is generated will be set to the total number of projections available in the data that has been set; thus, resulting in subsets containing a single view each. The default value is 0.
A formal description of the procedure can be found in the detailed class description and in numberOfSubsets().
Example:
void CTL::TransitionSchemeExtension::setMinimumNbSubsets | ( | uint | minNbSubsets | ) |
Sets the minimum number of subsets generated to minNbSubsets.
The minimum number of subsets refers to the lowest number of subsets generated in 'late' iterations (i.e. after enough transitions have taken place to lower the number of subsets to this level). If minNbSubsets = 1, all available projections will eventually end up in a single subset.
minNbSubsets must be larger than zero.
A formal description of the procedure can be found in the detailed class description and in numberOfSubsets().
Example:
|
overridevirtual |
Sets the projections that this instance shall operate on to projections.
This takes a ProjectionDataView to efficiently create subsets without overhead of data copies. Note that the underlying ProjectionData (i.e. the ones the view refers to) must remain valid throughout the entire use time of this instance. That means that all subsets created by this instance (w.r.t. the data from projections) are valid only as long as the ProjectionData projections refers to is valid.
This directly passes the call to the nested generator.
Reimplemented from CTL::AbstractSubsetGenerator.
|
overridevirtual |
Sets the AcquisitionSetup that belongs to the projection data to setup.
Whether or not setting the AcquisitionSetup is required, depends on the nested subset generator that is used. Please refer to the documentation of the nested subset generator for details.
This directly passes the call to the nested generator.
Reimplemented from CTL::AbstractSubsetGenerator.
Sets the number of subsets in the beginning (early iterations) and at the end of transitions (late iterations) to initialNbSubsets and finalNbSubsets, respectively.
This is a convenience method that is a combined call to setMaximumNbSubsets(initialNbSubsets) and setMinimumNbSubsets(finalNbSubsets);
A formal description of the procedure can be found in the detailed class description and in numberOfSubsets().
Example:
void CTL::TransitionSchemeExtension::setSubsetGenerator | ( | AbstractFixedSizeSubsetGenerator * | nestedGenerator | ) |
Sets the nested subset generator to nestedGenerator; deleted previous one.
This replaces the previous nested subset generator by nestedGenerator. This instance takes ownership of nestedGenerator and deletes the previous generator.
nestedGenerator must not be nullptr
.
Note that any previous call to setData() (or setProjections() / setSetup()) needs to be repeated after replacing the subset generator by means of this method. Please also pay attention of any potential differences in the requirements of the newly installed nested generator (such as requirement of the AcquisitionSetup etc.).
void CTL::TransitionSchemeExtension::setSubsetGenerator | ( | std::unique_ptr< AbstractFixedSizeSubsetGenerator > | nestedGenerator | ) |
Sets the nested subset generator to nestedGenerator; deleted previous one.
This replaces the previous nested subset generator by nestedGenerator.
nestedGenerator must not be nullptr
.
Note that any previous call to setData() (or setProjections() / setSetup()) needs to be repeated after replacing the subset generator by means of this method. Please also pay attention of any potential differences in the requirements of the newly installed nested generator (such as requirement of the AcquisitionSetup etc.).
void CTL::TransitionSchemeExtension::setTransitionPeriod | ( | uint | transitionEveryNIterations | ) |
Sets the transition period (i.e. the number of iterations after which the subset count is cut in half) to transitionEveryNIterations.
The transition period is the number of iterations after which the number of generated subsets is cut in half (rounded down). If the result of cutting the number in half deceeds the minimum number of subsets specified for this instance, the minimum value will be used instead (and thus, remains constant for all following iterations).
The number of subsets \( N \) generated in a particular iteration \( i \), can be expressed as follows (given the maximum and minimum subset count as \( N_{max}\) and \( N_{min}\), as well as the transition period \( T \)):
\[ \def\lf{\left\lfloor} \def\rf{\right\rfloor} N(i) = \max \left(\lf N_{max} / 2^{\lf i / T \rf} \rf, N_{min} \right) \]
The following special cases exist:
\( \begin{align*} T &== 0 \to T = N_{proj} \\ N_{max} &== 0 \to N_{max} = N_{proj} \end{align*} \)
where \( N_{proj} \) denotes the total number of projections in the data set to this instance.
Example:
|
overrideprotectedvirtual |
Randomly permutes the order of the subsets in subsets.
This permutes the order in which subsets appear in subsets. Uses std::shuffle in combination with the RNG member of this class.
Shuffling subset order may be beneficial in iterative reconstructions to avoid image artifacts as a result of (overly) structured update schemes.
This method override ensures that shuffling is only performed once. That means if both, the nested generator and this instance itself, have shuffling enabled (see isSubsetPermutationEnabled()), only the shuffling of the nested generator is performed.
Reimplemented from CTL::AbstractSubsetGenerator.
|
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:
Reimplemented from CTL::AbstractSubsetGenerator.
|
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.