4 #include <itkImageRegionIterator.h> 5 #include <itkImageRegionConstIterator.h> 12 template <
class TImage,
class TOutputImage>
14 StimulatedSpinEchoImageFilter <TImage,TOutputImage>
15 ::GenerateOutputInformation()
17 this->Superclass::GenerateOutputInformation();
20 output->SetVectorLength(m_NumberOfEchoes);
23 template <
class TImage,
class TOutputImage>
27 this->SetNumberOfRequiredInputs(3);
31 m_ExcitationFlipAngle = M_PI / 2.0;
35 template <
class TImage,
class TOutputImage>
37 ::SetInputT1(
const TImage* T1)
39 SetInput(0, const_cast<TImage*>(T1));
42 template <
class TImage,
class TOutputImage>
44 ::SetInputT2(
const TImage* T2)
46 SetInput(1, const_cast<TImage*>(T2));
49 template <
class TImage,
class TOutputImage>
51 ::SetInputM0(
const TImage* M0)
53 SetInput(2, const_cast<TImage*>(M0));
56 template <
class TImage,
class TOutputImage>
58 ::SetInputB1(
const TImage* B1)
60 this->SetInput(3, const_cast<TImage*>(B1));
63 template <
class TImage,
class TOutputImage>
66 ::GetOutputAs4DImage()
69 unsigned int ndim = outPtr->GetNumberOfComponentsPerPixel();
71 typename Image4DType::RegionType region4d;
72 typename TImage::RegionType region3d = outPtr->GetLargestPossibleRegion();
73 typename Image4DType::SizeType size4d;
74 typename Image4DType::SpacingType spacing4d;
75 typename Image4DType::PointType origin4d;
76 typename Image4DType::DirectionType direction4d;
78 region4d.SetIndex(3,0);
79 region4d.SetSize(3,ndim);
85 for (
unsigned int i = 0;i < 3;++i)
87 region4d.SetIndex(i,region3d.GetIndex()[i]);
88 region4d.SetSize(i,region3d.GetSize()[i]);
90 size4d[i] = region3d.GetSize()[i];
91 spacing4d[i] = outPtr->GetSpacing()[i];
92 origin4d[i] = outPtr->GetOrigin()[i];
93 for (
unsigned int j = 0;j < 3;++j)
94 direction4d(i,j) = (outPtr->GetDirection())(i,j);
100 m_Output4D = Image4DType::New();
101 m_Output4D->Initialize();
102 m_Output4D->SetRegions(region4d);
103 m_Output4D->SetSpacing (spacing4d);
104 m_Output4D->SetOrigin (origin4d);
105 m_Output4D->SetDirection (direction4d);
106 m_Output4D->Allocate();
108 typedef itk::ImageRegionConstIterator <OutputImageType> OutImageIteratorType;
109 typedef itk::ImageRegionIterator <Image4DType> Image4DIteratorType;
111 for (
unsigned int i = 0;i < ndim;++i)
113 region4d.SetIndex(3,i);
114 region4d.SetSize(3,1);
116 OutImageIteratorType outItr(outPtr,region3d);
117 Image4DIteratorType fillItr(m_Output4D,region4d);
119 while (!fillItr.IsAtEnd())
121 fillItr.Set(outItr.Get()[i]);
130 template <
class TImage,
class TOutputImage>
134 typename TImage::ConstPointer T1 = this->GetInput(0);
135 typename TImage::ConstPointer T2 = this->GetInput(1);
136 typename TImage::ConstPointer M0 = this->GetInput(2);
137 typename TImage::ConstPointer B1;
139 itk::ImageRegionIterator <TOutputImage> outputIterator(this->GetOutput(), outputRegionForThread);
140 itk::ImageRegionConstIterator <TImage> inputIteratorT1(T1, outputRegionForThread);
141 itk::ImageRegionConstIterator <TImage> inputIteratorT2(T2, outputRegionForThread);
142 itk::ImageRegionConstIterator <TImage> inputIteratorM0(M0, outputRegionForThread);
144 itk::ImageRegionConstIterator <TImage> inputIteratorB1;
145 bool b1DataPresent = (this->GetNumberOfIndexedInputs() == 4);
148 B1 = this->GetInput(3);
149 inputIteratorB1 = itk::ImageRegionConstIterator <TImage> (B1, outputRegionForThread);
152 typedef typename TOutputImage::PixelType VectorType;
153 VectorType outputVector(m_NumberOfEchoes);
163 while(!outputIterator.IsAtEnd())
165 outputVector.Fill(0);
166 if ((inputIteratorT1.Get() <= 0) || ( inputIteratorT2.Get() <= 0))
168 outputIterator.Set(outputVector);
182 b1Value = inputIteratorB1.Get();
184 double t1Value = inputIteratorT1.Get();
185 double t2Value = inputIteratorT2.Get();
186 double m0Value = inputIteratorM0.Get();
188 tmpOutputVector = t2SignalSimulator.
GetValue(t1Value,t2Value,b1Value * m_FlipAngle,m0Value);
190 for (
unsigned int i = 0;i < m_NumberOfEchoes;++i)
191 outputVector[i] = tmpOutputVector[i];
193 outputIterator.Set(outputVector);
itk::Image< typename TImage::PixelType, 4 > Image4DType
TOutputImage OutputImageType
std::vector< double > RealVectorType
Superclass::OutputImageRegionType OutputImageRegionType
void SetEchoSpacing(double val)
void SetExcitationFlipAngle(double val)
RealVectorType & GetValue(double t1Value, double t2Value, double flipAngle, double m0Value)
Get EPG values at given point.
void SetNumberOfEchoes(unsigned int val)