19 #ifndef __itkDWIGeneratorBase_hxx 20 #define __itkDWIGeneratorBase_hxx 28 template <
class TOutputImage,
class TScalarImage>
32 this->SetNumberOfRequiredOutputs(1);
33 this->SetNthOutput( 0, ( TOutputImage::New() ).GetPointer() );
34 this->SetNthOutput( 1, ( TScalarImage::New() ).GetPointer() );
35 this->SetNthOutput( 2, ( TOutputImage::New() ).GetPointer() );
36 this->SetNthOutput( 3, ( TOutputImage::New() ).GetPointer() );
37 this->SetNthOutput( 4, ( TOutputImage::New() ).GetPointer() );
38 this->SetNthOutput( 5, ( TScalarImage::New() ).GetPointer() );
39 this->SetNthOutput( 6, ( TScalarImage::New() ).GetPointer() );
41 m_SamplingSchemeQSpace = SamplingSchemeQSpaceType::New();
42 m_SamplingSchemeRSpace = SamplingSchemeQSpaceType::New();
44 m_CylinderModel = CylinderModelType::New();
49 m_ModelType = SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS;
51 m_MaxNumberOfPeaks = -1;
54 m_OutputOrigin.Fill(0);
55 m_OutputDirection.SetIdentity();
56 for (
int i = 0; i < OutputImageType::ImageDimension; i += 1 )
59 m_OutputSpacing[i]=1.0;
69 template <
class TOutputImage,
class TScalarImage>
75 template <
class TOutputImage,
class TScalarImage>
76 typename LightObject::Pointer
80 typename LightObject::Pointer loPtr = Superclass::InternalClone();
85 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
88 rval->m_NoiseSigma = m_NoiseSigma;
91 rval->m_ODFOrder = m_ODFOrder;
93 rval->m_ModelType = m_ModelType;
94 rval->m_B0Scale = m_B0Scale;
96 rval->m_MaxNumberOfPeaks = m_MaxNumberOfPeaks;
97 rval->m_PeakType = m_PeakType;
99 rval->m_CylinderModel = m_CylinderModel;
101 rval->m_OutputSize = m_OutputSize;
102 rval->m_OutputSpacing = m_OutputSpacing;
103 rval->m_OutputOrigin = m_OutputOrigin;
104 rval->m_OutputDirection = m_OutputDirection;
106 rval->m_SamplingSchemeQSpace = m_SamplingSchemeQSpace;
107 rval->m_SamplingSchemeRSpace = m_SamplingSchemeRSpace;
109 rval->m_IsOutputDWI=m_IsOutputDWI;
110 rval->m_IsOutputEAP=m_IsOutputEAP;
111 rval->m_IsOutputODF=m_IsOutputODF;
112 rval->m_IsOutputRTO=m_IsOutputRTO;
113 rval->m_IsOutputMSD=m_IsOutputMSD;
118 template <
class TOutputImage,
class TScalarImage>
124 utlGlobalException(!m_IsOutputDWI && !m_IsOutputODF && !m_IsOutputEAP && !m_IsOutputRTO && !m_IsOutputMSD && m_MaxNumberOfPeaks<=0,
"no output!");
125 utlGlobalException(m_IsOutputDWI && this->GetNumberOfQSpaceSamples()==0,
"need to set sampling schemes in q-space for DWI");
126 utlGlobalException((m_IsOutputODF || m_IsOutputEAP) && this->GetNumberOfRSpaceSamples()==0,
"need to set sampling schemes in r-space for EAP or ODF");
128 MatrixPointer qSpaceOrientationMatrix = m_SamplingSchemeQSpace->GetOrientationsCartesian();
130 MatrixPointer rSpaceOrientationMatrix = m_SamplingSchemeRSpace->GetOrientationsCartesian();
132 utlGlobalException(m_IsOutputDWI && qSpaceOrientationMatrix->Rows()!=bVector->size(),
"Need to set OrientationsCartesian and BVector. qSpaceOrientationMatrix->Rows()=" << qSpaceOrientationMatrix->Rows() <<
", bVector->size()=" << bVector->size());
133 utlGlobalException( (m_IsOutputODF || m_IsOutputEAP) && rSpaceOrientationMatrix->Rows()!=rVector->size(),
"Need to set rSpaceOrientationMatrix and rVector");
134 utlGlobalException(m_SNR>0 && m_NoiseSigma>0,
"Only one of m_SNR and m_NoiseSigma is allowed.");
136 double tau = this->m_SamplingSchemeQSpace->GetTau();
137 utlGlobalException(tau!=this->m_SamplingSchemeRSpace->GetTau(),
"need to use the same tau in m_SamplingSchemeQSpace and m_SamplingSchemeRSpace");
142 template <
class TOutputImage,
class TScalarImage>
149 bool isOutputPeak = this->m_MaxNumberOfPeaks>0;
151 OutputImagePointer outputDWI=this->GetDWIImage(), outputODF=this->GetODFImage(), outputEAP=this->GetEAPImage(), outputPeak=this->GetPeakImage();
157 outputStartIndex.Fill(0);
158 outputRegion.SetIndex( outputStartIndex );
159 outputRegion.SetSize( m_OutputSize );
161 int numberOfComponentsPerPixel4DWI = this->GetNumberOfQSpaceSamples();
162 int numberOfComponentsPerPixel4EAP = this->GetNumberOfRSpaceSamples();
163 int numberOfComponentsPerPixel4ODF = this->GetNumberOfRSpaceSamples();
170 outputDWI->SetRegions( outputRegion );
171 outputDWI->SetSpacing( m_OutputSpacing );
172 outputDWI->SetOrigin( m_OutputOrigin );
173 outputDWI->SetDirection( m_OutputDirection );
174 outputDWI->SetNumberOfComponentsPerPixel( numberOfComponentsPerPixel4DWI );
175 zeroPixel.SetSize( numberOfComponentsPerPixel4DWI );
177 outputDWI->Allocate();
178 outputDWI->FillBuffer( zeroPixel );
182 b0Image->SetRegions( outputRegion );
183 b0Image->SetSpacing( m_OutputSpacing );
184 b0Image->SetOrigin( m_OutputOrigin );
185 b0Image->SetDirection( m_OutputDirection );
187 b0Image->FillBuffer( 0 );
192 outputEAP->SetRegions( outputRegion );
193 outputEAP->SetSpacing( m_OutputSpacing );
194 outputEAP->SetOrigin( m_OutputOrigin );
195 outputEAP->SetDirection( m_OutputDirection );
196 outputEAP->SetNumberOfComponentsPerPixel( numberOfComponentsPerPixel4EAP );
197 zeroPixel.SetSize( numberOfComponentsPerPixel4EAP );
199 outputEAP->Allocate();
200 outputEAP->FillBuffer( zeroPixel );
205 outputODF->SetRegions( outputRegion );
206 outputODF->SetSpacing( m_OutputSpacing );
207 outputODF->SetOrigin( m_OutputOrigin );
208 outputODF->SetDirection( m_OutputDirection );
209 outputODF->SetNumberOfComponentsPerPixel( numberOfComponentsPerPixel4ODF );
210 zeroPixel.SetSize( numberOfComponentsPerPixel4ODF );
212 outputODF->Allocate();
213 outputODF->FillBuffer( zeroPixel );
218 outputPeak->SetRegions( outputRegion );
219 outputPeak->SetSpacing( m_OutputSpacing );
220 outputPeak->SetOrigin( m_OutputOrigin );
221 outputPeak->SetDirection( m_OutputDirection );
222 outputPeak->SetNumberOfComponentsPerPixel( numberOfComponentsPerPixel4Peak );
223 zeroPixel.SetSize( numberOfComponentsPerPixel4Peak );
225 outputPeak->Allocate();
226 outputPeak->FillBuffer( zeroPixel );
230 rtoImage->SetRegions( outputRegion );
231 rtoImage->SetSpacing( m_OutputSpacing );
232 rtoImage->SetOrigin( m_OutputOrigin );
233 rtoImage->SetDirection( m_OutputDirection );
234 rtoImage->Allocate();
235 rtoImage->FillBuffer( 0 );
239 msdImage->SetRegions( outputRegion );
240 msdImage->SetSpacing( m_OutputSpacing );
241 msdImage->SetOrigin( m_OutputOrigin );
242 msdImage->SetDirection( m_OutputDirection );
243 msdImage->Allocate();
244 msdImage->FillBuffer( 0 );
248 template <
class TOutputImage,
class TScalarImage>
253 Superclass::PrintSelf(os, indent);
255 os << indent <<
"Gneratortype: " << m_ModelType << std::endl;
256 os << indent <<
"ODFOrder: " << m_ODFOrder << std::endl;
257 os << indent <<
"NoiseSigma: " << m_NoiseSigma << std::endl;
258 os << indent <<
"SNR: " << m_SNR << std::endl;
259 if (m_MaxNumberOfPeaks>0)
261 PrintVar1(
true, m_OutputSize, os<<indent);
262 os << indent <<
"m_SamplingSchemeQSpace: " << m_SamplingSchemeQSpace << std::endl;
263 os << indent <<
"m_SamplingSchemeRSpace: " << m_SamplingSchemeRSpace << std::endl;
OutputImageType::RegionType OutputImageRegionType
#define PrintVar1(cond, var, os)
helper functions specifically used in dmritool
static int GetDimension(const PeakType peakType, const int numberOfPeaks)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
virtual void AllocateOutputs() ITK_OVERRIDE
utl_shared_ptr< STDVectorType > STDVectorPointer
static std::string GetString(const PeakType peakType)
#define utlGlobalException(cond, expout)
utl_shared_ptr< MatrixType > MatrixPointer
OutputImageType::PixelType OutputImagePixelType
ScalarImageType::Pointer ScalarImagePointer
OutputImageType::IndexType OutputImageIndexType
virtual void Initialization()
LightObject::Pointer InternalClone() const ITK_OVERRIDE
Generate DWI data based on provided parameter file.
SmartPointer< Self > Pointer
OutputImageType::Pointer OutputImagePointer
#define utlShowPosition(cond)
#define PrintVar2(cond, var1, var2, os)