X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=registration%2FclitkBSplineDeformableTransform.txx;h=9d7cc6b8e2427d195544854ce540d75390a0789b;hb=599d581f20dc1f11699c722d2cf40b958c517c74;hp=23851a29d5ad8a2c775befa4f5d1c92b96c38ef9;hpb=3a2e2acdcf35146a7016a9be56ff366208e0d4be;p=clitk.git diff --git a/registration/clitkBSplineDeformableTransform.txx b/registration/clitkBSplineDeformableTransform.txx index 23851a2..9d7cc6b 100644 --- a/registration/clitkBSplineDeformableTransform.txx +++ b/registration/clitkBSplineDeformableTransform.txx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef __clitkBSplineDeformableTransform_txx #define __clitkBSplineDeformableTransform_tx #include "clitkBSplineDeformableTransform.h" @@ -32,7 +32,11 @@ namespace clitk // Constructor with default arguments template BSplineDeformableTransform +#if ITK_VERSION_MAJOR >= 4 + ::BSplineDeformableTransform():Superclass(0) +#else ::BSplineDeformableTransform():Superclass(OutputDimension,0) +#endif { unsigned int i; @@ -251,7 +255,11 @@ namespace clitk // Get the number of parameters template +#if ITK_VERSION_MAJOR >= 4 + typename BSplineDeformableTransform::NumberOfParametersType +#else unsigned int +#endif BSplineDeformableTransform ::GetNumberOfParameters(void) const { @@ -576,10 +584,18 @@ namespace clitk m_CoefficientImage = m_WrappedImage; //JV Wrap jacobian into OutputDimension X Vectorial images +#if ITK_VERSION_MAJOR >= 4 + this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() ); +#else this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() ); +#endif // Use memset to set the memory +#if ITK_VERSION_MAJOR >= 4 + JacobianPixelType * jacobianDataPointer = reinterpret_cast(this->m_SharedDataBSplineJacobian.data_block()); +#else JacobianPixelType * jacobianDataPointer = reinterpret_cast(this->m_Jacobian.data_block()); +#endif memset(jacobianDataPointer, 0, OutputDimension*numberOfPixels*sizeof(JacobianPixelType)); m_LastJacobianIndex = m_ValidRegion.GetIndex(); m_NeedResetJacobian = false; @@ -904,6 +920,69 @@ namespace clitk // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!! // Compute the Jacobian in one position +#if ITK_VERSION_MAJOR >= 4 + template + void + BSplineDeformableTransform + ::ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & jacobian) const + { + if (m_NeedResetJacobian) + ResetJacobian(); + + //======================================================== + // For each dimension, copy the weight to the support region + //======================================================== + + // Check if inside mask + if (m_Mask && !(m_Mask->IsInside(point) ) ) + { + // Outside: no (deformable) displacement + jacobian = m_SharedDataBSplineJacobian; + return; + } + + //Get index + this->TransformPointToContinuousIndex( point, m_Index ); + + // NOTE: if the support region does not lie totally within the grid + // we assume zero displacement and return the input point + if ( !this->InsideValidRegion( m_Index ) ) + { + jacobian = m_SharedDataBSplineJacobian; + return; + } + + //Compute interpolation weights + const WeightsDataType *weights = NULL; + m_VectorInterpolator->EvaluateWeightsAtContinuousIndex( m_Index, &weights, m_LastJacobianIndex); + m_SupportRegion.SetIndex( m_LastJacobianIndex ); + + //Reset the iterators + unsigned int j = 0; + for ( j = 0; j < OutputDimension; j++ ) + m_Iterator[j] = IteratorType( m_JacobianImage[j], m_SupportRegion); + + // For each dimension, copy the weight to the support region + while ( ! (m_Iterator[0]).IsAtEnd() ) + { + //copy weight to jacobian image + for ( j = 0; j < OutputDimension; j++ ) + { + m_ZeroVector[j]=*weights; + (m_Iterator[j]).Set( m_ZeroVector); + m_ZeroVector[j]=itk::NumericTraits::Zero; + ++(m_Iterator[j]); + } + // go to next coefficient in the support region + weights++; + } + m_NeedResetJacobian = true; + + // Return the result + jacobian = m_SharedDataBSplineJacobian; + + } +#else template const typename BSplineDeformableTransform @@ -972,6 +1051,7 @@ namespace clitk return this->m_Jacobian; } +#endif template