18 #include <vnl/vnl_copy.h>
19 #include <itkNumericTraits.h>
24 : m_UseTrilinearInterpolation(true)
35 m_Size[0] = mask->GetLargestPossibleRegion().GetSize()[0];
36 m_Size[1] = mask->GetLargestPossibleRegion().GetSize()[1];
37 m_Size[2] = mask->GetLargestPossibleRegion().GetSize()[2];
47 vnl_matrix<double> temp = mask->GetDirection().GetVnlMatrix();
48 vnl_matrix<float> directionMatrix; directionMatrix.set_size(3,3);
49 vnl_copy(temp, directionMatrix);
50 vnl_matrix_fixed<float, 3, 3> I = directionMatrix*directionMatrix.transpose();
51 for (
int i = 0; i < 3; i++)
52 for (
int j = 0; j < 3; j++)
53 I[i][j] = fabs(I[i][j]);
54 if(!I.is_identity(0.001))
56 fprintf(stderr,
"EnergyComputer: image direction is not a rotation matrix. Tracking not possible!\n");
57 std::cout << directionMatrix << std::endl;
62 fprintf(stderr,
"EnergyComputer: error during init: data does not match with interpolation scheme\n");
71 for (
int x = 0; x < m_Size[0];x++)
72 for (
int y = 0; y < m_Size[1];y++)
73 for (
int z = 0; z < m_Size[2];z++)
75 int idx = x+(y+z*m_Size[1])*m_Size[0];
76 ItkFloatImageType::IndexType index;
77 index[0] = x; index[1] = y; index[2] = z;
78 if (
m_Mask->GetPixel(index) > 0.5)
88 std::cout <<
"EnergyComputer: " << m_NumActiveVoxels <<
" active voxels found" << std::endl;
91 void EnergyComputer::SetParameters(
float particleWeight,
float particleWidth,
float connectionPotential,
float curvThres,
float inexBalance,
float particlePotential)
97 float bal = 1/(1+exp(-inexBalance));
103 float sigma_s = particleWidth;
138 ItkFloatImageType::IndexType index;
143 if (
m_Mask->GetLargestPossibleRegion().IsInside(index))
144 return m_Mask->GetPixel(index);
165 return((x>=7.0) ? 0 : ((x>=5.0) ? (-0.0029*x+0.0213) : ((x>=3.0) ? (-0.0215*x+0.1144) : ((x>=2.0) ? (-0.0855*x+0.3064) : ((x>=1.0) ? (-0.2325*x+0.6004) : ((x>=0.5) ? (-0.4773*x+0.8452) : ((x>=0.0) ? (-0.7869*x+1.0000) : 1 )))))));
std::vector< int > m_ActiveIndices
vnl_vector_fixed< float, 3 > m_Spacing
std::vector< float > m_CumulatedSpatialProbability
Contains and manages particles.
vnl_matrix_fixed< float, 3, 3 > m_RotationMatrix
DataCollection - Class to facilitate loading/accessing structured data.
SphereInterpolator * m_SphereInterpolator
Lookuptable based trilinear interpolation of spherically arranged scalar values.
itk::Image< float, 3 > ItkFloatImageType
vnl_vector_fixed< int, 3 > m_Size
ItkRandGenType * m_RandGen
void DrawRandomPosition(vnl_vector_fixed< float, 3 > &R)
void SetParameters(float particleWeight, float particleWidth, float connectionPotential, float curvThres, float inexBalance, float particlePotential)
EnergyComputer(ItkFloatImageType *mask, ParticleGrid *particleGrid, SphereInterpolator *interpolator, ItkRandGenType *randGen)
float m_CurvatureThreshold
ParticleGrid * m_ParticleGrid
float m_ConnectionPotential
bool m_UseTrilinearInterpolation
float m_SquaredParticleLength
itk::Statistics::MersenneTwisterRandomVariateGenerator ItkRandGenType
float m_ParticleChemicalPotential
ItkFloatImageType * m_Mask
float SpatProb(vnl_vector_fixed< float, 3 > pos)