4 #include <vnl/vnl_matrix_fixed.h> 7 #include <itkImageRegionConstIteratorWithIndex.h> 12 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
16 m_FixedImagePoints.clear();
17 m_FixedImageValues.clear();
25 m_ZeroDiffusionVector = m_ZeroDiffusionModel->GetModelVector();
30 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
38 itkExceptionMacro(
"Fixed image has not been assigned");
40 if (this->m_NumberOfPixelsCounted == 0)
43 this->SetTransformParameters(parameters);
51 MCModelPointer currentMovingValue = movingImage->GetDescriptionModel()->Clone();
55 for (
unsigned int i = 0;i < this->m_NumberOfPixelsCounted;++i)
57 transformedPoint = this->m_Transform->TransformPoint(m_FixedImagePoints[i]);
58 this->m_Interpolator->GetInputImage()->TransformPhysicalPointToContinuousIndex(transformedPoint,transformedIndex);
60 if( this->m_Interpolator->IsInsideBuffer(transformedIndex))
62 movingValue = this->m_Interpolator->EvaluateAtContinuousIndex(transformedIndex);
64 if (!isZero(movingValue))
66 currentMovingValue->SetModelVector(movingValue);
68 if (this->GetModelRotation() != Superclass::NONE)
69 currentMovingValue->Reorient(this->m_OrientationMatrix, (this->GetModelRotation() ==
Superclass::PPD));
72 measure += m_L2DistanceComputer->ComputeDistance(m_FixedImageValues[i],currentMovingValue);
75 measure += m_L2DistanceComputer->ComputeDistance(m_FixedImageValues[i],m_ZeroDiffusionModel);
78 measure += m_L2DistanceComputer->ComputeDistance(m_FixedImageValues[i],m_ZeroDiffusionModel);
81 measure /= this->m_NumberOfPixelsCounted;
85 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
90 unsigned int ndim = vector.GetSize();
92 for (
unsigned int i = 0;i < ndim;++i)
101 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
106 if(!this->m_FixedImage)
107 itkExceptionMacro( <<
"Fixed image has not been assigned" );
110 this->m_NumberOfPixelsCounted = this->GetFixedImageRegion().GetNumberOfPixels();
111 typedef itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
112 FixedIteratorType ti(fixedImage, this->GetFixedImageRegion());
113 typename FixedImageType::IndexType index;
115 m_FixedImagePoints.resize(this->m_NumberOfPixelsCounted);
116 m_FixedImageValues.resize(this->m_NumberOfPixelsCounted);
120 unsigned int pos = 0;
124 index = ti.GetIndex();
125 fixedImage->TransformIndexToPhysicalPoint(index, inputPoint);
127 m_FixedImagePoints[pos] = inputPoint;
128 fixedValue = ti.Get();
130 if (!isZero(fixedValue))
132 m_FixedImageValues[pos] = fixedImage->GetDescriptionModel()->Clone();
133 m_FixedImageValues[pos]->SetModelVector(fixedValue);
137 m_FixedImageValues[pos] = m_ZeroDiffusionModel->Clone();
138 m_FixedImageValues[pos]->SetModelVector(m_ZeroDiffusionVector);
Superclass::MovingImageType MovingImageType
MCMPointer GetNewMultiCompartmentModel()
MeasureType GetValue(const TransformParametersType ¶meters) const ITK_OVERRIDE
Superclass::OutputPointType OutputPointType
Superclass::FixedImageType FixedImageType
void SetNumberOfCompartments(unsigned int num)
Superclass::FixedImageConstPointer FixedImageConstPointer
MCMMeanSquaresImageToImageMetric()
MCModelType::Pointer MCModelPointer
void PreComputeFixedValues()
void SetModelWithStationaryWaterComponent(bool arg)
Superclass::TransformParametersType TransformParametersType
Superclass::InputPointType InputPointType
TFixedImage::PixelType PixelType
Superclass::MeasureType MeasureType
itk::ContinuousIndex< double, ImageDimension > ContinuousIndexType
bool isZero(PixelType &vector) const
Really this class is some simplified factory that creates the MCM that it knows.
void SetModelWithFreeWaterComponent(bool arg)