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);
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;
typename HelperClass1Type::Pointer helper1=HelperClass1Type::New();
//Set input
- if(m_NumberOfThreadsIsGiven)helper1->SetNumberOfThreads(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);
typename HelperClass2Type::Pointer helper2=HelperClass2Type::New();
//Set temporary output as input
- if(m_NumberOfThreadsIsGiven)helper2->SetNumberOfThreads(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);
//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);
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;
};
typename HelperClass1Type::Pointer helper1=HelperClass1Type::New();
//Set input
- if(m_NumberOfThreadsIsGiven)helper1->SetNumberOfThreads(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);
typename HelperClass2Type::Pointer helper2=HelperClass2Type::New();
//Set temporary output as input
- if(m_NumberOfThreadsIsGiven)helper2->SetNumberOfThreads(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);
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;
}
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
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.
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;
}
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 );
typedef itk::TransformToDisplacementFieldFilter<DisplacementFieldType, double> 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
// =======================================================
// 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 "<<nLevels<<"..."<<std::endl;
multiResolutionFilter->SetFixedImage( fixedImage );
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
//------------------------------------
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; threadID<this->m_NumberOfThreads; threadID++) {
+#else
+ m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfWorkUnits];
+ for(unsigned int threadID=0; threadID<this->m_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; threadID<this->m_NumberOfThreads; threadID++) {
+#else
+ m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfWorkUnits];
+ for(unsigned int threadID=0; threadID<this->m_NumberOfWorkUnits; threadID++) {
+#endif
m_ThreaderDerivativeM[threadID].SetSize( this->m_NumberOfParameters );
}
}
//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
}
sf = m_ThreaderSF[0];
sm = m_ThreaderSM[0];
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=1; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=1; t<this->m_NumberOfWorkUnits; t++) {
+#endif
sff += m_ThreaderSFF[t];
smm += m_ThreaderSMM[t];
sfm += m_ThreaderSFM[t];
{
//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
}
m_SF = m_ThreaderSF[0];
m_SM = m_ThreaderSM[0];
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=1; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=1; t<this->m_NumberOfWorkUnits; t++) {
+#endif
m_SFF += m_ThreaderSFF[t];
m_SMM += m_ThreaderSMM[t];
m_SFM += m_ThreaderSFM[t];
memset( derivative.data_block(),
0,
this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) );
-
+#if ITK_VERSION_MAJOR <= 4
for( unsigned int threadID = 0; threadID<this->m_NumberOfThreads; threadID++ ) {
+#else
+ for( unsigned int threadID = 0; threadID<this->m_NumberOfWorkUnits; threadID++ ) {
+#endif
memset( m_ThreaderDerivativeF[threadID].data_block(),
0,
this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) );
// Accumulate over the threads
DerivativeType derivativeF(this->m_NumberOfParameters), derivativeM(this->m_NumberOfParameters);
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=0; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=0; t<this->m_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];
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; threadID<this->m_NumberOfThreads; threadID++) {
+#else
+ m_ThreaderDerivativeF = new DerivativeType[this->m_NumberOfWorkUnits];
+ for(unsigned int threadID=0; threadID<this->m_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; threadID<this->m_NumberOfThreads; threadID++) {
+#else
+ m_ThreaderDerivativeM = new DerivativeType[this->m_NumberOfWorkUnits];
+ for(unsigned int threadID=0; threadID<this->m_NumberOfWorkUnits; threadID++) {
+#endif
m_ThreaderDerivativeM[threadID].SetSize( this->m_NumberOfParameters );
}
}
//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
}
sf = m_ThreaderSF[0];
sm = m_ThreaderSM[0];
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=1; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=1; t<this->m_NumberOfWorkUnits; t++) {
+#endif
sff += m_ThreaderSFF[t];
smm += m_ThreaderSMM[t];
sfm += m_ThreaderSFM[t];
{
//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
}
m_SF = m_ThreaderSF[0];
m_SM = m_ThreaderSM[0];
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=1; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=1; t<this->m_NumberOfWorkUnits; t++) {
+#endif
m_SFF += m_ThreaderSFF[t];
m_SMM += m_ThreaderSMM[t];
m_SFM += m_ThreaderSFM[t];
0,
this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) );
+#if ITK_VERSION_MAJOR <= 4
for( unsigned int threadID = 0; threadID<this->m_NumberOfThreads; threadID++ ) {
+#else
+ for( unsigned int threadID = 0; threadID<this->m_NumberOfWorkUnits; threadID++ ) {
+#endif
memset( m_ThreaderDerivativeF[threadID].data_block(),
0,
this->m_NumberOfParameters * sizeof(typename DerivativeType::ValueType) );
// Accumulate over the threads
DerivativeType derivativeF(this->m_NumberOfParameters), derivativeM(this->m_NumberOfParameters);
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=0; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=0; t<this->m_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];
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();
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();
}
// 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();
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
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() );
}
}
unsigned int tPdfPtrOffset;
tPdfPtrOffset = ( m_ThreaderJointPDFStartBin[threadID]
* m_JointPDF->GetOffsetTable()[1] );
+#if ITK_VERSION_MAJOR <= 4
for(t=0; t<this->m_NumberOfThreads-1; t++) {
+#else
+ for(t=0; t<this->m_NumberOfWorkUnits-1; t++) {
+#endif
pdfPtr = pdfPtrStart;
tPdfPtr = m_ThreaderJointPDF[t]->GetBufferPointer() + tPdfPtrOffset;
tPdfPtrEnd = tPdfPtr + maxI;
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedPostProcessInitiate();
+#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
m_JointPDFSum += m_ThreaderJointPDFSum[threadID];
}
if ( m_JointPDFSum == 0.0 ) {
JointPDFDerivativesValueType *tPdfDPtrEnd;
unsigned int tPdfDPtrOffset;
tPdfDPtrOffset = m_ThreaderJointPDFStartBin[threadID] * rowSize;
+#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
pdfDPtr = pdfDPtrStart;
tPdfDPtr = m_ThreaderJointPDFDerivatives[t]->GetBufferPointer()
+ tPdfDPtrOffset;
} 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;
// CALL IF DOING THREADED POST PROCESSING
this->GetValueAndDerivativeMultiThreadedPostProcessInitiate();
+#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
m_JointPDFSum += m_ThreaderJointPDFSum[threadID];
}
if ( m_JointPDFSum == 0.0 ) {
// 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];
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; threadID<this->m_NumberOfThreads; threadID++) {
+#else
+ m_ThreaderMSEDerivatives = new DerivativeType[this->m_NumberOfWorkUnits];
+ for(unsigned int threadID=0; threadID<this->m_NumberOfWorkUnits; threadID++) {
+#endif
m_ThreaderMSEDerivatives[threadID].SetSize( this->m_NumberOfParameters );
}
}
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 );
}
double mse = m_ThreaderMSE[0];
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=1; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=1; t<this->m_NumberOfWorkUnits; t++) {
+#endif
mse += m_ThreaderMSE[t];
}
mse /= this->m_NumberOfPixelsCounted;
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) {
0,
this->m_NumberOfParameters * sizeof(double) );
+#if ITK_VERSION_MAJOR <= 4
for( unsigned int threadID = 0; threadID<this->m_NumberOfThreads; threadID++ ) {
+#else
+ for( unsigned int threadID = 0; threadID<this->m_NumberOfWorkUnits; threadID++ ) {
+#endif
memset( m_ThreaderMSEDerivatives[threadID].data_block(),
0,
this->m_NumberOfParameters * sizeof(double) );
}
value = 0;
+#if ITK_VERSION_MAJOR <= 4
for(unsigned int t=0; t<this->m_NumberOfThreads; t++) {
+#else
+ for(unsigned int t=0; t<this->m_NumberOfWorkUnits; t++) {
+#endif
value += m_ThreaderMSE[t];
for(unsigned int parameter = 0; parameter < this->m_NumberOfParameters;
parameter++) {
//---------------------------------
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;
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()) )
}
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()) )