3 #include <itkVectorImage.h> 6 #include <vtkPolyData.h> 7 #include <vtkSmartPointer.h> 8 #include <itkProcessObject.h> 9 #include <itkLinearInterpolateImageFunction.h> 11 #include <itkProgressReporter.h> 19 template <
class TInputModelImageType>
54 typedef itk::VariableLengthVector <ScalarType>
VectorType;
76 bool operator() (
const std::pair<unsigned int, double> & f,
const std::pair<unsigned int, double> & s)
77 {
return (f.second < s.second); }
138 itkSetMacro(NumberOfParticles,
unsigned int)
139 itkSetMacro(NumberOfFibersPerPixel,
unsigned int)
140 itkSetMacro(ResamplingThreshold,
double)
142 itkSetMacro(StepProgression,
double)
144 itkSetMacro(MinLengthFiber,
double)
145 itkSetMacro(MaxLengthFiber,
double)
147 itkSetMacro(FiberTrashThreshold,
double)
149 itkSetMacro(KappaOfPriorDistribution,
double)
150 itkGetMacro(KappaOfPriorDistribution,
double)
152 itkSetMacro(PositionDistanceFuseThreshold,
double)
153 itkSetMacro(KappaSplitThreshold,
double)
155 itkSetMacro(ClusterDistance,
unsigned int)
157 itkSetMacro(ComputeLocalColors,
bool)
158 itkSetMacro(MAPMergeFibers,
bool)
160 itkSetMacro(MinimalNumberOfParticlesPerClass,
unsigned int)
162 itkSetMacro(ModelDimension,
unsigned int)
163 itkGetMacro(ModelDimension,
unsigned int)
165 void Update() ITK_OVERRIDE;
175 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
ThreadTracker(
void *arg);
182 ListType &resultWeights,
unsigned int startSeedIndex,
183 unsigned int endSeedIndex);
187 unsigned int numThread,
ListType &resultWeights);
205 Vector3DType &sampling_direction,
double &log_prior,
double &log_proposal,
206 std::mt19937 &random_generator,
unsigned int threadId) = 0;
210 double &log_prior,
double &log_proposal,
unsigned int threadId) = 0;
228 unsigned int m_ModelDimension;
230 unsigned int m_NumberOfParticles;
231 unsigned int m_NumberOfFibersPerPixel;
232 unsigned int m_MinimalNumberOfParticlesPerClass;
234 double m_StepProgression;
236 double m_MinLengthFiber;
237 double m_MaxLengthFiber;
239 double m_FiberTrashThreshold;
241 double m_ResamplingThreshold;
243 double m_KappaOfPriorDistribution;
255 std::vector <std::mt19937> m_Generators;
265 double m_PositionDistanceFuseThreshold;
266 double m_KappaSplitThreshold;
268 unsigned int m_ClusterDistance;
270 bool m_MAPMergeFibers;
271 bool m_ComputeLocalColors;
273 vtkSmartPointer<vtkPolyData> m_Output;
275 std::mutex m_LockHighestProcessedSeed;
276 int m_HighestProcessedSeed;
277 itk::ProgressReporter *m_ProgressReport;
itk::Matrix< ScalarType, 3, 3 > Matrix3DType
std::vector< bool > stoppedParticles
virtual Vector3DType InitializeFirstIterationFromModel(Vector3DType &colinearDir, VectorType &modelValue, unsigned int threadId)=0
Initialize first direction from user input (model dependent, not implemented here) ...
MembershipType classMemberships
void createVTKOutput(FiberProcessVectorType &filteredFibers, ListType &filteredWeights)
FiberProcessVectorType ComputeFiber(FiberType &fiber, InterpolatorPointer &modelInterpolator, unsigned int numThread, ListType &resultWeights)
This little guy is the one handling probabilistic tracking.
MaskImageType::IndexType IndexType
virtual bool CheckModelProperties(double estimatedB0Value, double estimatedNoiseValue, VectorType &modelValue, unsigned int threadId)=0
Check stopping criterions to stop a particle (model dependent, not implemented here) ...
virtual void ComputeModelValue(InterpolatorPointer &modelInterpolator, ContinuousIndexType &index, VectorType &modelValue)=0
Estimate model from raw diffusion data (model dependent, not implemented here)
MaskImageType::PointType PointType
BaseProbabilisticTractographyImageFilter()
MaskImageType::Pointer MaskImagePointer
void Update() ITK_OVERRIDE
void ThreadedTrackComputer(unsigned int numThread, FiberProcessVectorType &resultFibers, ListType &resultWeights, unsigned int startSeedIndex, unsigned int endSeedIndex)
Doing the real tracking by calling ComputeFiber and merging its results.
BaseProbabilisticTractographyImageFilter Self
std::vector< unsigned int > MembershipType
MembershipType classSizes
bool operator()(const std::pair< unsigned int, double > &f, const std::pair< unsigned int, double > &s)
InputModelImageType * GetInputModelImage()
itk::SmartPointer< const Self > ConstPointer
FiberProcessVectorType FilterOutputFibers(FiberProcessVectorType &fibers, ListType &weights)
Filter output fibers by ROIs and compute local colors.
std::vector< FiberType > FiberProcessVectorType
virtual double ComputeLogWeightUpdate(double b0Value, double noiseValue, Vector3DType &newDirection, VectorType &modelValue, double &log_prior, double &log_proposal, unsigned int threadId)=0
Update particle weight based on an underlying model and the chosen direction (model dependent...
virtual ~BaseProbabilisticTractographyImageFilter()
itk::Image< unsigned short, 3 > MaskImageType
itk::InterpolateImageFunction< InputModelImageType > InterpolatorType
BaseProbabilisticTractographyImageFilter * trackerPtr
itk::Image< ScalarType, 3 > ScalarImageType
itk::LinearInterpolateImageFunction< ScalarImageType > ScalarInterpolatorType
itk::Vector< ScalarType, 3 > Vector3DType
FiberProcessVectorType fiberParticles
bool MergeParticleClassFibers(FiberWorkType &fiberData, FiberProcessVectorType &outputMerged, unsigned int classNumber)
This guy takes the result of computefiber and merges the classes, each one becomes one fiber...
itk::SmartPointer< Self > Pointer
std::vector< ListType > resultWeightsFromThreads
std::vector< MembershipType > reverseClassMemberships
unsigned int UpdateClassesMemberships(FiberWorkType &fiberData, DirectionVectorType &directions, std::mt19937 &random_generator)
This ugly guy is the heart of multi-modal probabilistic tractography, making decisions on split and m...
ScalarInterpolatorType::Pointer ScalarInterpolatorPointer
vtkPolyData * GetOutput()
void SetInitialColinearityDirection(const ColinearityDirectionType &colDir)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ThreadTracker(void *arg)
Multithread util function.
ColinearityDirectionType
Which direction should the very first direction point to? (used in conjunction with InitialDirectionM...
ScalarImageType::Pointer ScalarImagePointer
void ThreadTrack(unsigned int numThread, FiberProcessVectorType &resultFibers, ListType &resultWeights)
Doing the thread work dispatch.
virtual Vector3DType ProposeNewDirection(Vector3DType &oldDirection, VectorType &modelValue, Vector3DType &sampling_direction, double &log_prior, double &log_proposal, std::mt19937 &random_generator, unsigned int threadId)=0
Propose new direction for a particle, given the old direction, and a model (model dependent...
std::vector< FiberProcessVectorType > resultFibersFromThreads
std::vector< ScalarType > ListType
virtual void SetInputModelImage(InputModelImageType *inImage)
InputModelImageType::Pointer InputModelImagePointer
virtual void PrepareTractography()
Generate seed points (can be re-implemented but this one has to be called)
itk::VariableLengthVector< ScalarType > VectorType
std::vector< PointType > FiberType
InterpolatorType::ContinuousIndexType ContinuousIndexType
InterpolatorType::Pointer InterpolatorPointer
itk::VectorImage< double, 3 > InputModelImageType
InitialDirectionModeType
Tells how to choose the very first direction of each particle Colinear: Most colinear to colinear dir...
virtual void ComputeAdditionalScalarMaps()
Computes additional scalar maps that are model dependent to add to the output.
virtual InterpolatorType * GetModelInterpolator()
itk::ProcessObject Superclass
std::vector< Vector3DType > DirectionVectorType
void SetInitialDirectionMode(const InitialDirectionModeType &dir)