1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __clitkShapedBLUTSpatioTemporalDeformableTransform_txx
19 #define __clitkShapedBLUTSpatioTemporalDeformableTransform_txx
20 #include "clitkShapedBLUTSpatioTemporalDeformableTransform.h"
23 #include "itkContinuousIndex.h"
24 #include "itkImageRegionIterator.h"
25 #include "itkImageRegionConstIterator.h"
26 #include "itkImageRegionConstIteratorWithIndex.h"
27 #include "itkIdentityTransform.h"
32 // Constructor with default arguments
33 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
34 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
35 #if ITK_VERSION_MAJOR >= 4
36 ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(0)
38 ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(OutputDimension,0)
43 //JV default spline order
44 for ( i=0;i<InputDimension; i++)
47 //JV default LUTSamplingfactor
48 for ( i=0;i<InputDimension; i++)
49 m_LUTSamplingFactors[i]=20;
51 for (i=0;i<InputDimension; i++)
52 m_SupportSize[i] = m_SplineOrders[i]+1;
54 //Instantiate a Vector Bspline Interpolator
55 m_VectorInterpolator =VectorInterpolatorType::New();
56 m_VectorInterpolator->SetLUTSamplingFactors(m_LUTSamplingFactors);
57 m_VectorInterpolator->SetSplineOrders(m_SplineOrders);
59 // Set Bulk transform to NULL (no bulk performed)
60 m_BulkTransform = NULL;
68 // Default grid size is zero
72 //JV region containing the parameters
73 m_GridRegion.SetSize( m_NullSize);
74 m_GridRegion.SetIndex( m_NullIndex );
76 //JV use second region over the images
77 m_PaddedGridRegion.SetSize(m_NullSize);
78 m_PaddedGridRegion.SetIndex(m_NullIndex);
80 //JV Maintain two origins
81 m_GridOrigin.Fill( 0.0 ); // default origin is all zeros
82 m_PaddedGridOrigin.Fill( 0.0 ); // default origin is all zeros
84 m_GridSpacing.Fill( 1.0 ); // default spacing is all ones
85 m_GridDirection.SetIdentity(); // default spacing is all ones
87 m_InternalParametersBuffer = ParametersType(0);
88 // Make sure the parameters pointer is not NULL after construction.
89 m_InputParametersPointer = &m_InternalParametersBuffer;
91 // Initialize coeffient images
92 m_WrappedImage = CoefficientImageType::New();
93 m_WrappedImage->SetRegions( m_GridRegion );
94 m_WrappedImage->SetOrigin( m_GridOrigin.GetDataPointer() );
95 m_WrappedImage->SetSpacing( m_GridSpacing.GetDataPointer() );
96 m_WrappedImage->SetDirection( m_GridDirection );
98 // JV Initialize the padded version
99 m_PaddedCoefficientImage = CoefficientImageType::New();
100 m_PaddedCoefficientImage->SetRegions( m_PaddedGridRegion );
101 m_PaddedCoefficientImage->SetOrigin( m_GridOrigin.GetDataPointer() );
102 m_PaddedCoefficientImage->SetSpacing( m_GridSpacing.GetDataPointer() );
103 m_PaddedCoefficientImage->SetDirection( m_GridDirection );
105 m_CoefficientImage = NULL;
107 // Variables for computing interpolation
108 for (i=0; i <InputDimension;i++)
110 m_Offset[i] = m_SplineOrders[i] / 2;
111 if ( m_SplineOrders[i] % 2 )
113 m_SplineOrderOdd[i] = true;
117 m_SplineOrderOdd[i] = false;
121 //JV padded should be used when checking
122 m_ValidRegion = m_PaddedGridRegion;
124 // Initialize jacobian images
125 for (i=0; i <OutputDimension;i++)
127 m_JacobianImage[i] = JacobianImageType::New();
128 m_JacobianImage[i]->SetRegions( m_GridRegion );
129 m_JacobianImage[i]->SetOrigin( m_GridOrigin.GetDataPointer() );
130 m_JacobianImage[i]->SetSpacing( m_GridSpacing.GetDataPointer() );
131 m_JacobianImage[i]->SetDirection( m_GridDirection );
134 /** Fixed Parameters store the following information:
139 //JV we add the splineOrders, LUTsamplingfactor, m_Mask and m_BulkTransform
145 The size of these is equal to the NInputDimensions
146 *********************************************************/
147 this->m_FixedParameters.SetSize ( NInputDimensions * (NInputDimensions + 5)+3 );
148 this->m_FixedParameters.Fill ( 0.0 );
149 for ( i=0; i<NInputDimensions; i++)
151 this->m_FixedParameters[2*NInputDimensions+i] = m_GridSpacing[i];
153 for (unsigned int di=0; di<NInputDimensions; di++)
155 for (unsigned int dj=0; dj<NInputDimensions; dj++)
157 this->m_FixedParameters[3*NInputDimensions+(di*NInputDimensions+dj)] = m_GridDirection[di][dj];
161 //JV add splineOrders
162 for ( i=0; i<NInputDimensions; i++)
164 this->m_FixedParameters[ ( (3+NInputDimensions)*NInputDimensions)+i] = (this->GetSplineOrders())[i];
167 //JV add LUTsamplingFactors
168 for ( i=0; i<NInputDimensions; i++)
170 this->m_FixedParameters[( (4+NInputDimensions)*NInputDimensions)+i ] = this->GetLUTSamplingFactors()[i];
173 // JV add the mask pointer
174 this->m_FixedParameters[( (5+NInputDimensions)*NInputDimensions)]=(double)((size_t)m_Mask);
176 // JV add the bulkTransform pointer
177 this->m_FixedParameters[( (5+NInputDimensions)*NInputDimensions) +1]=(double)((size_t)m_BulkTransform);
179 // JV add the Transform shape
180 this->m_FixedParameters[( (5+NInputDimensions)*NInputDimensions) +2]=(double)(m_TransformShape);
183 // Calculate the PointToIndex matrices
185 for( unsigned int i=0; i<OutputDimension; i++)
187 scale[i][i] = m_GridSpacing[i];
190 m_IndexToPoint = m_GridDirection * scale;
191 m_PointToIndex = m_IndexToPoint.GetInverse();
193 m_LastJacobianIndex = m_ValidRegion.GetIndex();
196 //Weights to be used for the BC
198 std::vector<double> weights(5);
207 m_Weights[0]=weights;
215 m_Weights[1]=weights;
223 m_Weights[2]=weights;
231 m_Weights[3]=weights;
233 // Update the WeightRatios
234 m_WeightRatio.resize(4);
235 for (unsigned int i=0; i<4; i++)
237 m_WeightRatio[i].resize(4);
238 for (unsigned int j=0; j<4; j++)
239 m_WeightRatio[i][j]=m_Weights[m_SplineOrders[InputDimension-1]][i]/ m_Weights[m_SplineOrders[InputDimension-1]][j];
242 //JV initialize some variables for jacobian calculation
243 m_SupportRegion.SetSize(m_SupportSize);
244 m_SupportIndex.Fill(0);
245 m_SupportRegion.SetIndex(m_SupportIndex);
246 for ( i = 0; i < SpaceDimension ; i++ )
247 m_ZeroVector[i]=itk::NumericTraits<JacobianValueType>::Zero;
250 m_FirstRegion.SetSize(m_NullSize);
251 m_FirstRegion.SetIndex(m_NullIndex);
252 m_SecondRegion.SetSize(m_NullSize);
253 m_SecondRegion.SetIndex(m_NullIndex);
254 m_ThirdRegion.SetSize(m_NullSize);
255 m_ThirdRegion.SetIndex(m_NullIndex);
257 m_BCValues.resize(0);
258 m_BCRegions.resize(0);
260 m_BC2Values.resize(0);
261 m_BC2Regions.resize(0);
263 m_BC3Values.resize(0);
264 m_BC3Regions.resize(0);
268 for ( i = 0; i < SpaceDimension ; i++ )
270 m_FirstIterator[i]= IteratorType( m_JacobianImage[i], m_FirstRegion);
271 m_SecondIterator[i]= IteratorType( m_JacobianImage[i], m_SecondRegion);
272 m_ThirdIterator[i]= IteratorType( m_JacobianImage[i], m_ThirdRegion);
273 m_BCIterators[i].resize(0);
274 m_BC2Iterators[i].resize(0);
275 m_BC3Iterators[i].resize(0);
284 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
285 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
286 ::~ShapedBLUTSpatioTemporalDeformableTransform()
292 // JV set Spline Order
293 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
295 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
296 ::SetSplineOrder(const unsigned int & splineOrder)
298 SizeType splineOrders;
299 for (unsigned int i=0;i<InputDimension;i++)splineOrders[i]=splineOrder;
301 this->SetSplineOrders(splineOrders);
305 // JV set Spline Orders
306 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
308 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
309 ::SetSplineOrders(const SizeType & splineOrders)
311 if(m_SplineOrders!=splineOrders)
313 m_SplineOrders=splineOrders;
315 //update the interpolation function
316 m_VectorInterpolator->SetSplineOrders(m_SplineOrders);
318 //update the varaibles for computing interpolation
319 for (unsigned int i=0; i <InputDimension;i++)
321 m_SupportSize[i] = m_SplineOrders[i]+1;
322 m_Offset[i] = m_SplineOrders[i] / 2;
324 if ( m_SplineOrders[i] % 2 )
326 m_SplineOrderOdd[i] = true;
330 m_SplineOrderOdd[i] = false;
334 //SupportSize is updated!, update regions
335 //JV initialize some variables for jacobian calculation
336 m_SupportRegion.SetSize(m_SupportSize);
337 m_SupportIndex.Fill(0);
338 m_SupportRegion.SetIndex(m_SupportIndex);
340 // Update the WeightRatios
341 for (unsigned int i=0; i<4; i++)
342 for (unsigned int j=0; j<4; j++)
343 m_WeightRatio[i][j]=m_Weights[m_SplineOrders[InputDimension-1]][i]/ m_Weights[m_SplineOrders[InputDimension-1]][j];
350 // JV set sampling factor
351 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
353 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
354 ::SetLUTSamplingFactor( const int & samplingFactor)
356 SizeType samplingFactors;
357 for (unsigned int i=0; i<NInputDimensions; i++)
358 samplingFactors[i]=samplingFactor;
360 //update the interpolation function
361 this->SetLUTSamplingFactors(samplingFactors);
365 // JV set sampling factors
366 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
368 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
369 ::SetLUTSamplingFactors( const SizeType & samplingFactors)
371 if(m_LUTSamplingFactors!=samplingFactors)
373 for (unsigned int i=0; i<NInputDimensions; i++)
374 m_LUTSamplingFactors[i]=samplingFactors[i];
376 //update the interpolation function
377 m_VectorInterpolator->SetLUTSamplingFactors(m_LUTSamplingFactors);
384 // Get the number of parameters
385 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
386 #if ITK_VERSION_MAJOR >= 4
387 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::NumberOfParametersType
391 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
392 ::GetNumberOfParameters(void) const
395 // The number of parameters equal SpaceDimension * number of
396 // of pixels in the grid region.
397 return ( static_cast<unsigned int>( SpaceDimension ) *
398 static_cast<unsigned int>( m_GridRegion.GetNumberOfPixels() ) );
403 // Get the padded number of parameters
404 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
406 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
407 ::GetPaddedNumberOfParameters(void) const
410 // The number of parameters equal SpaceDimension * number of
411 // of pixels in the grid region.
412 return ( static_cast<unsigned int>( SpaceDimension ) *
413 static_cast<unsigned int>( m_PaddedGridRegion.GetNumberOfPixels() ) );
419 // Get the number of parameters per dimension
420 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
422 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
423 ::GetNumberOfParametersPerDimension(void) const
425 // The number of parameters per dimension equal number of
426 // of pixels in the grid region.
427 return ( static_cast<unsigned int>( m_GridRegion.GetNumberOfPixels() ) );
432 // Set the grid region
433 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
435 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
436 ::SetGridRegion( const RegionType & region )
438 if ( m_GridRegion != region )
440 m_GridRegion = region;
441 m_PaddedGridRegion=region;
443 // JV set the padded region
444 typename CoefficientImageType::RegionType::SizeType paddedSize= region.GetSize();
446 //JV size dependes on shape
447 switch (m_TransformShape)
451 paddedSize[InputDimension-1]+=4;
455 paddedSize[InputDimension-1]+=4;
459 paddedSize[InputDimension-1]+=3;
463 paddedSize[InputDimension-1]+=2;
467 paddedSize[InputDimension-1]+=3;
470 paddedSize[InputDimension-1]=+1;
472 m_PaddedGridRegion.SetSize(paddedSize);
474 // Set regions for each coefficient and jacobian image
475 m_WrappedImage->SetRegions( m_GridRegion );
476 m_PaddedCoefficientImage->SetRegions( m_PaddedGridRegion );
477 m_PaddedCoefficientImage->Allocate();
478 for (unsigned int j=0; j <OutputDimension;j++)
480 m_JacobianImage[j]->SetRegions( m_GridRegion );
483 // JV used the padded version for the valid region
484 // Set the valid region
485 // If the grid spans the interval [start, last].
486 // The valid interval for evaluation is [start+offset, last-offset]
487 // when spline order is even.
488 // The valid interval for evaluation is [start+offset, last-offset)
489 // when spline order is odd.
490 // Where offset = vcl_floor(spline / 2 ).
491 // Note that the last pixel is not included in the valid region
492 // with odd spline orders.
493 typename RegionType::SizeType size = m_PaddedGridRegion.GetSize();
494 typename RegionType::IndexType index = m_PaddedGridRegion.GetIndex();
495 for ( unsigned int j = 0; j < NInputDimensions; j++ )
498 static_cast< typename RegionType::IndexValueType >( m_Offset[j] );
500 static_cast< typename RegionType::SizeValueType> ( 2 * m_Offset[j] );
501 m_ValidRegionLast[j] = index[j] +
502 static_cast< typename RegionType::IndexValueType >( size[j] ) - 1;
504 m_ValidRegion.SetSize( size );
505 m_ValidRegion.SetIndex( index );
507 // If we are using the default parameters, update their size and set to identity.
508 // Input parameters point to internal buffer => using default parameters.
509 if (m_InputParametersPointer == &m_InternalParametersBuffer)
511 // Check if we need to resize the default parameter buffer.
512 if ( m_InternalParametersBuffer.GetSize() != this->GetNumberOfParameters() )
514 m_InternalParametersBuffer.SetSize( this->GetNumberOfParameters() );
515 // Fill with zeros for identity.
516 m_InternalParametersBuffer.Fill( 0 );
525 // Set the grid spacing
526 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
528 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
529 ::SetGridSpacing( const SpacingType & spacing )
531 if ( m_GridSpacing != spacing )
533 m_GridSpacing = spacing;
535 // Set spacing for each coefficient and jacobian image
536 m_WrappedImage->SetSpacing( m_GridSpacing.GetDataPointer() );
537 m_PaddedCoefficientImage->SetSpacing( m_GridSpacing.GetDataPointer() );
538 for (unsigned int j=0; j <OutputDimension; j++) m_JacobianImage[j]->SetSpacing( m_GridSpacing.GetDataPointer() );
542 for( unsigned int i=0; i<OutputDimension; i++)
544 scale[i][i] = m_GridSpacing[i];
547 m_IndexToPoint = m_GridDirection * scale;
548 m_PointToIndex = m_IndexToPoint.GetInverse();
555 // Set the grid direction
556 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
558 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
559 ::SetGridDirection( const DirectionType & direction )
561 if ( m_GridDirection != direction )
563 m_GridDirection = direction;
565 // Set direction for each coefficient and jacobian image
566 m_WrappedImage->SetDirection( m_GridDirection );
567 m_PaddedCoefficientImage->SetDirection( m_GridDirection );
568 for (unsigned int j=0; j <OutputDimension; j++) m_JacobianImage[j]->SetDirection( m_GridDirection );
572 for( unsigned int i=0; i<OutputDimension; i++)
574 scale[i][i] = m_GridSpacing[i];
577 m_IndexToPoint = m_GridDirection * scale;
578 m_PointToIndex = m_IndexToPoint.GetInverse();
586 // Set the grid origin
587 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
589 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
590 ::SetGridOrigin( const OriginType& origin )
592 if( m_GridOrigin!=origin)
594 m_GridOrigin = origin;
596 // JV The origin depends on the shape
597 switch (m_TransformShape)
601 m_PaddedGridOrigin=origin;
602 m_PaddedGridOrigin[InputDimension-1]=origin[InputDimension-1]-2* m_GridSpacing[InputDimension-1];
606 m_PaddedGridOrigin=origin;
607 m_PaddedGridOrigin[InputDimension-1]=origin[InputDimension-1]-1* m_GridSpacing[InputDimension-1];
611 m_PaddedGridOrigin=origin;
612 m_PaddedGridOrigin[InputDimension-1]=origin[InputDimension-1]-1* m_GridSpacing[InputDimension-1];
616 m_PaddedGridOrigin=origin;
620 m_PaddedGridOrigin=origin;
621 m_PaddedGridOrigin[InputDimension-1]=origin[InputDimension-1]-1* m_GridSpacing[InputDimension-1];
624 m_PaddedGridOrigin=origin;
627 // Set origin for each coefficient and jacobianimage
628 m_WrappedImage->SetOrigin( m_GridOrigin.GetDataPointer() );
629 m_PaddedCoefficientImage->SetOrigin( m_PaddedGridOrigin.GetDataPointer() );
630 for (unsigned int j=0; j <OutputDimension; j++) m_JacobianImage[j]->SetOrigin( m_GridOrigin.GetDataPointer() );
637 // Set the parameters
638 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
640 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
643 if( m_InputParametersPointer )
645 ParametersType * parameters =
646 const_cast<ParametersType *>( m_InputParametersPointer );
647 parameters->Fill( 0.0 );
652 itkExceptionMacro( << "Input parameters for the spline haven't been set ! "
653 << "Set them using the SetParameters or SetCoefficientImage method first." );
658 // Set the parameters
659 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
661 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
662 ::SetParameters( const ParametersType & parameters )
665 // Check if the number of parameters match the
666 // Expected number of parameters
667 if ( parameters.Size() != this->GetNumberOfParameters() )
669 itkExceptionMacro(<<"Mismatched between parameters size "
671 << " and region size "
672 << m_GridRegion.GetNumberOfPixels() );
675 // Clean up buffered parameters
676 m_InternalParametersBuffer = ParametersType( 0 );
678 // Keep a reference to the input parameters
679 m_InputParametersPointer = ¶meters;
681 // Wrap flat array as images of coefficients
682 this->WrapAsImages();
684 //JV Set padded input to vector interpolator
685 m_VectorInterpolator->SetInputImage(this->GetPaddedCoefficientImage());
687 // Modified is always called since we just have a pointer to the
688 // parameters and cannot know if the parameters have changed.
693 // Set the Fixed Parameters
694 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
696 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
697 ::SetFixedParameters( const ParametersType & parameters )
700 // JV number should be exact, no defaults for spacing
701 if ( parameters.Size() != NInputDimensions * (5 + NInputDimensions)+3 )
703 itkExceptionMacro(<< "Mismatched between parameters size "
705 << " and number of fixed parameters "
706 << NInputDimensions * (5 + NInputDimensions)+3 );
708 /*********************************************************
709 Fixed Parameters store the following information:
714 // JV we add the splineOrders, LUTsamplingfactor, mask pointer and bulktransform pointer
722 The size of these is equal to the NInputDimensions
723 *********************************************************/
725 /** Set the Grid Parameters */
727 for (unsigned int i=0; i<NInputDimensions; i++)
729 gridSize[i] = static_cast<int> (parameters[i]);
731 RegionType bsplineRegion;
732 bsplineRegion.SetSize( gridSize );
734 /** Set the Origin Parameters */
736 for (unsigned int i=0; i<NInputDimensions; i++)
738 origin[i] = parameters[NInputDimensions+i];
741 /** Set the Spacing Parameters */
743 for (unsigned int i=0; i<NInputDimensions; i++)
745 spacing[i] = parameters[2*NInputDimensions+i];
748 /** Set the Direction Parameters */
749 DirectionType direction;
750 for (unsigned int di=0; di<NInputDimensions; di++)
752 for (unsigned int dj=0; dj<NInputDimensions; dj++)
754 direction[di][dj] = parameters[3*NInputDimensions+(di*NInputDimensions+dj)];
758 //JV add the spline orders
759 SizeType splineOrders;
760 for (unsigned int i=0; i<NInputDimensions; i++)
762 splineOrders[i]=parameters[(3+NInputDimensions)*NInputDimensions+i];
765 //JV add the LUT sampling factor
766 SizeType samplingFactors;
767 for (unsigned int i=0; i<NInputDimensions; i++)
769 samplingFactors[i]=parameters[(4+NInputDimensions)*NInputDimensions+i];
772 //JV add the MaskPointer
773 m_Mask=((MaskPointer)( (size_t)parameters[(5+NInputDimensions)*NInputDimensions]));
775 //JV add the MaskPointer
776 m_BulkTransform=((BulkTransformPointer)( (size_t)parameters[(5+NInputDimensions)*NInputDimensions+1]));
778 //JV add the TransformShape
779 m_TransformShape=((unsigned int)parameters[(5+NInputDimensions)*NInputDimensions+2]);
782 this->SetSplineOrders( splineOrders );
783 this->SetGridSpacing( spacing );
784 this->SetGridDirection( direction );
785 this->SetGridOrigin( origin );
786 this->SetGridRegion( bsplineRegion );
787 this->SetLUTSamplingFactors( samplingFactors );
792 // Wrap flat parameters as images
793 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
795 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
798 //JV Wrap parameter array in vectorial image, changed parameter order: A1x A1y A1z, A2x ....
799 PixelType * dataPointer =reinterpret_cast<PixelType *>( const_cast<double *>(m_InputParametersPointer->data_block() )) ;
800 unsigned int numberOfPixels = m_GridRegion.GetNumberOfPixels();
802 m_WrappedImage->GetPixelContainer()->SetImportPointer( dataPointer,numberOfPixels);//InputDimension
803 m_CoefficientImage = m_WrappedImage;
805 //=====================================
806 //JV Create padded structure adding BC
807 //=====================================
808 PadCoefficientImage();
810 //=====================================
811 //JV Wrap jacobian into OutputDimension X Vectorial images
812 //=====================================
813 #if ITK_VERSION_MAJOR >= 4
814 this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
816 this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
819 // Use memset to set the memory
820 // JV four rows of three comps of parameters
821 #if ITK_VERSION_MAJOR >= 4
822 JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
824 JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
826 memset(jacobianDataPointer, 0, OutputDimension*numberOfPixels*sizeof(JacobianPixelType));
828 for (unsigned int j=0; j<OutputDimension; j++)
830 m_JacobianImage[j]->GetPixelContainer()->
831 SetImportPointer( jacobianDataPointer, numberOfPixels );
832 jacobianDataPointer += numberOfPixels;
835 // Reset the J parameters
836 m_LastJacobianIndex = m_ValidRegion.GetIndex();
837 m_FirstRegion.SetSize(m_NullSize);
838 m_SecondRegion.SetSize(m_NullSize);
839 for ( unsigned int j = 0; j < SpaceDimension ; j++ )
841 m_FirstIterator[j]= IteratorType( m_JacobianImage[j], m_FirstRegion);
842 m_SecondIterator[j]= IteratorType( m_JacobianImage[j], m_SecondRegion);
845 m_BCValues.resize(0);
846 m_BCRegions.resize(0);
848 m_BC2Values.resize(0);
849 m_BC2Regions.resize(0);
851 m_BC3Values.resize(0);
852 m_BC3Regions.resize(0);
858 // Set the parameters by value
859 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
861 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
862 ::SetParametersByValue( const ParametersType & parameters )
865 // Check if the number of parameters match the
866 // Expected number of parameters
867 if ( parameters.Size() != this->GetNumberOfParameters() )
869 itkExceptionMacro(<<"Mismatched between parameters size "
871 << " and region size "
872 << m_GridRegion.GetNumberOfPixels() );
876 m_InternalParametersBuffer = parameters;
877 m_InputParametersPointer = &m_InternalParametersBuffer;
879 // Wrap flat array as images of coefficients
880 this->WrapAsImages();
882 //JV Set padded input to vector interpolator
883 m_VectorInterpolator->SetInputImage(this->GetPaddedCoefficientImage());
885 // Modified is always called since we just have a pointer to the
886 // Parameters and cannot know if the parameters have changed.
891 // Get the parameters
892 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
894 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
896 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
897 ::GetParameters( void ) const
899 /** NOTE: For efficiency, this class does not keep a copy of the parameters -
900 * it just keeps pointer to input parameters.
902 if (NULL == m_InputParametersPointer)
904 itkExceptionMacro( <<"Cannot GetParameters() because m_InputParametersPointer is NULL. Perhaps SetCoefficientImage() has been called causing the NULL pointer." );
907 return (*m_InputParametersPointer);
911 // Get the parameters
912 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
914 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
916 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
917 ::GetFixedParameters( void ) const
919 RegionType resRegion = this->GetGridRegion( );
921 for (unsigned int i=0; i<NInputDimensions; i++)
923 this->m_FixedParameters[i] = (resRegion.GetSize())[i];
925 for (unsigned int i=0; i<NInputDimensions; i++)
927 this->m_FixedParameters[NInputDimensions+i] = (this->GetGridOrigin())[i];
929 for (unsigned int i=0; i<NInputDimensions; i++)
931 this->m_FixedParameters[2*NInputDimensions+i] = (this->GetGridSpacing())[i];
933 for (unsigned int di=0; di<NInputDimensions; di++)
935 for (unsigned int dj=0; dj<NInputDimensions; dj++)
937 this->m_FixedParameters[3*NInputDimensions+(di*NInputDimensions+dj)] = (this->GetGridDirection())[di][dj];
941 //JV add splineOrders
942 for (unsigned int i=0; i<NInputDimensions; i++)
944 this->m_FixedParameters[(3+NInputDimensions)*NInputDimensions+i] = (this->GetSplineOrders())[i];
947 //JV add LUTsamplingFactor
948 for (unsigned int i=0; i<NInputDimensions; i++)
950 this->m_FixedParameters[(4+NInputDimensions)*NInputDimensions+i] = (this->GetLUTSamplingFactors())[i];
954 this->m_FixedParameters[(5+NInputDimensions)*NInputDimensions]=(double)((size_t) m_Mask);
956 //JV add the bulktransform pointer
957 this->m_FixedParameters[(5+NInputDimensions)*NInputDimensions+1]=(double)((size_t) m_BulkTransform);
959 //JV add the transform shape
960 this->m_FixedParameters[(5+NInputDimensions)*NInputDimensions+2]=(double)( m_TransformShape);
962 return (this->m_FixedParameters);
966 // Set the B-Spline coefficients using input images
967 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
969 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
970 ::SetCoefficientImage( CoefficientImagePointer image )
972 this->SetGridSpacing( image->GetSpacing() );
973 this->SetGridOrigin( image->GetOrigin() );
974 this->SetGridDirection( image->GetDirection() );
975 this->SetGridRegion( image->GetBufferedRegion() );
976 m_CoefficientImage = image;
979 // m_WrappedImage=m_CoefficientImage;
981 // Update the interpolator
982 this->PadCoefficientImage();
983 m_VectorInterpolator->SetInputImage(this->GetPaddedCoefficientImage());
985 // Clean up buffered parameters
986 m_InternalParametersBuffer = ParametersType( 0 );
987 m_InputParametersPointer = NULL;
992 // // Set the B-Spline coefficients using input images
993 // template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
995 // ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
996 // ::SetPaddedCoefficientImage( CoefficientImagePointer image )
998 // //JV modify the region
999 // typename CoefficientImageType::RegionType region=image->GetBufferedRegion();
1000 // typename CoefficientImageType::RegionType::SizeType size=region.GetSize();
1001 // size[InputDimension-1]-=2;
1002 // region.SetSize(size);
1005 // this->SetGridRegion( region );
1006 // this->SetGridSpacing( image->GetSpacing() );
1007 // this->SetGridDirection( image->GetDirection() );
1008 // this->SetGridOrigin( image->GetOrigin() );
1009 // m_PaddedCoefficientImage = image;
1010 // this->ExtractCoefficientImage();
1011 // m_VectorInterpolator->SetInputImage(this->GetPaddedCoefficientImage());
1013 // // Clean up buffered parameters
1014 // m_InternalParametersBuffer = ParametersType( 0 );
1015 // m_InputParametersPointer = NULL;
1019 // Set the B-Spline coefficients using input images
1020 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
1021 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::CoefficientImageType::Pointer
1022 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
1023 ::ExtractTemporalRow(const typename CoefficientImageType::Pointer& coefficientImage, unsigned int temporalIndex)
1026 typename CoefficientImageType::RegionType sourceRegion=coefficientImage->GetLargestPossibleRegion();
1027 sourceRegion.SetSize(InputDimension-1, 1);
1028 sourceRegion.SetIndex(InputDimension-1, temporalIndex);
1031 typedef clitk::ExtractImageFilter<CoefficientImageType, CoefficientImageType> ExtractImageFilterType;
1032 typename ExtractImageFilterType::Pointer extract=ExtractImageFilterType::New();
1033 extract->SetInput(coefficientImage);
1034 extract->SetExtractionRegion(sourceRegion);
1036 typename CoefficientImageType::Pointer row= extract->GetOutput();
1038 // Set index to zero
1039 sourceRegion.SetIndex(InputDimension-1, 0);
1040 row->SetRegions(sourceRegion);
1045 // Set the B-Spline coefficients using input images
1046 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
1048 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
1049 ::PadCoefficientImage(void)
1052 // Define paste, extract and combine filters
1053 typedef itk::PasteImageFilter<CoefficientImageType, CoefficientImageType, CoefficientImageType> PasteImageFilterType;
1054 typedef clitk::ExtractImageFilter<CoefficientImageType, CoefficientImageType> ExtractImageFilterType;
1055 typedef clitk::LinearCombinationImageFilter<CoefficientImageType, CoefficientImageType> LinearCombinationFilterType;
1058 typename CoefficientImageType::RegionType sourceRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
1059 typename CoefficientImageType::RegionType destinationRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
1060 typename CoefficientImageType::RegionType::SizeType sourceSize=sourceRegion.GetSize();
1061 typename CoefficientImageType::IndexType sourceIndex=sourceRegion.GetIndex();
1062 typename CoefficientImageType::IndexType destinationIndex=destinationRegion.GetIndex();
1064 // JV Padding depends on the shape
1065 switch (m_TransformShape)
1070 2: rabbit 4 CP 3 DOF
1071 3: rabbit 5 CP 4 DOF
1072 4: sputnik 4 CP 4 DOF
1073 5: sputnik 5 CP 5 DOF
1074 6: diamond 6 CP 5 DOF
1075 7: diamond 7 CP 6 DOF
1080 // ----------------------------------------------------------------------
1081 // The egg with 4 internal CP (starting from inhale)
1082 // Periodic, constrained to zero at the reference
1083 // at position 3 and
1084 // Coeff row BC1 BC2 0 BC3 1 2 BC4
1085 // PaddedCoeff R: 0 1 2 3 4 5 6
1088 // BC3= -weights[2]/weights[0] ( R2+R4 )
1090 // ---------------------------------------------------------------------
1092 //---------------------------------
1093 // 1. First two temporal rows are identical: paste 1-2 to 0-1
1094 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1095 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1096 paster0->SetSourceImage(m_CoefficientImage);
1097 sourceRegion.SetIndex(NInputDimensions-1,1);
1098 sourceRegion.SetSize(NInputDimensions-1,2);
1099 destinationIndex[InputDimension-1]=0;
1100 paster0->SetDestinationIndex(destinationIndex);
1101 paster0->SetSourceRegion(sourceRegion);
1103 //---------------------------------
1104 // 1. Next temporal row = paste 0 to 2
1105 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1106 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1107 paster1->SetDestinationImage(paster0->GetOutput());
1108 paster1->SetSourceImage(row0);
1109 destinationIndex[InputDimension-1]=2;
1110 paster1->SetDestinationIndex(destinationIndex);
1111 paster1->SetSourceRegion(row0->GetLargestPossibleRegion());
1113 //---------------------------------
1114 // 2. Middle row at index 3=BC
1115 // Extract row at index 1, 2 (of coeff image)
1116 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1119 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1120 combine1->SetInput(0,row0);
1121 combine1->SetInput(1,row1);
1122 combine1->SetA(-m_WeightRatio[2][0]);
1123 combine1->SetB(-m_WeightRatio[2][0]);
1125 typename CoefficientImageType::Pointer bc3Row=combine1->GetOutput();
1127 // Paste middleRow at index 3 (padded coeff)
1128 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1129 paster2->SetDestinationImage(paster1->GetOutput());
1130 paster2->SetSourceImage(bc3Row);
1131 destinationIndex[InputDimension-1]=3;
1132 paster2->SetDestinationIndex(destinationIndex);
1133 paster2->SetSourceRegion(bc3Row->GetLargestPossibleRegion());
1135 //---------------------------------
1136 // 3. Next two temporal rows identical: paste 1,2 to 4,5
1137 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1138 paster3->SetDestinationImage(paster2->GetOutput());
1139 paster3->SetSourceImage(m_CoefficientImage);
1140 sourceRegion.SetIndex(InputDimension-1,1);
1141 sourceRegion.SetSize(InputDimension-1,2);
1142 destinationIndex[InputDimension-1]=4;
1143 paster3->SetDestinationIndex(destinationIndex);
1144 paster3->SetSourceRegion(sourceRegion);
1146 // ---------------------------------
1147 // 4. Row at index 6=BC4= R2
1148 // Paste BC3 row at index 5
1149 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1150 paster4->SetDestinationImage(paster3->GetOutput());
1151 paster4->SetSourceImage(row0);
1152 destinationIndex[InputDimension-1]=6;
1153 paster4->SetDestinationIndex(destinationIndex);
1154 paster4->SetSourceRegion(row0->GetLargestPossibleRegion());
1156 // Update the chain!
1158 m_PaddedCoefficientImage= paster4->GetOutput();
1165 // ----------------------------------------------------------------------
1166 // The egg with 5 internal CP (starting from inhale)
1167 // Periodic, constrained to zero at the reference
1168 // at position 3 and
1169 // Coeff row BC1 BC2 0 BC3 1 2 3 BC4
1170 // PaddedCoeff R: 0 1 2 3 4 5 6 7
1173 // BC3= -weights[3]/weights[1] ( R2+R5 ) - R4
1175 // ---------------------------------------------------------------------
1176 //---------------------------------
1177 // 1. First two temporal rows are identical: paste 2-3 to 0-1
1178 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1179 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1180 paster0->SetSourceImage(m_CoefficientImage);
1181 sourceRegion.SetIndex(NInputDimensions-1,2);
1182 sourceRegion.SetSize(NInputDimensions-1,2);
1183 destinationIndex[InputDimension-1]=0;
1184 paster0->SetDestinationIndex(destinationIndex);
1185 paster0->SetSourceRegion(sourceRegion);
1187 //---------------------------------
1188 // 1. Next temporal row = paste 0 to 2
1189 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1190 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1191 paster1->SetDestinationImage(paster0->GetOutput());
1192 paster1->SetSourceImage(row0);
1193 destinationIndex[InputDimension-1]=2;
1194 paster1->SetDestinationIndex(destinationIndex);
1195 paster1->SetSourceRegion(row0->GetLargestPossibleRegion());
1197 //---------------------------------
1198 // 2. Middle row at index 3=BC
1199 // Extract row at index 1, 2 (of coeff image)
1200 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1201 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1204 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1205 combine1->SetInput(0,row0);
1206 combine1->SetInput(1,row2);
1209 // combine1->Update();
1210 typename LinearCombinationFilterType::Pointer combine2=LinearCombinationFilterType::New();
1211 combine2->SetInput(0,row1);
1212 combine2->SetInput(1,combine1->GetOutput());
1213 combine2->SetA(-1.);
1214 combine2->SetB(-m_WeightRatio[3][1]);
1216 typename CoefficientImageType::Pointer bc3Row=combine2->GetOutput();
1218 // Paste middleRow at index 3 (padded coeff)
1219 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1220 paster2->SetDestinationImage(paster1->GetOutput());
1221 paster2->SetSourceImage(bc3Row);
1222 destinationIndex[InputDimension-1]=3;
1223 paster2->SetDestinationIndex(destinationIndex);
1224 paster2->SetSourceRegion(bc3Row->GetLargestPossibleRegion());
1226 //---------------------------------
1227 // 3. Next three temporal rows identical: paste 1,2,3 to 4,5,6
1228 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1229 paster3->SetDestinationImage(paster2->GetOutput());
1230 paster3->SetSourceImage(m_CoefficientImage);
1231 sourceRegion.SetIndex(InputDimension-1,1);
1232 sourceRegion.SetSize(InputDimension-1,3);
1233 destinationIndex[InputDimension-1]=4;
1234 paster3->SetDestinationIndex(destinationIndex);
1235 paster3->SetSourceRegion(sourceRegion);
1237 // ---------------------------------
1238 // 4. Row at index 7=BC4= R2
1239 // Paste BC3 row at index 5
1240 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1241 paster4->SetDestinationImage(paster3->GetOutput());
1242 paster4->SetSourceImage(row0);
1243 destinationIndex[InputDimension-1]=7;
1244 paster4->SetDestinationIndex(destinationIndex);
1245 paster4->SetSourceRegion(row0->GetLargestPossibleRegion());
1247 // Update the chain!
1249 m_PaddedCoefficientImage= paster4->GetOutput();
1255 // // ----------------------------------------------------------------------
1256 // // The egg with 5 internal CP:
1257 // // Periodic, C2 smooth everywhere and constrained to zero at the reference
1258 // // Coeff row R5 BC1 0 1 2 3 BC2 R2
1259 // // PaddedCoeff R: 0 1 2 3 4 5 6 7
1260 // // BC1= -weights[2]/weights[0] ( R2+R5)
1262 // // ---------------------------------------------------------------------
1264 // // Extract rows with index 0 and 3
1265 // typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1266 // typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1268 // // Paste the first row
1269 // typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1270 // destinationIndex.Fill(0);
1271 // paster1->SetDestinationIndex(destinationIndex);
1272 // paster1->SetSourceRegion(row3->GetLargestPossibleRegion());
1273 // paster1->SetSourceImage(row3);
1274 // paster1->SetDestinationImage(m_PaddedCoefficientImage);
1276 // // Linearly Combine rows for BC1 and BC2
1277 // typedef clitk::LinearCombinationImageFilter<CoefficientImageType, CoefficientImageType> LinearCombinationFilterType;
1278 // typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1279 // combine1->SetFirstInput(row0);
1280 // combine1->SetSecondInput(row3);
1281 // combine1->SetA(-m_WeightRatio[2][0]);
1282 // combine1->SetB(-m_WeightRatio[2][0]);
1283 // combine1->Update();
1284 // typename CoefficientImageType::Pointer bcRow=combine1->GetOutput();
1286 // // Paste the second row
1287 // typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1288 // destinationIndex[InputDimension-1]=1;
1289 // paster2->SetDestinationIndex(destinationIndex);
1290 // paster2->SetSourceRegion(bcRow->GetLargestPossibleRegion());
1291 // paster2->SetSourceImage(bcRow);
1292 // paster2->SetDestinationImage(paster1->GetOutput());
1294 // // Paste the coefficientImage
1295 // typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1296 // destinationIndex[InputDimension-1]=2;
1297 // paster3->SetDestinationIndex(destinationIndex);
1298 // paster3->SetSourceRegion(m_CoefficientImage->GetLargestPossibleRegion());
1299 // paster3->SetSourceImage(m_CoefficientImage);
1300 // paster3->SetDestinationImage(paster2->GetOutput());
1302 // // Paste the last two rows
1303 // typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1304 // destinationIndex[InputDimension-1]=6;
1305 // paster4->SetDestinationIndex(destinationIndex);
1306 // paster4->SetSourceRegion(bcRow->GetLargestPossibleRegion());
1307 // paster4->SetSourceImage(bcRow);
1308 // paster4->SetDestinationImage(paster3->GetOutput());
1310 // typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1311 // destinationIndex[InputDimension-1]=7;
1312 // paster5->SetDestinationIndex(destinationIndex);
1313 // paster5->SetSourceRegion(row0->GetLargestPossibleRegion());
1314 // paster5->SetSourceImage(row0);
1315 // paster5->SetDestinationImage(paster4->GetOutput());
1317 // // Update the chain!
1318 // paster5->Update();
1319 // m_PaddedCoefficientImage= paster5->GetOutput();
1326 // ----------------------------------------------------------------------
1327 // The rabbit with 4 internal CP
1328 // Periodic, constrained to zero at the reference
1329 // at position 3 and the extremes fixed with anit-symm bc
1330 // Coeff row BC1 0 1 BC2 2 BC3 BC4
1331 // PaddedCoeff R: 0 1 2 3 4 5 6
1333 // BC2= -weights[2]/weights[0] ( R2+R4 )
1336 // ---------------------------------------------------------------------
1338 // ---------------------------------
1339 // 0. First Row =BC1
1340 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1341 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1342 typename LinearCombinationFilterType::Pointer combine0=LinearCombinationFilterType::New();
1343 combine0->SetInput(0,row0);
1344 combine0->SetInput(1,row1);
1346 combine0->SetB(-1.);
1348 typename CoefficientImageType::Pointer bc1Row=combine0->GetOutput();
1350 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1351 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1352 paster0->SetSourceImage(bc1Row);
1353 destinationIndex[InputDimension-1]=0;
1354 paster0->SetDestinationIndex(destinationIndex);
1355 paster0->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1357 //---------------------------------
1358 // 1. Next two temporal rows are identical: paste 0-1 to 1-2
1359 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1360 paster1->SetDestinationImage(paster0->GetOutput());
1361 paster1->SetSourceImage(m_CoefficientImage);
1362 sourceRegion.SetIndex(NInputDimensions-1,0);
1363 destinationIndex[InputDimension-1]=1;
1364 sourceRegion.SetSize(NInputDimensions-1,2);
1365 paster1->SetDestinationIndex(destinationIndex);
1366 paster1->SetSourceRegion(sourceRegion);
1368 //---------------------------------
1369 // 2. Middle row at index 3=BC
1370 // Extract row at index 1, 2 (of coeff image)
1371 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1374 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1375 combine1->SetInput(0,row1);
1376 combine1->SetInput(1,row2);
1377 combine1->SetA(-m_WeightRatio[2][0]);
1378 combine1->SetB(-m_WeightRatio[2][0]);
1380 typename CoefficientImageType::Pointer bc2Row=combine1->GetOutput();
1382 // Paste middleRow at index 3 (padded coeff)
1383 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1384 paster2->SetDestinationImage(paster1->GetOutput());
1385 paster2->SetSourceImage(bc2Row);
1386 destinationIndex[InputDimension-1]=3;
1387 paster2->SetDestinationIndex(destinationIndex);
1388 paster2->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
1390 //---------------------------------
1391 // 3. Next temporal row is identical: paste 2 to 4
1392 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1393 paster3->SetDestinationImage(paster2->GetOutput());
1394 paster3->SetSourceImage(row2);
1395 destinationIndex[InputDimension-1]=4;
1396 paster3->SetDestinationIndex(destinationIndex);
1397 paster3->SetSourceRegion(row2->GetLargestPossibleRegion());
1399 // ---------------------------------
1400 // 4. Row at index 5=BC (paddedcoeff image) R1
1401 // Paste BC3 row at index 5
1402 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1403 paster4->SetDestinationImage(paster3->GetOutput());
1404 paster4->SetSourceImage(row0);
1405 destinationIndex[InputDimension-1]=5;
1406 paster4->SetDestinationIndex(destinationIndex);
1407 paster4->SetSourceRegion(row0->GetLargestPossibleRegion());
1409 // ---------------------------------
1410 // 5. Paste BC4 row at index 6
1411 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1412 combine3->SetInput(0,row0);
1413 combine3->SetInput(1,row2);
1415 combine3->SetB(-1.);
1417 typename CoefficientImageType::Pointer bc4Row=combine3->GetOutput();
1418 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1419 paster5->SetDestinationImage(paster4->GetOutput());
1420 paster5->SetSourceImage(bc4Row);
1421 destinationIndex[InputDimension-1]=6;
1422 paster5->SetDestinationIndex(destinationIndex);
1423 paster5->SetSourceRegion(bc4Row->GetLargestPossibleRegion());
1425 // Update the chain!
1427 m_PaddedCoefficientImage= paster5->GetOutput();
1434 // ----------------------------------------------------------------------
1435 // The rabbit with 5 internal CP
1436 // Periodic, constrained to zero at the reference at position 3.5
1437 // and the extremes fixed with anti-symmetrical BC
1438 // Coeff row BC1 0 1 BC2 2 3 BC3 BC4
1439 // PaddedCoeff R: 0 1 2 3 4 5 6 7
1441 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
1444 // ---------------------------------------------------------------------
1446 // ---------------------------------
1447 // 0. First Row =BC1
1448 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1449 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1450 typename LinearCombinationFilterType::Pointer combine0=LinearCombinationFilterType::New();
1451 combine0->SetInput(0,row0);
1452 combine0->SetInput(1,row1);
1454 combine0->SetB(-1.);
1456 typename CoefficientImageType::Pointer bc1Row=combine0->GetOutput();
1458 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1459 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1460 paster0->SetSourceImage(bc1Row);
1461 destinationIndex[InputDimension-1]=0;
1462 paster0->SetDestinationIndex(destinationIndex);
1463 paster0->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1465 //---------------------------------
1466 // 1. Next two temporal rows are identical: paste 0-1 to 1-2
1467 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1468 paster1->SetDestinationImage(paster0->GetOutput());
1469 paster1->SetSourceImage(m_CoefficientImage);
1470 sourceRegion.SetIndex(InputDimension-1,0);
1471 destinationIndex[InputDimension-1]=1;
1472 sourceRegion.SetSize(NInputDimensions-1,2);
1473 paster1->SetDestinationIndex(destinationIndex);
1474 paster1->SetSourceRegion(sourceRegion);
1476 //---------------------------------
1477 // 2. Middle row at index 3=BC
1478 // Extract row at index 1, 3 (of coeff image)
1479 //typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1480 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1483 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1484 combine1->SetInput(0,row1);
1485 combine1->SetInput(1,row3);
1490 // Extract row at index 2 (coeff image)
1491 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1494 typename LinearCombinationFilterType::Pointer combine2=LinearCombinationFilterType::New();
1495 combine2->SetInput(0,combine1->GetOutput());
1496 combine2->SetInput(1,row2);
1497 combine2->SetA(-m_WeightRatio[3][1]);
1498 combine2->SetB(-1.);
1500 typename CoefficientImageType::Pointer bc2Row=combine2->GetOutput();
1502 // Paste middleRow at index 3 (padded coeff)
1503 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1504 paster2->SetDestinationImage(paster1->GetOutput());
1505 paster2->SetSourceImage(bc2Row);
1506 destinationIndex[InputDimension-1]=3;
1507 paster2->SetDestinationIndex(destinationIndex);
1508 paster2->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
1510 //---------------------------------
1511 // 3. Next two temporal rows are identical: paste 2,3 to 4,5
1512 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1513 paster3->SetDestinationImage(paster2->GetOutput());
1514 paster3->SetSourceImage(m_CoefficientImage);
1515 sourceRegion.SetIndex(InputDimension-1,2);
1516 destinationIndex[InputDimension-1]=4;
1517 sourceRegion.SetSize(NInputDimensions-1,2);
1518 paster3->SetDestinationIndex(destinationIndex);
1519 paster3->SetSourceRegion(sourceRegion);
1521 // ---------------------------------
1522 // 4. Row at index 6=BC (paddedcoeff image)R1
1523 // Paste BC3 row at index 6
1524 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1525 paster4->SetDestinationImage(paster3->GetOutput());
1526 paster4->SetSourceImage(row0);
1527 destinationIndex[InputDimension-1]=6;
1528 paster4->SetDestinationIndex(destinationIndex);
1529 paster4->SetSourceRegion(row0->GetLargestPossibleRegion());
1531 // ---------------------------------
1532 // 5. Paste BC4 row at index 7
1533 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1534 combine3->SetInput(0,row0);
1535 combine3->SetInput(1,row3);
1537 combine3->SetB(-1.);
1539 typename CoefficientImageType::Pointer bc4Row=combine3->GetOutput();
1540 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1541 paster5->SetDestinationImage(paster4->GetOutput());
1542 paster5->SetSourceImage(bc4Row);
1543 destinationIndex[InputDimension-1]=7;
1544 paster5->SetDestinationIndex(destinationIndex);
1545 paster5->SetSourceRegion(bc4Row->GetLargestPossibleRegion());
1547 // Update the chain!
1549 m_PaddedCoefficientImage= paster5->GetOutput();
1556 // ----------------------------------------------------------------------
1557 // The sputnik with 4 internal CP
1558 // Periodic, constrained to zero at the reference
1559 // at position 3 and one indepent extremes copied
1560 // Coeff row BC1 0 1 BC2 2 BC2 3
1561 // PaddedCoeff R: 0 1 2 3 4 5 6
1563 // BC2= -weights[2]/weights[0] ( R2+R4 )
1564 // BC3= weights[2]/weights[0] ( R2-R4) + R1
1565 // ---------------------------------------------------------------------
1567 //---------------------------------
1568 // 1. First Row is equal to last row: paste 3 row to 0
1569 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1570 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1571 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1572 paster0->SetSourceImage(row3);
1573 destinationIndex[InputDimension-1]=0;
1574 paster0->SetDestinationIndex(destinationIndex);
1575 paster0->SetSourceRegion(row3->GetLargestPossibleRegion());
1577 //---------------------------------
1578 // 1. Next two temporal rows are identical: paste 0-1 to 1-2
1579 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1580 paster1->SetDestinationImage(paster0->GetOutput());
1581 paster1->SetSourceImage(m_CoefficientImage);
1582 sourceRegion.SetIndex(NInputDimensions-1,0);
1583 destinationIndex[InputDimension-1]=1;
1584 sourceRegion.SetSize(NInputDimensions-1,2);
1585 paster1->SetDestinationIndex(destinationIndex);
1586 paster1->SetSourceRegion(sourceRegion);
1588 //---------------------------------
1589 // 2. Middle row at index 3=BC
1590 // Extract row at index 1, 2 (of coeff image)
1591 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1592 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1595 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1596 combine1->SetInput(0,row1);
1597 combine1->SetInput(1,row2);
1598 combine1->SetA(-m_WeightRatio[2][0]);
1599 combine1->SetB(-m_WeightRatio[2][0]);
1601 typename CoefficientImageType::Pointer bc1Row=combine1->GetOutput();
1603 // Paste middleRow at index 3 (padded coeff)
1604 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1605 paster2->SetDestinationImage(paster1->GetOutput());
1606 paster2->SetSourceImage(bc1Row);
1607 destinationIndex[InputDimension-1]=3;
1608 paster2->SetDestinationIndex(destinationIndex);
1609 paster2->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1611 //---------------------------------
1612 // 3. Next temporal row is identical: paste 2 to 4
1613 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1614 paster3->SetDestinationImage(paster2->GetOutput());
1615 paster3->SetSourceImage(row2);
1616 destinationIndex[InputDimension-1]=4;
1617 paster3->SetDestinationIndex(destinationIndex);
1618 paster3->SetSourceRegion(row2->GetLargestPossibleRegion());
1620 //---------------------------------
1621 // 4. Final row at index 5=BC3 (paddedcoeff image)R1 R2 R4 corresponds to index in coeff image 0 1 2
1622 // Extract row at index 1, 2 (of coeff image)already done
1623 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1626 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1627 combine3->SetInput(0,row1);
1628 combine3->SetInput(1,row2);
1630 combine3->SetB(-1.);
1633 typename LinearCombinationFilterType::Pointer combine4=LinearCombinationFilterType::New();
1634 combine4->SetInput(0,combine3->GetOutput());
1635 combine4->SetInput(1,row0);
1636 combine4->SetA(m_WeightRatio[2][0]);
1639 typename CoefficientImageType::Pointer bc2Row=combine4->GetOutput();
1641 // Paste BC row at index 5
1642 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1643 paster4->SetDestinationImage(paster3->GetOutput());
1644 paster4->SetSourceImage(bc2Row);
1645 destinationIndex[InputDimension-1]=5;
1646 paster4->SetDestinationIndex(destinationIndex);
1647 paster4->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
1649 // Paste row 3 at index 6
1650 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1651 paster5->SetDestinationImage(paster4->GetOutput());
1652 paster5->SetSourceImage(row3);
1653 destinationIndex[InputDimension-1]=6;
1654 paster5->SetDestinationIndex(destinationIndex);
1655 paster5->SetSourceRegion(row3->GetLargestPossibleRegion());
1657 // Update the chain!
1659 m_PaddedCoefficientImage= paster5->GetOutput();
1667 // ----------------------------------------------------------------------
1668 // The sputnik with 5 internal CP
1669 // Periodic, constrained to zero at the reference
1670 // at position 3 and one indepent extreme
1671 // Coeff row BC1 0 1 BC2 2 3 BC3 4
1672 // PaddedCoeff R: 0 1 2 3 4 5 6 7
1673 // BC1= R2 + R5 - R7
1674 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
1675 // BC3= R1 + 0.5 R2 - 0.5 R7
1676 // ----------------------------------------------------------------------
1677 //---------------------------------
1679 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1680 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1681 typename CoefficientImageType::Pointer row4=this->ExtractTemporalRow(m_CoefficientImage, 4);
1684 typename LinearCombinationFilterType::Pointer combine0=LinearCombinationFilterType::New();
1685 combine0->SetInput(0,row1);
1686 combine0->SetInput(1,row3);
1689 //combine0->Update();
1690 typename LinearCombinationFilterType::Pointer combine0bis=LinearCombinationFilterType::New();
1691 combine0bis->SetInput(0,combine0->GetOutput());
1692 combine0bis->SetInput(1,row4);
1693 combine0bis->SetA(1.);
1694 combine0bis->SetB(-1.);
1695 combine0bis->Update();
1696 typename CoefficientImageType::Pointer bc1Row=combine0bis->GetOutput();
1698 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
1699 paster0->SetDestinationImage(m_PaddedCoefficientImage);
1700 paster0->SetSourceImage(bc1Row);
1701 destinationIndex[InputDimension-1]=0;
1702 paster0->SetDestinationIndex(destinationIndex);
1703 paster0->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1705 //---------------------------------
1706 // 1. Next two temporal rows are identical: paste 0-1 to 1-2
1707 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1708 paster1->SetDestinationImage(paster0->GetOutput());
1709 paster1->SetSourceImage(m_CoefficientImage);
1710 sourceRegion.SetIndex(NInputDimensions-1,0);
1711 destinationIndex[InputDimension-1]=1;
1712 sourceRegion.SetSize(NInputDimensions-1,2);
1713 paster1->SetDestinationIndex(destinationIndex);
1714 paster1->SetSourceRegion(sourceRegion);
1716 //---------------------------------
1717 // 2. Middle row at index 3=BC
1718 // Extract row at index 1, 2 (of coeff image)
1719 //typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1720 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1723 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1724 combine1->SetInput(0,row1);
1725 combine1->SetInput(1,row3);
1730 typename LinearCombinationFilterType::Pointer combine2=LinearCombinationFilterType::New();
1731 combine2->SetInput(0,combine1->GetOutput());
1732 combine2->SetInput(1,row2);
1733 combine2->SetA(-m_WeightRatio[3][1]);
1734 combine2->SetB(-1.);
1736 typename CoefficientImageType::Pointer bc2Row=combine2->GetOutput();
1738 // Paste middleRow at index 3 (padded coeff)
1739 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1740 paster2->SetDestinationImage(paster1->GetOutput());
1741 paster2->SetSourceImage(bc2Row);
1742 destinationIndex[InputDimension-1]=3;
1743 paster2->SetDestinationIndex(destinationIndex);
1744 paster2->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
1746 //---------------------------------
1747 // 3. Next two temporal rows are identical: paste 2,3 to 4,5
1748 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1749 paster3->SetDestinationImage(paster2->GetOutput());
1750 paster3->SetSourceImage(m_CoefficientImage);
1751 sourceRegion.SetIndex(InputDimension-1,2);
1752 destinationIndex[InputDimension-1]=4;
1753 sourceRegion.SetSize(NInputDimensions-1,2);
1754 paster3->SetDestinationIndex(destinationIndex);
1755 paster3->SetSourceRegion(sourceRegion);
1757 //---------------------------------
1758 // 4. Final row at index 6=BC3
1759 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1762 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1763 combine3->SetInput(0,row1);
1764 combine3->SetInput(1,row4);
1766 combine3->SetB(-1.);
1767 typename LinearCombinationFilterType::Pointer combine4=LinearCombinationFilterType::New();
1768 combine4->SetInput(0,row0);
1769 combine4->SetInput(1,combine3->GetOutput());
1773 typename CoefficientImageType::Pointer bc3Row=combine4->GetOutput();
1775 // Paste BC row at index 6
1776 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1777 paster4->SetDestinationImage(paster3->GetOutput());
1778 paster4->SetSourceImage(bc3Row);
1779 destinationIndex[InputDimension-1]=6;
1780 paster4->SetDestinationIndex(destinationIndex);
1781 paster4->SetSourceRegion(bc3Row->GetLargestPossibleRegion());
1783 // Paste row 4 at index 7
1784 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1785 paster5->SetDestinationImage(paster4->GetOutput());
1786 paster5->SetSourceImage(row4);
1787 destinationIndex[InputDimension-1]=7;
1788 paster5->SetDestinationIndex(destinationIndex);
1789 paster5->SetSourceRegion(row4->GetLargestPossibleRegion());
1791 // Update the chain!
1793 m_PaddedCoefficientImage= paster5->GetOutput();
1800 // ----------------------------------------------------------------------
1801 // The diamond with 4 internal CP:
1802 // Periodic, constrained to zero at the reference at position 3
1803 // Coeff row 0 1 2 BC1 3 BC2 4
1804 // PaddedCoeff R:0 1 2 3 4 5 6
1805 // BC1= -weights[2]/weights[0] ( R2+R4 )
1806 // BC2= weights[2]/weights[0] ( R0+R2-R4-R6 ) + R1
1807 // ---------------------------------------------------------------------
1809 //---------------------------------
1810 // 1. First Three temporal rows are identical: paste 0-2 to 0-2
1811 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1812 paster1->SetDestinationImage(m_PaddedCoefficientImage);
1813 paster1->SetSourceImage(m_CoefficientImage);
1814 sourceIndex.Fill(0);
1815 destinationIndex.Fill(0);
1816 sourceSize[NInputDimensions-1]=3;
1817 sourceRegion.SetSize(sourceSize);
1818 sourceRegion.SetIndex(sourceIndex);
1819 paster1->SetDestinationIndex(destinationIndex);
1820 paster1->SetSourceRegion(sourceRegion);
1822 //---------------------------------
1823 // 2. Middle row at index 3=BC
1824 // Extract row at index 0, 4 (of coeff image)
1825 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1826 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1829 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1830 combine1->SetInput(0,row2);
1831 combine1->SetInput(1,row3);
1832 combine1->SetA(-m_WeightRatio[2][0]);
1833 combine1->SetB(-m_WeightRatio[2][0]);
1835 typename CoefficientImageType::Pointer bc1Row=combine1->GetOutput();
1837 // Paste middleRow at index 3 (padded coeff)
1838 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1839 paster2->SetDestinationImage(paster1->GetOutput());
1840 paster2->SetSourceImage(bc1Row);
1841 destinationIndex[InputDimension-1]=3;
1842 paster2->SetDestinationIndex(destinationIndex);
1843 paster2->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1845 //---------------------------------
1846 // 3. Next row identical: paste 3 to 4
1847 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1848 paster3->SetDestinationImage(paster2->GetOutput());
1849 paster3->SetSourceImage(row3);
1850 destinationIndex[InputDimension-1]=4;
1851 paster3->SetDestinationIndex(destinationIndex);
1852 paster3->SetSourceRegion(row3->GetLargestPossibleRegion());
1854 //---------------------------------
1855 // 4. Final row at index 6=BC (paddedcoeff image)R0 R2 R5 R7 R1 corresponds to index in coeff image 0 2 4 5 1
1856 // Extract row at index 0, 2 (of coeff image)already done
1857 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1858 typename CoefficientImageType::Pointer row4=this->ExtractTemporalRow(m_CoefficientImage, 4);
1859 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1862 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1863 combine3->SetInput(0,row0);
1864 combine3->SetInput(1,row2);
1869 typename LinearCombinationFilterType::Pointer combine4=LinearCombinationFilterType::New();
1870 combine4->SetInput(0,row3);
1871 combine4->SetInput(1,row4);
1876 typename LinearCombinationFilterType::Pointer combine5=LinearCombinationFilterType::New();
1877 combine5->SetInput(0,combine3->GetOutput());
1878 combine5->SetInput(1,combine4->GetOutput());
1880 combine5->SetB(-1.);
1883 typename LinearCombinationFilterType::Pointer combine6=LinearCombinationFilterType::New();
1884 combine6->SetInput(0,combine5->GetOutput());
1885 combine6->SetInput(1,row1);
1886 combine6->SetA(m_WeightRatio[2][0]);
1889 typename CoefficientImageType::Pointer bc2Row=combine6->GetOutput();
1891 // Paste BC row at index 5
1892 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
1893 paster4->SetDestinationImage(paster3->GetOutput());
1894 paster4->SetSourceImage(bc2Row);
1895 destinationIndex[InputDimension-1]=5;
1896 paster4->SetDestinationIndex(destinationIndex);
1897 paster4->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
1899 // Paste last row at index 6
1900 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
1901 paster5->SetDestinationImage(paster4->GetOutput());
1902 paster5->SetSourceImage(row4);
1903 destinationIndex[InputDimension-1]=6;
1904 paster5->SetDestinationIndex(destinationIndex);
1905 paster5->SetSourceRegion(row4->GetLargestPossibleRegion());
1907 // Update the chain!
1909 m_PaddedCoefficientImage= paster5->GetOutput();
1915 // ----------------------------------------------------------------------
1916 // The diamond with 5 internal CP:
1917 // periodic, constrained to zero at the reference at position 3.5
1918 // Coeff row 0 1 2 BC1 3 4 BC2 5
1919 // PaddedCoeff R:0 1 2 3 4 5 6 7
1920 // BC1= -weights[3]/weights[1] ( R2+R5 ) - R4
1921 // BC2= weights[2]/weights[0] ( R0+R2-R5-R7 ) + R1
1922 // ---------------------------------------------------------------------
1924 //---------------------------------
1925 // 1. First Three temporal rows are identical: paste 0-2 to 0-2
1926 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
1927 paster1->SetDestinationImage(m_PaddedCoefficientImage);
1928 paster1->SetSourceImage(m_CoefficientImage);
1929 sourceIndex.Fill(0);
1930 destinationIndex.Fill(0);
1931 sourceSize[NInputDimensions-1]=3;
1932 sourceRegion.SetSize(sourceSize);
1933 sourceRegion.SetIndex(sourceIndex);
1934 paster1->SetDestinationIndex(destinationIndex);
1935 paster1->SetSourceRegion(sourceRegion);
1937 //---------------------------------
1938 // 2. Middle row at index 3=BC
1939 // Extract row at index 0, 4 (of coeff image)
1940 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
1941 typename CoefficientImageType::Pointer row4=this->ExtractTemporalRow(m_CoefficientImage, 4);
1944 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
1945 combine1->SetInput(0,row2);
1946 combine1->SetInput(1,row4);
1951 // Extract row at index 3 (coeff image)
1952 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
1955 typename LinearCombinationFilterType::Pointer combine2=LinearCombinationFilterType::New();
1956 combine2->SetInput(0,combine1->GetOutput());
1957 combine2->SetInput(1,row3);
1958 combine2->SetA(-m_WeightRatio[3][1] );
1959 combine2->SetB(-1.);
1961 typename CoefficientImageType::Pointer bc1Row=combine2->GetOutput();
1963 // Paste middleRow at index 3 (padded coeff)
1964 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
1965 paster2->SetDestinationImage(paster1->GetOutput());
1966 paster2->SetSourceImage(bc1Row);
1967 destinationIndex[InputDimension-1]=3;
1968 paster2->SetDestinationIndex(destinationIndex);
1969 paster2->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
1971 //---------------------------------
1972 // 3. Next two temporal rows are identical: paste 3,4 to 4,5
1973 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
1974 paster3->SetDestinationImage(paster2->GetOutput());
1975 paster3->SetSourceImage(m_CoefficientImage);
1976 sourceIndex[InputDimension-1]=3;
1977 destinationIndex[InputDimension-1]=4;
1978 sourceSize[NInputDimensions-1]=2;
1979 sourceRegion.SetSize(sourceSize);
1980 sourceRegion.SetIndex(sourceIndex);
1981 paster3->SetDestinationIndex(destinationIndex);
1982 paster3->SetSourceRegion(sourceRegion);
1984 //---------------------------------
1985 // 4. Final row at index 6=BC (paddedcoeff image)R0 R2 R5 R7 R1 corresponds to index in coeff image 0 2 4 5 1
1986 // Extract row at index 0, 2 (of coeff image)already done
1987 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
1988 typename CoefficientImageType::Pointer row5=this->ExtractTemporalRow(m_CoefficientImage, 5);
1989 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
1992 typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
1993 combine3->SetInput(0,row0);
1994 combine3->SetInput(1,row2);
1999 typename LinearCombinationFilterType::Pointer combine4=LinearCombinationFilterType::New();
2000 combine4->SetInput(0,row4);
2001 combine4->SetInput(1,row5);
2006 typename LinearCombinationFilterType::Pointer combine5=LinearCombinationFilterType::New();
2007 combine5->SetInput(0,combine3->GetOutput());
2008 combine5->SetInput(1,combine4->GetOutput());
2010 combine5->SetB(-1.);
2013 typename LinearCombinationFilterType::Pointer combine6=LinearCombinationFilterType::New();
2014 combine6->SetInput(0,combine5->GetOutput());
2015 combine6->SetInput(1,row1);
2016 combine6->SetA(m_WeightRatio[2][0]);
2019 typename CoefficientImageType::Pointer bc2Row=combine6->GetOutput();
2021 // Paste BC row at index 6
2022 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
2023 paster4->SetDestinationImage(paster3->GetOutput());
2024 paster4->SetSourceImage(bc2Row);
2025 destinationIndex[InputDimension-1]=6;
2026 paster4->SetDestinationIndex(destinationIndex);
2027 paster4->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
2029 // Paste last row at index 7
2030 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
2031 paster5->SetDestinationImage(paster4->GetOutput());
2032 paster5->SetSourceImage(row5);
2033 destinationIndex[InputDimension-1]=7;
2034 paster5->SetDestinationIndex(destinationIndex);
2035 paster5->SetSourceRegion(row5->GetLargestPossibleRegion());
2037 // Update the chain!
2039 m_PaddedCoefficientImage= paster5->GetOutput();
2046 // ----------------------------------------------------------------------
2047 // The sputnik with 5 internal CP T''(0)=T''(10)
2048 // Periodic, constrained to zero at the reference
2049 // at position 3 and one indepent extreme
2050 // Coeff row BC1 0 1 BC2 2 3 BC3 4
2051 // PaddedCoeff R: 0 1 2 3 4 5 6 7
2053 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
2055 // ---------------------------------------------------------------------
2057 //---------------------------------
2059 typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
2060 typename CoefficientImageType::Pointer row3=this->ExtractTemporalRow(m_CoefficientImage, 3);
2061 typename CoefficientImageType::Pointer row4=this->ExtractTemporalRow(m_CoefficientImage, 4);
2064 typename LinearCombinationFilterType::Pointer combine0=LinearCombinationFilterType::New();
2065 combine0->SetInput(0,row3);
2066 combine0->SetInput(1,row4);
2069 typename LinearCombinationFilterType::Pointer combine0bis=LinearCombinationFilterType::New();
2070 combine0bis->SetInput(0,combine0->GetOutput());
2071 combine0bis->SetInput(1,row1);
2072 combine0bis->SetA(1.);
2073 combine0bis->SetB(-1.);
2074 combine0bis->Update();
2075 typename CoefficientImageType::Pointer bc1Row=combine0bis->GetOutput();
2077 typename PasteImageFilterType::Pointer paster0=PasteImageFilterType::New();
2078 paster0->SetDestinationImage(m_PaddedCoefficientImage);
2079 paster0->SetSourceImage(bc1Row);
2080 destinationIndex[InputDimension-1]=0;
2081 paster0->SetDestinationIndex(destinationIndex);
2082 paster0->SetSourceRegion(bc1Row->GetLargestPossibleRegion());
2084 //---------------------------------
2085 // 1. Next two temporal rows are identical: paste 0-1 to 1-2
2086 typename PasteImageFilterType::Pointer paster1=PasteImageFilterType::New();
2087 paster1->SetDestinationImage(paster0->GetOutput());
2088 paster1->SetSourceImage(m_CoefficientImage);
2089 sourceRegion.SetIndex(NInputDimensions-1,0);
2090 destinationIndex[InputDimension-1]=1;
2091 sourceRegion.SetSize(NInputDimensions-1,2);
2092 paster1->SetDestinationIndex(destinationIndex);
2093 paster1->SetSourceRegion(sourceRegion);
2095 //---------------------------------
2096 // 2. Middle row at index 3=BC
2097 // Extract row at index 1, 2 (of coeff image)
2098 // typename CoefficientImageType::Pointer row1=this->ExtractTemporalRow(m_CoefficientImage, 1);
2099 typename CoefficientImageType::Pointer row2=this->ExtractTemporalRow(m_CoefficientImage, 2);
2102 typename LinearCombinationFilterType::Pointer combine1=LinearCombinationFilterType::New();
2103 combine1->SetInput(0,row1);
2104 combine1->SetInput(1,row3);
2109 typename LinearCombinationFilterType::Pointer combine2=LinearCombinationFilterType::New();
2110 combine2->SetInput(0,combine1->GetOutput());
2111 combine2->SetInput(1,row2);
2112 combine2->SetA(-m_WeightRatio[3][1]);
2113 combine2->SetB(-1.);
2115 typename CoefficientImageType::Pointer bc2Row=combine2->GetOutput();
2117 // Paste middleRow at index 3 (padded coeff)
2118 typename PasteImageFilterType::Pointer paster2=PasteImageFilterType::New();
2119 paster2->SetDestinationImage(paster1->GetOutput());
2120 paster2->SetSourceImage(bc2Row);
2121 destinationIndex[InputDimension-1]=3;
2122 paster2->SetDestinationIndex(destinationIndex);
2123 paster2->SetSourceRegion(bc2Row->GetLargestPossibleRegion());
2125 //---------------------------------
2126 // 3. Next two temporal rows are identical: paste 2,3 to 4,5
2127 typename PasteImageFilterType::Pointer paster3=PasteImageFilterType::New();
2128 paster3->SetDestinationImage(paster2->GetOutput());
2129 paster3->SetSourceImage(m_CoefficientImage);
2130 sourceRegion.SetIndex(InputDimension-1,2);
2131 destinationIndex[InputDimension-1]=4;
2132 sourceRegion.SetSize(NInputDimensions-1,2);
2133 paster3->SetDestinationIndex(destinationIndex);
2134 paster3->SetSourceRegion(sourceRegion);
2136 //---------------------------------
2137 // 4. Final row at index 6=BC3
2138 typename CoefficientImageType::Pointer row0=this->ExtractTemporalRow(m_CoefficientImage, 0);
2141 // typename LinearCombinationFilterType::Pointer combine3=LinearCombinationFilterType::New();
2142 // combine3->SetInput(0,row0);
2143 // combine3->SetInput(1,row1);
2144 // combine3->SetA(1.);
2145 // combine3->SetB(0.5);
2146 // combine3->Update();
2147 // typename CoefficientImageType::Pointer bc3Row=combine3->GetOutput();
2149 // Paste BC row at index 6
2150 typename PasteImageFilterType::Pointer paster4=PasteImageFilterType::New();
2151 paster4->SetDestinationImage(paster3->GetOutput());
2152 paster4->SetSourceImage(row0);
2153 destinationIndex[InputDimension-1]=6;
2154 paster4->SetDestinationIndex(destinationIndex);
2155 paster4->SetSourceRegion(row0->GetLargestPossibleRegion());
2157 // Paste row 4 at index 7
2158 typename PasteImageFilterType::Pointer paster5=PasteImageFilterType::New();
2159 paster5->SetDestinationImage(paster4->GetOutput());
2160 paster5->SetSourceImage(row4);
2161 destinationIndex[InputDimension-1]=7;
2162 paster5->SetDestinationIndex(destinationIndex);
2163 paster5->SetSourceRegion(row4->GetLargestPossibleRegion());
2165 // Update the chain!
2167 m_PaddedCoefficientImage= paster5->GetOutput();
2173 DD ("Shape not available");
2179 // // Extract coefficients from padded version
2180 // template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2182 // ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2183 // ::ExtractCoefficientImage( )
2185 // ////DD("extract coeff image");
2186 // typename ExtractImageFilterType::Pointer extractImageFilter = ExtractImageFilterType::New();
2187 // typename CoefficientImageType::RegionType extractionRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
2188 // typename CoefficientImageType::RegionType::SizeType extractionSize=extractionRegion.GetSize();
2189 // typename CoefficientImageType::RegionType::IndexType extractionIndex = extractionRegion.GetIndex();
2190 // extractionSize[InputDimension-1]-=4;
2191 // extractionIndex[InputDimension-1]=2;
2192 // extractionRegion.SetSize(extractionSize);
2193 // extractionRegion.SetIndex(extractionIndex);
2194 // extractImageFilter->SetInput(m_PaddedCoefficientImage);
2195 // extractImageFilter->SetExtractionRegion(extractionRegion);
2196 // extractImageFilter->Update();
2197 // m_CoefficientImage=extractImageFilter->GetOutput();
2202 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2204 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2205 ::PrintSelf(std::ostream &os, itk::Indent indent) const
2208 this->Superclass::PrintSelf(os, indent);
2210 os << indent << "GridRegion: " << m_GridRegion << std::endl;
2211 os << indent << "GridOrigin: " << m_GridOrigin << std::endl;
2212 os << indent << "GridSpacing: " << m_GridSpacing << std::endl;
2213 os << indent << "GridDirection: " << m_GridDirection << std::endl;
2214 os << indent << "IndexToPoint: " << m_IndexToPoint << std::endl;
2215 os << indent << "PointToIndex: " << m_PointToIndex << std::endl;
2217 os << indent << "CoefficientImage: [ ";
2218 os << m_CoefficientImage.GetPointer() << " ]" << std::endl;
2220 os << indent << "WrappedImage: [ ";
2221 os << m_WrappedImage.GetPointer() << " ]" << std::endl;
2223 os << indent << "InputParametersPointer: "
2224 << m_InputParametersPointer << std::endl;
2225 os << indent << "ValidRegion: " << m_ValidRegion << std::endl;
2226 os << indent << "LastJacobianIndex: " << m_LastJacobianIndex << std::endl;
2227 os << indent << "BulkTransform: ";
2228 os << m_BulkTransform << std::endl;
2230 if ( m_BulkTransform )
2232 os << indent << "BulkTransformType: "
2233 << m_BulkTransform->GetNameOfClass() << std::endl;
2235 os << indent << "VectorBSplineInterpolator: ";
2236 os << m_VectorInterpolator.GetPointer() << std::endl;
2237 os << indent << "Mask: ";
2238 os << m_Mask<< std::endl;
2243 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2245 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2246 ::InsideValidRegion( const ContinuousIndexType& index ) const
2250 if ( !m_ValidRegion.IsInside( index ) )
2255 // JV verify all dimensions
2258 typedef typename ContinuousIndexType::ValueType ValueType;
2259 for( unsigned int j = 0; j < NInputDimensions; j++ )
2261 if (m_SplineOrderOdd[j])
2263 if ( index[j] >= static_cast<ValueType>( m_ValidRegionLast[j] ) )
2275 // Transform a point
2276 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2277 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2279 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2280 ::TransformPoint(const InputPointType &inputPoint) const
2283 InputPointType transformedPoint;
2284 OutputPointType outputPoint;
2287 if ( m_BulkTransform )
2289 transformedPoint = m_BulkTransform->TransformPoint( inputPoint );
2293 transformedPoint = inputPoint;
2296 // Deformable transform
2297 if ( m_PaddedCoefficientImage )
2299 // Check if inside mask
2300 if(m_Mask && !(m_Mask->IsInside(inputPoint) ) )
2302 // Outside: no (deformable) displacement
2303 return transformedPoint;
2306 // Check if inside valid region
2308 ContinuousIndexType index;
2309 this->TransformPointToContinuousIndex( inputPoint, index );
2310 inside = this->InsideValidRegion( index );
2313 // Outside: no (deformable) displacement
2314 DD("outside valid region");
2315 return transformedPoint;
2318 // Call the vector interpolator
2319 itk::Vector<TCoordRep,SpaceDimension> displacement=m_VectorInterpolator->EvaluateAtContinuousIndex(index);
2321 // JV add for the spatial dimensions
2322 outputPoint=transformedPoint;
2323 for (unsigned int i=0; i<NInputDimensions-1; i++)
2324 outputPoint[i] += displacement[i];
2330 itkWarningMacro( << "B-spline coefficients have not been set" );
2331 outputPoint = transformedPoint;
2339 //JV Deformably transform a point
2340 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2341 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2343 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2344 ::DeformablyTransformPoint(const InputPointType &inputPoint) const
2346 OutputPointType outputPoint;
2347 if ( m_PaddedCoefficientImage )
2350 // Check if inside mask
2351 if(m_Mask && !(m_Mask->IsInside(inputPoint) ) )
2353 // Outside: no (deformable) displacement
2359 ContinuousIndexType index;
2360 this->TransformPointToContinuousIndex( inputPoint, index );
2361 inside = this->InsideValidRegion( index );
2365 //outside: no (deformable) displacement
2366 outputPoint = inputPoint;
2370 // Call the vector interpolator
2371 itk::Vector<TCoordRep,SpaceDimension> displacement=m_VectorInterpolator->EvaluateAtContinuousIndex(index);
2373 // JV add for the spatial dimensions
2374 outputPoint=inputPoint;
2375 for (unsigned int i=0; i<NInputDimensions-1; i++)
2376 outputPoint[i] += displacement[i];
2379 // No coefficients available
2382 itkWarningMacro( << "B-spline coefficients have not been set" );
2383 outputPoint = inputPoint;
2390 // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!!
2391 // Compute the Jacobian in one position
2392 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2393 #if ITK_VERSION_MAJOR >= 4
2395 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2396 ::ComputeJacobianWithRespectToParameters( const InputPointType & point, JacobianType & jacobian) const
2399 typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2401 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2402 ::GetJacobian( const InputPointType & point ) const
2406 //========================================================
2407 // Zero all components of jacobian
2408 //========================================================
2409 // JV not thread safe (m_LastJacobianIndex), instantiate N transforms
2410 // NOTE: for efficiency, we only need to zero out the coefficients
2411 // that got fill last time this method was called.
2412 unsigned int j=0,b=0;
2414 //Set the previously-set to zero
2415 for ( j = 0; j < SpaceDimension; j++ )
2417 m_FirstIterator[j].GoToBegin();
2418 while ( !m_FirstIterator[j].IsAtEnd() )
2420 m_FirstIterator[j].Set( m_ZeroVector );
2421 ++(m_FirstIterator[j]);
2425 //Set the previously-set to zero
2426 for ( j = 0; j < SpaceDimension; j++ )
2428 m_SecondIterator[j].GoToBegin();
2429 while ( ! (m_SecondIterator[j]).IsAtEnd() )
2431 m_SecondIterator[j].Set( m_ZeroVector );
2432 ++(m_SecondIterator[j]);
2436 //Set the previously-set to zero
2438 for ( j = 0; j < SpaceDimension; j++ )
2440 m_ThirdIterator[j].GoToBegin();
2441 while ( ! (m_ThirdIterator[j]).IsAtEnd() )
2443 m_ThirdIterator[j].Set( m_ZeroVector );
2444 ++(m_ThirdIterator[j]);
2448 //Set the previously-set to zero
2450 for (b=0; b<m_BCSize;b++)
2451 if ( !( m_FirstRegion.IsInside(m_BCRegions[b]) | m_SecondRegion.IsInside(m_BCRegions[b]) ) )
2452 for ( j = 0; j < SpaceDimension; j++ )
2454 m_BCIterators[j][b].GoToBegin();
2455 while ( ! (m_BCIterators[j][b]).IsAtEnd() )
2457 m_BCIterators[j][b].Set( m_ZeroVector );
2458 ++(m_BCIterators[j][b]);
2462 //Set the previously-set to zero
2464 for (b=0; b<m_BC2Size;b++)
2465 if ( !( m_FirstRegion.IsInside(m_BC2Regions[b]) | m_SecondRegion.IsInside(m_BC2Regions[b]) ) )
2466 for ( j = 0; j < SpaceDimension; j++ )
2468 m_BC2Iterators[j][b].GoToBegin();
2469 while ( ! (m_BC2Iterators[j][b]).IsAtEnd() )
2471 m_BC2Iterators[j][b].Set( m_ZeroVector );
2472 ++(m_BC2Iterators[j][b]);
2476 //Set the previously-set to zero
2478 for (b=0; b<m_BC3Size;b++)
2479 if ( !( m_FirstRegion.IsInside(m_BC3Regions[b]) | m_SecondRegion.IsInside(m_BC3Regions[b]) ) )
2480 for ( j = 0; j < SpaceDimension; j++ )
2482 m_BC3Iterators[j][b].GoToBegin();
2483 while ( ! (m_BC3Iterators[j][b]).IsAtEnd() )
2485 m_BC3Iterators[j][b].Set( m_ZeroVector );
2486 ++(m_BC3Iterators[j][b]);
2491 //========================================================
2492 // For each dimension, copy the weight to the support region
2493 //========================================================
2495 // Check if inside mask
2496 if(m_Mask && !(m_Mask->IsInside(point) ) )
2498 // Outside: no (deformable) displacement
2499 #if ITK_VERSION_MAJOR >= 4
2500 jacobian = m_SharedDataBSplineJacobian;
2503 return this->m_Jacobian;
2508 this->TransformPointToContinuousIndex( point, m_Index );
2510 // NOTE: if the support region does not lie totally within the grid
2511 // we assume zero displacement and return the input point
2512 if ( !this->InsideValidRegion( m_Index ) )
2514 #if ITK_VERSION_MAJOR >= 4
2515 jacobian = m_SharedDataBSplineJacobian;
2518 return this->m_Jacobian;
2522 // Compute interpolation weights
2523 const WeightsDataType *weights=NULL;
2524 m_VectorInterpolator->EvaluateWeightsAtContinuousIndex( m_Index, &weights, m_LastJacobianIndex);
2527 m_SupportRegion.SetIndex( m_LastJacobianIndex );
2528 WrapRegion(m_SupportRegion, m_FirstRegion, m_SecondRegion, m_ThirdRegion, m_BCRegions, m_BCValues, m_BC2Regions, m_BC2Values, m_BC3Regions, m_BC3Values, m_InitialOffset);
2529 m_ThirdSize=m_ThirdRegion.GetSize()[InputDimension-1];
2530 m_BCSize=m_BCRegions.size();
2531 m_BC2Size=m_BC2Regions.size();
2532 m_BC3Size=m_BC3Regions.size();
2534 // Reset the iterators
2535 for ( j = 0; j < SpaceDimension ; j++ )
2537 m_FirstIterator[j] = IteratorType( m_JacobianImage[j], m_FirstRegion);
2538 m_SecondIterator[j] = IteratorType( m_JacobianImage[j], m_SecondRegion);
2539 if(m_ThirdSize) m_ThirdIterator[j] = IteratorType( m_JacobianImage[j], m_ThirdRegion);
2541 m_BCIterators[j].resize(m_BCSize);
2542 for (b=0; b<m_BCSize;b++)
2543 m_BCIterators[j][b]= IteratorType( m_JacobianImage[j], m_BCRegions[b]);
2544 m_BC2Iterators[j].resize(m_BC2Size);
2545 for (b=0; b<m_BC2Size;b++)
2546 m_BC2Iterators[j][b]= IteratorType( m_JacobianImage[j], m_BC2Regions[b]);
2547 m_BC3Iterators[j].resize(m_BC3Size);
2548 for (b=0; b<m_BC3Size;b++)
2549 m_BC3Iterators[j][b]= IteratorType( m_JacobianImage[j], m_BC3Regions[b]);
2552 // Skip if on a fixed condition
2555 if (m_BCSize) weights+=m_InitialOffset*m_BCRegions[0].GetNumberOfPixels();
2556 else std::cerr<<"InitialOffset without BCSize: Error!!!!!!!"<<std::endl;
2559 //copy weight to jacobian image
2560 for ( j = 0; j < SpaceDimension; j++ )
2562 // For each dimension, copy the weight to the support region
2563 while ( ! (m_FirstIterator[j]).IsAtEnd() )
2565 m_ZeroVector[j]=*weights;
2566 (m_FirstIterator[j]).Set( m_ZeroVector);
2567 ++(m_FirstIterator[j]);
2571 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2572 if (j != SpaceDimension-1) weights-=m_FirstRegion.GetNumberOfPixels();
2575 // Skip BC1 and go to the second region
2576 if (m_BCSize) weights+=m_BCRegions[0].GetNumberOfPixels();
2578 // For each dimension, copy the weight to the support region
2579 //copy weight to jacobian image
2580 for ( j = 0; j < SpaceDimension; j++ )
2582 while ( ! (m_SecondIterator[j]).IsAtEnd() )
2584 m_ZeroVector[j]=*weights;
2585 (m_SecondIterator[j]).Set( m_ZeroVector);
2586 ++(m_SecondIterator[j]);
2589 weights-=m_SecondRegion.GetNumberOfPixels();
2590 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2596 // Put pointer in correct position
2597 weights-=m_BCRegions[0].GetNumberOfPixels();
2599 for ( j = 0; j < SpaceDimension; j++ )
2601 for ( b=0; b < m_BCSize; b++ )
2603 while ( ! (m_BCIterators[j][b]).IsAtEnd() )
2605 //copy weight to jacobian image
2606 m_ZeroVector[j]=(*weights) * m_BCValues[b];
2607 (m_BCIterators[j][b]).Value()+= m_ZeroVector;
2608 ++(m_BCIterators[j][b]);
2611 weights-=m_BCRegions[b].GetNumberOfPixels();
2613 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2615 weights+=m_BCRegions[m_BCSize-1].GetNumberOfPixels();
2618 // Add the BC2 to the weights
2621 // Move further in the weights pointer
2622 weights+=m_SecondRegion.GetNumberOfPixels();
2624 for ( j = 0; j < SpaceDimension; j++ )
2626 for ( b=0; b < m_BC2Size; b++ )
2628 while ( ! (m_BC2Iterators[j][b]).IsAtEnd() )
2630 //copy weight to jacobian image
2631 m_ZeroVector[j]=(*weights) * m_BC2Values[b];
2632 (m_BC2Iterators[j][b]).Value()+= m_ZeroVector;
2633 ++(m_BC2Iterators[j][b]);
2636 weights-=m_BC2Regions[b].GetNumberOfPixels();
2638 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2640 // Move further in the weights pointer
2641 weights+=m_BC2Regions[m_BC2Size-1].GetNumberOfPixels();
2647 // For each dimension, copy the weight to the support region
2648 //copy weight to jacobian image
2649 for ( j = 0; j < SpaceDimension; j++ )
2651 while ( ! (m_ThirdIterator[j]).IsAtEnd() )
2653 m_ZeroVector[j]=*weights;
2654 (m_ThirdIterator[j]).Value()+= m_ZeroVector;
2655 ++(m_ThirdIterator[j]);
2659 // Move further in the weights pointer?
2660 if (j != SpaceDimension-1) weights-=m_ThirdRegion.GetNumberOfPixels();
2661 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2665 // Add the BC3 to the weights
2668 for ( j = 0; j < SpaceDimension; j++ )
2670 for ( b=0; b < m_BC3Size; b++ )
2672 while ( ! (m_BC3Iterators[j][b]).IsAtEnd() )
2674 //copy weight to jacobian image
2675 m_ZeroVector[j]=(*weights) * m_BC3Values[b];
2676 (m_BC3Iterators[j][b]).Value()+= m_ZeroVector;
2677 ++(m_BC3Iterators[j][b]);
2680 weights-=m_BC3Regions[b].GetNumberOfPixels();
2682 m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
2686 // Return the result
2687 #if ITK_VERSION_MAJOR >= 4
2688 jacobian = m_SharedDataBSplineJacobian;
2690 return this->m_Jacobian;
2695 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
2697 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
2698 ::WrapRegion( const RegionType & m_SupportRegion,
2699 RegionType & m_FirstRegion,
2700 RegionType & m_SecondRegion,
2701 RegionType & m_ThirdRegion,
2702 std::vector<RegionType>& m_BCRegions,std::vector<double>& m_BCValues,
2703 std::vector<RegionType>& m_BC2Regions,std::vector<double>& m_BC2Values,
2704 std::vector<RegionType>& m_BC3Regions,std::vector<double>& m_BC3Values,
2705 unsigned int& m_InitialOffset ) const
2708 // Synchronize regions
2710 m_FirstRegion=m_SupportRegion;
2711 m_BCRegion=m_SupportRegion;
2712 m_BCRegion.SetSize(InputDimension-1,1);
2713 m_SecondRegion=m_SupportRegion;
2714 m_ThirdRegion=m_SupportRegion;
2715 m_ThirdRegion.SetSize(InputDimension-1,0);
2716 m_BC3Regions.resize(0);
2719 // BC depends on shape
2720 switch(m_TransformShape)
2725 2: rabbit 4 CP 3 DOF
2726 3: rabbit 5 CP 4 DOF
2727 4: sputnik 4 CP 4 DOF
2728 5: sputnik 5 CP 5 DOF
2729 6: diamond 6 CP 5 DOF
2730 7: diamond 7 CP 6 DOF
2735 // ----------------------------------------------------------------------
2736 // The egg with 4 internal CP (starting from inhale)
2737 // Periodic, constrained to zero at the reference
2738 // at position 3 and
2739 // Coeff row BC1 BC2 0 BC3 1 2 BC4
2740 // PaddedCoeff R: 0 1 2 3 4 5 6
2743 // BC3= -weights[2]/weights[0] ( R2+R4 )
2745 // ---------------------------------------------------------------------
2746 switch(m_SupportRegion.GetIndex(InputDimension-1))
2751 m_FirstRegion.SetSize(InputDimension-1,2);
2752 m_FirstRegion.SetIndex(InputDimension-1,1);
2755 m_BCRegions.resize(0);
2758 m_SecondRegion.SetSize(InputDimension-1,1);
2759 m_SecondRegion.SetIndex(InputDimension-1,0);
2762 m_BC2Regions.resize(2);
2763 m_BC2Values.resize(2);
2764 m_BCRegion.SetIndex(InputDimension-1,0);
2765 m_BC2Regions[0]=m_BCRegion;
2766 m_BC2Values[0]=-m_WeightRatio[2][0];
2767 m_BCRegion.SetIndex(InputDimension-1,1);
2768 m_BC2Regions[1]=m_BCRegion;
2769 m_BC2Values[1]= -m_WeightRatio[2][0];
2776 m_FirstRegion.SetSize(InputDimension-1,1);
2777 m_FirstRegion.SetIndex(InputDimension-1,2);
2780 m_BCRegions.resize(0);
2783 m_SecondRegion.SetSize(InputDimension-1,1);
2784 m_SecondRegion.SetIndex(InputDimension-1,0);
2787 m_BC2Regions.resize(2);
2788 m_BC2Values.resize(2);
2789 m_BCRegion.SetIndex(InputDimension-1,0);
2790 m_BC2Regions[0]=m_BCRegion;
2791 m_BC2Values[0]=-m_WeightRatio[2][0];
2792 m_BCRegion.SetIndex(InputDimension-1,1);
2793 m_BC2Regions[1]=m_BCRegion;
2794 m_BC2Values[1]= -m_WeightRatio[2][0];
2797 m_FirstRegion.SetSize(InputDimension-1,1);
2798 m_FirstRegion.SetIndex(InputDimension-1,1);
2805 m_FirstRegion.SetSize(InputDimension-1,1);
2806 m_FirstRegion.SetIndex(InputDimension-1,0);
2809 m_BCRegions.resize(2);
2810 m_BCValues.resize(2);
2811 m_BCRegion.SetIndex(InputDimension-1,0);
2812 m_BCRegions[0]=m_BCRegion;
2813 m_BCValues[0]=-m_WeightRatio[2][0];
2814 m_BCRegion.SetIndex(InputDimension-1,1);
2815 m_BCRegions[1]=m_BCRegion;
2816 m_BCValues[1]= -m_WeightRatio[2][0];
2819 m_SecondRegion.SetSize(InputDimension-1,2);
2820 m_SecondRegion.SetIndex(InputDimension-1,1);
2823 m_BC2Regions.resize(0);
2830 m_FirstRegion.SetSize(InputDimension-1,0);
2833 m_BCRegions.resize(2);
2834 m_BCValues.resize(2);
2835 m_BCRegion.SetIndex(InputDimension-1,0);
2836 m_BCRegions[0]=m_BCRegion;
2837 m_BCValues[0]=-m_WeightRatio[2][0];
2838 m_BCRegion.SetIndex(InputDimension-1,1);
2839 m_BCRegions[1]=m_BCRegion;
2840 m_BCValues[1]= -m_WeightRatio[2][0];
2843 m_SecondRegion.SetSize(InputDimension-1,2);
2844 m_SecondRegion.SetIndex(InputDimension-1,1);
2847 m_BC2Regions.resize(1);
2848 m_BC2Values.resize(1);
2849 m_BCRegion.SetIndex(InputDimension-1,0);
2850 m_BC2Regions[0]=m_BCRegion;
2858 DD("supportindex > 3 ???");
2859 DD(m_SupportRegion.GetIndex(InputDimension-1));
2861 } // end switch index
2868 // ----------------------------------------------------------------------
2869 // The egg with 5 internal CP (starting from inhale)
2870 // Periodic, constrained to zero at the reference
2871 // at position 3 and
2872 // Coeff row BC1 BC2 0 BC3 1 2 3 BC4
2873 // PaddedCoeff R: 0 1 2 3 4 5 6 7
2876 // BC3= -weights[3]/weights[1] ( R2+R5 ) - R4
2878 // ---------------------------------------------------------------------
2879 switch(m_SupportRegion.GetIndex(InputDimension-1))
2884 m_FirstRegion.SetSize(InputDimension-1,2);
2885 m_FirstRegion.SetIndex(InputDimension-1,2);
2888 m_BCRegions.resize(0);
2891 m_SecondRegion.SetSize(InputDimension-1,1);
2892 m_SecondRegion.SetIndex(InputDimension-1,0);
2895 m_BC2Regions.resize(3);
2896 m_BC2Values.resize(3);
2897 m_BCRegion.SetIndex(InputDimension-1,0);
2898 m_BC2Regions[0]=m_BCRegion;
2899 m_BC2Values[0]=-m_WeightRatio[3][1];
2900 m_BCRegion.SetIndex(InputDimension-1,1);
2901 m_BC2Regions[1]=m_BCRegion;
2903 m_BCRegion.SetIndex(InputDimension-1,2);
2904 m_BC2Regions[2]=m_BCRegion;
2905 m_BC2Values[2]=-m_WeightRatio[3][1];
2912 m_FirstRegion.SetSize(InputDimension-1,1);
2913 m_FirstRegion.SetIndex(InputDimension-1,3);
2916 m_BCRegions.resize(0);
2919 m_SecondRegion.SetSize(InputDimension-1,1);
2920 m_SecondRegion.SetIndex(InputDimension-1,0);
2923 m_BC2Regions.resize(3);
2924 m_BC2Values.resize(3);
2925 m_BCRegion.SetIndex(InputDimension-1,0);
2926 m_BC2Regions[0]=m_BCRegion;
2927 m_BC2Values[0]=-m_WeightRatio[3][1];
2928 m_BCRegion.SetIndex(InputDimension-1,1);
2929 m_BC2Regions[1]=m_BCRegion;
2931 m_BCRegion.SetIndex(InputDimension-1,2);
2932 m_BC2Regions[2]=m_BCRegion;
2933 m_BC2Values[2]=-m_WeightRatio[3][1];
2936 m_FirstRegion.SetSize(InputDimension-1,1);
2937 m_FirstRegion.SetIndex(InputDimension-1,1);
2944 m_FirstRegion.SetSize(InputDimension-1,1);
2945 m_FirstRegion.SetIndex(InputDimension-1,0);
2948 m_BCRegions.resize(3);
2949 m_BCValues.resize(3);
2950 m_BCRegion.SetIndex(InputDimension-1,0);
2951 m_BCRegions[0]=m_BCRegion;
2952 m_BCValues[0]=-m_WeightRatio[3][1];
2953 m_BCRegion.SetIndex(InputDimension-1,1);
2954 m_BCRegions[1]=m_BCRegion;
2956 m_BCRegion.SetIndex(InputDimension-1,2);
2957 m_BCRegions[2]=m_BCRegion;
2958 m_BCValues[2]=-m_WeightRatio[3][1];
2961 m_SecondRegion.SetSize(InputDimension-1,2);
2962 m_SecondRegion.SetIndex(InputDimension-1,1);
2965 m_BC2Regions.resize(0);
2972 m_FirstRegion.SetSize(InputDimension-1,0);
2975 m_BCRegions.resize(3);
2976 m_BCValues.resize(3);
2977 m_BCRegion.SetIndex(InputDimension-1,0);
2978 m_BCRegions[0]=m_BCRegion;
2979 m_BCValues[0]=-m_WeightRatio[3][1];
2980 m_BCRegion.SetIndex(InputDimension-1,1);
2981 m_BCRegions[1]=m_BCRegion;
2983 m_BCRegion.SetIndex(InputDimension-1,2);
2984 m_BCRegions[2]=m_BCRegion;
2985 m_BCValues[2]=-m_WeightRatio[3][1];
2988 m_SecondRegion.SetSize(InputDimension-1,3);
2989 m_SecondRegion.SetIndex(InputDimension-1,1);
2992 m_BC2Regions.resize(0);
2999 m_FirstRegion.SetSize(InputDimension-1,3);
3000 m_FirstRegion.SetIndex(InputDimension-1,1);
3003 m_BCRegions.resize(0);
3006 m_SecondRegion.SetSize(InputDimension-1,1);
3007 m_SecondRegion.SetIndex(InputDimension-1,0);
3010 m_BC2Regions.resize(0);
3017 DD("supportindex > 3 ???");
3018 DD(m_SupportRegion.GetIndex(InputDimension-1));
3020 } // end switch index
3024 // // ----------------------------------------------------------------------
3025 // // The egg with 5 internal CP:
3026 // // Periodic, C2 smooth everywhere and constrained to zero at the reference
3027 // // Coeff row R5 BC1 0 1 2 3 BC2 R2
3028 // // PaddedCoeff R: 0 1 2 3 4 5 6 7
3029 // // BC1= -weights[2]/weights[0] ( R2+R5)
3031 // // ---------------------------------------------------------------------
3032 // switch(m_SupportRegion.GetIndex(InputDimension-1))
3037 // m_FirstRegion.SetSize(InputDimension-1,1);
3038 // m_FirstRegion.SetIndex(InputDimension-1,3);
3041 // m_BCRegions.resize(2);
3042 // m_BCValues.resize(2);
3043 // m_BCRegion.SetIndex(InputDimension-1,0);
3044 // m_BCRegions[0]=m_BCRegion;
3045 // m_BCValues[0]=-m_WeightRatio[2][0];
3046 // m_BCRegion.SetIndex(InputDimension-1,3);
3047 // m_BCRegions[1]=m_BCRegion;
3048 // m_BCValues[1]=-m_WeightRatio[2][0];
3051 // m_SecondRegion.SetSize(InputDimension-1,2);
3052 // m_SecondRegion.SetIndex(InputDimension-1,0);
3055 // m_BC2Regions.resize(0);
3062 // m_FirstRegion.SetSize(InputDimension-1,0);
3065 // m_BCRegions.resize(2);
3066 // m_BCValues.resize(2);
3067 // m_BCRegion.SetIndex(InputDimension-1,0);
3068 // m_BCRegions[0]=m_BCRegion;
3069 // m_BCValues[0]=-m_WeightRatio[2][0];
3070 // m_BCRegion.SetIndex(InputDimension-1,3);
3071 // m_BCRegions[1]=m_BCRegion;
3072 // m_BCValues[1]=-m_WeightRatio[2][0];
3075 // m_SecondRegion.SetSize(InputDimension-1,3);
3076 // m_SecondRegion.SetIndex(InputDimension-1,0);
3079 // m_BC2Regions.resize(0);
3086 // m_FirstRegion.SetSize(InputDimension-1,4);
3087 // m_FirstRegion.SetIndex(InputDimension-1,0);
3090 // m_BCRegions.resize(0);
3093 // m_SecondRegion.SetSize(InputDimension-1,0);
3096 // m_BC2Regions.resize(0);
3103 // m_FirstRegion.SetSize(InputDimension-1,3);
3104 // m_FirstRegion.SetIndex(InputDimension-1,1);
3107 // m_BCRegions.resize(2);
3108 // m_BCValues.resize(2);
3109 // m_BCRegion.SetIndex(InputDimension-1,0);
3110 // m_BCRegions[0]=m_BCRegion;
3111 // m_BCValues[0]=-m_WeightRatio[2][0];
3112 // m_BCRegion.SetIndex(InputDimension-1,3);
3113 // m_BCRegions[1]=m_BCRegion;
3114 // m_BCValues[1]=-m_WeightRatio[2][0];
3117 // m_SecondRegion.SetSize(InputDimension-1,0);
3120 // m_BC2Regions.resize(0);
3128 // m_FirstRegion.SetSize(InputDimension-1,2);
3129 // m_FirstRegion.SetIndex(InputDimension-1,2);
3132 // m_BCRegions.resize(2);
3133 // m_BCValues.resize(2);
3134 // m_BCRegion.SetIndex(InputDimension-1,0);
3135 // m_BCRegions[0]=m_BCRegion;
3136 // m_BCValues[0]=-m_WeightRatio[2][0];
3137 // m_BCRegion.SetIndex(InputDimension-1,3);
3138 // m_BCRegions[1]=m_BCRegion;
3139 // m_BCValues[1]=-m_WeightRatio[2][0];
3142 // m_SecondRegion.SetSize(InputDimension-1,1);
3143 // m_SecondRegion.SetIndex(InputDimension-1,0);
3146 // m_BC2Regions.resize(0);
3153 // DD("supportindex > 4 ???");
3154 // DD(m_SupportRegion.GetIndex(InputDimension-1));
3155 // DD(m_TransformShape);
3157 // }// end swith index
3160 // } // end case 1 shape
3164 // ----------------------------------------------------------------------
3165 // The rabbit with 4 internal CP
3166 // Periodic, constrained to zero at the reference
3167 // at position 3 and the extremes fixed with anit-symm bc
3168 // Coeff row BC1 0 1 BC2 2 BC3 BC4
3169 // PaddedCoeff R: 0 1 2 3 4 5 6
3171 // BC2= -weights[2]/weights[0] ( R2+R4 )
3174 // ---------------------------------------------------------------------
3175 switch(m_SupportRegion.GetIndex(InputDimension-1))
3180 m_FirstRegion.SetSize(InputDimension-1,0);
3183 m_BCRegions.resize(2);
3184 m_BCValues.resize(2);
3185 m_BCRegion.SetIndex(InputDimension-1,0);
3186 m_BCRegions[0]=m_BCRegion;
3188 m_BCRegion.SetIndex(InputDimension-1,1);
3189 m_BCRegions[1]=m_BCRegion;
3193 m_SecondRegion.SetSize(InputDimension-1,2);
3194 m_SecondRegion.SetIndex(InputDimension-1,0);
3197 m_BC2Regions.resize(2);
3198 m_BC2Values.resize(2);
3199 m_BCRegion.SetIndex(InputDimension-1,1);
3200 m_BC2Regions[0]=m_BCRegion;
3201 m_BC2Values[0]=-m_WeightRatio[2][0];
3202 m_BCRegion.SetIndex(InputDimension-1,2);
3203 m_BC2Regions[1]=m_BCRegion;
3204 m_BC2Values[1]= -m_WeightRatio[2][0];
3211 m_FirstRegion.SetSize(InputDimension-1,2);
3212 m_FirstRegion.SetIndex(InputDimension-1,0);
3215 m_BCRegions.resize(2);
3216 m_BCValues.resize(2);
3217 m_BCRegion.SetIndex(InputDimension-1,1);
3218 m_BCRegions[0]=m_BCRegion;
3219 m_BCValues[0]=-m_WeightRatio[2][0];
3220 m_BCRegion.SetIndex(InputDimension-1,2);
3221 m_BCRegions[1]=m_BCRegion;
3222 m_BCValues[1]= -m_WeightRatio[2][0];
3225 m_SecondRegion.SetSize(InputDimension-1,1);
3226 m_SecondRegion.SetIndex(InputDimension-1,2);
3229 m_BC2Regions.resize(0);
3236 m_FirstRegion.SetSize(InputDimension-1,1);
3237 m_FirstRegion.SetIndex(InputDimension-1,1);
3240 m_BCRegions.resize(2);
3241 m_BCValues.resize(2);
3242 m_BCRegion.SetIndex(InputDimension-1,1);
3243 m_BCRegions[0]=m_BCRegion;
3244 m_BCValues[0]=-m_WeightRatio[2][0];
3245 m_BCRegion.SetIndex(InputDimension-1,2);
3246 m_BCRegions[1]=m_BCRegion;
3247 m_BCValues[1]= -m_WeightRatio[2][0];
3250 m_SecondRegion.SetSize(InputDimension-1,1);
3251 m_SecondRegion.SetIndex(InputDimension-1,2);
3254 m_BC2Regions.resize(1);
3255 m_BC2Values.resize(1);
3256 m_BCRegion.SetIndex(InputDimension-1,0);
3257 m_BC2Regions[0]=m_BCRegion;
3265 m_FirstRegion.SetSize(InputDimension-1,0);
3268 m_BCRegions.resize(2);
3269 m_BCValues.resize(2);
3270 m_BCRegion.SetIndex(InputDimension-1,1);
3271 m_BCRegions[0]=m_BCRegion;
3272 m_BCValues[0]=-m_WeightRatio[2][0];
3273 m_BCRegion.SetIndex(InputDimension-1,2);
3274 m_BCRegions[1]=m_BCRegion;
3275 m_BCValues[1]= -m_WeightRatio[2][0];
3278 m_SecondRegion.SetSize(InputDimension-1,1);
3279 m_SecondRegion.SetIndex(InputDimension-1,2);
3282 m_BC2Regions.resize(1);
3283 m_BC2Values.resize(1);
3284 m_BCRegion.SetIndex(InputDimension-1,0);
3285 m_BC2Regions[0]=m_BCRegion;
3289 m_BC3Regions.resize(2);
3290 m_BC3Values.resize(2);
3291 m_BCRegion.SetIndex(InputDimension-1,0);
3292 m_BC3Regions[0]=m_BCRegion;
3294 m_BCRegion.SetIndex(InputDimension-1,2);
3295 m_BC3Regions[1]=m_BCRegion;
3303 DD("supportindex > 3 ???");
3304 DD(m_SupportRegion.GetIndex(InputDimension-1));
3306 } // end switch index
3309 } // end case 2 shape
3312 // ----------------------------------------------------------------------
3313 // The rabbit with 5 internal CP
3314 // Periodic, constrained to zero at the reference at position 3.5
3315 // and the extremes fixed with anti-symmetrical BC
3316 // Coeff row BC1 0 1 BC2 2 3 BC3 BC4
3317 // PaddedCoeff R: 0 1 2 3 4 5 6 7
3319 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
3322 // ---------------------------------------------------------------------
3323 switch(m_SupportRegion.GetIndex(InputDimension-1))
3328 m_FirstRegion.SetSize(InputDimension-1,0);
3331 m_BCRegions.resize(2);
3332 m_BCValues.resize(2);
3333 m_BCRegion.SetIndex(InputDimension-1,0);
3334 m_BCRegions[0]=m_BCRegion;
3336 m_BCRegion.SetIndex(InputDimension-1,1);
3337 m_BCRegions[1]=m_BCRegion;
3341 m_SecondRegion.SetSize(InputDimension-1,2);
3342 m_SecondRegion.SetIndex(InputDimension-1,0);
3345 m_BC2Regions.resize(3);
3346 m_BC2Values.resize(3);
3347 m_BCRegion.SetIndex(InputDimension-1,1);
3348 m_BC2Regions[0]=m_BCRegion;
3349 m_BC2Values[0]=-m_WeightRatio[3][1];
3350 m_BCRegion.SetIndex(InputDimension-1,2);
3351 m_BC2Regions[1]=m_BCRegion;
3353 m_BCRegion.SetIndex(InputDimension-1,3);
3354 m_BC2Regions[2]=m_BCRegion;
3355 m_BC2Values[2]=-m_WeightRatio[3][1];
3362 m_FirstRegion.SetSize(InputDimension-1,2);
3363 m_FirstRegion.SetIndex(InputDimension-1,0);
3366 m_BCRegions.resize(3);
3367 m_BCValues.resize(3);
3368 m_BCRegion.SetIndex(InputDimension-1,1);
3369 m_BCRegions[0]=m_BCRegion;
3370 m_BCValues[0]=-m_WeightRatio[3][1];
3371 m_BCRegion.SetIndex(InputDimension-1,2);
3372 m_BCRegions[1]=m_BCRegion;
3374 m_BCRegion.SetIndex(InputDimension-1,3);
3375 m_BCRegions[2]=m_BCRegion;
3376 m_BCValues[2]=-m_WeightRatio[3][1];
3379 m_SecondRegion.SetSize(InputDimension-1,1);
3380 m_SecondRegion.SetIndex(InputDimension-1,2);
3383 m_BC2Regions.resize(0);
3390 m_FirstRegion.SetSize(InputDimension-1,1);
3391 m_FirstRegion.SetIndex(InputDimension-1,1);
3394 m_BCRegions.resize(3);
3395 m_BCValues.resize(3);
3396 m_BCRegion.SetIndex(InputDimension-1,1);
3397 m_BCRegions[0]=m_BCRegion;
3398 m_BCValues[0]=-m_WeightRatio[3][1];
3399 m_BCRegion.SetIndex(InputDimension-1,2);
3400 m_BCRegions[1]=m_BCRegion;
3402 m_BCRegion.SetIndex(InputDimension-1,3);
3403 m_BCRegions[2]=m_BCRegion;
3404 m_BCValues[2]=-m_WeightRatio[3][1];
3407 m_SecondRegion.SetSize(InputDimension-1,2);
3408 m_SecondRegion.SetIndex(InputDimension-1,2);
3411 m_BC2Regions.resize(0);
3418 m_FirstRegion.SetSize(InputDimension-1,0);
3421 m_BCRegions.resize(3);
3422 m_BCValues.resize(3);
3423 m_BCRegion.SetIndex(InputDimension-1,1);
3424 m_BCRegions[0]=m_BCRegion;
3425 m_BCValues[0]=-m_WeightRatio[3][1];
3426 m_BCRegion.SetIndex(InputDimension-1,2);
3427 m_BCRegions[1]=m_BCRegion;
3429 m_BCRegion.SetIndex(InputDimension-1,3);
3430 m_BCRegions[2]=m_BCRegion;
3431 m_BCValues[2]=-m_WeightRatio[3][1];
3434 m_SecondRegion.SetSize(InputDimension-1,2);
3435 m_SecondRegion.SetIndex(InputDimension-1,2);
3438 m_BC2Regions.resize(1);
3439 m_BC2Values.resize(1);
3440 m_BCRegion.SetIndex(InputDimension-1,0);
3441 m_BC2Regions[0]=m_BCRegion;
3450 m_FirstRegion.SetSize(InputDimension-1,2);
3451 m_FirstRegion.SetIndex(InputDimension-1,2);
3454 m_BCRegions.resize(1);
3455 m_BCValues.resize(1);
3456 m_BCRegion.SetIndex(InputDimension-1,0);
3457 m_BCRegions[0]=m_BCRegion;
3461 m_SecondRegion.SetSize(InputDimension-1,0);
3464 m_BC2Regions.resize(2);
3465 m_BC2Values.resize(2);
3466 m_BCRegion.SetIndex(InputDimension-1,0);
3467 m_BC2Regions[0]=m_BCRegion;
3469 m_BCRegion.SetIndex(InputDimension-1,3);
3470 m_BC2Regions[1]=m_BCRegion;
3478 DD("supportindex > 4 ???");
3479 DD(m_SupportRegion.GetIndex(InputDimension-1));
3481 } // end switch index
3484 } // end case 3 shape
3488 // ----------------------------------------------------------------------
3489 // The sputnik with 4 internal CP
3490 // Periodic, constrained to zero at the reference
3491 // at position 3 and one indepent extremes copied
3492 // Coeff row BC1 0 1 BC2 2 BC2 3
3493 // PaddedCoeff R: 0 1 2 3 4 5 6
3495 // BC2= -weights[2]/weights[0] ( R2+R4 )
3496 // BC3= weights[2]/weights[0] ( R2-R4) + R1
3497 // ---------------------------------------------------------------------
3498 switch(m_SupportRegion.GetIndex(InputDimension-1))
3503 m_FirstRegion.SetSize(InputDimension-1,0);
3506 m_BCRegions.resize(1);
3507 m_BCValues.resize(1);
3508 m_BCRegion.SetIndex(InputDimension-1,3);
3509 m_BCRegions[0]=m_BCRegion;
3513 m_SecondRegion.SetSize(InputDimension-1,2);
3514 m_SecondRegion.SetIndex(InputDimension-1,0);
3517 m_BC2Regions.resize(2);
3518 m_BC2Values.resize(2);
3519 m_BCRegion.SetIndex(InputDimension-1,1);
3520 m_BC2Regions[0]=m_BCRegion;
3521 m_BC2Values[0]=-m_WeightRatio[2][0];
3522 m_BCRegion.SetIndex(InputDimension-1,2);
3523 m_BC2Regions[1]=m_BCRegion;
3524 m_BC2Values[1]= -m_WeightRatio[2][0];
3531 m_FirstRegion.SetSize(InputDimension-1,2);
3532 m_FirstRegion.SetIndex(InputDimension-1,0);
3535 m_BCRegions.resize(2);
3536 m_BCValues.resize(2);
3537 m_BCRegion.SetIndex(InputDimension-1,1);
3538 m_BCRegions[0]=m_BCRegion;
3539 m_BCValues[0]=-m_WeightRatio[2][0];
3540 m_BCRegion.SetIndex(InputDimension-1,2);
3541 m_BCRegions[1]=m_BCRegion;
3542 m_BCValues[1]= -m_WeightRatio[2][0];
3545 m_SecondRegion.SetSize(InputDimension-1,1);
3546 m_SecondRegion.SetIndex(InputDimension-1,2);
3549 m_BC2Regions.resize(0);
3556 m_FirstRegion.SetSize(InputDimension-1,1);
3557 m_FirstRegion.SetIndex(InputDimension-1,1);
3560 m_BCRegions.resize(2);
3561 m_BCValues.resize(2);
3562 m_BCRegion.SetIndex(InputDimension-1,1);
3563 m_BCRegions[0]=m_BCRegion;
3564 m_BCValues[0]=-m_WeightRatio[2][0];
3565 m_BCRegion.SetIndex(InputDimension-1,2);
3566 m_BCRegions[1]=m_BCRegion;
3567 m_BCValues[1]= -m_WeightRatio[2][0];
3570 m_SecondRegion.SetSize(InputDimension-1,1);
3571 m_SecondRegion.SetIndex(InputDimension-1,2);
3574 m_BC2Regions.resize(3);
3575 m_BC2Values.resize(3);
3576 m_BCRegion.SetIndex(InputDimension-1,0);
3577 m_BC2Regions[0]=m_BCRegion;
3579 m_BCRegion.SetIndex(InputDimension-1,1);
3580 m_BC2Regions[1]=m_BCRegion;
3581 m_BC2Values[1]=m_WeightRatio[2][0];
3582 m_BCRegion.SetIndex(InputDimension-1,2);
3583 m_BC2Regions[2]=m_BCRegion;
3584 m_BC2Values[2]=-m_WeightRatio[2][0];
3591 m_FirstRegion.SetSize(InputDimension-1,0);
3594 m_BCRegions.resize(2);
3595 m_BCValues.resize(2);
3596 m_BCRegion.SetIndex(InputDimension-1,1);
3597 m_BCRegions[0]=m_BCRegion;
3598 m_BCValues[0]=-m_WeightRatio[2][0];
3599 m_BCRegion.SetIndex(InputDimension-1,2);
3600 m_BCRegions[1]=m_BCRegion;
3601 m_BCValues[1]= -m_WeightRatio[2][0];
3604 m_SecondRegion.SetSize(InputDimension-1,1);
3605 m_SecondRegion.SetIndex(InputDimension-1,2);
3608 m_BC2Regions.resize(3);
3609 m_BC2Values.resize(3);
3610 m_BCRegion.SetIndex(InputDimension-1,0);
3611 m_BC2Regions[0]=m_BCRegion;
3613 m_BCRegion.SetIndex(InputDimension-1,1);
3614 m_BC2Regions[1]=m_BCRegion;
3615 m_BC2Values[1]=m_WeightRatio[2][0];
3616 m_BCRegion.SetIndex(InputDimension-1,2);
3617 m_BC2Regions[2]=m_BCRegion;
3618 m_BC2Values[2]=-m_WeightRatio[2][0];
3621 m_ThirdRegion.SetSize(InputDimension-1,1);
3622 m_ThirdRegion.SetIndex(InputDimension-1,3);
3629 DD("supportindex > 3 ???");
3630 DD(m_SupportRegion.GetIndex(InputDimension-1));
3632 } // end switch index
3635 } // end case 4 shape
3639 // ----------------------------------------------------------------------
3640 // The sputnik with 5 internal CP
3641 // Periodic, constrained to zero at the reference
3642 // at position 3 and one indepent extreme
3643 // Coeff row BC1 0 1 BC2 2 3 BC3 4
3644 // PaddedCoeff R: 0 1 2 3 4 5 6 7
3645 // BC1= R2 + R5 - R7
3646 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
3647 // BC3= R1 + 0.5 R2 - 0.5 R7
3648 // ----------------------------------------------------------------------
3649 switch(m_SupportRegion.GetIndex(InputDimension-1))
3654 m_FirstRegion.SetSize(InputDimension-1,0);
3657 m_BCRegions.resize(3);
3658 m_BCValues.resize(3);
3659 m_BCRegion.SetIndex(InputDimension-1,1);
3660 m_BCRegions[0]=m_BCRegion;
3662 m_BCRegion.SetIndex(InputDimension-1,3);
3663 m_BCRegions[1]=m_BCRegion;
3665 m_BCRegion.SetIndex(InputDimension-1,4);
3666 m_BCRegions[2]=m_BCRegion;
3670 m_SecondRegion.SetSize(InputDimension-1,2);
3671 m_SecondRegion.SetIndex(InputDimension-1,0);
3674 m_BC2Regions.resize(3);
3675 m_BC2Values.resize(3);
3676 m_BCRegion.SetIndex(InputDimension-1,1);
3677 m_BC2Regions[0]=m_BCRegion;
3678 m_BC2Values[0]=-m_WeightRatio[3][1];
3679 m_BCRegion.SetIndex(InputDimension-1,2);
3680 m_BC2Regions[1]=m_BCRegion;
3682 m_BCRegion.SetIndex(InputDimension-1,3);
3683 m_BC2Regions[2]=m_BCRegion;
3684 m_BC2Values[2]=-m_WeightRatio[3][1];
3691 m_FirstRegion.SetSize(InputDimension-1,2);
3692 m_FirstRegion.SetIndex(InputDimension-1,0);
3695 m_BCRegions.resize(3);
3696 m_BCValues.resize(3);
3697 m_BCRegion.SetIndex(InputDimension-1,1);
3698 m_BCRegions[0]=m_BCRegion;
3699 m_BCValues[0]=-m_WeightRatio[3][1];
3700 m_BCRegion.SetIndex(InputDimension-1,2);
3701 m_BCRegions[1]=m_BCRegion;
3703 m_BCRegion.SetIndex(InputDimension-1,3);
3704 m_BCRegions[2]=m_BCRegion;
3705 m_BCValues[2]=-m_WeightRatio[3][1];
3708 m_SecondRegion.SetSize(InputDimension-1,1);
3709 m_SecondRegion.SetIndex(InputDimension-1,2);
3712 m_BC2Regions.resize(0);
3719 m_FirstRegion.SetSize(InputDimension-1,1);
3720 m_FirstRegion.SetIndex(InputDimension-1,1);
3723 m_BCRegions.resize(3);
3724 m_BCValues.resize(3);
3725 m_BCRegion.SetIndex(InputDimension-1,1);
3726 m_BCRegions[0]=m_BCRegion;
3727 m_BCValues[0]=-m_WeightRatio[3][1];
3728 m_BCRegion.SetIndex(InputDimension-1,2);
3729 m_BCRegions[1]=m_BCRegion;
3731 m_BCRegion.SetIndex(InputDimension-1,3);
3732 m_BCRegions[2]=m_BCRegion;
3733 m_BCValues[2]=-m_WeightRatio[3][1];
3736 m_SecondRegion.SetSize(InputDimension-1,2);
3737 m_SecondRegion.SetIndex(InputDimension-1,2);
3740 m_BC2Regions.resize(0);
3747 m_FirstRegion.SetSize(InputDimension-1,0);
3750 m_BCRegions.resize(3);
3751 m_BCValues.resize(3);
3752 m_BCRegion.SetIndex(InputDimension-1,1);
3753 m_BCRegions[0]=m_BCRegion;
3754 m_BCValues[0]=-m_WeightRatio[3][1];
3755 m_BCRegion.SetIndex(InputDimension-1,2);
3756 m_BCRegions[1]=m_BCRegion;
3758 m_BCRegion.SetIndex(InputDimension-1,3);
3759 m_BCRegions[2]=m_BCRegion;
3760 m_BCValues[2]=-m_WeightRatio[3][1];
3763 m_SecondRegion.SetSize(InputDimension-1,2);
3764 m_SecondRegion.SetIndex(InputDimension-1,2);
3767 m_BC2Regions.resize(3);
3768 m_BC2Values.resize(3);
3769 m_BCRegion.SetIndex(InputDimension-1,0);
3770 m_BC2Regions[0]=m_BCRegion;
3772 m_BCRegion.SetIndex(InputDimension-1,1);
3773 m_BC2Regions[1]=m_BCRegion;
3775 m_BCRegion.SetIndex(InputDimension-1,4);
3776 m_BC2Regions[2]=m_BCRegion;
3777 m_BC2Values[2]=-0.5;
3784 m_FirstRegion.SetSize(InputDimension-1,2);
3785 m_FirstRegion.SetIndex(InputDimension-1,2);
3788 m_BCRegions.resize(3);
3789 m_BCValues.resize(3);
3790 m_BCRegion.SetIndex(InputDimension-1,0);
3791 m_BCRegions[0]=m_BCRegion;
3793 m_BCRegion.SetIndex(InputDimension-1,1);
3794 m_BCRegions[1]=m_BCRegion;
3796 m_BCRegion.SetIndex(InputDimension-1,4);
3797 m_BCRegions[2]=m_BCRegion;
3801 m_SecondRegion.SetSize(InputDimension-1,1);
3802 m_SecondRegion.SetIndex(InputDimension-1,4);
3805 m_BC2Regions.resize(0);
3811 DD("supportindex > 4 ???");
3812 DD(m_SupportRegion.GetIndex(InputDimension-1));
3814 } // end switch index
3817 } // end case 5 shape
3824 // ----------------------------------------------------------------------
3825 // The diamond with 4 internal CP:
3826 // Periodic, constrained to zero at the reference at position 3
3827 // Coeff row 0 1 2 BC1 3 BC2 4
3828 // PaddedCoeff R:0 1 2 3 4 5 6
3829 // BC1= -weights[2]/weights[0] ( R2+R4 )
3830 // BC2= weights[2]/weights[0] ( R0+R2-R4-R6 ) + R1
3831 // ---------------------------------------------------------------------
3832 switch(m_SupportRegion.GetIndex(InputDimension-1))
3837 m_FirstRegion.SetSize(InputDimension-1,3);
3838 m_FirstRegion.SetIndex(InputDimension-1,0);
3841 m_BCRegions.resize(2);
3842 m_BCValues.resize(2);
3843 m_BCRegion.SetIndex(InputDimension-1,2);
3844 m_BCRegions[0]=m_BCRegion;
3845 m_BCValues[0]=-m_WeightRatio[2][0];
3846 m_BCRegion.SetIndex(InputDimension-1,3);
3847 m_BCRegions[1]=m_BCRegion;
3848 m_BCValues[1]=-m_WeightRatio[2][0];
3851 m_SecondRegion.SetSize(InputDimension-1,0);
3854 m_BC2Regions.resize(0);
3861 m_FirstRegion.SetSize(InputDimension-1,2);
3862 m_FirstRegion.SetIndex(InputDimension-1,1);
3865 m_BCRegions.resize(2);
3866 m_BCValues.resize(2);
3867 m_BCRegion.SetIndex(InputDimension-1,2);
3868 m_BCRegions[0]=m_BCRegion;
3869 m_BCValues[0]=-m_WeightRatio[2][0];
3870 m_BCRegion.SetIndex(InputDimension-1,3);
3871 m_BCRegions[1]=m_BCRegion;
3872 m_BCValues[1]=-m_WeightRatio[2][0];
3875 m_SecondRegion.SetSize(InputDimension-1,1);
3876 m_SecondRegion.SetIndex(InputDimension-1,3);
3879 m_BC2Regions.resize(0);
3886 m_FirstRegion.SetSize(InputDimension-1,1);
3887 m_FirstRegion.SetIndex(InputDimension-1,2);
3890 m_BCRegions.resize(2);
3891 m_BCValues.resize(2);
3892 m_BCRegion.SetIndex(InputDimension-1,2);
3893 m_BCRegions[0]=m_BCRegion;
3894 m_BCValues[0]=-m_WeightRatio[2][0];
3895 m_BCRegion.SetIndex(InputDimension-1,3);
3896 m_BCRegions[1]=m_BCRegion;
3897 m_BCValues[1]=-m_WeightRatio[2][0];
3900 m_SecondRegion.SetSize(InputDimension-1,1);
3901 m_SecondRegion.SetIndex(InputDimension-1,3);
3904 m_BC2Regions.resize(5);
3905 m_BC2Values.resize(5);
3906 m_BCRegion.SetIndex(InputDimension-1,0);
3907 m_BC2Regions[0]=m_BCRegion;
3908 m_BC2Values[0]=m_WeightRatio[2][0];
3909 m_BCRegion.SetIndex(InputDimension-1,1);
3910 m_BC2Regions[1]=m_BCRegion;
3912 m_BCRegion.SetIndex(InputDimension-1,2);
3913 m_BC2Regions[2]=m_BCRegion;
3914 m_BC2Values[2]=m_WeightRatio[2][0];
3915 m_BCRegion.SetIndex(InputDimension-1,3);
3916 m_BC2Regions[3]=m_BCRegion;
3917 m_BC2Values[3]=-m_WeightRatio[2][0];
3918 m_BCRegion.SetIndex(InputDimension-1,4);
3919 m_BC2Regions[4]=m_BCRegion;
3920 m_BC2Values[4]=-m_WeightRatio[2][0];
3927 m_FirstRegion.SetSize(InputDimension-1,0);
3930 m_BCRegions.resize(2);
3931 m_BCValues.resize(2);
3932 m_BCRegion.SetIndex(InputDimension-1,2);
3933 m_BCRegions[0]=m_BCRegion;
3934 m_BCValues[0]=-m_WeightRatio[2][0];
3935 m_BCRegion.SetIndex(InputDimension-1,3);
3936 m_BCRegions[1]=m_BCRegion;
3937 m_BCValues[1]=-m_WeightRatio[2][0];
3940 m_SecondRegion.SetSize(InputDimension-1,1);
3941 m_SecondRegion.SetIndex(InputDimension-1,3);
3944 m_BC2Regions.resize(5);
3945 m_BC2Values.resize(5);
3946 m_BCRegion.SetIndex(InputDimension-1,0);
3947 m_BC2Regions[0]=m_BCRegion;
3948 m_BC2Values[0]=m_WeightRatio[2][0];
3949 m_BCRegion.SetIndex(InputDimension-1,1);
3950 m_BC2Regions[1]=m_BCRegion;
3952 m_BCRegion.SetIndex(InputDimension-1,2);
3953 m_BC2Regions[2]=m_BCRegion;
3954 m_BC2Values[2]=m_WeightRatio[2][0];
3955 m_BCRegion.SetIndex(InputDimension-1,3);
3956 m_BC2Regions[3]=m_BCRegion;
3957 m_BC2Values[3]=-m_WeightRatio[2][0];
3958 m_BCRegion.SetIndex(InputDimension-1,4);
3959 m_BC2Regions[4]=m_BCRegion;
3960 m_BC2Values[4]=-m_WeightRatio[2][0];
3963 m_ThirdRegion.SetSize(InputDimension-1,1);
3964 m_ThirdRegion.SetIndex(InputDimension-1,4);
3971 DD("supportindex > 3 ???");
3972 DD(m_SupportRegion.GetIndex(InputDimension-1));
3974 } // end switch index
3977 } // end case 7 shape
3981 // ----------------------------------------------------------------------
3982 // The diamond with 5 internal CP:
3983 // periodic, constrained to zero at the reference at position 3.5
3984 // Coeff row 0 1 2 BC1 3 4 BC2 5
3985 // PaddedCoeff R:0 1 2 3 4 5 6 7
3986 // BC1= -weights[3]/weights[1] ( R2+R5 ) - R4
3987 // BC2= weights[2]/weights[0] ( R0+R2-R5-R7 ) + R1
3988 // ---------------------------------------------------------------------
3989 switch(m_SupportRegion.GetIndex(InputDimension-1))
3994 m_FirstRegion.SetSize(InputDimension-1,3);
3995 m_FirstRegion.SetIndex(InputDimension-1,0);
3998 m_BCRegions.resize(3);
3999 m_BCValues.resize(3);
4000 m_BCRegion.SetIndex(InputDimension-1,2);
4001 m_BCRegions[0]=m_BCRegion;
4002 m_BCValues[0]=-m_WeightRatio[3][1];
4003 m_BCRegion.SetIndex(InputDimension-1,3);
4004 m_BCRegions[1]=m_BCRegion;
4006 m_BCRegion.SetIndex(InputDimension-1,4);
4007 m_BCRegions[2]=m_BCRegion;
4008 m_BCValues[2]=-m_WeightRatio[3][1];
4011 m_SecondRegion.SetSize(InputDimension-1,0);
4014 m_BC2Regions.resize(0);
4021 m_FirstRegion.SetSize(InputDimension-1,2);
4022 m_FirstRegion.SetIndex(InputDimension-1,1);
4025 m_BCRegions.resize(3);
4026 m_BCValues.resize(3);
4027 m_BCRegion.SetIndex(InputDimension-1,2);
4028 m_BCRegions[0]=m_BCRegion;
4029 m_BCValues[0]=-m_WeightRatio[3][1];
4030 m_BCRegion.SetIndex(InputDimension-1,3);
4031 m_BCRegions[1]=m_BCRegion;
4033 m_BCRegion.SetIndex(InputDimension-1,4);
4034 m_BCRegions[2]=m_BCRegion;
4035 m_BCValues[2]=-m_WeightRatio[3][1];
4038 m_SecondRegion.SetSize(InputDimension-1,1);
4039 m_SecondRegion.SetIndex(InputDimension-1,3);
4042 m_BC2Regions.resize(0);
4049 m_FirstRegion.SetSize(InputDimension-1,1);
4050 m_FirstRegion.SetIndex(InputDimension-1,2);
4053 m_BCRegions.resize(3);
4054 m_BCValues.resize(3);
4055 m_BCRegion.SetIndex(InputDimension-1,2);
4056 m_BCRegions[0]=m_BCRegion;
4057 m_BCValues[0]=-m_WeightRatio[3][1];
4058 m_BCRegion.SetIndex(InputDimension-1,3);
4059 m_BCRegions[1]=m_BCRegion;
4061 m_BCRegion.SetIndex(InputDimension-1,4);
4062 m_BCRegions[2]=m_BCRegion;
4063 m_BCValues[2]=-m_WeightRatio[3][1];
4066 m_SecondRegion.SetSize(InputDimension-1,2);
4067 m_SecondRegion.SetIndex(InputDimension-1,3);
4070 m_BC2Regions.resize(0);
4077 m_FirstRegion.SetSize(InputDimension-1,0);
4078 m_FirstRegion.SetIndex(InputDimension-1,0);
4081 m_BCRegions.resize(3);
4082 m_BCValues.resize(3);
4083 m_BCRegion.SetIndex(InputDimension-1,2);
4084 m_BCRegions[0]=m_BCRegion;
4085 m_BCValues[0]=-m_WeightRatio[3][1];
4086 m_BCRegion.SetIndex(InputDimension-1,3);
4087 m_BCRegions[1]=m_BCRegion;
4089 m_BCRegion.SetIndex(InputDimension-1,4);
4090 m_BCRegions[2]=m_BCRegion;
4091 m_BCValues[2]=-m_WeightRatio[3][1];
4094 m_SecondRegion.SetSize(InputDimension-1,2);
4095 m_SecondRegion.SetIndex(InputDimension-1,3);
4098 m_BC2Regions.resize(5);
4099 m_BC2Values.resize(5);
4100 m_BCRegion.SetIndex(InputDimension-1,0);
4101 m_BC2Regions[0]=m_BCRegion;
4102 m_BC2Values[0]=m_WeightRatio[2][0];
4103 m_BCRegion.SetIndex(InputDimension-1,1);
4104 m_BC2Regions[1]=m_BCRegion;
4106 m_BCRegion.SetIndex(InputDimension-1,2);
4107 m_BC2Regions[2]=m_BCRegion;
4108 m_BC2Values[2]=m_WeightRatio[2][0];
4109 m_BCRegion.SetIndex(InputDimension-1,4);
4110 m_BC2Regions[3]=m_BCRegion;
4111 m_BC2Values[3]=-m_WeightRatio[2][0];
4112 m_BCRegion.SetIndex(InputDimension-1,5);
4113 m_BC2Regions[4]=m_BCRegion;
4114 m_BC2Values[4]=-m_WeightRatio[2][0];
4122 m_FirstRegion.SetSize(InputDimension-1,2);
4123 m_FirstRegion.SetIndex(InputDimension-1,3);
4126 m_BCRegions.resize(5);
4127 m_BCValues.resize(5);
4128 m_BCRegion.SetIndex(InputDimension-1,0);
4129 m_BCRegions[0]=m_BCRegion;
4130 m_BCValues[0]=m_WeightRatio[2][0];
4131 m_BCRegion.SetIndex(InputDimension-1,1);
4132 m_BCRegions[1]=m_BCRegion;
4134 m_BCRegion.SetIndex(InputDimension-1,2);
4135 m_BCRegions[2]=m_BCRegion;
4136 m_BCValues[2]=m_WeightRatio[2][0];
4137 m_BCRegion.SetIndex(InputDimension-1,4);
4138 m_BCRegions[3]=m_BCRegion;
4139 m_BCValues[3]=-m_WeightRatio[2][0];
4140 m_BCRegion.SetIndex(InputDimension-1,5);
4141 m_BCRegions[4]=m_BCRegion;
4142 m_BCValues[4]=-m_WeightRatio[2][0];
4145 m_SecondRegion.SetSize(InputDimension-1,1);
4146 m_SecondRegion.SetIndex(InputDimension-1,5);
4149 m_BC2Regions.resize(0);
4156 DD("supportindex > 4 ???");
4157 DD(m_SupportRegion.GetIndex(InputDimension-1));
4159 } // end switch index
4162 } // end case 7 shape
4166 // ----------------------------------------------------------------------
4167 // The sputnik with 5 internal CP
4168 // Periodic, constrained to zero at the reference
4169 // at position 3 and one indepent extreme
4170 // Coeff row BC1 0 1 BC2 2 3 BC3 4
4171 // PaddedCoeff R: 0 1 2 3 4 5 6 7
4173 // BC2= -weights[3]/weights[1] ( R2+R5 ) - R4
4175 // ---------------------------------------------------------------------
4176 switch(m_SupportRegion.GetIndex(InputDimension-1))
4181 m_FirstRegion.SetSize(InputDimension-1,0);
4184 m_BCRegions.resize(3);
4185 m_BCValues.resize(3);
4186 m_BCRegion.SetIndex(InputDimension-1,1);
4187 m_BCRegions[0]=m_BCRegion;
4189 m_BCRegion.SetIndex(InputDimension-1,3);
4190 m_BCRegions[1]=m_BCRegion;
4192 m_BCRegion.SetIndex(InputDimension-1,4);
4193 m_BCRegions[2]=m_BCRegion;
4197 m_SecondRegion.SetSize(InputDimension-1,2);
4198 m_SecondRegion.SetIndex(InputDimension-1,0);
4201 m_BC2Regions.resize(3);
4202 m_BC2Values.resize(3);
4203 m_BCRegion.SetIndex(InputDimension-1,1);
4204 m_BC2Regions[0]=m_BCRegion;
4205 m_BC2Values[0]=-m_WeightRatio[3][1];
4206 m_BCRegion.SetIndex(InputDimension-1,2);
4207 m_BC2Regions[1]=m_BCRegion;
4209 m_BCRegion.SetIndex(InputDimension-1,3);
4210 m_BC2Regions[2]=m_BCRegion;
4211 m_BC2Values[2]=-m_WeightRatio[3][1];
4218 m_FirstRegion.SetSize(InputDimension-1,2);
4219 m_FirstRegion.SetIndex(InputDimension-1,0);
4222 m_BCRegions.resize(3);
4223 m_BCValues.resize(3);
4224 m_BCRegion.SetIndex(InputDimension-1,1);
4225 m_BCRegions[0]=m_BCRegion;
4226 m_BCValues[0]=-m_WeightRatio[3][1];
4227 m_BCRegion.SetIndex(InputDimension-1,2);
4228 m_BCRegions[1]=m_BCRegion;
4230 m_BCRegion.SetIndex(InputDimension-1,3);
4231 m_BCRegions[2]=m_BCRegion;
4232 m_BCValues[2]=-m_WeightRatio[3][1];
4235 m_SecondRegion.SetSize(InputDimension-1,1);
4236 m_SecondRegion.SetIndex(InputDimension-1,2);
4239 m_BC2Regions.resize(0);
4246 m_FirstRegion.SetSize(InputDimension-1,1);
4247 m_FirstRegion.SetIndex(InputDimension-1,1);
4250 m_BCRegions.resize(3);
4251 m_BCValues.resize(3);
4252 m_BCRegion.SetIndex(InputDimension-1,1);
4253 m_BCRegions[0]=m_BCRegion;
4254 m_BCValues[0]=-m_WeightRatio[3][1];
4255 m_BCRegion.SetIndex(InputDimension-1,2);
4256 m_BCRegions[1]=m_BCRegion;
4258 m_BCRegion.SetIndex(InputDimension-1,3);
4259 m_BCRegions[2]=m_BCRegion;
4260 m_BCValues[2]=-m_WeightRatio[3][1];
4263 m_SecondRegion.SetSize(InputDimension-1,2);
4264 m_SecondRegion.SetIndex(InputDimension-1,2);
4267 m_BC2Regions.resize(0);
4274 m_FirstRegion.SetSize(InputDimension-1,0);
4277 m_BCRegions.resize(3);
4278 m_BCValues.resize(3);
4279 m_BCRegion.SetIndex(InputDimension-1,1);
4280 m_BCRegions[0]=m_BCRegion;
4281 m_BCValues[0]=-m_WeightRatio[3][1];
4282 m_BCRegion.SetIndex(InputDimension-1,2);
4283 m_BCRegions[1]=m_BCRegion;
4285 m_BCRegion.SetIndex(InputDimension-1,3);
4286 m_BCRegions[2]=m_BCRegion;
4287 m_BCValues[2]=-m_WeightRatio[3][1];
4290 m_SecondRegion.SetSize(InputDimension-1,1);
4291 m_SecondRegion.SetIndex(InputDimension-1,2);
4294 m_BC2Regions.resize(1);
4295 m_BC2Values.resize(1);
4296 m_BCRegion.SetIndex(InputDimension-1,0);
4297 m_BC2Regions[0]=m_BCRegion;
4305 m_FirstRegion.SetSize(InputDimension-1,2);
4306 m_FirstRegion.SetIndex(InputDimension-1,2);
4309 m_BCRegions.resize(1);
4310 m_BCValues.resize(1);
4311 m_BCRegion.SetIndex(InputDimension-1,0);
4312 m_BCRegions[0]=m_BCRegion;
4316 m_SecondRegion.SetSize(InputDimension-1,1);
4317 m_SecondRegion.SetIndex(InputDimension-1,4);
4320 m_BC2Regions.resize(0);
4326 DD("supportindex > 4 ???");
4327 DD(m_SupportRegion.GetIndex(InputDimension-1));
4329 } // end switch index
4332 } // end case 9 shape
4337 DD ("Other shapes currently not implemented");
4340 } // end switch shape
4341 } // end wrap region
4345 template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
4347 ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions,NOutputDimensions>
4348 ::TransformPointToContinuousIndex( const InputPointType & point, ContinuousIndexType & index ) const
4352 itk::Vector<double, OutputDimension> tvector;
4354 for ( j = 0; j < OutputDimension; j++ )
4356 //JV find the index in the PADDED version
4357 tvector[j] = point[j] - this->m_PaddedGridOrigin[j];
4360 itk::Vector<double, OutputDimension> cvector;
4362 cvector = m_PointToIndex * tvector;
4364 for ( j = 0; j < OutputDimension; j++ )
4366 index[j] = static_cast< typename ContinuousIndexType::CoordRepType >( cvector[j] );