DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkRotateSHCoefficientsImageFilter.h
Go to the documentation of this file.
1 
18 #ifndef __itkRotateSHCoefficientsImageFilter_h
19 #define __itkRotateSHCoefficientsImageFilter_h
20 
21 #include <vnl/vnl_matrix.h>
22 #include "utl.h"
24 #include "itkUnaryFunctorImageFilter.h"
26 
27 
28 namespace itk
29 {
30 
44 namespace Functor {
45 
46 template< class TInput, class TOutput>
48 {
49 public:
54 
56  {
57  m_RotationMatrix.SetIdentity();
59  };
61  {
62  };
63  bool operator!=( const RotateSHCoefficients & other ) const
64  {
65  return !(*this == other);
66  }
67  bool operator==( const RotateSHCoefficients & other ) const
68  {
69  return m_RotationMatrix.IsEqual(other.m_RotationMatrix, 1e-8);
70  }
71  inline TOutput operator()( const TInput & A ) const
72  {
73  const int N = A.GetSize();
74  TOutput output(A);
75  VectorType vec(N);
76  utl::VectorToVector<TInput, VectorType >(A, vec, N);
77  VectorType vecRotated = m_SHRotate->GetRotatedSHCoefficients(vec, m_RotationMatrix);
78  utl::VectorToVector<VectorType, TInput>(vecRotated, output, N);
79  return output;
80  }
81 
82  void SetRotationMatrix(const MatrixType& mat)
83  { this->m_RotationMatrix = mat; }
84 
85  const MatrixType & GetRotationMatrix() const
86  { return m_RotationMatrix; }
87 
88  void SetSHRotate(const SHRotationPointer& ptr)
89  { this->m_SHRotate = ptr; }
90 
91  const SHRotationPointer & GetSHRotate() const
92  { return m_SHRotate; }
93 
94  MatrixType m_RotationMatrix;
95  SHRotationPointer m_SHRotate;
96 };
97 }
98 
99 template <class TInputImage, class TOutputImage>
101 public
102 UnaryFunctorImageFilter<TInputImage,TOutputImage,
103  Functor::RotateSHCoefficients<
104  typename TInputImage::PixelType,
105  typename TOutputImage::PixelType> >
106 {
107 public:
110  typedef UnaryFunctorImageFilter<
111  TInputImage,TOutputImage,
113  typename TInputImage::PixelType,
114  typename TOutputImage::PixelType> > Superclass;
115 
116  typedef SmartPointer<Self> Pointer;
117  typedef SmartPointer<const Self> ConstPointer;
118 
122 
124  itkNewMacro(Self);
125 
127  itkTypeMacro(RotateSHCoefficientsImageFilter, UnaryFunctorImageFilter);
128 
130  {
131  this->GetFunctor().GetSHRotate()->SetTessOrder(3);
132  this->GetFunctor().GetSHRotate()->SetMaxRank(10);
133  this->GetFunctor().GetSHRotate()->Initialize();
134  }
135 
137  void SetRotationMatrix(const MatrixType& mat)
138  {
139  if( !mat.IsEqual(this->GetFunctor().GetRotationMatrix(), 1e-8) )
140  {
141  this->GetFunctor().SetRotationMatrix(mat);
142  this->Modified();
143  }
144  }
145  const MatrixType & GetRotationMatrix() const
146  {
147  return this->GetFunctor().GetRotationMatrix();
148  }
149 
150 protected:
153 
154  void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
155  {
156  Superclass::PrintSelf(os, indent);
157  os << indent << "RotationMatrix: "
158  << this->GetRotationMatrix()
159  << std::endl;
160  }
161 
162 
163 private:
164  RotateSHCoefficientsImageFilter(const Self&); //purposely not implemented
165  void operator=(const Self&); //purposely not implemented
166 
167 };
168 
169 
170 } // end namespace itk
171 
172 
173 #endif
174 
Created "03-26-2014.
bool operator==(const RotateSHCoefficients &other) const
helper functions specifically used in dmritool
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::RotateSHCoefficients< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
SHCoefficientsRotation< double > SHRotationFilter
void SetSHRotate(const SHRotationPointer &ptr)
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
bool IsEqual(const NDArrayBase< T, Dim > &r, const double eps) const
Definition: utlNDArray.h:502
Rotate SH coefficient to all input pixels.
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
const SHRotationPointer & GetSHRotate() const
rotate SH coefficient vector by a given rotation matrix.
bool operator!=(const RotateSHCoefficients &other) const