27 , m_ConnectionProb(0.45)
30 , m_ChempotParticle(0.0)
31 , m_AcceptedProposals(0)
61 m_ConnectionProb /= sum;
63 std::cout <<
"Update proposal probabilities" << std::endl;
68 std::cout <<
"Connection: " << m_ConnectionProb << std::endl;
75 std::cout <<
"Proposal time probes (toal%/mean)" << std::endl;
76 std::cout <<
"Birth: " << 100*
m_BirthTime.GetTotal()/sum <<
"/" <<
m_BirthTime.GetMean()*1000 << std::endl;
77 std::cout <<
"Death: " << 100*
m_DeathTime.GetTotal()/sum <<
"/" <<
m_DeathTime.GetMean()*1000 << std::endl;
78 std::cout <<
"Shift: " << 100*
m_ShiftTime.GetTotal()/sum <<
"/" <<
m_ShiftTime.GetMean()*1000 << std::endl;
93 vec[0] +=
m_RandGen->GetNormalVariate(0.0, sigma);
94 vec[1] +=
m_RandGen->GetNormalVariate(0.0, sigma);
95 vec[2] +=
m_RandGen->GetNormalVariate(0.0, sigma);
101 vnl_vector_fixed<float, 3> vec;
118 vnl_vector_fixed<float, 3> R;
131 if (prob > 1 ||
m_RandGen->GetVariate() < prob)
151 if (dp->
pID == -1 && dp->
mID == -1)
158 if (prob > 1 ||
m_RandGen->GetVariate() < prob)
179 prop_p.
GetDir().normalize();
189 vnl_vector_fixed<float, 3> Rtmp = p->
GetPos();
190 vnl_vector_fixed<float, 3> Ntmp = p->
GetDir();
212 bool no_proposal =
false;
214 if (p->
pID != -1 && p->
mID != -1)
217 int ep_plus = (plus->
pID == p->
ID)? 1 : -1;
219 int ep_minus = (minus->
pID == p->
ID)? 1 : -1;
223 prop_p.
GetDir().normalize();
225 else if (p->
pID != -1)
228 int ep_plus = (plus->
pID == p->
ID)? 1 : -1;
232 else if (p->
mID != -1)
235 int ep_minus = (minus->
pID == p->
ID)? 1 : -1;
255 vnl_vector_fixed<float, 3> Rtmp = p->
GetPos();
256 vnl_vector_fixed<float, 3> Ntmp = p->
GetDir();
322 float AccumProb = 1.0;
331 if (Current.
p->
pID != -1)
338 else if (Current.
ep == -1)
340 if (Current.
p->
mID != -1)
348 { fprintf(stderr,
"MetropolisHastingsSampler_randshift: Connection inconsistent 3\n");
break; }
350 if (Next.
p ==
nullptr)
357 if (Next.
p->
pID == Current.
p->
ID)
362 else if (Next.
p->
mID == Current.
p->
ID)
368 { fprintf(stderr,
"MetropolisHastingsSampler_randshift: Connection inconsistent 4\n");
break; }
374 if (Next.
p ==
nullptr)
398 float AccumProb = 1.0;
405 if ((Current.
ep == 1 && Current.
p->
pID != -1) || (Current.
ep == -1 && Current.
p->
mID != -1))
425 AccumProb *= probability;
460 if (p2 ==
nullptr)
break;
461 if (p!=p2 && p2->
label == 0)
void CreateConnection(Particle *P1, int ep1, Particle *P2, int ep2)
void add(float p, EndPoint obj)
Track m_ProposalTrack
stores proposal track
A particle is the basic element of the Gibbs fiber tractography method.
vnl_vector_fixed< float, 3 > & GetDir()
void ImplementTrack(Track &T)
void SetProbabilities(float birth, float death, float shift, float optShift, float connect)
update the probabilities of the single proposals
virtual float ComputeInternalEnergy(Particle *dp)=0
void ComputeNeighbors(vnl_vector_fixed< float, 3 > &R)
Contains and manages particles.
std::vector< EndPoint > track
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
int GetNumAcceptedProposals()
float m_DeathProb
probability for particle death
DataCollection - Class to facilitate loading/accessing structured data.
void PrintProposalTimes()
print the state of the proposal time probes
itk::TimeProbe m_OptShiftTime
float m_OptShiftProb
probability for optimal particle shift
vnl_vector_fixed< float, 3 > & GetPos()
ParticleGrid * m_ParticleGrid
storest all particles
float m_BirthProb
probability for particle birth
Particle * GetParticle(int ID)
itk::TimeProbe m_BirthTime
float m_ExTemp
simulated annealing temperature
unsigned int m_AcceptedProposals
counts accepted proposals
virtual float ComputeExternalEnergy(vnl_vector_fixed< float, 3 > &R, vnl_vector_fixed< float, 3 > &N, Particle *dp)=0
EnergyComputer * m_EnergyComputer
computes internal and external energy of particles
void MakeTrackProposal(EndPoint P)
void DrawRandomPosition(vnl_vector_fixed< float, 3 > &R)
vnl_vector_fixed< float, 3 > GetRandomDirection()
void RemoveParticle(int k)
MetropolisHastingsSampler(ParticleGrid *grid, EnergyComputer *enComp, ItkRandGenType *randGen, float curvThres)
itk::Statistics::MersenneTwisterRandomVariateGenerator ItkRandGenType
itk::TimeProbe m_DeathTime
float m_InTemp
simulated annealing temperature
void ComputeEndPointProposalDistribution(EndPoint P)
float m_ShiftProb
probability for particle shift
itk::TimeProbe m_ShiftTime
float m_CurvatureThreshold
threshold for maximum angle between connected particles
MITKCORE_EXPORT const ScalarType eps
virtual float ComputeInternalEnergyConnection(Particle *p1, int ep1)=0
ItkRandGenType * m_RandGen
random generator
Track m_BackupTrack
stores track removed for new proposal traCK
itk::TimeProbe m_ConnectionTime
Particle * GetNextNeighbor()
void MakeProposal()
make proposal for birth/death/shift/connection of particles
float m_DistanceThreshold
threshold for maximum distance between connected particles
Particle * NewParticle(vnl_vector_fixed< float, 3 > R)
void RemoveAndSaveTrack(EndPoint P)
bool TryUpdateGrid(int k)
void DistortVector(float sigma, vnl_vector_fixed< float, 3 > &vec)
void SetTemperature(float val)