File: itkPhysicsBasedNonRigidRegistrationMethod.hxx

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg2-4%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 491,276 kB
  • sloc: cpp: 557,593; ansic: 180,546; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 133; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (128 lines) | stat: -rw-r--r-- 5,635 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef itkPhysicsBasedNonRigidRegistrationMethod_hxx
#define itkPhysicsBasedNonRigidRegistrationMethod_hxx

#include <iostream>
#include "itkTimeProbe.h"
#include "itkPhysicsBasedNonRigidRegistrationMethod.h"


namespace itk
{

namespace fem
{

template <typename TFixedImage, typename TMovingImage, typename TMaskImage, typename TMesh, typename TDeformationField>
PhysicsBasedNonRigidRegistrationMethod<TFixedImage, TMovingImage, TMaskImage, TMesh, TDeformationField>
::PhysicsBasedNonRigidRegistrationMethod() :
  m_SelectFraction( 0.1 ),
  m_NonConnectivity( 0 ), // VERTEX_CONNECTIVITY
  m_ApproximationSteps( 10 ),
  m_OutlierRejectionSteps( 10 )
{
  this->m_BlockRadius.Fill( 2 );
  this->m_SearchRadius.Fill( 5 );

  // Set up internal pipeline
  this->m_FeatureSelectionFilter = FeatureSelectionFilterType::New();
  this->m_FeatureSelectionFilter->ComputeStructureTensorsOn();
  this->m_BlockMatchingFilter = BlockMatchingFilterType::New();
  this->m_BlockMatchingFilter->SetFeaturePoints( this->m_FeatureSelectionFilter->GetOutput() );
  this->m_FEMFilter = FEMFilterType::New();
  this->m_FEMFilter->SetConfidencePointSet( this->m_BlockMatchingFilter->GetSimilarities() );
  this->m_FEMFilter->SetTensorPointSet( this->m_FeatureSelectionFilter->GetOutput() );

  // All inputs are required
  this->SetPrimaryInputName("FixedImage");
  this->AddRequiredInputName("FixedImage");
  this->AddRequiredInputName("MovingImage");
  this->AddRequiredInputName("MaskImage");
  this->AddRequiredInputName("Mesh");
}

template <typename TFixedImage, typename TMovingImage, typename TMaskImage, typename TMesh, typename TDeformationField>
PhysicsBasedNonRigidRegistrationMethod<TFixedImage, TMovingImage, TMaskImage, TMesh, TDeformationField>
::~PhysicsBasedNonRigidRegistrationMethod()
{
}

template <typename TFixedImage, typename TMovingImage, typename TMaskImage, typename TMesh, typename TDeformationField>
void
PhysicsBasedNonRigidRegistrationMethod<TFixedImage, TMovingImage, TMaskImage, TMesh, TDeformationField>
::GenerateData()
{
  // Feature selection
  this->m_FeatureSelectionFilter->SetInput( this->GetMovingImage() );
  this->m_FeatureSelectionFilter->SetMaskImage( this->GetMaskImage() );
  this->m_FeatureSelectionFilter->SetSelectFraction( this->m_SelectFraction );
  this->m_FeatureSelectionFilter->SetNonConnectivity( this->m_NonConnectivity );
  this->m_FeatureSelectionFilter->SetBlockRadius( this->m_BlockRadius );

  // Block matching
  this->m_BlockMatchingFilter->SetFixedImage( this->GetFixedImage() );
  this->m_BlockMatchingFilter->SetMovingImage( this->GetMovingImage() );
  this->m_BlockMatchingFilter->SetBlockRadius( this->m_BlockRadius );
  this->m_BlockMatchingFilter->SetSearchRadius( this->m_SearchRadius );

  // Assembly and solver
  typename BlockMatchingFilterType::DisplacementsType * displacements = this->m_BlockMatchingFilter->GetDisplacements();
  this->m_FEMFilter->SetInput( displacements );
  this->m_FEMFilter->SetMesh( const_cast< MeshType * >( this->GetMesh() ) );
  const FixedImageType * fixedImage = this->GetFixedImage();
  this->m_FEMFilter->SetSpacing( fixedImage->GetSpacing() );
  this->m_FEMFilter->SetOrigin( fixedImage->GetOrigin() );
  this->m_FEMFilter->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );

  typename FEMFilterType::FEMSolverType * femSolver = this->m_FEMFilter->GetModifiableFEMSolver();
  femSolver->SetApproximationSteps( this->m_ApproximationSteps );
  femSolver->SetOutlierRejectionSteps( this->m_OutlierRejectionSteps );

  // Graft our output to the filter to force the proper regions to be generated
  this->m_FEMFilter->GraftOutput( this->GetOutput() );

  this->m_FEMFilter->Update();

  // Graft the output of the subtract filter back onto this filter's output
  // this is needed to get the appropriate regions passed back
  this->GraftOutput( this->m_FEMFilter->GetOutput() );
}

template <typename TFixedImage, typename TMovingImage, typename TMaskImage, typename TMesh, typename TDeformationField>
void
PhysicsBasedNonRigidRegistrationMethod<TFixedImage, TMovingImage, TMaskImage, TMesh, TDeformationField>
::PrintSelf( std::ostream & os, Indent indent ) const
{
  Superclass::PrintSelf( os, indent );

  os << indent << "m_SelectFraction: " << m_SelectFraction << std::endl;
  os << indent << "m_NonConnectivity: " << m_NonConnectivity << std::endl;
  os << indent << "m_BlockRadius: " << m_BlockRadius << std::endl;
  os << indent << "m_SearchRadius: " << m_SearchRadius << std::endl;
  os << indent << "m_ApproximationSteps: " << m_ApproximationSteps << std::endl;
  os << indent << "m_OutlierRejectionSteps: " << m_OutlierRejectionSteps << std::endl;

  itkPrintSelfObjectMacro( FeatureSelectionFilter );
  itkPrintSelfObjectMacro( BlockMatchingFilter );
  itkPrintSelfObjectMacro( FEMFilter );
}
} // end namespace fem
} // end namespace itk

#endif