From: tbaudier Date: Tue, 7 Aug 2018 08:26:42 +0000 (+0200) Subject: Ensure compatibility with ITK5 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6e0a67751d42e76d806ea3245b4eaf545cf3e404;p=clitk.git Ensure compatibility with ITK5 Change NumberOfThreads to NumberOfWorkUnits --- diff --git a/itk/clitkForwardWarpImageFilter.h b/itk/clitkForwardWarpImageFilter.h index 85a5c22..7efac8f 100644 --- a/itk/clitkForwardWarpImageFilter.h +++ b/itk/clitkForwardWarpImageFilter.h @@ -71,10 +71,18 @@ namespace clitk itkSetMacro( Verbose, bool); itkSetMacro( EdgePaddingValue, PixelType ); itkSetMacro( DeformationField, typename DeformationFieldType::Pointer); +#if ITK_VERSION_MAJOR <= 4 void SetNumberOfThreads(unsigned int r ) +#else + void SetNumberOfWorkUnits(unsigned int r ) +#endif { m_NumberOfThreadsIsGiven=true; +#if ITK_VERSION_MAJOR <= 4 m_NumberOfThreads=r; +#else + m_NumberOfWorkUnits=r; +#endif } itkSetMacro(ThreadSafe, bool); @@ -102,7 +110,11 @@ namespace clitk private: bool m_Verbose; bool m_NumberOfThreadsIsGiven; +#if ITK_VERSION_MAJOR <= 4 unsigned int m_NumberOfThreads; +#else + unsigned int m_NumberOfWorkUnits; +#endif PixelType m_EdgePaddingValue; typename DeformationFieldType::Pointer m_DeformationField; bool m_ThreadSafe; diff --git a/itk/clitkForwardWarpImageFilter.txx b/itk/clitkForwardWarpImageFilter.txx index f5e9853..4d49b4d 100644 --- a/itk/clitkForwardWarpImageFilter.txx +++ b/itk/clitkForwardWarpImageFilter.txx @@ -445,7 +445,13 @@ void ForwardWarpImageFilterSetNumberOfThreads(m_NumberOfThreads); + if(m_NumberOfThreadsIsGiven) { +#if ITK_VERSION_MAJOR <= 4 + helper1->SetNumberOfThreads(m_NumberOfThreads); +#else + helper1->SetNumberOfWorkUnits(m_NumberOfWorkUnits); +#endif + } helper1->SetInput(inputPtr); helper1->SetDeformationField(m_DeformationField); helper1->SetWeights(weights); @@ -478,7 +484,13 @@ void ForwardWarpImageFilterSetNumberOfThreads(m_NumberOfThreads); + if(m_NumberOfThreadsIsGiven) { +#if ITK_VERSION_MAJOR <= 4 + helper2->SetNumberOfThreads(m_NumberOfThreads); +#else + helper2->SetNumberOfWorkUnits(m_NumberOfWorkUnits); +#endif + } helper2->SetInput(temp); helper2->SetWeights(weights); helper2->SetEdgePaddingValue(m_EdgePaddingValue); diff --git a/itk/clitkInvertVFFilter.h b/itk/clitkInvertVFFilter.h index 52edcd9..8ad84a2 100644 --- a/itk/clitkInvertVFFilter.h +++ b/itk/clitkInvertVFFilter.h @@ -65,10 +65,18 @@ namespace clitk //Set Methods(inline) itkSetMacro( Verbose, bool); itkSetMacro( EdgePaddingValue, PixelType ); +#if ITK_VERSION_MAJOR <= 4 void SetNumberOfThreads(unsigned int r ) ITK_OVERRIDE +#else + void SetNumberOfWorkUnits(unsigned int r ) ITK_OVERRIDE +#endif { m_NumberOfThreadsIsGiven=true; +#if ITK_VERSION_MAJOR <= 4 m_NumberOfThreads=r; +#else + m_NumberOfWorkUnits=r; +#endif } itkSetMacro(ThreadSafe, bool); itkSetMacro(OutputSpacing, SpacingType); @@ -84,7 +92,11 @@ namespace clitk bool m_NumberOfThreadsIsGiven; SpacingType m_OutputSpacing; SizeType m_OutputSize; +#if ITK_VERSION_MAJOR <= 4 unsigned int m_NumberOfThreads; +#else + unsigned int m_NumberOfWorkUnits; +#endif PixelType m_EdgePaddingValue; bool m_ThreadSafe; }; diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index 4b98230..b2485e0 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -438,7 +438,13 @@ template void InvertVFFilterSetNumberOfThreads(m_NumberOfThreads); + if(m_NumberOfThreadsIsGiven) { +#if ITK_VERSION_MAJOR <= 4 + helper1->SetNumberOfThreads(m_NumberOfThreads); +#else + helper1->SetNumberOfWorkUnits(m_NumberOfWorkUnits); +#endif + } helper1->SetInput(inputPtr); helper1->SetWeights(weights); @@ -468,7 +474,13 @@ template void InvertVFFilterSetNumberOfThreads(m_NumberOfThreads); + if(m_NumberOfThreadsIsGiven) { +#if ITK_VERSION_MAJOR <= 4 + helper2->SetNumberOfThreads(m_NumberOfThreads); +#else + helper2->SetNumberOfWorkUnits(m_NumberOfWorkUnits); +#endif + } helper2->SetInput(temp); helper2->SetWeights(weights); helper2->SetEdgePaddingValue(m_EdgePaddingValue); diff --git a/itk/clitkResampleImageWithOptionsFilter.txx b/itk/clitkResampleImageWithOptionsFilter.txx index 4c949ce..97f6f41 100644 --- a/itk/clitkResampleImageWithOptionsFilter.txx +++ b/itk/clitkResampleImageWithOptionsFilter.txx @@ -224,7 +224,11 @@ GenerateData() case B_LUT: std::cout << "B-LUT " << m_BSplineOrder << " " << m_BLUTSamplingFactor << std::endl; break; case WSINC: std::cout << "Windowed Sinc" << std::endl; break; } +#if ITK_VERSION_MAJOR <= 4 std::cout << "Threads = " << this->GetNumberOfThreads() << std::endl; +#else + std::cout << "Threads = " << this->GetNumberOfWorkUnits() << std::endl; +#endif std::cout << "LastDimIsTime = " << m_LastDimensionIsTime << std::endl; } @@ -241,7 +245,11 @@ GenerateData() filter->SetOutputSpacing(m_OutputSpacing); filter->SetOutputOrigin(m_OutputOrigin); filter->SetDefaultPixelValue(m_DefaultPixelValue); +#if ITK_VERSION_MAJOR <= 4 filter->SetNumberOfThreads(this->GetNumberOfThreads()); +#else + filter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); +#endif filter->SetOutputDirection(m_OutputDirection); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example) // Select interpolator diff --git a/registration/clitkAffineRegistrationGenericFilter.cxx b/registration/clitkAffineRegistrationGenericFilter.cxx index 17ebca9..d034912 100644 --- a/registration/clitkAffineRegistrationGenericFilter.cxx +++ b/registration/clitkAffineRegistrationGenericFilter.cxx @@ -393,7 +393,13 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType() typename MetricType::Pointer metric=genericMetric->GetMetricPointer(); if (movingMask) metric->SetMovingImageMask(movingMask); - if (threadsGiven) metric->SetNumberOfThreads( threads ); + if (threadsGiven) { +#if ITK_VERSION_MAJOR <= 4 + metric->SetNumberOfThreads( threads ); +#else + metric->SetNumberOfWorkUnits( threads ); +#endif + } //============================================================================ // Initialize using image moments. diff --git a/registration/clitkBLUTDIRGenericFilter.cxx b/registration/clitkBLUTDIRGenericFilter.cxx index 35ac6eb..24d4613 100644 --- a/registration/clitkBLUTDIRGenericFilter.cxx +++ b/registration/clitkBLUTDIRGenericFilter.cxx @@ -649,7 +649,11 @@ namespace clitk typename MetricType::Pointer metric=genericMetric->GetMetricPointer(); if (movingMask) metric->SetMovingImageMask(movingMask); if (threadsGiven) { +#if ITK_VERSION_MAJOR <= 4 metric->SetNumberOfThreads( threads ); +#else + metric->SetNumberOfWorkUnits( threads ); +#endif if (m_Verbose) std::cout<< "Using " << threads << " threads." << std::endl; } @@ -675,7 +679,11 @@ namespace clitk registration->SetInterpolator( interpolator ); registration->SetTransform (regTransform ); if(threadsGiven) { +#if ITK_VERSION_MAJOR <= 4 registration->SetNumberOfThreads(threads); +#else + registration->SetNumberOfWorkUnits(threads); +#endif if (m_Verbose) std::cout<< "Using " << threads << " threads." << std::endl; } registration->SetFixedImage( croppedFixedImage ); @@ -793,7 +801,11 @@ namespace clitk typedef itk::TransformToDisplacementFieldFilter ConvertorType; #endif typename ConvertorType::Pointer filter= ConvertorType::New(); +#if ITK_VERSION_MAJOR <= 4 filter->SetNumberOfThreads(1); +#else + filter->SetNumberOfWorkUnits(1); +#endif if(m_ArgsInfo.itkbspline_flag) sTransform->SetBulkTransform(ITK_NULLPTR); else diff --git a/registration/clitkDemonsDeformableRegistrationGenericFilter.txx b/registration/clitkDemonsDeformableRegistrationGenericFilter.txx index d4b0cb2..0c49dd7 100644 --- a/registration/clitkDemonsDeformableRegistrationGenericFilter.txx +++ b/registration/clitkDemonsDeformableRegistrationGenericFilter.txx @@ -335,7 +335,13 @@ namespace clitk // ======================================================= // The multiresolution scheme // ======================================================= - if (threadsGiven) multiResolutionFilter->SetNumberOfThreads(threads); + if (threadsGiven) { +#if ITK_VERSION_MAJOR <= 4 + multiResolutionFilter->SetNumberOfThreads(threads); +#else + multiResolutionFilter->SetNumberOfWorkUnits(threads); +#endif + } unsigned int nLevels=m_ArgsInfo.levels_arg; if (m_Verbose) std::cout<<"Setting the number of resolution levels to "<SetFixedImage( fixedImage ); @@ -343,8 +349,14 @@ namespace clitk multiResolutionFilter->SetNumberOfLevels( nLevels ); multiResolutionFilter->SetFixedImagePyramid( fixedImagePyramid ); multiResolutionFilter->SetMovingImagePyramid( movingImagePyramid ); - if (threadsGiven) multiResolutionFilter->SetNumberOfThreads( threads ); - + if (threadsGiven) { +#if ITK_VERSION_MAJOR <= 4 + multiResolutionFilter->SetNumberOfThreads( threads ); +#else + multiResolutionFilter->SetNumberOfWorkUnits( threads ); +#endif + } + //------------------------------------ //Set the number of iterations //------------------------------------ diff --git a/registration/clitkOptNormalizedCorrelationImageToImageMetric.txx b/registration/clitkOptNormalizedCorrelationImageToImageMetric.txx index 0f8fa64..146fb00 100644 --- a/registration/clitkOptNormalizedCorrelationImageToImageMetric.txx +++ b/registration/clitkOptNormalizedCorrelationImageToImageMetric.txx @@ -130,44 +130,74 @@ NormalizedCorrelationImageToImageMetric if(m_ThreaderSFF != NULL) { delete [] m_ThreaderSFF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSFF = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSFF = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSMM != NULL) { delete [] m_ThreaderSMM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSMM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSMM = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSFM != NULL) { delete [] m_ThreaderSFM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSFM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSFM = new double[this->m_NumberOfWorkUnits]; +#endif if(this->m_SubtractMean) { if(m_ThreaderSF != NULL) { delete [] m_ThreaderSF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSF = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSF = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSM != NULL) { delete [] m_ThreaderSM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSM = new double[this->m_NumberOfWorkUnits]; +#endif } if(m_ThreaderDerivativeF != NULL) { delete [] m_ThreaderDerivativeF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfThreads]; for(unsigned int threadID=0; threadIDm_NumberOfThreads; threadID++) { +#else + m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfWorkUnits]; + for(unsigned int threadID=0; threadIDm_NumberOfWorkUnits; threadID++) { +#endif m_ThreaderDerivativeF[threadID].SetSize( this->m_NumberOfParameters ); } if(m_ThreaderDerivativeM != NULL) { delete [] m_ThreaderDerivativeM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfThreads]; for(unsigned int threadID=0; threadIDm_NumberOfThreads; threadID++) { +#else + m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfWorkUnits]; + for(unsigned int threadID=0; threadIDm_NumberOfWorkUnits; threadID++) { +#endif m_ThreaderDerivativeM[threadID].SetSize( this->m_NumberOfParameters ); } } @@ -208,12 +238,23 @@ NormalizedCorrelationImageToImageMetric //Reset the accumulators +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSFF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSMM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSFM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSFF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSMM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSFM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif if(this->m_SubtractMean) { +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif } @@ -244,7 +285,11 @@ NormalizedCorrelationImageToImageMetric sf = m_ThreaderSF[0]; sm = m_ThreaderSM[0]; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=1; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=1; tm_NumberOfWorkUnits; t++) { +#endif sff += m_ThreaderSFF[t]; smm += m_ThreaderSMM[t]; sfm += m_ThreaderSFM[t]; @@ -282,12 +327,23 @@ NormalizedCorrelationImageToImageMetric { //No checking for the fixed image, done in the caller //Reset the accumulators +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSFF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSMM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSFM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSFF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSMM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSFM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif if(this->m_SubtractMean) { +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif } @@ -317,7 +373,11 @@ NormalizedCorrelationImageToImageMetric m_SF = m_ThreaderSF[0]; m_SM = m_ThreaderSM[0]; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=1; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=1; tm_NumberOfWorkUnits; t++) { +#endif m_SFF += m_ThreaderSFF[t]; m_SMM += m_ThreaderSMM[t]; m_SFM += m_ThreaderSFM[t]; @@ -431,8 +491,11 @@ NormalizedCorrelationImageToImageMetric memset( derivative.data_block(), 0, this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) ); - +#if ITK_VERSION_MAJOR <= 4 for( unsigned int threadID = 0; threadIDm_NumberOfThreads; threadID++ ) { +#else + for( unsigned int threadID = 0; threadIDm_NumberOfWorkUnits; threadID++ ) { +#endif memset( m_ThreaderDerivativeF[threadID].data_block(), 0, this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) ); @@ -447,7 +510,11 @@ NormalizedCorrelationImageToImageMetric // Accumulate over the threads DerivativeType derivativeF(this->m_NumberOfParameters), derivativeM(this->m_NumberOfParameters); +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=0; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=0; tm_NumberOfWorkUnits; t++) { +#endif for(unsigned int parameter = 0; parameter < this->m_NumberOfParameters; parameter++) { derivativeF[parameter] += m_ThreaderDerivativeF[t][parameter]; derivativeM[parameter] += m_ThreaderDerivativeM[t][parameter]; diff --git a/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx index 959bfed..5ed23c3 100644 --- a/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx +++ b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx @@ -130,44 +130,74 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD if(m_ThreaderSFF != NULL) { delete [] m_ThreaderSFF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSFF = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSFF = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSMM != NULL) { delete [] m_ThreaderSMM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSMM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSMM = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSFM != NULL) { delete [] m_ThreaderSFM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSFM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSFM = new double[this->m_NumberOfWorkUnits]; +#endif if(this->m_SubtractMean) { if(m_ThreaderSF != NULL) { delete [] m_ThreaderSF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSF = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSF = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderSM != NULL) { delete [] m_ThreaderSM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderSM = new double[this->m_NumberOfThreads]; +#else + m_ThreaderSM = new double[this->m_NumberOfWorkUnits]; +#endif } if(m_ThreaderDerivativeF != NULL) { delete [] m_ThreaderDerivativeF; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfThreads]; for(unsigned int threadID=0; threadIDm_NumberOfThreads; threadID++) { +#else + m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfWorkUnits]; + for(unsigned int threadID=0; threadIDm_NumberOfWorkUnits; threadID++) { +#endif m_ThreaderDerivativeF[threadID].SetSize( this->m_NumberOfParameters ); } if(m_ThreaderDerivativeM != NULL) { delete [] m_ThreaderDerivativeM; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfThreads]; for(unsigned int threadID=0; threadIDm_NumberOfThreads; threadID++) { +#else + m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfWorkUnits]; + for(unsigned int threadID=0; threadIDm_NumberOfWorkUnits; threadID++) { +#endif m_ThreaderDerivativeM[threadID].SetSize( this->m_NumberOfParameters ); } } @@ -208,12 +238,23 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD //Reset the accumulators +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSFF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSMM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSFM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSFF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSMM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSFM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif if(this->m_SubtractMean) { +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif } @@ -244,7 +285,11 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD sf = m_ThreaderSF[0]; sm = m_ThreaderSM[0]; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=1; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=1; tm_NumberOfWorkUnits; t++) { +#endif sff += m_ThreaderSFF[t]; smm += m_ThreaderSMM[t]; sfm += m_ThreaderSFM[t]; @@ -282,12 +327,23 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD { //No checking for the fixed image, done in the caller //Reset the accumulators +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSFF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSMM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSFM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSFF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSMM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSFM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif if(this->m_SubtractMean) { +#if ITK_VERSION_MAJOR <= 4 memset( m_ThreaderSF, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); memset( m_ThreaderSM, 0, this->m_NumberOfThreads * sizeof(AccumulateType) ); +#else + memset( m_ThreaderSF, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); + memset( m_ThreaderSM, 0, this->m_NumberOfWorkUnits * sizeof(AccumulateType) ); +#endif } @@ -317,7 +373,11 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD m_SF = m_ThreaderSF[0]; m_SM = m_ThreaderSM[0]; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=1; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=1; tm_NumberOfWorkUnits; t++) { +#endif m_SFF += m_ThreaderSFF[t]; m_SMM += m_ThreaderSMM[t]; m_SFM += m_ThreaderSFM[t]; @@ -457,7 +517,11 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD 0, this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) ); +#if ITK_VERSION_MAJOR <= 4 for( unsigned int threadID = 0; threadIDm_NumberOfThreads; threadID++ ) { +#else + for( unsigned int threadID = 0; threadIDm_NumberOfWorkUnits; threadID++ ) { +#endif memset( m_ThreaderDerivativeF[threadID].data_block(), 0, this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) ); @@ -472,7 +536,11 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD // Accumulate over the threads DerivativeType derivativeF(this->m_NumberOfParameters), derivativeM(this->m_NumberOfParameters); +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=0; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=0; tm_NumberOfWorkUnits; t++) { +#endif for(unsigned int parameter = 0; parameter < this->m_NumberOfParameters; parameter++) { derivativeF[parameter] += m_ThreaderDerivativeF[t][parameter]; derivativeM[parameter] += m_ThreaderDerivativeM[t][parameter]; diff --git a/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx b/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx index dec3acf..96e8f0a 100644 --- a/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx +++ b/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx @@ -192,7 +192,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD typename FixedImageStatisticsFilterType::Pointer fixedImageStats = FixedImageStatisticsFilterType::New(); fixedImageStats->SetInput( this->m_FixedImage ); +#if ITK_VERSION_MAJOR <= 4 fixedImageStats->SetNumberOfThreads( this->m_NumberOfThreads ); +#else + fixedImageStats->SetNumberOfWorkUnits( this->m_NumberOfWorkUnits ); +#endif fixedImageStats->Update(); m_FixedImageTrueMin = fixedImageStats->GetMinimum(); @@ -205,7 +209,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD typename MovingImageStatisticsFilterType::Pointer movingImageStats = MovingImageStatisticsFilterType::New(); movingImageStats->SetInput( this->m_MovingImage ); +#if ITK_VERSION_MAJOR <= 4 movingImageStats->SetNumberOfThreads( this->m_NumberOfThreads ); +#else + movingImageStats->SetNumberOfWorkUnits( this->m_NumberOfWorkUnits ); +#endif movingImageStats->Update(); m_MovingImageTrueMin = movingImageStats->GetMinimum(); @@ -362,35 +370,62 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD } // Assumes number of threads doesn't change between calls to Initialize m_ThreaderFixedImageMarginalPDF = new - PDFValueType[(this->m_NumberOfThreads-1) - * m_NumberOfHistogramBins]; +#if ITK_VERSION_MAJOR <= 4 + PDFValueType[(this->m_NumberOfThreads-1) * m_NumberOfHistogramBins]; +#else + PDFValueType[(this->m_NumberOfWorkUnits-1) * m_NumberOfHistogramBins]; +#endif if(m_ThreaderJointPDF != NULL) { delete [] m_ThreaderJointPDF; } m_ThreaderJointPDF = new typename +#if ITK_VERSION_MAJOR <= 4 JointPDFType::Pointer[this->m_NumberOfThreads-1]; +#else + JointPDFType::Pointer[this->m_NumberOfWorkUnits-1]; +#endif if(m_ThreaderJointPDFStartBin != NULL) { delete [] m_ThreaderJointPDFStartBin; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderJointPDFStartBin = new int[this->m_NumberOfThreads]; +#else + m_ThreaderJointPDFStartBin = new int[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderJointPDFEndBin != NULL) { delete [] m_ThreaderJointPDFEndBin; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderJointPDFEndBin = new int[this->m_NumberOfThreads]; +#else + m_ThreaderJointPDFEndBin = new int[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderJointPDFSum != NULL) { delete [] m_ThreaderJointPDFSum; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderJointPDFSum = new double[this->m_NumberOfThreads]; +#else + m_ThreaderJointPDFSum = new double[this->m_NumberOfWorkUnits]; +#endif unsigned int threadID; +#if ITK_VERSION_MAJOR <= 4 int binRange = m_NumberOfHistogramBins / this->m_NumberOfThreads; +#else + int binRange = m_NumberOfHistogramBins / this->m_NumberOfWorkUnits; +#endif +#if ITK_VERSION_MAJOR <= 4 for(threadID = 0; threadID < this->m_NumberOfThreads-1; threadID++) { +#else + for(threadID = 0; threadID < this->m_NumberOfWorkUnits-1; threadID++) { +#endif m_ThreaderJointPDF[threadID] = JointPDFType::New(); m_ThreaderJointPDF[threadID]->SetRegions( jointPDFRegion ); m_ThreaderJointPDF[threadID]->Allocate(); @@ -399,10 +434,13 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD m_ThreaderJointPDFEndBin[threadID] = (threadID + 1) * binRange - 1; } - m_ThreaderJointPDFStartBin[this->m_NumberOfThreads-1] = - (this->m_NumberOfThreads - 1 ) * binRange; - +#if ITK_VERSION_MAJOR <= 4 + m_ThreaderJointPDFStartBin[this->m_NumberOfThreads-1] = (this->m_NumberOfThreads - 1 ) * binRange; m_ThreaderJointPDFEndBin[this->m_NumberOfThreads-1] = m_NumberOfHistogramBins - 1; +#else + m_ThreaderJointPDFStartBin[this->m_NumberOfWorkUnits-1] = (this->m_NumberOfWorkUnits - 1 ) * binRange; + m_ThreaderJointPDFEndBin[this->m_NumberOfWorkUnits-1] = m_NumberOfHistogramBins - 1; +#endif // Release memory of arrays that may have been used for // previous executions of this metric with different settings @@ -420,18 +458,34 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD if( this->m_UseExplicitPDFDerivatives ) { m_ThreaderJointPDFDerivatives = new typename +#if ITK_VERSION_MAJOR <= 4 JointPDFDerivativesType::Pointer[this->m_NumberOfThreads-1]; +#else + JointPDFDerivativesType::Pointer[this->m_NumberOfWorkUnits-1]; +#endif +#if ITK_VERSION_MAJOR <= 4 for(threadID = 0; threadID < this->m_NumberOfThreads-1; threadID++) { +#else + for(threadID = 0; threadID < this->m_NumberOfWorkUnits-1; threadID++) { +#endif m_ThreaderJointPDFDerivatives[threadID] = JointPDFDerivativesType::New(); m_ThreaderJointPDFDerivatives[threadID]->SetRegions( jointPDFDerivativesRegion ); m_ThreaderJointPDFDerivatives[threadID]->Allocate(); } } else { +#if ITK_VERSION_MAJOR <= 4 m_ThreaderMetricDerivative = new DerivativeType[this->m_NumberOfThreads-1]; +#else + m_ThreaderMetricDerivative = new DerivativeType[this->m_NumberOfWorkUnits-1]; +#endif +#if ITK_VERSION_MAJOR <= 4 for(threadID = 0; threadID < this->m_NumberOfThreads-1; threadID++) { +#else + for(threadID = 0; threadID < this->m_NumberOfWorkUnits-1; threadID++) { +#endif this->m_ThreaderMetricDerivative[threadID] = DerivativeType( this->GetNumberOfParameters() ); } } @@ -595,7 +649,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD unsigned int tPdfPtrOffset; tPdfPtrOffset = ( m_ThreaderJointPDFStartBin[threadID] * m_JointPDF->GetOffsetTable()[1] ); +#if ITK_VERSION_MAJOR <= 4 for(t=0; tm_NumberOfThreads-1; t++) { +#else + for(t=0; tm_NumberOfWorkUnits-1; t++) { +#endif pdfPtr = pdfPtrStart; tPdfPtr = m_ThreaderJointPDF[t]->GetBufferPointer() + tPdfPtrOffset; tPdfPtrEnd = tPdfPtr + maxI; @@ -637,7 +695,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD // MUST BE CALLED TO INITIATE PROCESSING this->GetValueMultiThreadedPostProcessInitiate(); +#if ITK_VERSION_MAJOR <= 4 for(unsigned int threadID = 0; threadIDm_NumberOfThreads-1; threadID++) { +#else + for(unsigned int threadID = 0; threadIDm_NumberOfWorkUnits-1; threadID++) { +#endif m_JointPDFSum += m_ThreaderJointPDFSum[threadID]; } if ( m_JointPDFSum == 0.0 ) { @@ -883,7 +945,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD JointPDFDerivativesValueType *tPdfDPtrEnd; unsigned int tPdfDPtrOffset; tPdfDPtrOffset = m_ThreaderJointPDFStartBin[threadID] * rowSize; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=0; tm_NumberOfThreads-1; t++) { +#else + for(unsigned int t=0; tm_NumberOfWorkUnits-1; t++) { +#endif pdfDPtr = pdfDPtrStart; tPdfDPtr = m_ThreaderJointPDFDerivatives[t]->GetBufferPointer() + tPdfDPtrOffset; @@ -930,7 +996,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD } else { this->m_PRatioArray.Fill( 0.0 ); this->m_MetricDerivative.Fill( NumericTraits< MeasureType >::Zero ); +#if ITK_VERSION_MAJOR <= 4 for(unsigned int threadID = 0; threadID < this->m_NumberOfThreads-1; threadID++ ) { +#else + for(unsigned int threadID = 0; threadID < this->m_NumberOfWorkUnits-1; threadID++ ) { +#endif this->m_ThreaderMetricDerivative[threadID].Fill( NumericTraits< MeasureType >::Zero ); } this->m_ImplicitDerivativesSecondPass = false; @@ -945,7 +1015,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD // CALL IF DOING THREADED POST PROCESSING this->GetValueAndDerivativeMultiThreadedPostProcessInitiate(); +#if ITK_VERSION_MAJOR <= 4 for(unsigned int threadID = 0; threadIDm_NumberOfThreads-1; threadID++) { +#else + for(unsigned int threadID = 0; threadIDm_NumberOfWorkUnits-1; threadID++) { +#endif m_JointPDFSum += m_ThreaderJointPDFSum[threadID]; } if ( m_JointPDFSum == 0.0 ) { @@ -1054,7 +1128,11 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD // Consolidate the contributions from each one of the threads to the total // derivative. +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t = 0; t < this->m_NumberOfThreads-1; t++ ) { +#else + for(unsigned int t = 0; t < this->m_NumberOfWorkUnits-1; t++ ) { +#endif DerivativeType * source = &(this->m_ThreaderMetricDerivative[t]); for(unsigned int pp=0; pp < this->m_NumberOfParameters; pp++ ) { this->m_MetricDerivative[pp] += (*source)[pp]; diff --git a/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx b/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx index dd7000d..39cfa8e 100644 --- a/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx +++ b/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx @@ -109,13 +109,22 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD if(m_ThreaderMSE != NULL) { delete [] m_ThreaderMSE; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderMSE = new double[this->m_NumberOfThreads]; +#else + m_ThreaderMSE = new double[this->m_NumberOfWorkUnits]; +#endif if(m_ThreaderMSEDerivatives != NULL) { delete [] m_ThreaderMSEDerivatives; } +#if ITK_VERSION_MAJOR <= 4 m_ThreaderMSEDerivatives = new DerivativeType[this->m_NumberOfThreads]; for(unsigned int threadID=0; threadIDm_NumberOfThreads; threadID++) { +#else + m_ThreaderMSEDerivatives = new DerivativeType[this->m_NumberOfWorkUnits]; + for(unsigned int threadID=0; threadIDm_NumberOfWorkUnits; threadID++) { +#endif m_ThreaderMSEDerivatives[threadID].SetSize( this->m_NumberOfParameters ); } } @@ -147,9 +156,11 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD itkExceptionMacro( << "Fixed image has not been assigned" ); } - memset( m_ThreaderMSE, - 0, - this->m_NumberOfThreads * sizeof(MeasureType) ); +#if ITK_VERSION_MAJOR <= 4 + memset( m_ThreaderMSE, 0, this->m_NumberOfThreads * sizeof(MeasureType) ); +#else + memset( m_ThreaderMSE, 0, this->m_NumberOfWorkUnits * sizeof(MeasureType) ); +#endif // Set up the parameters in the transform this->m_Transform->SetParameters( parameters ); @@ -171,7 +182,11 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD } double mse = m_ThreaderMSE[0]; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=1; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=1; tm_NumberOfWorkUnits; t++) { +#endif mse += m_ThreaderMSE[t]; } mse /= this->m_NumberOfPixelsCounted; @@ -252,9 +267,11 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD this->m_Transform->SetParameters( parameters ); // Reset the joint pdfs to zero - memset( m_ThreaderMSE, - 0, - this->m_NumberOfThreads * sizeof(MeasureType) ); +#if ITK_VERSION_MAJOR <= 4 + memset( m_ThreaderMSE, 0, this->m_NumberOfThreads * sizeof(MeasureType) ); +#else + memset( m_ThreaderMSE, 0, this->m_NumberOfWorkUnits * sizeof(MeasureType) ); +#endif // Set output values to zero if(derivative.GetSize() != this->m_NumberOfParameters) { @@ -264,7 +281,11 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD 0, this->m_NumberOfParameters * sizeof(double) ); +#if ITK_VERSION_MAJOR <= 4 for( unsigned int threadID = 0; threadIDm_NumberOfThreads; threadID++ ) { +#else + for( unsigned int threadID = 0; threadIDm_NumberOfWorkUnits; threadID++ ) { +#endif memset( m_ThreaderMSEDerivatives[threadID].data_block(), 0, this->m_NumberOfParameters * sizeof(double) ); @@ -287,7 +308,11 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD } value = 0; +#if ITK_VERSION_MAJOR <= 4 for(unsigned int t=0; tm_NumberOfThreads; t++) { +#else + for(unsigned int t=0; tm_NumberOfWorkUnits; t++) { +#endif value += m_ThreaderMSE[t]; for(unsigned int parameter = 0; parameter < this->m_NumberOfParameters; parameter++) { diff --git a/tools/clitkBackProjectImageGenericFilter.txx b/tools/clitkBackProjectImageGenericFilter.txx index b13186e..d5a552d 100644 --- a/tools/clitkBackProjectImageGenericFilter.txx +++ b/tools/clitkBackProjectImageGenericFilter.txx @@ -62,7 +62,13 @@ namespace clitk //--------------------------------- unsigned int i=0; filter->SetInput(input); - if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); + if (m_ArgsInfo.threads_given) { +#if ITK_VERSION_MAJOR <= 4 + filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); +#else + filter->SetNumberOfWorkUnits(m_ArgsInfo.threads_arg); +#endif + } //Projection parameters OutputImageType::PointType iso; diff --git a/tools/clitkInvertVFGenericFilter.txx b/tools/clitkInvertVFGenericFilter.txx index a18a641..405540c 100644 --- a/tools/clitkInvertVFGenericFilter.txx +++ b/tools/clitkInvertVFGenericFilter.txx @@ -156,7 +156,13 @@ InvertVFGenericFilter::UpdateWithDimAndPixelType() filter->SetInput(input); filter->SetVerbose(m_Verbose); - if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); + if (m_ArgsInfo.threads_given) { +#if ITK_VERSION_MAJOR <= 4 + filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); +#else + filter->SetNumberOfWorkUnits(m_ArgsInfo.threads_arg); +#endif + } if (m_ArgsInfo.pad_given) { PixelType pad; if (m_ArgsInfo.pad_given != (pad.GetNumberOfComponents()) ) @@ -187,7 +193,13 @@ InvertVFGenericFilter::UpdateWithDimAndPixelType() } filter->SetVerbose(m_Verbose); - if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); + if (m_ArgsInfo.threads_given) { +#if ITK_VERSION_MAJOR <= 4 + filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); +#else + filter->SetNumberOfWorkUnits(m_ArgsInfo.threads_arg); +#endif + } if (m_ArgsInfo.pad_given) { PixelType pad; if (m_ArgsInfo.pad_given != (pad.GetNumberOfComponents()) )