Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkTensorReconstructionWithEigenvalueCorrectionFilter.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 #ifndef _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_
17 #define _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_
18 
19 #include "itkImageToImageFilter.h"
20 #include <itkDiffusionTensor3D.h>
21 #include <itkVectorImage.h>
22 #include <vnl/algo/vnl_symmetric_eigensystem.h>
23 
24 #include <math.h>
25 
26 
27 
28 namespace itk
29 {
30 
31  template <class TDiffusionPixelType, class TTensorPixelType>
33  : public ImageToImageFilter< itk::Image< TDiffusionPixelType, 3 >, itk::Image<itk::DiffusionTensor3D<TTensorPixelType>,3> >
34  {
35 
36  public:
37 
38 
39  typedef itk::VectorImage<short, 3> ImageType;
40 
41 
42 
46 
47 
48 
49  typedef ImageToImageFilter< Image< TDiffusionPixelType, 3>,
50  Image< DiffusionTensor3D< TTensorPixelType >, 3 > >
52 
54  itkFactorylessNewMacro(Self)
55  itkCloneMacro(Self)
56 
58  itkTypeMacro(TensorReconstructionWithEigenvalueCorrectionFilter, ImageToImageFilter)
59 
60 
61  typedef typename itk::Image<itk::DiffusionTensor3D<TTensorPixelType>,3> OutputType;
62  typedef TDiffusionPixelType GradientPixelType;
63  typedef DiffusionTensor3D< TTensorPixelType > TensorPixelType;
64 
65  typedef Image< TensorPixelType, 3 > TensorImageType;
66 
67  typedef typename Superclass::OutputImageRegionType
69 
70 
75  typedef VectorImage< GradientPixelType, 3 > GradientImagesType;
76  typedef typename GradientImagesType::PixelType GradientVectorType;
77 
78 
79 
81  typedef vnl_vector_fixed< double, 3 > GradientDirectionType;
82 
84  typedef VectorContainer< unsigned int,
85  GradientDirectionType > GradientDirectionContainerType;
86 
87 
88 
95  void SetGradientImage( GradientDirectionContainerType *,
96  const GradientImagesType *image);
97 
98 
99 
100 
101 
102  itkSetMacro( BValue, TTensorPixelType)
103 
105  itkSetMacro( B0Threshold, double)
106 
108  itkGetMacro(PseudoInverse, vnl_matrix<double>)
109 
111  itkGetMacro(CorrectedDiffusionVolumes, ImageType::Pointer)
112 
114  itkGetMacro(H, vnl_matrix<double>)
115 
117  itkGetMacro(BVec, vnl_vector<double>)
118 
120  itkGetMacro(B0Mask, vnl_vector<short>)
121 
122 
124  ImageType::Pointer GetGradientImagePointer()
125  {
126  return m_GradientImagePointer;
127  }
128 
131  {
132  return m_MaskImage;
133  }
134 
135 
136  protected:
137 
140 
141 
142  void GenerateData();
143 
144 
145  typedef enum
146  {
151 
152 
153 
154  private:
155 
156  double CheckNeighbours(int x, int y, int z,int f, itk::Size<3> size, itk::Image<short, 3> ::Pointer mask,typename GradientImagesType::Pointer corrected_diffusion_temp);
157 
159  void CalculateAttenuation(vnl_vector<double> org_data, vnl_vector<double> &atten,int nof,int numberb0);
160 
161 
163  void CorrectDiffusionImage(int nof,int numberb0,itk::Size<3> size,typename GradientImagesType::Pointer corrected_diffusion,itk::Image<short, 3>::Pointer mask,vnl_vector< double> pixel_max,vnl_vector< double> pixel_min);
164 
166  void GenerateTensorImage(int nof,int numberb0,itk::Size<3> size,itk::VectorImage<short, 3>::Pointer corrected_diffusion,itk::Image<short, 3>::Pointer mask,double what_mask, typename itk::Image< itk::DiffusionTensor3D<TTensorPixelType>, 3 >::Pointer tensorImg );
167 
168  //void DeepCopyTensorImage(itk::Image< itk::DiffusionTensor3D<double>, 3 >::Pointer tensorImg, itk::Image< itk::DiffusionTensor3D<double>, 3 >::Pointer temp_tensorImg);
169 
170  //void DeepCopyDiffusionImage(itk::VectorImage<short, 3>::Pointer corrected_diffusion, itk::VectorImage<short, 3>::Pointer corrected_diffusion_temp,int nof);
171 
172 
173  void TurnMask( itk::Size<3> size, itk::Image<short, 3>::Pointer mask, double previous_mask, double set_mask);
174 
175  double CheckNegatives ( itk::Size<3> size, itk::Image<short, 3>::Pointer mask, typename itk::Image< itk::DiffusionTensor3D<TTensorPixelType>, 3 >::Pointer tensorImg );
176 
177 
179  GradientImageTypeEnumeration m_GradientImageTypeEnumeration;
180 
182  unsigned int m_NumberOfGradientDirections;
183 
185  GradientDirectionContainerType::Pointer m_GradientDirectionContainer;
186 
187 
189  TTensorPixelType m_BValue;
190 
192  unsigned int m_NumberOfBaselineImages;
193 
194  ImageType::Pointer m_CorrectedDiffusionVolumes;
195 
196  double m_B0Threshold;
197 
198 
200  itk::Image<short, 3>::Pointer m_MaskImage;
201 
203  vnl_matrix<double> m_PseudoInverse;
204 
206  vnl_matrix<double> m_H;
207 
209  vnl_vector<double> m_BVec;
210 
212  vnl_vector<short> m_B0Mask;
213 
215  typename GradientImagesType::Pointer m_GradientImagePointer;
216 
217  };
218 
219 
220 
221 
222 
223 
224 } // end of namespace
225 
226 
227 #ifndef ITK_MANUAL_INSTANTIATION
229 #endif
230 
231 
232 #endif
itk::SmartPointer< Self > Pointer
void SetGradientImage(GradientDirectionContainerType *, const GradientImagesType *image)
VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType
class ITK_EXPORT Image
double TTensorPixelType
ImageToImageFilter< Image< TDiffusionPixelType, 3 >, Image< DiffusionTensor3D< TTensorPixelType >, 3 > > Superclass
unsigned short PixelType