Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMetropolisHastingsSampler.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _SAMPLER
18 #define _SAMPLER
19 
20 // MITK
21 #include <MitkFiberTrackingExports.h>
22 #include <mitkParticleGrid.h>
23 #include <mitkEnergyComputer.h>
24 #include <mitkSimpSamp.h>
25 
26 // ITK
27 #include <itkImage.h>
28 #include <itkTimeProbe.h>
29 #include <itkMersenneTwisterRandomVariateGenerator.h>
30 
31 // MISC
32 #include <fstream>
33 
34 namespace mitk
35 {
36 
40 class MITKFIBERTRACKING_EXPORT MetropolisHastingsSampler
41 {
42 public:
43 
44  typedef itk::Image< float, 3 > ItkFloatImageType;
45  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator ItkRandGenType;
46 
47  MetropolisHastingsSampler(ParticleGrid* grid, EnergyComputer* enComp, ItkRandGenType* randGen, float curvThres);
48  void SetTemperature(float val);
49 
50  void MakeProposal();
51  int GetNumAcceptedProposals();
52  void SetProbabilities(float birth, float death, float shift, float optShift, float connect);
53  void PrintProposalTimes();
54 
55 protected:
56 
58  void ImplementTrack(Track& T);
59  void RemoveAndSaveTrack(EndPoint P);
60  void MakeTrackProposal(EndPoint P);
61  void ComputeEndPointProposalDistribution(EndPoint P);
62 
64  void DistortVector(float sigma, vnl_vector_fixed<float, 3>& vec);
65  vnl_vector_fixed<float, 3> GetRandomDirection();
66 
67  ItkRandGenType* m_RandGen;
71 
72  float m_InTemp;
73  float m_ExTemp;
74  float m_Density;
75 
76  float m_BirthProb;
77  float m_DeathProb;
78  float m_ShiftProb;
81 
82  float m_Sigma;
83  float m_Gamma;
84  float m_Z;
85 
88  float m_TractProb;
89  float m_StopProb;
90  float m_DelProb;
93 
96  unsigned int m_AcceptedProposals;
97 
99  itk::TimeProbe m_BirthTime;
100  itk::TimeProbe m_DeathTime;
101  itk::TimeProbe m_ShiftTime;
102  itk::TimeProbe m_OptShiftTime;
103  itk::TimeProbe m_ConnectionTime;
104 };
105 
106 }
107 
108 #endif
109 
110 
Track m_ProposalTrack
stores proposal track
Contains and manages particles.
float m_ConnectionProb
probability for particle connection proposal
Calculates internal and external energy of the new particle configuration proposal.
SimpSamp m_SimpSamp
neighbouring particles and their probabilities for the local tracking
float m_DeathProb
probability for particle death
DataCollection - Class to facilitate loading/accessing structured data.
float m_OptShiftProb
probability for optimal particle shift
ParticleGrid * m_ParticleGrid
storest all particles
float m_BirthProb
probability for particle birth
float m_ExTemp
simulated annealing temperature
unsigned int m_AcceptedProposals
counts accepted proposals
EnergyComputer * m_EnergyComputer
computes internal and external energy of particles
Samples new tract from surrounding fiber segments.
Definition: mitkSimpSamp.h:32
Generates ne proposals of particle configurations.
itk::Statistics::MersenneTwisterRandomVariateGenerator ItkRandGenType
float m_InTemp
simulated annealing temperature
float m_ShiftProb
probability for particle shift
float m_CurvatureThreshold
threshold for maximum angle between connected particles
ItkRandGenType * m_RandGen
random generator
Track m_BackupTrack
stores track removed for new proposal traCK
float m_DistanceThreshold
threshold for maximum distance between connected particles