14 #ifndef __itkDWIGenerator_hxx 15 #define __itkDWIGenerator_hxx 18 #include "itkImageRegionIteratorWithIndex.h" 22 #include "itksys/SystemTools.hxx" 29 template <
class TOutputImage,
class TScalarImage>
35 template <
class TOutputImage,
class TScalarImage>
41 template <
class TOutputImage,
class TScalarImage>
45 Superclass::PrintSelf(os, indent);
46 os << indent <<
"FileName: " << m_FileName << std::endl;
49 template <
class TOutputImage,
class TScalarImage>
50 typename LightObject::Pointer
54 typename LightObject::Pointer loPtr = Superclass::InternalClone();
59 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
62 rval->m_BackgroundDiffusionParameterValues = m_BackgroundDiffusionParameterValues;
63 rval->m_FileName = m_FileName;
67 template <
class TOutputImage,
class TScalarImage>
73 this->Initialization();
75 bool isOutputPeak = this->m_MaxNumberOfPeaks>0;
77 MatrixPointer qSpaceOrientationMatrix = this->m_SamplingSchemeQSpace->GetOrientationsCartesian();
79 MatrixPointer rSpaceOrientationMatrix = this->m_SamplingSchemeRSpace->GetOrientationsCartesian();
81 double tau = this->m_SamplingSchemeQSpace->GetTau();
83 std::cout <<
"tau = " << tau << std::endl << std::flush;
90 pixelPeak.SetSize(numberOfComponentsPerPixel4Peak);
97 unsigned int ndims = 0;
99 std::string line, extractedLine;
103 double backgroundScale = -1;
107 diffusionParameterContainer.clear();
109 backgroundDiffusionParameterValues.clear();
114 std::vector<std::vector<std::string> > stringMatrix;
117 for (
int i = 0; i < stringMatrix.size(); i += 1 )
119 if (stringMatrix[i][0]==
"NDims" && stringMatrix[i][1]==
"=")
120 std::istringstream ( stringMatrix[i][2] ) >> ndims;
122 if (stringMatrix[i][0]==
"DimSize" && stringMatrix[i][1]==
"=")
124 for (
int kk = 0; kk < stringMatrix[i].size()-2; kk += 1 )
125 std::istringstream ( stringMatrix[i][kk+2] ) >> this->m_OutputSize[kk];
128 if (stringMatrix[i][0]==
"ElementSpacing" && stringMatrix[i][1]==
"=")
130 for (
int kk = 0; kk < stringMatrix[i].size()-2; kk += 1 )
131 std::istringstream ( stringMatrix[i][kk+2] ) >> this->m_OutputSpacing[kk];
151 if (stringMatrix[i][0]==
"Scale" && stringMatrix[i][1]==
"=")
152 std::istringstream ( stringMatrix[i][2] ) >> this->m_B0Scale;
154 if (stringMatrix[i][0]==
"ModelType" && stringMatrix[i][1]==
"=")
156 if (stringMatrix[i][2]==
"SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS")
157 this->m_ModelType = Superclass::SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS;
158 else if (stringMatrix[i][2]==
"SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS")
159 this->m_ModelType = Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS;
160 else if (stringMatrix[i][2]==
"TENSOR_IN_EULER_ANGLES")
162 this->m_ModelType = Superclass::TENSOR_IN_EULER_ANGLES;
165 else if (stringMatrix[i][2]==
"CYLINDER_SPHERICAL_MODEL")
166 this->m_ModelType = Superclass::CYLINDER_SPHERICAL_MODEL;
171 if (stringMatrix[i][0]==
"BackgroundScale" && stringMatrix[i][1]==
"=")
172 std::istringstream ( stringMatrix[i][2] ) >> backgroundScale;
174 if (stringMatrix[i][0]==
"DiffusionParameters" && stringMatrix[i][1]==
"=")
176 diffusionParameterValues.clear();
177 for (
int kk = 0; kk < stringMatrix[i].size()-2; kk += 1 )
178 diffusionParameterValues.push_back( atof(stringMatrix[i][kk+2].c_str()) );
180 diffusionParameterContainer.push_back( diffusionParameterValues );
183 if (stringMatrix[i][0]==
"BackgroundDiffusionParameters" && stringMatrix[i][1]==
"=")
185 backgroundDiffusionParameterValues.clear();
186 for (
int kk = 0; kk < stringMatrix[i].size()-2; kk += 1 )
187 backgroundDiffusionParameterValues.push_back( atof(stringMatrix[i][kk+2].c_str()) );
190 if (stringMatrix[i][0]==
"RicianNoiseSigma" && stringMatrix[i][1]==
"=")
191 std::istringstream ( stringMatrix[i][2] ) >> sigma;
193 if (stringMatrix[i][0]==
"SNR" && stringMatrix[i][1]==
"=")
194 std::istringstream ( stringMatrix[i][2] ) >> snr;
197 if ( this->m_NoiseSigma >= 0 )
199 sigma = this->m_NoiseSigma;
202 if ( this->m_SNR >= 0 )
207 utlException(snr>0 && sigma>0,
"snr and sigma can not be set simultaneously. snr="<<snr<<
", sigma="<<sigma);
209 scale = this->m_B0Scale;
210 if (backgroundScale<=0)
211 backgroundScale = this->m_B0Scale;
214 for (
int i = this->m_OutputSize.GetSizeDimension()-1; i >= 0; i -= 1 )
216 if (this->m_OutputSize[i]==1)
217 this->m_OutputSpacing[i] = 1;
223 this->AllocateOutputs();
226 OutputImagePointer outputDWI=this->GetDWIImage(), outputODF=this->GetODFImage(), outputEAP=this->GetEAPImage(), outputPeak=this->GetPeakImage();
227 ScalarImagePointer b0Image = this->GetB0Image(), outputRTO = this->GetRTOImage(), outputMSD = this->GetMSDImage();
229 double pixelRTO=0, tempPixelRTO=0, pixelMSD=0, tempPixelMSD=0;
230 unsigned int numberOfComponentsPerPixel4DWI = this->GetNumberOfQSpaceSamples();
231 unsigned int numberOfComponentsPerPixel4EAP = this->GetNumberOfRSpaceSamples();
232 unsigned int numberOfComponentsPerPixel4ODF = this->GetNumberOfRSpaceSamples();
234 if (this->m_IsOutputDWI)
236 pixelDWI.SetSize( numberOfComponentsPerPixel4DWI );
238 tempPixelDWI.SetSize( numberOfComponentsPerPixel4DWI );
239 tempPixelDWI.Fill( 0 );
241 if (this->m_IsOutputEAP)
243 pixelEAP.SetSize( numberOfComponentsPerPixel4EAP );
245 tempPixelEAP.SetSize( numberOfComponentsPerPixel4EAP );
246 tempPixelEAP.Fill( 0 );
248 if (this->m_IsOutputODF)
250 pixelODF.SetSize( numberOfComponentsPerPixel4ODF );
252 tempPixelODF.SetSize( numberOfComponentsPerPixel4ODF );
253 tempPixelODF.Fill( 0 );
260 int numberOfParameterSets = -1;
261 unsigned int numberOfOrientationComponentsPerParameterSet = 3;
262 int numberOfComponentsPerParameterSet = -1;
263 int numberOfDiffusivityComponentsPerParameterSet = -1;
265 bool isTensorModel=
false;
268 bool isCylinderModel=
false;
272 if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS)
274 numberOfDiffusivityComponentsPerParameterSet=2;
275 numberOfOrientationComponentsPerParameterSet = 3;
276 numberOfComponentsPerParameterSet = 6;
277 isTensorModel =
true;
279 else if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS)
281 numberOfDiffusivityComponentsPerParameterSet=2;
282 numberOfOrientationComponentsPerParameterSet = 2;
283 numberOfComponentsPerParameterSet = 5;
284 isTensorModel =
true;
286 else if (this->m_ModelType==Superclass::TENSOR_IN_EULER_ANGLES)
288 numberOfDiffusivityComponentsPerParameterSet=3;
289 numberOfOrientationComponentsPerParameterSet = 3;
290 numberOfComponentsPerParameterSet = 7;
291 isTensorModel =
true;
294 else if (this->m_ModelType==Superclass::CYLINDER_SPHERICAL_MODEL)
296 numberOfDiffusivityComponentsPerParameterSet=0;
297 numberOfOrientationComponentsPerParameterSet = 2;
298 numberOfComponentsPerParameterSet = 3;
299 isCylinderModel =
true;
306 this->m_CylinderModel->SetDebug(this->GetDebug());
307 this->m_CylinderModel->BuildTable();
308 this->m_CylinderModel->SetSamplingSchemeQSpace(this->m_SamplingSchemeQSpace);
309 this->m_CylinderModel->SetSamplingSchemeRSpace(this->m_SamplingSchemeRSpace);
312 Vector<PrecisionType, 3> principalDirection(0.0);
314 if (numberOfDiffusivityComponentsPerParameterSet>0)
315 diffusivities.resize(numberOfDiffusivityComponentsPerParameterSet);
316 Vector<PrecisionType, 3> e1;
317 e1[0]=1.0, e1[1]=0.0, e1[2]=0.0;
318 double partialVolumeWeight = 0;
328 for (
unsigned int k=0; k<diffusionParameterContainer.size(); k++ )
330 diffusionParameterValues = diffusionParameterContainer[k];
332 for (
unsigned int dim=0; dim<ndims; dim++ )
334 index[dim] = diffusionParameterValues[dim];
336 if (this->GetDebug())
338 std::cout <<
"index = " << index << std::endl << std::flush;
343 utlSAGlobalException(!
utl::IsInt( (1.0*diffusionParameterValues.size()-ndims)/numberOfComponentsPerParameterSet) )(diffusionParameterValues.size())(ndims)(numberOfComponentsPerParameterSet).msg(
"wrong diffusion parameter size");
344 numberOfParameterSets = ( diffusionParameterValues.size() - ndims ) /numberOfComponentsPerParameterSet;
345 if (this->m_IsOutputDWI)
347 if (this->m_IsOutputEAP)
349 if (this->m_IsOutputODF)
353 pixelMSD=0, pixelRTO=0;
359 for (
unsigned int s=0; s<numberOfParameterSets; s++ )
361 for (
unsigned int d=0; d<numberOfOrientationComponentsPerParameterSet; d++ )
362 principalDirection[d] = diffusionParameterValues[ndims + s* numberOfComponentsPerParameterSet + d];
364 norm = principalDirection.GetNorm();
365 if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS || this->m_ModelType==Superclass::CYLINDER_SPHERICAL_MODEL)
367 principalDirection *= vnl_math::pi/180.0;
368 double theta=principalDirection[0], phi=principalDirection[1];
373 for (
unsigned int d=0; d<3; d++ )
374 principalDirection[d] /= norm;
377 for (
unsigned int d=0; d<numberOfDiffusivityComponentsPerParameterSet; d++ )
379 diffusivities[d] = diffusionParameterValues[ndims + s
380 * numberOfComponentsPerParameterSet
381 + numberOfOrientationComponentsPerParameterSet + d ];
383 if (diffusivities.size()>0)
384 std::sort(diffusivities.begin(), diffusivities.end(), std::greater<double>());
386 partialVolumeWeight = diffusionParameterValues[ndims + s
387 * numberOfComponentsPerParameterSet
388 + numberOfOrientationComponentsPerParameterSet
389 + numberOfDiffusivityComponentsPerParameterSet];
391 sumPartialVolumeWeight += partialVolumeWeight;
398 PeakContainerHelper::SetPeak<Vector<double,3>,
OutputImagePixelType >(principalDirection, pixelPeak, s, this->m_PeakType);
399 if (this->m_PeakType==
NXYZV || this->m_PeakType==
XYZV)
400 PeakContainerHelper::SetPeakValue<OutputImagePixelType >(partialVolumeWeight, pixelPeak, s, this->m_PeakType);
406 std::vector<double> vec(3,1);
407 if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS || this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS)
408 vec[0]=diffusivities[0], vec[1]=diffusivities[1], vec[2]=diffusivities[1];
409 else if (this->m_ModelType==Superclass::TENSOR_IN_EULER_ANGLES)
410 vec[0]=diffusivities[0], vec[1]=diffusivities[1], vec[2]=diffusivities[2];
414 Matrix<double,3,3> rotation;
415 utl::RotationMatrixFromVectors<Vector<double,3>, Matrix<double,3> >(e1, principalDirection, rotation);
419 if ( this->m_IsOutputDWI )
421 tensor.
GetDWISamples(tempPixelDWI, *qSpaceOrientationMatrix, *bVector);
424 pixelDWI += tempPixelDWI*scale*partialVolumeWeight;
426 if ( this->m_IsOutputODF )
428 tensor.
GetODFSamples(tempPixelODF, *rSpaceOrientationMatrix,this->m_ODFOrder,
false);
429 pixelODF += tempPixelODF*partialVolumeWeight;
431 if ( this->m_IsOutputEAP)
433 tensor.
GetEAPSamples(tempPixelEAP, *rSpaceOrientationMatrix, *rVector,tau);
434 pixelEAP += tempPixelEAP*partialVolumeWeight;
437 if ( this->m_IsOutputRTO)
440 pixelRTO += tempPixelRTO*partialVolumeWeight;
442 if ( this->m_IsOutputMSD)
445 pixelMSD += tempPixelMSD*partialVolumeWeight;
448 else if (isCylinderModel)
450 cylinderAxis[0] = principalDirection[0];
451 cylinderAxis[1] = principalDirection[1];
452 cylinderAxis[2] = principalDirection[2];
453 this->m_CylinderModel->SetCylinderAxis(cylinderAxis);
454 if (this->m_IsOutputDWI)
456 if (this->GetDebug())
457 this->m_CylinderModel->Print(std::cout<<
"this->m_CylinderModel=");
458 this->m_CylinderModel->ComputeDWISamples();
459 tempPixelDWIVec = this->m_CylinderModel->GetDWISamples();
460 for (
int i = 0; i < tempPixelDWIVec->size(); i += 1 )
461 pixelDWI[i] += (*tempPixelDWIVec)[i]*scale*partialVolumeWeight;
463 if ( this->m_IsOutputODF )
467 if ( this->m_IsOutputEAP )
471 if ( this->m_IsOutputRTO )
475 if ( this->m_IsOutputMSD )
484 if (this->m_PeakType==
NXYZ || this->m_PeakType==
NXYZV)
485 pixelPeak[0] = numberOfPeaks;
488 utlException(sumPartialVolumeWeight<1e-9,
"wrong partialVolumeWeight");
489 if ( this->m_IsOutputDWI )
490 pixelDWI /= sumPartialVolumeWeight;
491 if ( this->m_IsOutputODF )
492 pixelODF /= sumPartialVolumeWeight;
493 if ( this->m_IsOutputEAP )
494 pixelEAP /= sumPartialVolumeWeight;
495 if ( this->m_IsOutputRTO )
496 pixelRTO /= sumPartialVolumeWeight;
497 if ( this->m_IsOutputMSD )
498 pixelMSD /= sumPartialVolumeWeight;
499 if (this->m_IsOutputODF && this->m_ODFOrder!=2)
501 PrecisionType normFactor = 4*vnl_math::pi*utl::GetSumOfVector<OutputImagePixelType>(pixelODF,pixelODF.Size()) / pixelODF.Size();
503 pixelODF /= normFactor;
507 if ( this->m_IsOutputDWI && (sigma>0 || snr>0) && pixelDWI.GetSquaredNorm()>0 )
510 if ( snr > 0 && sigma <= 0)
513 for (
unsigned int k=0; k<numberOfComponentsPerPixel4DWI; k++ )
515 mean /= numberOfComponentsPerPixel4DWI;
516 sigma_real = mean/snr;
518 else if ( snr <= 0 && sigma > 0)
521 pixelDWI = utl::AddNoise<OutputImagePixelType>(pixelDWI, pixelDWI.GetSize(), sigma_real,
true);
526 outputPeak->SetPixel(index, pixelPeak);
528 if ( this->m_IsOutputDWI )
530 outputDWI->SetPixel(index, pixelDWI);
531 b0Image->SetPixel(index, scale);
533 if ( this->m_IsOutputODF )
534 outputODF->SetPixel(index, pixelODF);
535 if ( this->m_IsOutputEAP )
536 outputEAP->SetPixel(index, pixelEAP);
537 if ( this->m_IsOutputRTO )
538 outputRTO->SetPixel(index, pixelRTO);
539 if ( this->m_IsOutputMSD )
540 outputMSD->SetPixel(index, pixelMSD);
543 ImageRegionIteratorWithIndex<OutputImageType> outputDWIIt, outputODFIt, outputEAPIt, outputPeakIt;
544 ImageRegionIteratorWithIndex<ScalarImageType> b0It, outputRTOIt, outputMSDIt;
545 if ( this->m_IsOutputDWI )
547 outputDWIIt = ImageRegionIteratorWithIndex<OutputImageType>( outputDWI, outputDWI->GetRequestedRegion() );
548 b0It = ImageRegionIteratorWithIndex<ScalarImageType>( b0Image, outputDWI->GetRequestedRegion() );
550 if ( this->m_IsOutputODF )
551 outputODFIt = ImageRegionIteratorWithIndex<OutputImageType>( outputODF, outputODF->GetRequestedRegion() );
552 if ( this->m_IsOutputEAP )
553 outputEAPIt = ImageRegionIteratorWithIndex<OutputImageType>( outputEAP, outputEAP->GetRequestedRegion() );
555 outputPeakIt = ImageRegionIteratorWithIndex<OutputImageType>( outputPeak, outputPeak->GetRequestedRegion() );
556 if ( this->m_IsOutputRTO )
557 outputRTOIt = ImageRegionIteratorWithIndex<ScalarImageType>( outputRTO, outputRTO->GetRequestedRegion() );
558 if ( this->m_IsOutputMSD )
559 outputMSDIt = ImageRegionIteratorWithIndex<ScalarImageType>( outputMSD, outputMSD->GetRequestedRegion() );
562 if (m_BackgroundDiffusionParameterValues.size()>0)
563 backgroundDiffusionParameterValues = m_BackgroundDiffusionParameterValues;
566 if ( backgroundDiffusionParameterValues.size() > 0 )
568 numberOfParameterSets = backgroundDiffusionParameterValues.size() /numberOfComponentsPerParameterSet;
571 if (this->m_IsOutputDWI)
573 if (this->m_IsOutputEAP)
575 if (this->m_IsOutputODF)
577 pixelRTO=0, pixelMSD=0;
580 for (
unsigned int s=0; s<numberOfParameterSets; s++ )
582 for (
unsigned int d=0; d<numberOfOrientationComponentsPerParameterSet; d++ )
583 principalDirection[d] = backgroundDiffusionParameterValues[s* numberOfComponentsPerParameterSet + d];
587 norm = principalDirection.GetNorm();
588 if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS || this->m_ModelType==Superclass::CYLINDER_SPHERICAL_MODEL)
590 principalDirection *= vnl_math::pi/180.0;
591 double theta=principalDirection[0], phi=principalDirection[1];
596 for (
unsigned int d=0; d<3; d++ )
597 principalDirection[d] /= norm;
600 for (
unsigned int d=0; d<numberOfDiffusivityComponentsPerParameterSet; d++ )
602 diffusivities[d] = backgroundDiffusionParameterValues[s* numberOfComponentsPerParameterSet
603 + numberOfOrientationComponentsPerParameterSet + d ];
605 if (diffusivities.size()>0)
606 std::sort(diffusivities.begin(), diffusivities.end(), std::greater<double>());
608 partialVolumeWeight = backgroundDiffusionParameterValues[s* numberOfComponentsPerParameterSet
609 + numberOfOrientationComponentsPerParameterSet
610 + numberOfDiffusivityComponentsPerParameterSet];
612 sumPartialVolumeWeight += partialVolumeWeight;
616 std::vector<double> vec(3,1);
617 if (this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_CARTESIAN_COORDS || this->m_ModelType==Superclass::SYMMETRICAL_TENSOR_IN_SPHERICAL_COORDS)
618 vec[0]=diffusivities[0], vec[1]=diffusivities[1], vec[2]=diffusivities[1];
619 else if (this->m_ModelType==Superclass::TENSOR_IN_EULER_ANGLES)
620 vec[0]=diffusivities[0], vec[1]=diffusivities[1], vec[2]=diffusivities[2];
624 Matrix<double,3,3> rotation;
625 utl::RotationMatrixFromVectors<Vector<double,3>, Matrix<double,3> >(e1, principalDirection, rotation);
629 if ( this->m_IsOutputDWI )
631 tensor.
GetDWISamples(tempPixelDWI, *qSpaceOrientationMatrix, *bVector);
632 pixelDWI += tempPixelDWI*backgroundScale*partialVolumeWeight;
634 if ( this->m_IsOutputODF )
636 tensor.
GetODFSamples(tempPixelODF, *rSpaceOrientationMatrix,this->m_ODFOrder,
false);
637 pixelODF += tempPixelODF*partialVolumeWeight;
639 if ( this->m_IsOutputEAP)
641 tensor.
GetEAPSamples(tempPixelEAP, *rSpaceOrientationMatrix, *rVector,tau);
642 pixelEAP += tempPixelEAP*partialVolumeWeight;
644 if ( this->m_IsOutputRTO)
647 pixelRTO += tempPixelRTO*partialVolumeWeight;
649 if ( this->m_IsOutputMSD)
652 pixelMSD += tempPixelMSD*partialVolumeWeight;
655 else if (isCylinderModel)
657 cylinderAxis[0] = principalDirection[0];
658 cylinderAxis[1] = principalDirection[1];
659 cylinderAxis[2] = principalDirection[2];
660 this->m_CylinderModel->SetCylinderAxis(cylinderAxis);
661 if (this->m_IsOutputDWI)
664 this->m_CylinderModel->ComputeDWISamples();
665 tempPixelDWIVec = this->m_CylinderModel->GetDWISamples();
666 for (
int i = 0; i < tempPixelDWIVec->size(); i += 1 )
667 pixelDWI[i] += (*tempPixelDWIVec)[i]*backgroundScale*partialVolumeWeight;
673 utlException(sumPartialVolumeWeight<1e-9,
"wrong partialVolumeWeight");
674 if ( this->m_IsOutputDWI )
675 pixelDWI /= sumPartialVolumeWeight;
676 if ( this->m_IsOutputODF )
677 pixelODF /= sumPartialVolumeWeight;
678 if ( this->m_IsOutputEAP )
679 pixelEAP /= sumPartialVolumeWeight;
680 if ( this->m_IsOutputRTO )
681 pixelRTO /= sumPartialVolumeWeight;
682 if ( this->m_IsOutputMSD )
683 pixelMSD /= sumPartialVolumeWeight;
684 if (this->m_IsOutputODF && this->m_ODFOrder!=2)
686 PrecisionType normFactor = 4*vnl_math::pi*utl::GetSumOfVector<OutputImagePixelType>(pixelODF,pixelODF.Size()) / pixelODF.Size();
688 pixelODF /= normFactor;
693 if ( this->m_IsOutputDWI && (sigma>0 || snr>0) && pixelDWI.GetSquaredNorm()>0 )
695 if ( snr > 0 && sigma <= 0)
698 for (
unsigned int k=0; k<numberOfComponentsPerPixel4DWI; k++ )
700 mean /= numberOfComponentsPerPixel4DWI;
701 sigma_real = mean/snr;
703 else if ( snr <= 0 && sigma > 0)
709 if (this->m_IsOutputDWI)
712 outputDWIIt.GoToBegin();
714 while ( !b0It.IsAtEnd() )
716 if ( outputDWIIt.Get().GetNorm() == 0 )
719 pixel_noise = utl::AddNoise<OutputImagePixelType>(pixelDWI, pixelDWI.GetSize(), sigma_real,
true);
720 outputDWIIt.Set( pixel_noise );
721 b0It.Set( backgroundScale );
728 if (this->m_IsOutputODF)
730 outputODFIt.GoToBegin();
731 while ( !outputODFIt.IsAtEnd() )
733 if ( outputODFIt.Get().GetNorm() == 0 )
734 outputODFIt.Set( pixelODF );
739 if (this->m_IsOutputEAP)
741 outputEAPIt.GoToBegin();
742 while ( !outputEAPIt.IsAtEnd() )
744 if ( outputEAPIt.Get().GetNorm() == 0 )
745 outputEAPIt.Set( pixelEAP );
750 if (this->m_IsOutputRTO)
752 outputRTOIt.GoToBegin();
753 while ( !outputRTOIt.IsAtEnd() )
755 if ( outputRTOIt.Get() == 0 )
756 outputRTOIt.Set( pixelRTO );
760 if (this->m_IsOutputMSD)
762 outputMSDIt.GoToBegin();
763 while ( !outputMSDIt.IsAtEnd() )
765 if ( outputMSDIt.Get() == 0 )
766 outputMSDIt.Set( pixelMSD );
Superclass::DiffusionParameterValuesType DiffusionParameterValuesType
void GetEAPSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &rValues, const TPrecision &tau) const
Superclass::STDVectorPointer STDVectorPointer
Superclass::OutputImagePointer OutputImagePointer
SmartPointer< Self > Pointer
helper functions specifically used in dmritool
void GetDWISamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &bValues) const
static int GetDimension(const PeakType peakType, const int numberOfPeaks)
#define utlException(cond, expout)
bool IsFileExist(const std::string &file)
void spherical2Cartesian(const T r, const T theta, const T phi, T &x, T &y, T &z)
RealValueType GetReturnToOrigin(const TPrecision tau) const
#define utlSAGlobalException(expr)
Superclass::OutputImageIndexType OutputImageIndexType
static void sort(int *irOut, T *prOut, int beg, int end)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
Self & Rotate(const typename Self::MatrixType &mat)
Superclass::ScalarImagePointer ScalarImagePointer
Superclass::PointType PointType
Superclass::DiffusionParameterContainerType DiffusionParameterContainerType
#define utlGlobalException(cond, expout)
Superclass::VectorPointer VectorPointer
bool IsInt(const std::string &input, const double epss=1e-10)
Superclass::MatrixPointer MatrixPointer
LightObject::Pointer InternalClone() const ITK_OVERRIDE
void SetEigenValues(const TArrayType &array)
Generate DWI data based on provided parameter file.
Superclass::STDVectorType STDVectorType
void PrintVector(const std::vector< T > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)
Generate DWI data based on provided parameter file.
void ReadLines(const std::string &filename, std::vector< std::vector< std::string > > &strVec, const char *cc=" ")
Superclass::OutputImagePixelType OutputImagePixelType
#define utlShowPosition(cond)
Superclass::PrecisionType PrecisionType
RealValueType GetMeanSquaredDisplacement(const TPrecision tau) const
void GetODFSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const int &odfOrder=2, const bool &isNormalize=false) const
tensor with some useful functions