Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkCorrelationCalculator.h
Go to the documentation of this file.
1 
2 /*===================================================================
3 
4 The Medical Imaging Interaction Toolkit (MITK)
5 
6 Copyright (c) German Cancer Research Center,
7 Division of Medical and Biological Informatics.
8 All rights reserved.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without
11 even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE.
13 
14 See LICENSE.txt or http://www.mitk.org for details.
15 
16 ===================================================================*/
17 
18 #ifndef _MITK_CORRELATIONCALCULATOR_H
19 #define _MITK_CORRELATIONCALCULATOR_H
20 
21 #include "mitkCommon.h"
22 #include <itkObject.h>
23 #include <mitkImage.h>
24 #include <vnl/vnl_matrix.h>
26 
27 namespace mitk {
28 
47  template< class T >
48  class CorrelationCalculator : public itk::Object
49  {
50 
51  public:
52 
53  // Standard macros
55  itkFactorylessNewMacro(Self)
56  itkCloneMacro(Self)
57 
58 
69  {
73  };
74 
85  static double CalculatePearsonCorrelationCoefficient( const std::vector<T>& one, const std::vector<T>& two );
86 
97  static double CalculateCovariance( const std::vector<T>& one, const std::vector<T>& two );
98 
112  std::vector< double > ExtractAverageTimeSeriesOfParcel( int parcelValue );
113 
117  void DoWholeCorrelation();
118 
123 
127  virtual void Modified();
128 
129  const vnl_matrix< double >* GetCorrelationMatrix() const;
130  const std::map< unsigned int, int >* GetLabelOrderMap() const;
132 
133  // Get/Set macros
134  itkSetMacro(ParcellationImage, mitk::Image::Pointer)
135  itkSetMacro(TimeSeriesImage, mitk::Image::Pointer)
136 
137  protected:
138 
139  // intentionally not accessible, use our non-const Modified function instead
140  virtual void Modified() const override;
141 
143  virtual ~CorrelationCalculator();
144 
145  template< typename TPixel, unsigned int VImageDimension >
146  void ExtractAllAverageTimeSeries( itk::Image< TPixel, VImageDimension>* itkTimeSeriesImage );
147 
149 
150 
151  double GetParcelCorrelation(const int& parcelA,const int& parcelB, ParcelMode& mode) const;
152 
153  // Member variables
155 
158 
159  std::map< int, std::vector<double> > m_AverageTimeSeries;
160  std::map< int, std::vector<std::vector< T > > > m_ParcelTimeSeries;
161 
163 
164  vnl_matrix< double > m_CorrelationMatrix;
165 
166  std::map< unsigned int, int > m_LabelOrderMap;
167  };
168 
169 }
170 
171 #include <mitkCorrelationCalculator.txx>
172 
173 #endif /* _MITK_CORRELATIONCALCULATOR_H */
mitkClassMacroItkParent(CorrelationCalculator, itk::Object)
void DoParcelCorrelation(ParcelMode mode=UseAverageTimeSeries)
Create a #parcel x #parcel correlation matrix.
static double CalculateCovariance(const std::vector< T > &one, const std::vector< T > &two)
Calculates the covariance of two vectors of data.
Class to calculate covariance and correlation.
virtual void Modified()
Marks average time series as invalid and calls superclass modified.
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
std::map< int, std::vector< double > > m_AverageTimeSeries
ParcelMode
The ParcelMode enum defines how to define the correlation between two parcels.
void ExtractAllAverageTimeSeries(itk::Image< TPixel, VImageDimension > *itkTimeSeriesImage)
std::map< int, std::vector< std::vector< T > > > m_ParcelTimeSeries
std::vector< double > ExtractAverageTimeSeriesOfParcel(int parcelValue)
Extracts the average time series from a roi defined by the parcellation image.
const vnl_matrix< double > * GetCorrelationMatrix() const
double GetParcelCorrelation(const int &parcelA, const int &parcelB, ParcelMode &mode) const
Image class for storing images.
Definition: mitkImage.h:76
void DoWholeCorrelation()
Create a #voxel x #voxel correlation matrix.
std::map< int, mitk::Point3D > m_ParcelCenterOfMass
mitk::ConnectomicsNetwork::Pointer GetConnectomicsNetwork()
std::map< unsigned int, int > m_LabelOrderMap
const std::map< unsigned int, int > * GetLabelOrderMap() const
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. ...