ANIMA  4.0
animaSimuBlochCoherentGRE.hxx
Go to the documentation of this file.
1 #pragma once
3 
4 #include <itkObjectFactory.h>
5 #include <itkImageRegionIterator.h>
6 #include <itkImageRegionConstIterator.h>
7 
8 namespace anima
9 {
10 
11 template< class TImage>
13 {
14  this->SetNumberOfRequiredInputs(3);
15 }
16 
17 template< class TImage>
19 {
20  SetInput(0, const_cast<TImage*>(T1));
21 }
22 
23 template< class TImage>
25 {
26  SetInput(1, const_cast<TImage*>(T2s));
27 }
28 
29 template< class TImage>
31 {
32  SetInput(2, const_cast<TImage*>(M0));
33 }
34 
35 template< class TImage>
36 void SimuBlochCoherentGRE<TImage>::SetInputT2(const TImage* T2)//changed for CoherentGRE
37 {
38  SetInput(3, const_cast<TImage*>(T2));//changed for CoherentGRE
39 }
40 
41 template< class TImage>//changed for CoherentGRE
42 
45 {
46  typename TImage::ConstPointer T1 = this->GetInput(0);
47  typename TImage::ConstPointer T2s = this->GetInput(1);
48  typename TImage::ConstPointer M0 = this->GetInput(2);
49  typename TImage::ConstPointer T2 = this->GetInput(3);//changed for CoherentGRE
50 
51  itk::ImageRegionIterator<TImage> outputIterator(this->GetOutput(), outputRegionForThread);
52  itk::ImageRegionConstIterator<TImage> inputIteratorT1(T1, outputRegionForThread);
53  itk::ImageRegionConstIterator<TImage> inputIteratorT2s(T2s, outputRegionForThread);
54  itk::ImageRegionConstIterator<TImage> inputIteratorM0(M0, outputRegionForThread);
55  itk::ImageRegionConstIterator<TImage> inputIteratorT2(T2, outputRegionForThread);//changed for CoherentGRE
56 
57  double sinFA= sin(M_PI * m_FA / 180);
58  double cosFA = cos(M_PI * m_FA / 180);
59 
60  // For each voxel, calculate the signal of CoherentGRE
61  while(!outputIterator.IsAtEnd())
62  {
63  if ( (inputIteratorT1.Get() <= 0) || ( inputIteratorT2s.Get() <=0) || ( inputIteratorT2.Get() <=0))//changed for CoherentGRE
64  {
65  outputIterator.Set(0);
66  }
67  else
68  {
69  // outputIterator.Set(inputIteratorM0.Get() * (1- exp(- m_TR / inputIteratorT1.Get())) * sinFA / (1 - exp(- m_TR / inputIteratorT1.Get()) * cosFA - exp( - m_TR / inputIteratorT2.Get() ) * (exp( - m_TR / inputIteratorT1.Get() ) - cosFA) ) * exp(- m_TE / inputIteratorT2s.Get()) ); //changed for CoherentGRE//changed for CoherentGRE
70  outputIterator.Set(inputIteratorM0.Get() * sinFA / (1 + inputIteratorT1.Get() / inputIteratorT2.Get() - cosFA * ( inputIteratorT1.Get()/ inputIteratorT2.Get() -1 ) ) * exp(- m_TE / inputIteratorT2s.Get()) ); //changed for CoherentGRE//changed for CoherentGRE
71  }
72 
73  ++inputIteratorT1;
74  ++inputIteratorT2s;
75  ++inputIteratorM0;
76  ++inputIteratorT2;//changed for CoherentGRE
77 
78  ++outputIterator;
79  }
80 }
81 
82 }// end of namespace anima
Superclass::OutputImageRegionType OutputImageRegionType
virtual void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE