Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures > Class Template Reference

Manages random forests for fiber tractography. The preparation of the features from the inputa data and the training process are handled here. The data preprocessing and actual prediction for the tracking process is also performed here. The tracking itself is performed in MLBSTrackingFilter. More...

#include <mitkTrackingForestHandler.h>

Inheritance diagram for mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >:
Collaboration diagram for mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >:

Public Types

typedef itk::Image< unsigned char, 3 > ItkUcharImgType
 
typedef itk::Image< itk::Vector< float, NumberOfSignalFeatures *2 >, 3 > InterpolatedRawImageType
 
typedef itk::Image< Vector< float, NumberOfSignalFeatures >, 3 > FeatureImageType
 

Public Member Functions

 TrackingForestHandler ()
 
 ~TrackingForestHandler ()
 
void SetRawData (std::vector< Image::Pointer > images)
 
void AddRawData (Image::Pointer img)
 
void SetTractograms (std::vector< FiberBundle::Pointer > tractograms)
 
void SetMaskImages (std::vector< ItkUcharImgType::Pointer > images)
 
void SetWhiteMatterImages (std::vector< ItkUcharImgType::Pointer > images)
 
void StartTraining ()
 
void SaveForest (std::string forestFile)
 
void LoadForest (std::string forestFile)
 
void SetNumTrees (int num)
 
void SetMaxTreeDepth (int depth)
 
void SetStepSize (double step)
 
void SetGrayMatterSamplesPerVoxel (int samples)
 
void SetSampleFraction (double fraction)
 
std::shared_ptr< vigra::RandomForest< int > > GetForest ()
 
void InitForTracking ()
 calls InputDataValidForTracking() and creates feature images from the war input DWI More...
 
vnl_vector_fixed< double, 3 > Classify (itk::Point< double, 3 > &pos, int &candidates, vnl_vector_fixed< double, 3 > &olddir, double angularThreshold, double &w, ItkUcharImgType::Pointer mask=nullptr)
 predicts next progression direction at the given position More...
 
bool IsForestValid ()
 true is forest is not null, has more than 0 trees and the correct number of features (NumberOfSignalFeatures + 3) More...
 

Protected Member Functions

void InputDataValidForTracking ()
 check if raw data is set and tracking forest is valid More...
 
FeatureImageType::PixelType GetFeatureValues (itk::Point< float, 3 > itkP)
 get trilinearly interpolated feature values at given world position More...
 
void InputDataValidForTraining ()
 Check if everything is tehere for training (raw datasets, fiber tracts) More...
 
void PreprocessInputDataForTraining ()
 Generate masks if necessary, resample fibers, spherically interpolate raw DWIs. More...
 
void CalculateFeaturesForTraining ()
 Calculate GM and WM features using the interpolated raw data, the WM masks and the fibers. More...
 
void TrainForest ()
 start training process More...
 
InterpolatedRawImageType::PixelType GetImageValues (itk::Point< float, 3 > itkP, typename InterpolatedRawImageType::Pointer image)
 get trilinearly interpolated raw image values at given world position More...
 

Protected Attributes

std::vector< Image::Pointerm_RawData
 original input DWI data More...
 
std::shared_ptr< vigra::RandomForest< int > > m_Forest
 random forest classifier More...
 
std::chrono::time_point< std::chrono::system_clock > m_StartTime
 
std::chrono::time_point< std::chrono::system_clock > m_EndTime
 
std::vector< FiberBundle::Pointerm_Tractograms
 training tractograms More...
 
std::vector< ItkUcharImgType::Pointer > m_MaskImages
 binary mask images to constrain training to a certain area (e.g. brain mask) More...
 
std::vector< ItkUcharImgType::Pointer > m_WhiteMatterImages
 defines white matter voxels. if not set, theses mask images are automatically generated from the input tractograms More...
 
std::vector< typename InterpolatedRawImageType::Pointer > m_InterpolatedRawImages
 spherically interpolated and resampled raw datasets More...
 
double m_WmSampleDistance
 deterines the number of white matter samples (distance of sampling points on each fiber). More...
 
int m_NumTrees
 number of trees in random forest More...
 
int m_MaxTreeDepth
 limits the tree depth More...
 
double m_SampleFraction
 fraction of samples used to train each tree More...
 
unsigned int m_NumberOfSamples
 stores overall number of samples used for training More...
 
std::vector< unsigned int > m_GmSamples
 number of gray matter samples More...
 
int m_GmSamplesPerVoxel
 number of gray matter samplees per voxel. if -1, then the number is automatically chosen to gain an overall number of GM samples close to the number of WM samples. More...
 
vigra::MultiArray< 2, double > m_FeatureData
 vigra container for training features More...
 
FeatureImageType::Pointer m_FeatureImage
 feature image used for tracking More...
 
vigra::MultiArray< 2, double > m_LabelData
 vigra container for training labels More...
 
std::vector< int > m_DirectionIndices
 maps each of the NumberOfSignalFeatures possible output directions to one of the 2*NumberOfSignalFeatures ODF directions. More...
 
itk::OrientationDistributionFunction< double, NumberOfSignalFeatures *2 > m_DirContainer
 direction container More...
 

Detailed Description

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
class mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >

Manages random forests for fiber tractography. The preparation of the features from the inputa data and the training process are handled here. The data preprocessing and actual prediction for the tracking process is also performed here. The tracking itself is performed in MLBSTrackingFilter.

Definition at line 45 of file mitkTrackingForestHandler.h.

Member Typedef Documentation

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
typedef itk::Image< Vector< float, NumberOfSignalFeatures > , 3 > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::FeatureImageType

Definition at line 55 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
typedef itk::Image< itk::Vector< float, NumberOfSignalFeatures*2 > , 3 > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::InterpolatedRawImageType

Definition at line 54 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
typedef itk::Image<unsigned char, 3> mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::ItkUcharImgType

Definition at line 53 of file mitkTrackingForestHandler.h.

Constructor & Destructor Documentation

template<int ShOrder, int NumberOfSignalFeatures>
mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::TrackingForestHandler ( )

Definition at line 27 of file mitkTrackingForestHandler.cpp.

template<int ShOrder, int NumberOfSignalFeatures>
mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::~TrackingForestHandler ( )

Definition at line 38 of file mitkTrackingForestHandler.cpp.

Member Function Documentation

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::AddRawData ( Image::Pointer  img)
inline

Definition at line 58 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::CalculateFeaturesForTraining ( )
protected

Calculate GM and WM features using the interpolated raw data, the WM masks and the fibers.

Definition at line 484 of file mitkTrackingForestHandler.cpp.

References itk::OrientationDistributionFunction< TComponent, NOdfDirections >::GetDirection(), MITK_INFO, and mitk::New().

template<int ShOrder, int NumberOfSignalFeatures>
vnl_vector_fixed< double, 3 > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::Classify ( itk::Point< double, 3 > &  pos,
int &  candidates,
vnl_vector_fixed< double, 3 > &  olddir,
double  angularThreshold,
double &  w,
ItkUcharImgType::Pointer  mask = nullptr 
)

predicts next progression direction at the given position

Definition at line 245 of file mitkTrackingForestHandler.cpp.

template<int ShOrder, int NumberOfSignalFeatures>
TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::FeatureImageType::PixelType mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::GetFeatureValues ( itk::Point< float, 3 >  itkP)
protected

get trilinearly interpolated feature values at given world position

Definition at line 172 of file mitkTrackingForestHandler.cpp.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::shared_ptr< vigra::RandomForest<int> > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::GetForest ( )
inline

Definition at line 81 of file mitkTrackingForestHandler.h.

template<int ShOrder, int NumberOfSignalFeatures>
TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::InterpolatedRawImageType::PixelType mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::GetImageValues ( itk::Point< float, 3 >  itkP,
typename InterpolatedRawImageType::Pointer  image 
)
protected

get trilinearly interpolated raw image values at given world position

Definition at line 43 of file mitkTrackingForestHandler.cpp.

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::InputDataValidForTracking ( )
protected

check if raw data is set and tracking forest is valid

Definition at line 116 of file mitkTrackingForestHandler.cpp.

References mitkThrow.

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::InputDataValidForTraining ( )
protected

Check if everything is tehere for training (raw datasets, fiber tracts)

Definition at line 346 of file mitkTrackingForestHandler.cpp.

References mitkThrow.

template<int ShOrder, int NumberOfSignalFeatures>
bool mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::IsForestValid ( )

true is forest is not null, has more than 0 trees and the correct number of features (NumberOfSignalFeatures + 3)

Definition at line 357 of file mitkTrackingForestHandler.cpp.

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::LoadForest ( std::string  forestFile)

Definition at line 696 of file mitkTrackingForestHandler.cpp.

References MITK_INFO.

Referenced by main().

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::PreprocessInputDataForTraining ( )
protected
template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SaveForest ( std::string  forestFile)

Definition at line 685 of file mitkTrackingForestHandler.cpp.

References MITK_INFO.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetGrayMatterSamplesPerVoxel ( int  samples)
inline

Definition at line 79 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetMaskImages ( std::vector< ItkUcharImgType::Pointer >  images)
inline

Definition at line 67 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetMaxTreeDepth ( int  depth)
inline

Definition at line 77 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetNumTrees ( int  num)
inline

Definition at line 76 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetRawData ( std::vector< Image::Pointer images)
inline

Definition at line 57 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetSampleFraction ( double  fraction)
inline

Definition at line 80 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetStepSize ( double  step)
inline

Definition at line 78 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetTractograms ( std::vector< FiberBundle::Pointer tractograms)
inline

Definition at line 59 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::SetWhiteMatterImages ( std::vector< ItkUcharImgType::Pointer >  images)
inline

Definition at line 68 of file mitkTrackingForestHandler.h.

Referenced by main().

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::StartTraining ( )

Definition at line 331 of file mitkTrackingForestHandler.cpp.

References MITK_INFO.

Referenced by main().

template<int ShOrder, int NumberOfSignalFeatures>
void mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::TrainForest ( )
protected

start training process

Definition at line 648 of file mitkTrackingForestHandler.cpp.

References MITK_INFO.

Member Data Documentation

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
itk::OrientationDistributionFunction< double, NumberOfSignalFeatures*2 > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_DirContainer
protected

direction container

Definition at line 125 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< int > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_DirectionIndices
protected

maps each of the NumberOfSignalFeatures possible output directions to one of the 2*NumberOfSignalFeatures ODF directions.

Definition at line 124 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::chrono::time_point<std::chrono::system_clock> mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_EndTime
protected

Definition at line 105 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
vigra::MultiArray<2, double> mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_FeatureData
protected

vigra container for training features

Definition at line 119 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
FeatureImageType::Pointer mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_FeatureImage
protected

feature image used for tracking

Definition at line 122 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::shared_ptr< vigra::RandomForest<int> > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_Forest
protected

random forest classifier

Definition at line 103 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::GetForest().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< unsigned int > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_GmSamples
protected

number of gray matter samples

Definition at line 117 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
int mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_GmSamplesPerVoxel
protected

number of gray matter samplees per voxel. if -1, then the number is automatically chosen to gain an overall number of GM samples close to the number of WM samples.

Definition at line 118 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetGrayMatterSamplesPerVoxel().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< typename InterpolatedRawImageType::Pointer > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_InterpolatedRawImages
protected

spherically interpolated and resampled raw datasets

Definition at line 111 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
vigra::MultiArray<2, double> mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_LabelData
protected

vigra container for training labels

Definition at line 123 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< ItkUcharImgType::Pointer > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_MaskImages
protected

binary mask images to constrain training to a certain area (e.g. brain mask)

Definition at line 109 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetMaskImages().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
int mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_MaxTreeDepth
protected

limits the tree depth

Definition at line 114 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetMaxTreeDepth().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
unsigned int mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_NumberOfSamples
protected

stores overall number of samples used for training

Definition at line 116 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
int mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_NumTrees
protected

number of trees in random forest

Definition at line 113 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetNumTrees().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< Image::Pointer > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_RawData
protected
template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
double mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_SampleFraction
protected

fraction of samples used to train each tree

Definition at line 115 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetSampleFraction().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::chrono::time_point<std::chrono::system_clock> mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_StartTime
protected

Definition at line 104 of file mitkTrackingForestHandler.h.

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< FiberBundle::Pointer > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_Tractograms
protected

training tractograms

Definition at line 108 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetTractograms().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
std::vector< ItkUcharImgType::Pointer > mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_WhiteMatterImages
protected

defines white matter voxels. if not set, theses mask images are automatically generated from the input tractograms

Definition at line 110 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetWhiteMatterImages().

template<int ShOrder = 6, int NumberOfSignalFeatures = 100>
double mitk::TrackingForestHandler< ShOrder, NumberOfSignalFeatures >::m_WmSampleDistance
protected

deterines the number of white matter samples (distance of sampling points on each fiber).

Definition at line 112 of file mitkTrackingForestHandler.h.

Referenced by mitk::TrackingForestHandler< ShOrder >::SetStepSize().


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