17 #ifndef _TrackingForestHandler
18 #define _TrackingForestHandler
25 #include <itkMersenneTwisterRandomVariateGenerator.h>
30 #define VIGRA_STATIC_LIB
31 #include <vigra/random_forest.hxx>
32 #include <vigra/multi_array.hxx>
33 #include <vigra/random_forest_hdf5_impex.hxx>
35 #define _USE_MATH_DEFINES
44 template<
int ShOrder=6,
int NumberOfSignalFeatures=100 >
62 for (
auto fib : tractograms)
84 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);
103 std::shared_ptr< vigra::RandomForest<int> >
m_Forest;
105 std::chrono::time_point<std::chrono::system_clock>
m_EndTime;
std::vector< int > m_DirectionIndices
maps each of the NumberOfSignalFeatures possible output directions to one of the 2*NumberOfSignalFeat...
void SetMaxTreeDepth(int depth)
std::chrono::time_point< std::chrono::system_clock > m_EndTime
itk::SmartPointer< Self > Pointer
std::vector< Image::Pointer > m_RawData
original input DWI data
std::vector< ItkUcharImgType::Pointer > m_WhiteMatterImages
defines white matter voxels. if not set, theses mask images are automatically generated from the inpu...
vigra::MultiArray< 2, double > m_FeatureData
vigra container for training features
unsigned int m_NumberOfSamples
stores overall number of samples used for training
int m_NumTrees
number of trees in random forest
void PreprocessInputDataForTraining()
Generate masks if necessary, resample fibers, spherically interpolate raw DWIs.
void SetGrayMatterSamplesPerVoxel(int samples)
void SetTractograms(std::vector< FiberBundle::Pointer > tractograms)
itk::OrientationDistributionFunction< double, NumberOfSignalFeatures *2 > m_DirContainer
direction container
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< unsigned int > m_GmSamples
number of gray matter samples
std::shared_ptr< vigra::RandomForest< int > > m_Forest
random forest classifier
std::shared_ptr< vigra::RandomForest< int > > GetForest()
void SetSampleFraction(double fraction)
void SetRawData(std::vector< Image::Pointer > images)
void LoadForest(std::string forestFile)
Manages random forests for fiber tractography. The preparation of the features from the inputa data a...
std::chrono::time_point< std::chrono::system_clock > m_StartTime
void SetStepSize(double step)
void InputDataValidForTracking()
check if raw data is set and tracking forest is valid
double m_SampleFraction
fraction of samples used to train each tree
int m_MaxTreeDepth
limits the tree depth
FeatureImageType::Pointer m_FeatureImage
feature image used for tracking
std::vector< typename InterpolatedRawImageType::Pointer > m_InterpolatedRawImages
spherically interpolated and resampled raw datasets
vigra::MultiArray< 2, double > m_LabelData
vigra container for training labels
int m_GmSamplesPerVoxel
number of gray matter samplees per voxel. if -1, then the number is automatically chosen to gain an o...
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
double m_WmSampleDistance
deterines the number of white matter samples (distance of sampling points on each fiber)...
void SetWhiteMatterImages(std::vector< ItkUcharImgType::Pointer > images)
void CalculateFeaturesForTraining()
Calculate GM and WM features using the interpolated raw data, the WM masks and the fibers...
itk::Image< Vector< float, NumberOfSignalFeatures >, 3 > FeatureImageType
void SaveForest(std::string forestFile)
InterpolatedRawImageType::PixelType GetImageValues(itk::Point< float, 3 > itkP, typename InterpolatedRawImageType::Pointer image)
get trilinearly interpolated raw image values at given world position
void InputDataValidForTraining()
Check if everything is tehere for training (raw datasets, fiber tracts)
void InitForTracking()
calls InputDataValidForTracking() and creates feature images from the war input DWI ...
std::vector< FiberBundle::Pointer > m_Tractograms
training tractograms
void AddRawData(Image::Pointer img)
FeatureImageType::PixelType GetFeatureValues(itk::Point< float, 3 > itkP)
get trilinearly interpolated feature values at given world position
itk::Image< itk::Vector< float, NumberOfSignalFeatures *2 >, 3 > InterpolatedRawImageType
void TrainForest()
start training process
itk::Image< unsigned char, 3 > ItkUcharImgType
void SetNumTrees(int num)
void SetMaskImages(std::vector< ItkUcharImgType::Pointer > images)
section MAP_FRAME_Mapper_Settings Mapper settings For the mapping of corrected images
bool IsForestValid()
true is forest is not null, has more than 0 trees and the correct number of features (NumberOfSignalF...
std::vector< ItkUcharImgType::Pointer > m_MaskImages
binary mask images to constrain training to a certain area (e.g. brain mask)