ANIMA  4.0
animaMCMAverageImagesImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageToImageFilter.h>
4 #include <animaMCMImage.h>
5 
8 
9 namespace anima
10 {
11 
12 template <class TPixelType>
14 public itk::ImageToImageFilter< anima::MCMImage <TPixelType, 3>, anima::MCMImage<TPixelType, 3> >
15 {
16 public:
22  typedef itk::ImageToImageFilter <InputImageType, OutputImageType > Superclass;
23  typedef itk::SmartPointer<Self> Pointer;
24  typedef itk::SmartPointer<const Self> ConstPointer;
25 
27  itkNewMacro(Self)
28 
29 
30  itkTypeMacro(MCMAverageImagesImageFilter, ImageToImageFilter)
31 
32  typedef typename InputImageType::ConstPointer InputImagePointer;
33  typedef typename OutputImageType::Pointer OutputImagePointer;
34 
35  typedef typename InputImageType::RegionType InputRegionType;
36  typedef typename InputImageType::IndexType InputIndexType;
37  typedef typename InputImageType::PixelType PixelType;
38 
39  using MaskImageType = itk::Image <unsigned char, 3>;
40  using MaskImagePointer = typename MaskImageType::Pointer;
41 
42  // Multi-compartment models typedefs
44  typedef MCModelType::Pointer MCModelPointer;
45 
47  typedef typename MCMAveragerType::Pointer MCMAveragerPointer;
48 
49  void SetReferenceOutputModel(MCModelPointer &model);
50  MCModelType *GetReferenceOutputModel() {return m_ReferenceOutputModel;}
51 
52  void AddMaskImage(MaskImageType *maskImage) {m_MaskImages.push_back(maskImage);}
53 
54 protected:
57 
58  bool isZero(const itk::VariableLengthVector <double> &value) const
59  {
60  for (unsigned int i = 0;i < value.GetNumberOfElements();++i)
61  {
62  if (value[i] != 0)
63  return false;
64  }
65 
66  return true;
67  }
68 
69  void BeforeThreadedGenerateData() ITK_OVERRIDE;
70  void DynamicThreadedGenerateData(const InputRegionType &region) ITK_OVERRIDE;
72 
73 private:
74  ITK_DISALLOW_COPY_AND_ASSIGN(MCMAverageImagesImageFilter);
75 
76  std::vector <MCModelPointer> m_ReferenceInputModels;
77  std::vector <MaskImagePointer> m_MaskImages;
78  MCModelPointer m_ReferenceOutputModel;
79 };
80 
81 } // end namespace anima
82 
anima::MCMImage< TPixelType, 3 > OutputImageType
Computes a weighted average of input multi-compartment models. The output model is at the same time g...
void DynamicThreadedGenerateData(const InputRegionType &region) ITK_OVERRIDE
itk::ImageToImageFilter< InputImageType, OutputImageType > Superclass
MultiCompartmentModel: holds several diffusion compartments, ordered by type It also handles weights ...
typename MaskImageType::Pointer MaskImagePointer
bool isZero(const itk::VariableLengthVector< double > &value) const
anima::MCMImage< TPixelType, 3 > InputImageType