ANIMA  4.0
animaMCMScalarMapsImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageToImageFilter.h>
4 #include <animaMCMImage.h>
5 
7 
8 namespace anima
9 {
10 
11 template <class TPixelType>
13 public itk::ImageToImageFilter< anima::MCMImage <TPixelType, 3>, itk::Image<TPixelType, 3> >
14 {
15 public:
19  typedef itk::Image <TPixelType, 3> OutputImageType;
20  typedef itk::ImageToImageFilter <InputImageType, OutputImageType > Superclass;
21  typedef itk::SmartPointer<Self> Pointer;
22  typedef itk::SmartPointer<const Self> ConstPointer;
23 
25  itkNewMacro(Self)
26 
27 
28  itkTypeMacro(MCMScalarMapsImageFilter, itk::ImageToImageFilter)
29 
30  typedef typename InputImageType::ConstPointer InputImagePointer;
31  typedef typename OutputImageType::Pointer OutputImagePointer;
32 
33  typedef typename InputImageType::RegionType InputRegionType;
34  typedef typename InputImageType::IndexType InputIndexType;
35  typedef typename InputImageType::PixelType PixelType;
36 
37  // Multi-compartment models typedefs
39  typedef MCModelType::Pointer MCModelPointer;
40 
41  itkSetMacro(IncludeIsotropicWeights, bool)
42 
43 protected:
45  {
46  // Seven outputs for now:
47  // - free water weight, isotropic restricted weight (sum of IR or Stanisz compartments)
48  // - anisotropic weight
49  // - FA and MD
50  // - Apparent parallel and perpendicular diffusivities
51  unsigned int numOutputs = 7;
52  this->SetNumberOfRequiredOutputs(numOutputs);
53 
54  for (unsigned int i = 0;i < numOutputs;++i)
55  this->SetNthOutput(i,this->MakeOutput(i));
56 
57  m_IncludeIsotropicWeights = false;
58  }
59 
61 
62  template <class T> bool isZero(const itk::VariableLengthVector <T> &value) const
63  {
64  for (unsigned int i = 0;i < value.GetNumberOfElements();++i)
65  {
66  if (value[i] != 0.0)
67  return false;
68  }
69 
70  return true;
71  }
72 
73  void DynamicThreadedGenerateData(const InputRegionType &outputRegionForThread) ITK_OVERRIDE;
74 
75 private:
76  ITK_DISALLOW_COPY_AND_ASSIGN(MCMScalarMapsImageFilter);
77 
78  // Use to compute FA and MD measures with or without iso compartments contributions
79  bool m_IncludeIsotropicWeights;
80 };
81 
82 } // end namespace anima
83 
itk::Image< TPixelType, 3 > OutputImageType
anima::MCMImage< TPixelType, 3 > InputImageType
bool isZero(const itk::VariableLengthVector< T > &value) const
itk::SmartPointer< const Self > ConstPointer
void DynamicThreadedGenerateData(const InputRegionType &outputRegionForThread) ITK_OVERRIDE
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
MultiCompartmentModel: holds several diffusion compartments, ordered by type It also handles weights ...
InputImageType::ConstPointer InputImagePointer