Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
QmitkDataGeneratorBase Class Referenceabstract

QmitkDataGeneratorBase BaseClass that implements the organization of (statistic) data generation for pairs of images and ROIs. The key idea is that this class ensures that for vector of given image ROI pairs (defined by derived classes) a result instance (e.g ImageStatisticsContainer) will be calculated, if needed (e.g. because it is missing or not up to date anymore), and stored in the data storage passed to a generator instance. While derived classes i.a. specify how to generate the image ROI pairs, how to detect latest results, what the next generation step is and how to remove obsolete data from the storage, the base class takes care of the observation of the data storage and orchestrates the whole checking and generation workflow. In all the generation/orchestration process the data storage, passed to the generator, 1) serves as place where the final results are stored and searched and 2) it resembles the state of the generation process with these final results and WIP place holder nodes that indicate planed or currently processed generation steps. More...

#include <QmitkDataGeneratorBase.h>

Inheritance diagram for QmitkDataGeneratorBase:
Collaboration diagram for QmitkDataGeneratorBase:

Public Types

using JobResultMapType = QmitkDataGenerationJobBase::ResultMapType
 

Public Slots

void SetDataStorage (mitk::DataStorage *storage)
 
void SetAutoUpdate (bool autoUpdate)
 

Signals

void DataGenerationStarted (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode, const QmitkDataGenerationJobBase *job) const
 Signal that is emitted if a data generation job is started to generate outdated/inexistent data. More...
 
void NewDataAvailable (mitk::DataStorage::SetOfObjects::ConstPointer data) const
 Signal that is emitted if new final data is produced. More...
 
void GenerationFinished () const
 Signal that is emitted if all jobs are finished and everything is up to date. More...
 
void JobError (QString error, const QmitkDataGenerationJobBase *failedJob) const
 Signal that is emitted in case of job errors. More...
 

Public Member Functions

 QmitkDataGeneratorBase (const QmitkDataGeneratorBase &other)=delete
 
QmitkDataGeneratorBaseoperator= (const QmitkDataGeneratorBase &other)=delete
 
virtual ~QmitkDataGeneratorBase ()
 
mitk::DataStorage::Pointer GetDataStorage () const
 
bool GetAutoUpdate () const
 
bool IsGenerating () const
 
bool Generate () const
 
virtual bool IsValidResultAvailable (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
 

Protected Types

using InputPairVectorType = std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > >
 

Protected Slots

void OnJobError (QString error, const QmitkDataGenerationJobBase *failedJob) const
 
void OnFinalResultsAvailable (JobResultMapType results, const QmitkDataGenerationJobBase *job) const
 

Protected Member Functions

 QmitkDataGeneratorBase (mitk::DataStorage::Pointer storage, QObject *parent=nullptr)
 Constructor. More...
 
 QmitkDataGeneratorBase (QObject *parent=nullptr)
 
virtual bool ChangedNodeIsRelevant (const mitk::DataNode *changedNode) const =0
 
virtual InputPairVectorType GetAllImageROICombinations () const =0
 
virtual void IndicateFutureResults (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
 
virtual std::pair< QmitkDataGenerationJobBase *, mitk::DataNode::PointerGetNextMissingGenerationJob (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
 Is called to generate the next job instance that needs to be done and is associated dummy node in order to progress the data generation workflow. More...
 
virtual void RemoveObsoleteDataNodes (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
 
virtual mitk::DataNode::Pointer PrepareResultForStorage (const std::string &label, mitk::BaseData *result, const QmitkDataGenerationJobBase *job) const =0
 
InputPairVectorType FilterImageROICombinations (InputPairVectorType &&imageROICombinations) const
 
std::string GetPairDescription (const InputPairVectorType::value_type &imageAndSeg) const
 
bool DoGenerate () const
 
void EnsureRecheckingAndGeneration () const
 

Static Protected Member Functions

static mitk::DataNode::Pointer CreateWIPDataNode (mitk::BaseData *dataDummy, const std::string &nodeName)
 

Protected Attributes

mitk::WeakPointer< mitk::DataStoragem_Storage
 
bool m_AutoUpdate
 
std::mutex m_DataMutex
 
itk::TimeStamp m_GenerationTime
 

Detailed Description

QmitkDataGeneratorBase BaseClass that implements the organization of (statistic) data generation for pairs of images and ROIs. The key idea is that this class ensures that for vector of given image ROI pairs (defined by derived classes) a result instance (e.g ImageStatisticsContainer) will be calculated, if needed (e.g. because it is missing or not up to date anymore), and stored in the data storage passed to a generator instance. While derived classes i.a. specify how to generate the image ROI pairs, how to detect latest results, what the next generation step is and how to remove obsolete data from the storage, the base class takes care of the observation of the data storage and orchestrates the whole checking and generation workflow. In all the generation/orchestration process the data storage, passed to the generator, 1) serves as place where the final results are stored and searched and 2) it resembles the state of the generation process with these final results and WIP place holder nodes that indicate planed or currently processed generation steps.

Definition at line 41 of file QmitkDataGeneratorBase.h.

Member Typedef Documentation

◆ InputPairVectorType

◆ JobResultMapType

Constructor & Destructor Documentation

◆ QmitkDataGeneratorBase() [1/3]

QmitkDataGeneratorBase::QmitkDataGeneratorBase ( const QmitkDataGeneratorBase other)
delete

◆ ~QmitkDataGeneratorBase()

virtual QmitkDataGeneratorBase::~QmitkDataGeneratorBase ( )
virtual

◆ QmitkDataGeneratorBase() [2/3]

QmitkDataGeneratorBase::QmitkDataGeneratorBase ( mitk::DataStorage::Pointer  storage,
QObject *  parent = nullptr 
)
protected

Constructor.

Parameters
storagethe data storage where all produced data should be stored
parent

◆ QmitkDataGeneratorBase() [3/3]

QmitkDataGeneratorBase::QmitkDataGeneratorBase ( QObject *  parent = nullptr)
protected

Member Function Documentation

◆ ChangedNodeIsRelevant()

virtual bool QmitkDataGeneratorBase::ChangedNodeIsRelevant ( const mitk::DataNode changedNode) const
protectedpure virtual

This method must be implemented by derived to indicate if a changed node is relevant and therefore if an update must be triggered.

Implemented in QmitkImageAndRoiDataGeneratorBase, and QmitkImageStatisticsDataGenerator.

◆ CreateWIPDataNode()

static mitk::DataNode::Pointer QmitkDataGeneratorBase::CreateWIPDataNode ( mitk::BaseData dataDummy,
const std::string &  nodeName 
)
staticprotected

Creates a data node for WIP place holder results. It can be used by IndicateFutureResults().

◆ DataGenerationStarted

void QmitkDataGeneratorBase::DataGenerationStarted ( const mitk::DataNode imageNode,
const mitk::DataNode roiNode,
const QmitkDataGenerationJobBase job 
) const
signal

Signal that is emitted if a data generation job is started to generate outdated/inexistent data.

◆ DoGenerate()

bool QmitkDataGeneratorBase::DoGenerate ( ) const
protected

Internal part of the generation strategy. Here is where the heavy lifting is done.

◆ EnsureRecheckingAndGeneration()

void QmitkDataGeneratorBase::EnsureRecheckingAndGeneration ( ) const
protected

Methods either directly calls generation or if its already ongoing flags to restart the generation.

◆ FilterImageROICombinations()

InputPairVectorType QmitkDataGeneratorBase::FilterImageROICombinations ( InputPairVectorType &&  imageROICombinations) const
protected

Filters a passed pair vector. The returned pair vector only contains pair of nodes that exist in the data storage.

◆ Generate()

bool QmitkDataGeneratorBase::Generate ( ) const

Checks data validity and triggers generation of data, if needed. The generation itself will be done with a thread pool and is orchestrated by this class. To learn if the threads are finished and everything is uptodate, listen to the signal GenerationFinished.

Returns
indicates if everything is already valid (true) or if the generation of new data was triggered (false).

◆ GenerationFinished

void QmitkDataGeneratorBase::GenerationFinished ( ) const
signal

Signal that is emitted if all jobs are finished and everything is up to date.

◆ GetAllImageROICombinations()

virtual InputPairVectorType QmitkDataGeneratorBase::GetAllImageROICombinations ( ) const
protectedpure virtual

This method must be implemented by derived classes to return the pairs of images and ROIs (ROI may be null if no ROI is needed) for which data are needed.

Implemented in QmitkImageAndRoiDataGeneratorBase.

◆ GetAutoUpdate()

bool QmitkDataGeneratorBase::GetAutoUpdate ( ) const

Indicates if the generator may trigger the update automatically (true). Reasons for an update are:

  • Input data has been changed or modified
  • Generation relevant settings in derived classes have been changed (must be implemented in derived classes)

◆ GetDataStorage()

mitk::DataStorage::Pointer QmitkDataGeneratorBase::GetDataStorage ( ) const

◆ GetNextMissingGenerationJob()

virtual std::pair<QmitkDataGenerationJobBase*,mitk::DataNode::Pointer> QmitkDataGeneratorBase::GetNextMissingGenerationJob ( const mitk::DataNode imageNode,
const mitk::DataNode roiNode 
) const
protectedpure virtual

Is called to generate the next job instance that needs to be done and is associated dummy node in order to progress the data generation workflow.

Remarks
The method can assume that the caller takes care of the job instance deletion.
Returns
std::pair of job pointer and placeholder node associated with the job. Following combinations are possible:
  • Both are null: nothing to do;
  • Both are set: there is something to do for a pending dummy node -> trigger computation;
  • Job null and node set: a job for this node is already work in progress -> pass on till its finished.

Implemented in QmitkImageStatisticsDataGenerator.

◆ GetPairDescription()

std::string QmitkDataGeneratorBase::GetPairDescription ( const InputPairVectorType::value_type &  imageAndSeg) const
protected

Return a descriptive label of a passed pair. Used e.g. for some debug log messages.

◆ IndicateFutureResults()

virtual void QmitkDataGeneratorBase::IndicateFutureResults ( const mitk::DataNode imageNode,
const mitk::DataNode roiNode 
) const
protectedpure virtual

This method should indicate all missing and outdated (interim) results in the data storage, with new placeholder nodes and WIP dummy data added to the storage. The placeholder nodes will be replaced by the real results as soon as they are ready. The strategy how to detect which placeholder node is need and how the dummy data should look like must be implemented by derived classes.

Implemented in QmitkImageStatisticsDataGenerator.

◆ IsGenerating()

bool QmitkDataGeneratorBase::IsGenerating ( ) const

Indicates if there is currently work in progress, thus data generation jobs are running or pending. It is set to true when GenerationStarted is triggered and becomes false as soon as GenerationFinished is triggered.

◆ IsValidResultAvailable()

virtual bool QmitkDataGeneratorBase::IsValidResultAvailable ( const mitk::DataNode imageNode,
const mitk::DataNode roiNode 
) const
pure virtual

Indicates if for a given image and ROI a valid final result is available.

Implemented in QmitkImageStatisticsDataGenerator.

◆ JobError

void QmitkDataGeneratorBase::JobError ( QString  error,
const QmitkDataGenerationJobBase failedJob 
) const
signal

Signal that is emitted in case of job errors.

◆ NewDataAvailable

void QmitkDataGeneratorBase::NewDataAvailable ( mitk::DataStorage::SetOfObjects::ConstPointer  data) const
signal

Signal that is emitted if new final data is produced.

◆ OnFinalResultsAvailable

void QmitkDataGeneratorBase::OnFinalResultsAvailable ( JobResultMapType  results,
const QmitkDataGenerationJobBase job 
) const
protectedslot

Used by QmitkDataGenerationJobBase to signal and communicate the results of there computation.

◆ OnJobError

void QmitkDataGeneratorBase::OnJobError ( QString  error,
const QmitkDataGenerationJobBase failedJob 
) const
protectedslot

Used by QmitkDataGenerationJobBase to signal the generator that an error occurred.

◆ operator=()

QmitkDataGeneratorBase& QmitkDataGeneratorBase::operator= ( const QmitkDataGeneratorBase other)
delete

◆ PrepareResultForStorage()

virtual mitk::DataNode::Pointer QmitkDataGeneratorBase::PrepareResultForStorage ( const std::string &  label,
mitk::BaseData result,
const QmitkDataGenerationJobBase job 
) const
protectedpure virtual

Prepares result to be added to the storage in an appropriate way and returns the data node for that.

Implemented in QmitkImageStatisticsDataGenerator.

◆ RemoveObsoleteDataNodes()

virtual void QmitkDataGeneratorBase::RemoveObsoleteDataNodes ( const mitk::DataNode imageNode,
const mitk::DataNode roiNode 
) const
protectedpure virtual

Remove all obsolete data nodes for the given image and ROI node from the data storage. Obsolete nodes are (interim) result nodes that are not the most recent any more.

Implemented in QmitkImageStatisticsDataGenerator.

◆ SetAutoUpdate

void QmitkDataGeneratorBase::SetAutoUpdate ( bool  autoUpdate)
slot

◆ SetDataStorage

void QmitkDataGeneratorBase::SetDataStorage ( mitk::DataStorage storage)
slot

Sets the data storage the generator should monitor and where WIP placeholder nodes and final result nodes should be stored.

Member Data Documentation

◆ m_AutoUpdate

bool QmitkDataGeneratorBase::m_AutoUpdate
protected

Definition at line 154 of file QmitkDataGeneratorBase.h.

◆ m_DataMutex

std::mutex QmitkDataGeneratorBase::m_DataMutex
mutableprotected

Definition at line 156 of file QmitkDataGeneratorBase.h.

◆ m_GenerationTime

itk::TimeStamp QmitkDataGeneratorBase::m_GenerationTime
mutableprotected

Time stamp for the last successful run through with the current image roi pairs.

Definition at line 159 of file QmitkDataGeneratorBase.h.

◆ m_Storage

mitk::WeakPointer<mitk::DataStorage> QmitkDataGeneratorBase::m_Storage
protected

Definition at line 152 of file QmitkDataGeneratorBase.h.


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