ITK  5.2.0
Insight Toolkit
itkDiffusionTensor3DReconstructionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkDiffusionTensor3DReconstructionImageFilter_h
19 #define itkDiffusionTensor3DReconstructionImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkSpatialObject.h"
23 #include "itkDiffusionTensor3D.h"
24 #include "vnl/vnl_matrix.h"
25 #include "vnl/vnl_vector_fixed.h"
26 #include "vnl/vnl_matrix_fixed.h"
27 #include "vnl/algo/vnl_svd.h"
28 #include "itkVectorContainer.h"
29 #include "itkVectorImage.h"
30 #include "ITKDiffusionTensorImageExport.h"
31 
32 namespace itk
33 {
39 {
40 public:
46  {
49  Else
50  };
51 };
52 // Define how to print enumeration
53 extern ITKDiffusionTensorImage_EXPORT std::ostream &
55 
145 template <typename TReferenceImagePixelType,
146  typename TGradientImagePixelType = TReferenceImagePixelType,
147  typename TTensorPixelType = double,
148  typename TMaskImageType = Image<unsigned char, 3>>
150  : public ImageToImageFilter<Image<TReferenceImagePixelType, 3>, Image<DiffusionTensor3D<TTensorPixelType>, 3>>
151 {
152 public:
156  using Superclass =
158 
160  itkNewMacro(Self);
161 
164 
165  using ReferencePixelType = TReferenceImagePixelType;
166 
167  using GradientPixelType = TGradientImagePixelType;
168 
170 
173  using ReferenceImageType = typename Superclass::InputImageType;
174 
176 
178 
179  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
180 
183 
189 
192 
194  using MaskImageType = TMaskImageType;
195 
197  using TensorBasisMatrixType = vnl_matrix_fixed<double, 6, 6>;
198 
199  using CoefficientMatrixType = vnl_matrix<double>;
200 
202  using GradientDirectionType = vnl_vector_fixed<double, 3>;
203 
206 
208  void
209  AddGradientImage(const GradientDirectionType &, const GradientImageType * image);
210  const GradientImageType *
211  GetGradientImage(unsigned index) const;
213 
220  void
221  SetGradientImage(GradientDirectionContainerType *, const GradientImagesType * image);
222 
224  void
226  {
227  if (m_GradientImageTypeEnumeration ==
229  {
230  itkExceptionMacro(<< "Cannot call both methods:"
231  << "AddGradientImage and SetGradientImage. Please call only one of them.");
232  }
233 
234  this->ProcessObject::SetNthInput(0, referenceImage);
235 
236  m_GradientImageTypeEnumeration =
238  }
239 
241  virtual ReferenceImageType *
243  {
244  return (static_cast<ReferenceImageType *>(this->ProcessObject::GetInput(0)));
245  }
246 
248  virtual GradientDirectionType
249  GetGradientDirection(unsigned int idx) const
250  {
251  if (idx >= m_NumberOfGradientDirections)
252  {
253  itkExceptionMacro(<< "Gradient direction " << idx << "does not exist");
254  }
255  return m_GradientDirectionContainer->ElementAt(idx + 1);
256  }
258 
260  void
261  SetMaskImage(MaskImageType * maskImage);
262 
264  void
265  SetMaskSpatialObject(MaskSpatialObjectType * maskSpatialObject);
266 
267 
271  itkSetMacro(Threshold, ReferencePixelType);
272  itkGetConstMacro(Threshold, ReferencePixelType);
274 
281  itkSetMacro(BValue, TTensorPixelType);
282 #ifdef GetBValue
283 # undef GetBValue
284 #endif
285  itkGetConstReferenceMacro(BValue, TTensorPixelType);
287 
288 #ifdef ITK_USE_CONCEPT_CHECKING
289  // Begin concept checking
290  itkConceptMacro(ReferenceEqualityComparableCheck, (Concept::EqualityComparable<ReferencePixelType>));
291  itkConceptMacro(TensorEqualityComparableCheck, (Concept::EqualityComparable<TensorPixelType>));
292  itkConceptMacro(GradientConvertibleToDoubleCheck, (Concept::Convertible<GradientPixelType, double>));
293  itkConceptMacro(DoubleConvertibleToTensorCheck, (Concept::Convertible<double, TensorPixelType>));
294  itkConceptMacro(GradientReferenceAdditiveOperatorsCheck,
296  itkConceptMacro(GradientReferenceAdditiveAndAssignOperatorsCheck,
298 
299  itkConceptMacro(ReferenceOStreamWritableCheck, (Concept::OStreamWritable<ReferencePixelType>));
300  itkConceptMacro(TensorOStreamWritableCheck, (Concept::OStreamWritable<TensorPixelType>));
301  // End concept checking
302 #endif
303 
304 protected:
306  ~DiffusionTensor3DReconstructionImageFilter() override = default;
307  void
308  PrintSelf(std::ostream & os, Indent indent) const override;
309 
310  void
311  ComputeTensorBasis();
312 
313  void
314  BeforeThreadedGenerateData() override;
315 
316  void
317  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
318 
319  void
320  VerifyPreconditions() ITKv5_CONST override;
321 
324 #if !defined(ITK_LEGACY_REMOVE)
325  // We need to expose the enum values at the class level
326  // for backwards compatibility
327  static constexpr GradientImageTypeEnumeration GradientIsInASingleImage =
328  GradientImageTypeEnumeration::GradientIsInASingleImage;
329  static constexpr GradientImageTypeEnumeration GradientIsInManyImages =
330  GradientImageTypeEnumeration::GradientIsInManyImages;
331  static constexpr GradientImageTypeEnumeration Else = GradientImageTypeEnumeration::Else;
332 #endif
333 
334 private:
335  /* Tensor basis coeffs */
337 
339 
342 
345 
348 
351 
353  TTensorPixelType m_BValue;
354 
357 
360 };
361 } // namespace itk
362 
363 #ifndef ITK_MANUAL_INSTANTIATION
364 # include "itkDiffusionTensor3DReconstructionImageFilter.hxx"
365 #endif
366 
367 #endif
itk::DiffusionTensor3DReconstructionImageFilter::ReferenceImageType
typename Superclass::InputImageType ReferenceImageType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:173
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::DiffusionTensor3DReconstructionImageFilter::TensorBasisMatrixType
vnl_matrix_fixed< double, 6, 6 > TensorBasisMatrixType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:197
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:634
itk::DiffusionTensor3DReconstructionImageFilterEnums
Contains all enum classes used by DiffusionTensor3DReconstructionImageFilter class.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:38
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:213
itk::DiffusionTensor3DReconstructionImageFilter::CoefficientMatrixType
vnl_matrix< double > CoefficientMatrixType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:199
itk::DiffusionTensor3DReconstructionImageFilter::m_GradientImageTypeEnumeration
GradientImageTypeEnumeration m_GradientImageTypeEnumeration
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:356
itk::DiffusionTensor3DReconstructionImageFilter::GradientPixelType
TGradientImagePixelType GradientPixelType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:167
itk::DiffusionTensor3DReconstructionImageFilter::m_Threshold
ReferencePixelType m_Threshold
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:350
itkSpatialObject.h
itk::VectorImage
Templated n-dimensional vector image class.
Definition: itkImageAlgorithm.h:29
itkDiffusionTensor3D.h
itk::DiffusionTensor3D
Represent a diffusion tensor as used in DTI images.
Definition: itkDiffusionTensor3D.h:79
itk::DiffusionTensor3DReconstructionImageFilter::m_BValue
TTensorPixelType m_BValue
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:353
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat
GradientImageFormat
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:45
itk::DiffusionTensor3DReconstructionImageFilter::ReferencePixelType
TReferenceImagePixelType ReferencePixelType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:165
itk::Concept::AdditiveAndAssignOperators
Definition: itkConceptChecking.h:388
itk::DiffusionTensor3DReconstructionImageFilter::m_BMatrix
CoefficientMatrixType m_BMatrix
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:338
itkVectorImage.h
itk::DiffusionTensor3DReconstructionImageFilter::GetGradientDirection
virtual GradientDirectionType GetGradientDirection(unsigned int idx) const
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:249
itk::DiffusionTensor3DReconstructionImageFilter::m_TensorBasis
TensorBasisMatrixType m_TensorBasis
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:336
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat::GradientIsInManyImages
itk::DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat::Else
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::DiffusionTensor3DReconstructionImageFilter::m_NumberOfGradientDirections
unsigned int m_NumberOfGradientDirections
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:344
itk::DiffusionTensor3DReconstructionImageFilter::SetReferenceImage
void SetReferenceImage(ReferenceImageType *referenceImage)
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:225
itk::DiffusionTensor3DReconstructionImageFilter::m_MaskImagePresent
bool m_MaskImagePresent
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:359
itk::DiffusionTensor3DReconstructionImageFilter::MaskImageType
TMaskImageType MaskImageType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:194
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:57
itk::DiffusionTensor3DReconstructionImageFilter::GradientDirectionType
vnl_vector_fixed< double, 3 > GradientDirectionType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:202
itkImageToImageFilter.h
itk::DiffusionTensor3DReconstructionImageFilter::m_NumberOfBaselineImages
unsigned int m_NumberOfBaselineImages
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:347
itkVectorContainer.h
itk::DiffusionTensor3DReconstructionImageFilter::m_GradientDirectionContainer
GradientDirectionContainerType::Pointer m_GradientDirectionContainer
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:341
itk::Concept::AdditiveOperators
Definition: itkConceptChecking.h:356
itk::DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat::GradientIsInASingleImage
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject::SetNthInput
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
GradientImageFormat
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::DiffusionTensor3DReconstructionImageFilter::OutputImageRegionType
typename Superclass::OutputImageRegionType OutputImageRegionType
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:179
itk::VectorContainer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
Definition: itkVectorContainer.h:48
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:304
itk::DiffusionTensor3DReconstructionImageFilter::GetReferenceImage
virtual ReferenceImageType * GetReferenceImage()
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:242
itk::DiffusionTensor3DReconstructionImageFilter
This class takes as input one or more reference image (acquired in the absence of diffusion sensitizi...
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:149