Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::CorrelationCalculator< T > Class Template Reference

Class to calculate covariance and correlation. More...

#include <mitkCorrelationCalculator.h>

Inheritance diagram for mitk::CorrelationCalculator< T >:
Collaboration diagram for mitk::CorrelationCalculator< T >:

Public Types

enum  ParcelMode { UseAverageTimeSeries, UseMaximumCorrelation, UseAverageCorrelation }
 The ParcelMode enum defines how to define the correlation between two parcels. More...
 

Public Member Functions

 mitkClassMacroItkParent (CorrelationCalculator, itk::Object)
 
Pointer Clone () const
 
std::vector< double > ExtractAverageTimeSeriesOfParcel (int parcelValue)
 Extracts the average time series from a roi defined by the parcellation image. More...
 
void DoWholeCorrelation ()
 Create a #voxel x #voxel correlation matrix. More...
 
void DoParcelCorrelation (ParcelMode mode=UseAverageTimeSeries)
 Create a #parcel x #parcel correlation matrix. More...
 
virtual void Modified ()
 Marks average time series as invalid and calls superclass modified. More...
 
const vnl_matrix< double > * GetCorrelationMatrix () const
 
const std::map< unsigned int, int > * GetLabelOrderMap () const
 
mitk::ConnectomicsNetwork::Pointer GetConnectomicsNetwork ()
 
virtual void SetParcellationImage (mitk::Image::Pointer _arg)
 
virtual void SetTimeSeriesImage (mitk::Image::Pointer _arg)
 

Static Public Member Functions

static Pointer New ()
 
static double CalculatePearsonCorrelationCoefficient (const std::vector< T > &one, const std::vector< T > &two)
 Calculate and return the pearson correlation coefficient for two vectors of data. More...
 
static double CalculateCovariance (const std::vector< T > &one, const std::vector< T > &two)
 Calculates the covariance of two vectors of data. More...
 

Protected Member Functions

virtual void Modified () const override
 
 CorrelationCalculator ()
 
virtual ~CorrelationCalculator ()
 
template<typename TPixel , unsigned int VImageDimension>
void ExtractAllAverageTimeSeries (itk::Image< TPixel, VImageDimension > *itkTimeSeriesImage)
 
void ExtractCenterOfMassForParcels ()
 
double GetParcelCorrelation (const int &parcelA, const int &parcelB, ParcelMode &mode) const
 

Protected Attributes

bool m_InvalidTimeSeries
 
mitk::Image::Pointer m_ParcellationImage
 
mitk::Image::Pointer m_TimeSeriesImage
 
std::map< int, std::vector< double > > m_AverageTimeSeries
 
std::map< int, std::vector< std::vector< T > > > m_ParcelTimeSeries
 
std::map< int, mitk::Point3Dm_ParcelCenterOfMass
 
vnl_matrix< double > m_CorrelationMatrix
 
std::map< unsigned int, int > m_LabelOrderMap
 

Detailed Description

template<class T>
class mitk::CorrelationCalculator< T >

Class to calculate covariance and correlation.

In addition to static functions to calculate covariance and correlation, this class offers capability to set a time series image and optionally a parcellation image and calculate a correlation matrix.

Whole correlation only needs a time series image and will return a #voxel x #voxel matrix where each voxel's time series is correlated against the time series of each other voxel.

Parcel correlation will compute an average time series for each parcel of a parcellation image and create a #parcel x #parcel correlation matrix.

Please note that time series images are assumed to be 4D and parcellation images integer valued and 3D.

Definition at line 48 of file mitkCorrelationCalculator.h.

Member Enumeration Documentation

template<class T >
enum mitk::CorrelationCalculator::ParcelMode

The ParcelMode enum defines how to define the correlation between two parcels.

Available choices are:

  1. UseAverageTimeSeries - Average time series across the parcel, correlate average time series between parcels
  2. UseMaximumCorrelation - Correlate all voxels of the parcels with each other, use maximum correlation
  3. UseAverageCorrelation - Correlate all voxels of the parcels with each other, use average correlation
Enumerator
UseAverageTimeSeries 
UseMaximumCorrelation 
UseAverageCorrelation 

Definition at line 68 of file mitkCorrelationCalculator.h.

Constructor & Destructor Documentation

template<class T >
mitk::CorrelationCalculator< T >::CorrelationCalculator ( )
protected
template<class T >
virtual mitk::CorrelationCalculator< T >::~CorrelationCalculator ( )
protectedvirtual

Member Function Documentation

template<class T >
static double mitk::CorrelationCalculator< T >::CalculateCovariance ( const std::vector< T > &  one,
const std::vector< T > &  two 
)
static

Calculates the covariance of two vectors of data.

Expects two vectors of the same length and data type and returns the covariance of the two. Variance can be calculated by providing the same data vector twice.

Parameters
onefirst data vector
twosecond data vector
Returns
covariance of the two
template<class T >
static double mitk::CorrelationCalculator< T >::CalculatePearsonCorrelationCoefficient ( const std::vector< T > &  one,
const std::vector< T > &  two 
)
static

Calculate and return the pearson correlation coefficient for two vectors of data.

This function expects two vectors of the same length and data type and calculates the pearson correlation coefficient.

Parameters
onefirst data vector
twosecond data vector
Returns
pearson correlation coefficent
template<class T >
Pointer mitk::CorrelationCalculator< T >::Clone ( ) const
template<class T >
void mitk::CorrelationCalculator< T >::DoParcelCorrelation ( ParcelMode  mode = UseAverageTimeSeries)

Create a #parcel x #parcel correlation matrix.

template<class T >
void mitk::CorrelationCalculator< T >::DoWholeCorrelation ( )

Create a #voxel x #voxel correlation matrix.

template<class T >
template<typename TPixel , unsigned int VImageDimension>
void mitk::CorrelationCalculator< T >::ExtractAllAverageTimeSeries ( itk::Image< TPixel, VImageDimension > *  itkTimeSeriesImage)
protected
template<class T >
std::vector< double > mitk::CorrelationCalculator< T >::ExtractAverageTimeSeriesOfParcel ( int  parcelValue)

Extracts the average time series from a roi defined by the parcellation image.

This function requires a parcellation image and a time series image to be set and registered to each other. For each voxel in the time series image it will check whether it is inside the specified parcel of the parcellation image. All inside voxels will be averaged for all time steps and an average time series is returned.

Calculates and saves the averages for all parcellations, to speed up consecutive calls.

Parameters
parcelValuethe voxel value of the roi in the parcellation image.
Returns
vector of the average values of the roi for each timestep
template<class T >
void mitk::CorrelationCalculator< T >::ExtractCenterOfMassForParcels ( )
protected
template<class T >
mitk::ConnectomicsNetwork::Pointer mitk::CorrelationCalculator< T >::GetConnectomicsNetwork ( )
template<class T >
const vnl_matrix< double >* mitk::CorrelationCalculator< T >::GetCorrelationMatrix ( ) const
template<class T >
const std::map< unsigned int, int >* mitk::CorrelationCalculator< T >::GetLabelOrderMap ( ) const
template<class T >
double mitk::CorrelationCalculator< T >::GetParcelCorrelation ( const int &  parcelA,
const int &  parcelB,
ParcelMode mode 
) const
protected
template<class T >
mitk::CorrelationCalculator< T >::mitkClassMacroItkParent ( CorrelationCalculator< T >  ,
itk::Object   
)
template<class T >
virtual void mitk::CorrelationCalculator< T >::Modified ( )
virtual

Marks average time series as invalid and calls superclass modified.

template<class T >
virtual void mitk::CorrelationCalculator< T >::Modified ( ) const
overrideprotectedvirtual
template<class T >
static Pointer mitk::CorrelationCalculator< T >::New ( )
static
template<class T >
virtual void mitk::CorrelationCalculator< T >::SetParcellationImage ( mitk::Image::Pointer  _arg)
virtual
template<class T >
virtual void mitk::CorrelationCalculator< T >::SetTimeSeriesImage ( mitk::Image::Pointer  _arg)
virtual

Member Data Documentation

template<class T >
std::map< int, std::vector<double> > mitk::CorrelationCalculator< T >::m_AverageTimeSeries
protected

Definition at line 159 of file mitkCorrelationCalculator.h.

template<class T >
vnl_matrix< double > mitk::CorrelationCalculator< T >::m_CorrelationMatrix
protected

Definition at line 164 of file mitkCorrelationCalculator.h.

template<class T >
bool mitk::CorrelationCalculator< T >::m_InvalidTimeSeries
protected

Definition at line 154 of file mitkCorrelationCalculator.h.

template<class T >
std::map< unsigned int, int > mitk::CorrelationCalculator< T >::m_LabelOrderMap
protected

Definition at line 166 of file mitkCorrelationCalculator.h.

template<class T >
std::map< int, mitk::Point3D > mitk::CorrelationCalculator< T >::m_ParcelCenterOfMass
protected

Definition at line 162 of file mitkCorrelationCalculator.h.

template<class T >
mitk::Image::Pointer mitk::CorrelationCalculator< T >::m_ParcellationImage
protected

Definition at line 156 of file mitkCorrelationCalculator.h.

template<class T >
std::map< int, std::vector<std::vector< T > > > mitk::CorrelationCalculator< T >::m_ParcelTimeSeries
protected

Definition at line 160 of file mitkCorrelationCalculator.h.

template<class T >
mitk::Image::Pointer mitk::CorrelationCalculator< T >::m_TimeSeriesImage
protected

Definition at line 157 of file mitkCorrelationCalculator.h.


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