Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkDiffusionQballReconstructionImageFilter.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 __itkDiffusionQballReconstructionImageFilter_h_
18 #define __itkDiffusionQballReconstructionImageFilter_h_
19 
20 #include "itkImageToImageFilter.h"
21 //#include "vnl/vnl_matrix.h"
22 #include "vnl/vnl_vector_fixed.h"
23 #include "vnl/vnl_matrix.h"
24 #include "vnl/algo/vnl_svd.h"
25 #include "itkVectorContainer.h"
26 #include "itkVectorImage.h"
27 
28 namespace itk{
95 template< class TReferenceImagePixelType,
96  class TGradientImagePixelType,
97  class TOdfPixelType,
98  int NrOdfDirections,
99  int NrBasisFunctionCenters = NrOdfDirections>
101  public ImageToImageFilter< Image< TReferenceImagePixelType, 3 >,
102  Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > >
103 {
104 
105 public:
106 
123  };
124 
128  typedef ImageToImageFilter< Image< TReferenceImagePixelType, 3>,
129  Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > >
131 
133  itkFactorylessNewMacro(Self)
134  itkCloneMacro(Self)
135 
138  ImageToImageFilter);
139 
140  typedef TReferenceImagePixelType ReferencePixelType;
141 
142  typedef TGradientImagePixelType GradientPixelType;
143 
144  typedef Vector< TOdfPixelType, NrOdfDirections >
146 
150 
152 
153  typedef OdfImageType OutputImageType;
154 
155  typedef TOdfPixelType BZeroPixelType;
156 
157  typedef Image< BZeroPixelType, 3 > BZeroImageType;
158 
159  typedef typename Superclass::OutputImageRegionType
161 
163  typedef Image< GradientPixelType, 3 > GradientImageType;
164 
169  typedef VectorImage< GradientPixelType, 3 > GradientImagesType;
170 
172  typedef vnl_matrix< TOdfPixelType >*
174 
176  typedef vnl_vector_fixed< double, 3 > GradientDirectionType;
177 
179  typedef VectorContainer< unsigned int,
180  GradientDirectionType > GradientDirectionContainerType;
181 
182  itkStaticConstMacro(NOdfDirections,int,NrOdfDirections);
183  itkStaticConstMacro(NBasisFunctionCenters,int,NrBasisFunctionCenters);
184 
186  void AddGradientImage( const GradientDirectionType &, const GradientImageType *image);
187 
194  void SetGradientImage( const GradientDirectionContainerType *,
195  const GradientImagesType *image);
196 
198  void SetReferenceImage( ReferenceImageType *referenceImage )
199  {
200  if( m_GradientImageTypeEnumeration == GradientIsInASingleImage)
201  {
202  itkExceptionMacro( << "Cannot call both methods:"
203  << "AddGradientImage and SetGradientImage. Please call only one of them.");
204  }
205 
206  this->ProcessObject::SetNthInput( 0, referenceImage );
207 
208  m_GradientImageTypeEnumeration = GradientIsInManyImages;
209  }
210 
213  { return ( static_cast< ReferenceImageType *>(this->ProcessObject::GetInput(0)) ); }
214 
216  virtual GradientDirectionType GetGradientDirection( unsigned int idx) const
217  {
218  if( idx >= m_NumberOfGradientDirections )
219  {
220  itkExceptionMacro( << "Gradient direction " << idx << "does not exist" );
221  }
222  return m_GradientDirectionContainer->ElementAt( idx+1 );
223  }
224 
228  OdfPixelType Normalize(OdfPixelType odf, typename NumericTraits<ReferencePixelType>::AccumulateType b0 );
229 
233  vnl_vector<TOdfPixelType> PreNormalize( vnl_vector<TOdfPixelType> vec );
234 
238  itkSetMacro( Threshold, ReferencePixelType );
239  itkGetMacro( Threshold, ReferencePixelType );
240 
242  itkSetMacro( NormalizationMethod, Normalization);
243  itkGetMacro( NormalizationMethod, Normalization );
244 
246  itkGetMacro( BZeroImage, typename BZeroImageType::Pointer);
247 
249  itkSetMacro( BValue, TOdfPixelType);
250 #ifdef GetBValue
251 #undef GetBValue
252 #endif
253  itkGetConstReferenceMacro( BValue, TOdfPixelType);
254 
255 #ifdef ITK_USE_CONCEPT_CHECKING
256 
257  itkConceptMacro(ReferenceEqualityComparableCheck,
258  (Concept::EqualityComparable<ReferencePixelType>));
259  itkConceptMacro(TensorEqualityComparableCheck,
260  (Concept::EqualityComparable<OdfPixelType>));
261  itkConceptMacro(GradientConvertibleToDoubleCheck,
262  (Concept::Convertible<GradientPixelType, double>));
263  itkConceptMacro(DoubleConvertibleToTensorCheck,
264  (Concept::Convertible<double, OdfPixelType>));
265  itkConceptMacro(GradientReferenceAdditiveOperatorsCheck,
266  (Concept::AdditiveOperators<GradientPixelType, GradientPixelType,
268  itkConceptMacro(ReferenceOStreamWritableCheck,
269  (Concept::OStreamWritable<ReferencePixelType>));
270  itkConceptMacro(TensorOStreamWritableCheck,
271  (Concept::OStreamWritable<OdfPixelType>));
273 #endif
274 
275 protected:
278  void PrintSelf(std::ostream& os, Indent indent) const;
279 
282 
284  void ThreadedGenerateData( const
285  OutputImageRegionType &outputRegionForThread, ThreadIdType);
286 
289  typedef enum
290  {
295 
296 private:
297 
298  /* Tensor basis coeffs */
299  OdfReconstructionMatrixType m_ReconstructionMatrix;
300 
302  GradientDirectionContainerType::Pointer m_GradientDirectionContainer;
303 
305  unsigned int m_NumberOfGradientDirections;
306 
308  unsigned int m_NumberOfEquatorSamplingPoints;
309 
311  unsigned int m_NumberOfBaselineImages;
312 
314  ReferencePixelType m_Threshold;
315 
317  TOdfPixelType m_BValue;
318 
320  GradientImageTypeEnumeration m_GradientImageTypeEnumeration;
321 
323  typename BZeroImageType::Pointer m_BZeroImage;
324 
328  bool m_DirectionsDuplicated;
329 
331  Normalization m_NormalizationMethod;
332 };
333 
334 }
335 
336 #ifndef ITK_MANUAL_INSTANTIATION
338 #endif
339 
340 #endif //__itkDiffusionQballReconstructionImageFilter_h_
341 
itk::SmartPointer< Self > Pointer
virtual GradientDirectionType GetGradientDirection(unsigned int idx) const
This class takes as input one or more reference images (acquired in the absence of diffusion sensitiz...
OdfPixelType Normalize(OdfPixelType odf, typename NumericTraits< ReferencePixelType >::AccumulateType b0)
void AddGradientImage(const GradientDirectionType &, const GradientImageType *image)
void SetGradientImage(const GradientDirectionContainerType *, const GradientImagesType *image)
class ITK_EXPORT Image
itk::Image< double, 3 > InputImageType
void PrintSelf(std::ostream &os, Indent indent) const
ImageToImageFilter< Image< TReferenceImagePixelType, 3 >, Image< Vector< TOdfPixelType, NrOdfDirections >, 3 > > Superclass
vnl_vector< TOdfPixelType > PreNormalize(vnl_vector< TOdfPixelType > vec)
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType)
itkStaticConstMacro(NOdfDirections, int, NrOdfDirections)
VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType