Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkStreamlineTrackingFilter.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 /*===================================================================
18 
19 This file is based heavily on a corresponding ITK filter.
20 
21 ===================================================================*/
22 #ifndef __itkStreamlineTrackingFilter_h_
23 #define __itkStreamlineTrackingFilter_h_
24 
25 #include <MitkFiberTrackingExports.h>
26 #include <itkImageToImageFilter.h>
27 #include <itkVectorContainer.h>
28 #include <itkVectorImage.h>
29 #include <itkDiffusionTensor3D.h>
30 #include <vtkSmartPointer.h>
31 #include <vtkPolyData.h>
32 #include <vtkCellArray.h>
33 #include <vtkPoints.h>
34 #include <vtkPolyLine.h>
35 
36 namespace itk{
37 
41  template< class TTensorPixelType, class TPDPixelType=double>
43  public ImageToImageFilter< Image< DiffusionTensor3D<TTensorPixelType>, 3 >,
44  Image< Vector< TPDPixelType, 3 >, 3 > >
45  {
46 
47  public:
48 
52  typedef ImageToImageFilter< Image< DiffusionTensor3D<TTensorPixelType>, 3 >, Image< Vector< TPDPixelType, 3 >, 3 > > Superclass;
53 
55  itkFactorylessNewMacro(Self)
56  itkCloneMacro(Self)
57 
59  itkTypeMacro(StreamlineTrackingFilter, ImageToImageFilter)
60 
62  typedef TPDPixelType DirectionPixelType;
63  typedef typename Superclass::InputImageType InputImageType;
64  typedef typename Superclass::OutputImageType OutputImageType;
65  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
66  typedef itk::Image<unsigned char, 3> ItkUcharImgType;
67  typedef itk::Image<double, 3> ItkDoubleImgType;
68  typedef itk::Image<float, 3> ItkFloatImgType;
69  typedef itk::Image< vnl_vector_fixed<double,3>, 3> ItkPDImgType;
70  typedef vtkSmartPointer< vtkPolyData > FiberPolyDataType;
71 
72  itkGetMacro( FiberPolyData, FiberPolyDataType )
73  itkSetMacro( SeedImage, ItkUcharImgType::Pointer)
74  itkSetMacro( MaskImage, ItkUcharImgType::Pointer)
75  itkSetMacro( FaImage, ItkFloatImgType::Pointer)
76  itkSetMacro( SeedsPerVoxel, int)
77  itkSetMacro( FaThreshold, double)
78  itkSetMacro( StepSize, double)
79  itkSetMacro( F, double )
80  itkSetMacro( G, double )
81  itkSetMacro( Interpolate, bool )
82  itkSetMacro( MinTractLength, double )
83  itkGetMacro( MinTractLength, double )
84  itkSetMacro( MinCurvatureRadius, double )
85  itkGetMacro( MinCurvatureRadius, double )
86  itkSetMacro( ResampleFibers, bool )
87 
88  protected:
89  StreamlineTrackingFilter();
90  ~StreamlineTrackingFilter() {}
91  void PrintSelf(std::ostream& os, Indent indent) const;
92 
93  void CalculateNewPosition(itk::ContinuousIndex<double, 3>& pos, vnl_vector_fixed<double,3>& dir, typename InputImageType::IndexType& index);
94  double FollowStreamline(itk::ContinuousIndex<double, 3> pos, int dirSign, vtkPoints* points, std::vector< vtkIdType >& ids, int imageIdx);
95  bool IsValidPosition(itk::ContinuousIndex<double, 3>& pos, typename InputImageType::IndexType& index, vnl_vector_fixed< double, 8 >& interpWeights, int imageIdx);
96 
97  double RoundToNearest(double num);
99  void ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId);
101 
103 
105  vtkSmartPointer<vtkPoints> m_Points;
106  vtkSmartPointer<vtkCellArray> m_Cells;
107 
108  std::vector< ItkDoubleImgType::Pointer > m_EmaxImage;
110  std::vector< ItkPDImgType::Pointer > m_PdImage;
111  std::vector< typename InputImageType::Pointer > m_InputImage;
112 
116  double m_StepSize;
120  double m_F;
121  double m_G;
125  std::vector< int > m_ImageSize;
126  std::vector< double > m_ImageSpacing;
129 
131 
132  private:
133 
134  };
135 
136 }
137 
138 #ifndef ITK_MANUAL_INSTANTIATION
140 #endif
141 
142 #endif //__itkStreamlineTrackingFilter_h_
143 
std::vector< typename InputImageType::Pointer > m_InputImage
Input tensor images. For multi tensor tracking provide multiple tensor images.
itk::SmartPointer< Self > Pointer
Performes deterministic streamline tracking on the input tensor image.
itk::VectorContainer< int, FiberPolyDataType >::Pointer m_PolyDataContainer
void CalculateNewPosition(itk::ContinuousIndex< double, 3 > &pos, vnl_vector_fixed< double, 3 > &dir, typename InputImageType::IndexType &index)
Calculate next integration step.
itk::Image< unsigned char, 3 > SeedImage
double FollowStreamline(itk::ContinuousIndex< double, 3 > pos, int dirSign, vtkPoints *points, std::vector< vtkIdType > &ids, int imageIdx)
Start streamline in one direction.
vtkSmartPointer< vtkCellArray > m_Cells
std::vector< ItkPDImgType::Pointer > m_PdImage
Stores principal direction of each tensor in each voxel.
vtkSmartPointer< vtkPoints > m_Points
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
ImageToImageFilter< Image< DiffusionTensor3D< TTensorPixelType >, 3 >, Image< Vector< TPDPixelType, 3 >, 3 > > Superclass
FiberPolyDataType AddPolyData(FiberPolyDataType poly1, FiberPolyDataType poly2)
Combine tracking results generated by the individual threads.
void PrintSelf(std::ostream &os, Indent indent) const
ItkFloatImgType::Pointer m_FaImage
FA image used to determine streamline termination.
Superclass::OutputImageType OutputImageType
Superclass::InputImageType InputImageType
class ITK_EXPORT Image
itk::Image< unsigned char, 3 > ItkUcharImgType
SmartPointer< const Self > ConstPointer
double TTensorPixelType
vtkSmartPointer< vtkPolyData > FiberPolyDataType
itk::Image< vnl_vector_fixed< double, 3 >, 3 > ItkPDImgType
bool IsValidPosition(itk::ContinuousIndex< double, 3 > &pos, typename InputImageType::IndexType &index, vnl_vector_fixed< double, 8 > &interpWeights, int imageIdx)
Are we outside of the mask image? Is the FA too low?
std::vector< ItkDoubleImgType::Pointer > m_EmaxImage
Stores largest eigenvalues per voxel (one for each tensor)
Superclass::OutputImageRegionType OutputImageRegionType