Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkAnalyticalDiffusionQballReconstructionImageFilter.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 #ifndef __itkAnalyticalDiffusionQballReconstructionImageFilter_h_
18 #define __itkAnalyticalDiffusionQballReconstructionImageFilter_h_
19 
20 #include "itkImageToImageFilter.h"
21 #include "vnl/vnl_vector_fixed.h"
22 #include "vnl/vnl_matrix.h"
23 #include "vnl/algo/vnl_svd.h"
24 #include "itkVectorContainer.h"
25 #include "itkVectorImage.h"
26 
27 
28 namespace itk{
86 template< class TReferenceImagePixelType,
87  class TGradientImagePixelType,
88  class TOdfPixelType,
89  int NOrderL,
90  int NrOdfDirections>
92  public ImageToImageFilter< Image< TReferenceImagePixelType, 3 >,
93  Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > >
94 {
95 
96 public:
97 
107  };
108 
112  typedef ImageToImageFilter< Image< TReferenceImagePixelType, 3>,
113  Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > > Superclass;
114 
116  itkFactorylessNewMacro(Self)
117  itkCloneMacro(Self)
118 
120  itkTypeMacro(AnalyticalDiffusionQballReconstructionImageFilter, ImageToImageFilter)
121 
122  typedef TReferenceImagePixelType ReferencePixelType;
123 
124  typedef TGradientImagePixelType GradientPixelType;
125 
126  typedef Vector< TOdfPixelType, NrOdfDirections > OdfPixelType;
127 
128  typedef TOdfPixelType BZeroPixelType;
129 
132  typedef typename Superclass::InputImageType ReferenceImageType;
133 
134  typedef Image< OdfPixelType, 3 > OdfImageType;
135 
136  typedef OdfImageType OutputImageType;
137 
138  typedef Image< Vector< TOdfPixelType, (NOrderL*NOrderL + NOrderL + 2)/2 + NOrderL >, 3 > CoefficientImageType;
139 
140  typedef Image< BZeroPixelType, 3 > BZeroImageType;
141 
142  typedef typename Superclass::OutputImageRegionType
144 
146  typedef Image< GradientPixelType, 3 > GradientImageType;
147 
152  typedef VectorImage< GradientPixelType, 3 > GradientImagesType;
153 
155  typedef vnl_matrix< TOdfPixelType >*
157 
158  typedef vnl_matrix< double > CoefficientMatrixType;
159 
161  typedef vnl_vector_fixed< double, 3 > GradientDirectionType;
162 
164  typedef VectorContainer< unsigned int,
165  GradientDirectionType > GradientDirectionContainerType;
166 
173  void SetGradientImage( const GradientDirectionContainerType *,
174  const GradientImagesType *image);
175 
177  virtual ReferenceImageType * GetReferenceImage()
178  { return ( static_cast< ReferenceImageType *>(this->ProcessObject::GetInput(0)) ); }
179 
181  virtual GradientDirectionType GetGradientDirection( unsigned int idx) const
182  {
183  if( idx >= m_NumberOfGradientDirections )
184  itkExceptionMacro( << "Gradient direction " << idx << "does not exist" );
185  return m_GradientDirectionContainer->ElementAt( idx+1 );
186  }
187 
188  static void tofile2(vnl_matrix<double> *A, std::string fname);
189  static void Cart2Sph(double x, double y, double z, double* cart);
190  static double Yj(int m, int k, double theta, double phi, bool useMRtrixBasis = false);
191  double Legendre0(int l);
192 
193  OdfPixelType Normalize(OdfPixelType odf, typename NumericTraits<ReferencePixelType>::AccumulateType b0 );
194  vnl_vector<TOdfPixelType> PreNormalize( vnl_vector<TOdfPixelType> vec, typename NumericTraits<ReferencePixelType>::AccumulateType b0 );
195 
199  itkSetMacro( Threshold, ReferencePixelType )
200  itkGetMacro( Threshold, ReferencePixelType )
201 
202  itkSetMacro( NormalizationMethod, Normalization)
203  itkGetMacro( NormalizationMethod, Normalization )
204 
205  typedef Image<float, 3> FloatImageType;
206  itkGetMacro( BZeroImage, typename BZeroImageType::Pointer)
207  itkGetMacro( ODFSumImage, typename FloatImageType::Pointer)
208  itkGetMacro( CoefficientImage, typename CoefficientImageType::Pointer)
209 
210  itkSetMacro( BValue, TOdfPixelType)
211 #ifdef GetBValue
212 #undef GetBValue
213 #endif
214  itkGetConstReferenceMacro( BValue, TOdfPixelType)
215  itkSetMacro( Lambda, double )
216  itkGetMacro( Lambda, double )
217 
218  itkSetMacro( UseMrtrixBasis, bool )
219 
220 #ifdef ITK_USE_CONCEPT_CHECKING
221 
222  itkConceptMacro(ReferenceEqualityComparableCheck,
223  (Concept::EqualityComparable<ReferencePixelType>));
224  itkConceptMacro(TensorEqualityComparableCheck,
225  (Concept::EqualityComparable<OdfPixelType>));
226  itkConceptMacro(GradientConvertibleToDoubleCheck,
227  (Concept::Convertible<GradientPixelType, double>));
228  itkConceptMacro(DoubleConvertibleToTensorCheck,
229  (Concept::Convertible<double, OdfPixelType>));
230  itkConceptMacro(GradientReferenceAdditiveOperatorsCheck,
231  (Concept::AdditiveOperators<GradientPixelType, GradientPixelType,
233  itkConceptMacro(ReferenceOStreamWritableCheck,
234  (Concept::OStreamWritable<ReferencePixelType>));
235  itkConceptMacro(TensorOStreamWritableCheck,
236  (Concept::OStreamWritable<OdfPixelType>));
238 #endif
239 
240 protected:
243  void PrintSelf(std::ostream& os, Indent indent) const;
244 
247  void ThreadedGenerateData( const
248  OutputImageRegionType &outputRegionForThread, ThreadIdType);
249 
250 private:
251 
252  OdfReconstructionMatrixType m_ReconstructionMatrix;
253  OdfReconstructionMatrixType m_CoeffReconstructionMatrix;
254  OdfReconstructionMatrixType m_SphericalHarmonicBasisMatrix;
256  GradientDirectionContainerType::Pointer m_GradientDirectionContainer;
258  unsigned int m_NumberOfGradientDirections;
260  unsigned int m_NumberOfBaselineImages;
262  ReferencePixelType m_Threshold;
264  TOdfPixelType m_BValue;
265  typename BZeroImageType::Pointer m_BZeroImage;
266  double m_Lambda;
267  bool m_DirectionsDuplicated;
268  Normalization m_NormalizationMethod;
269  int m_NumberCoefficients;
270  vnl_matrix<double>* m_B_t;
271  vnl_vector<double>* m_LP;
272  FloatImageType::Pointer m_ODFSumImage;
273  typename CoefficientImageType::Pointer m_CoefficientImage;
274  TOdfPixelType m_Delta1;
275  TOdfPixelType m_Delta2;
276  bool m_UseMrtrixBasis;
277 };
278 
279 }
280 
281 #ifndef ITK_MANUAL_INSTANTIATION
283 #endif
284 
285 #endif //__itkAnalyticalDiffusionQballReconstructionImageFilter_h_
286 
itk::SmartPointer< Self > Pointer
VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType
Image< Vector< TOdfPixelType,(NOrderL *NOrderL+NOrderL+2)/2+NOrderL >, 3 > CoefficientImageType
ImageToImageFilter< Image< TReferenceImagePixelType, 3 >, Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > > Superclass
static double Yj(int m, int k, double theta, double phi, bool useMRtrixBasis=false)
void SetGradientImage(const GradientDirectionContainerType *, const GradientImagesType *image)
vnl_vector< TOdfPixelType > PreNormalize(vnl_vector< TOdfPixelType > vec, typename NumericTraits< ReferencePixelType >::AccumulateType b0)
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType)
class ITK_EXPORT Image
This class takes as input one or more reference image (acquired in the absence of diffusion sensitizi...
itk::Image< double, 3 > InputImageType
OdfPixelType Normalize(OdfPixelType odf, typename NumericTraits< ReferencePixelType >::AccumulateType b0)