From 417fa02691e61ff52abb5ce74c81d767755aca7e Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Mon, 2 May 2011 13:23:43 +0200 Subject: [PATCH] Make clitkBSplineDeformableRegistration work with itk BSplines * clitkBSplineDeformableRegistration did not work with itk Bsplines, certainly due to api evolution. --- ...ineDeformableRegistrationGenericFilter.txx | 119 +++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/registration/clitkBSplineDeformableRegistrationGenericFilter.txx b/registration/clitkBSplineDeformableRegistrationGenericFilter.txx index 5de043f..c49a873 100644 --- a/registration/clitkBSplineDeformableRegistrationGenericFilter.txx +++ b/registration/clitkBSplineDeformableRegistrationGenericFilter.txx @@ -479,6 +479,7 @@ namespace clitk typename RegionType::SizeType gridBorderSize; typename RegionType::SizeType totalGridSize; +#if 0 //Set the number of control points for(unsigned int r=0; rGetSpacing(); + + // Only spacing given: adjust if necessary + if (m_ArgsInfo.spacing_given && !m_ArgsInfo.control_given) + { + for(unsigned int r=0; rGetDirection(); + SpacingType gridOriginOffset = gridDirection * adaptedSpacing; + + // Origin: 1 CP border for spatial dimensions + typedef typename BSplineTransformType::OriginType OriginType; + OriginType gridOrigin = transformRegionOrigin - gridOriginOffset; + if (m_Verbose) std::cout<<"The control point grid origin was set to "<SetGridSpacing( adaptedSpacing ); + bsplineTransform->SetGridOrigin( gridOrigin ); + bsplineTransform->SetGridRegion( bsplineRegion ); + bsplineTransform->SetGridDirection( gridDirection ); + + //Bulk transform + //if (m_Verbose) std::cout<<"Setting rigid transform..."<SetBulkTransform( rigidTransform ); + + //Vector BSpline interpolator + //bsplineTransform->SetOutputSpacing(fixedImage->GetSpacing()); + + // Initial parameters + if (m_ArgsInfo.init_given) + { + typedef itk::ImageFileReader CoefficientReaderType; + typename BSplineTransformType::ImageType::Pointer coeffImages[SpaceDimension]; + for(unsigned int i=0; iSetFileName(m_ArgsInfo.init_arg[i]); + coeffReader->Update(); + coeffImages[i]=coeffReader->GetOutput(); + } + bsplineTransform->SetCoefficientImage(coeffImages); + } + else + { + const unsigned int numberOfParameters = bsplineTransform->GetNumberOfParameters(); + parameters=ParametersType( numberOfParameters ); + parameters.Fill( 0.0 ); + bsplineTransform->SetParameters( parameters ); + } + + // Pass + transform=bsplineTransform; +#endif } @@ -571,10 +687,11 @@ namespace clitk typedef clitk::GenericMetric GenericMetricType; typename GenericMetricType::Pointer genericMetric=GenericMetricType::New(); genericMetric->SetArgsInfo(m_ArgsInfo); + genericMetric->SetFixedImage(fixedImage); + if (spatialObjectMask) genericMetric->SetFixedImageMask( spatialObjectMask ); genericMetric->SetFixedImageRegion(metricRegion); typedef itk::ImageToImageMetric< FixedImageType, MovingImageType > MetricType; typename MetricType::Pointer metric=genericMetric->GetMetricPointer(); - if (spatialObjectMask) metric->SetFixedImageMask( spatialObjectMask ); #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS if (threadsGiven) metric->SetNumberOfThreads( threads ); -- 2.47.1