3 #include <vnl/vnl_vector_fixed.h>
4 #include <vnl/vnl_copy.h>
5 #include <itkNumericTraits.h>
6 #include <MitkFiberTrackingExports.h>
7 #include <itkMersenneTwisterRandomVariateGenerator.h>
25 const int sampleSteps = 10;
26 vnl_vector_fixed<float, 3> samplePos;
37 for (
int i=-sampleSteps; i <= sampleSteps;i++)
43 ItkQBallImgType::IndexType index;
47 if (
m_Image->GetLargestPossibleRegion().IsInside(index))
64 if (xint >= 0 && xint <
m_Size[0]-1 && yint >= 0 && yint <
m_Size[1]-1 && zint >= 0 && zint <
m_Size[2]-1)
66 float xfrac = Rx-xint;
67 float yfrac = Ry-yint;
68 float zfrac = Rz-zint;
70 ItkQBallImgType::IndexType index;
73 weight = (1-xfrac)*(1-yfrac)*(1-zfrac);
74 index[0] = xint; index[1] = yint; index[2] = zint;
79 weight = (xfrac)*(1-yfrac)*(1-zfrac);
80 index[0] = xint+1; index[1] = yint; index[2] = zint;
85 weight = (1-xfrac)*(yfrac)*(1-zfrac);
86 index[0] = xint; index[1] = yint+1; index[2] = zint;
91 weight = (1-xfrac)*(1-yfrac)*(zfrac);
92 index[0] = xint; index[1] = yint; index[2] = zint+1;
97 weight = (xfrac)*(yfrac)*(1-zfrac);
98 index[0] = xint+1; index[1] = yint+1; index[2] = zint;
103 weight = (1-xfrac)*(yfrac)*(zfrac);
104 index[0] = xint; index[1] = yint+1; index[2] = zint+1;
109 weight = (xfrac)*(1-yfrac)*(zfrac);
110 index[0] = xint+1; index[1] = yint; index[2] = zint+1;
115 weight = (xfrac)*(yfrac)*(zfrac);
116 index[0] = xint+1; index[1] = yint+1; index[2] = zint+1;
123 result /= (2*sampleSteps+1);
130 return itk::NumericTraits<float>::NonpositiveMin();
137 while (neighbour!=
nullptr)
142 float dot = fabs(dot_product(N,neighbour->
GetDir()));
144 float dpos = (neighbour->
GetPos()-R).squared_magnitude();
179 if (p2->
mID == p1->
ID)
181 else if (p2->
pID == p1->
ID)
184 std::cout <<
"EnergyComputer: Connections are inconsistent!" << std::endl;
193 return itk::NumericTraits<float>::NonpositiveMin();
201 return itk::NumericTraits<float>::NonpositiveMin();
204 vnl_vector_fixed<float, 3> R = (p2->
GetPos() + p1->
GetPos()); R *= 0.5;
208 return itk::NumericTraits<float>::NonpositiveMin();
211 float norm1 = (endPoint1-R).squared_magnitude();
212 float norm2 = (endPoint2-R).squared_magnitude();
vnl_vector_fixed< float, 3 > interpw
A particle is the basic element of the Gibbs fiber tractography method.
vnl_vector_fixed< float, 3 > & GetDir()
vnl_vector_fixed< float, 3 > m_Spacing
float EvaluateOdf(vnl_vector_fixed< float, 3 > &pos, vnl_vector_fixed< float, 3 > dir)
void ComputeNeighbors(vnl_vector_fixed< float, 3 > &R)
Contains and manages particles.
Calculates internal and external energy of the new particle configuration proposal.
vnl_matrix_fixed< float, 3, 3 > m_RotationMatrix
DataCollection - Class to facilitate loading/accessing structured data.
SphereInterpolator * m_SphereInterpolator
vnl_vector_fixed< int, 3 > idx
Lookuptable based trilinear interpolation of spherically arranged scalar values.
itk::Image< float, 3 > ItkFloatImageType
vnl_vector_fixed< int, 3 > m_Size
vnl_vector_fixed< float, 3 > & GetPos()
Particle * GetParticle(int ID)
void getInterpolation(const vnl_vector_fixed< float, 3 > &N)
float ComputeExternalEnergy(vnl_vector_fixed< float, 3 > &R, vnl_vector_fixed< float, 3 > &N, Particle *dp) override
virtual ~GibbsEnergyComputer()
float m_CurvatureThreshold
ParticleGrid * m_ParticleGrid
GibbsEnergyComputer(ItkQBallImgType *qballImage, ItkFloatImageType *mask, ParticleGrid *particleGrid, SphereInterpolator *interpolator, ItkRandGenType *randGen)
float ComputeInternalEnergyConnection(Particle *p1, int ep1) override
itk::Image< OdfVectorType, 3 > ItkQBallImgType
float m_ConnectionPotential
bool m_UseTrilinearInterpolation
float m_SquaredParticleLength
itk::Statistics::MersenneTwisterRandomVariateGenerator ItkRandGenType
Particle * GetNextNeighbor()
float m_ParticleChemicalPotential
ItkQBallImgType * m_Image
float ComputeInternalEnergy(Particle *dp) override
float SpatProb(vnl_vector_fixed< float, 3 > pos)