Skip to content

Commit 79b9244

Browse files
committed
STYLE: Address Greptile review on PrincipalComponentsAnalysis
itkVectorFieldPCA.h: in-class-initialize the GaussianDistanceKernel members so Evaluate() before SetKernelSigma() is well-defined; drop the unused m_VertexCount member that was never assigned. itkVectorFieldPCA.hxx: drop the redundant inner if(m_PointSet) check — control reaches it only after the preceding if(!m_PointSet) throw. Remove the m_VertexCount line from PrintSelf(). itkVectorKernelPCATest.cxx: drop the duplicated vnl_vector.h include and the unused debugOut std::ofstream.
1 parent c51445a commit 79b9244

3 files changed

Lines changed: 6 additions & 16 deletions

File tree

Modules/Numerics/PrincipalComponentsAnalysis/include/itkVectorFieldPCA.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class ITK_TEMPLATE_EXPORT GaussianDistanceKernel : public KernelFunctionBase<TRe
9797
}
9898

9999
private:
100-
double m_KernelSigma;
101-
double m_OneOverMinusTwoSigmaSqr;
100+
double m_KernelSigma{ 1.0 };
101+
double m_OneOverMinusTwoSigmaSqr{ -0.5 };
102102
};
103103

104104
template <typename TVectorFieldElementType,
@@ -227,7 +227,6 @@ class ITK_TEMPLATE_EXPORT VectorFieldPCA : public Object
227227
unsigned int m_ComponentCount{ 0 };
228228
unsigned int m_SetSize{ 0 };
229229
unsigned int m_VectorDimCount{ 0 };
230-
unsigned int m_VertexCount{ 0 };
231230
unsigned int m_PointDim{ 0 };
232231

233232
MatrixType m_V0;

Modules/Numerics/PrincipalComponentsAnalysis/include/itkVectorFieldPCA.hxx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,11 @@ VectorFieldPCA<TVectorFieldElementType,
9898
return;
9999
}
100100

101-
// PointSet only necessary for Kernel PCA, but check that it matches if set...
102-
if (m_PointSet)
101+
// PointSet only necessary for Kernel PCA, check that it matches.
102+
if (m_PointSet->GetNumberOfPoints() != m_VectorDimCount)
103103
{
104-
if (m_PointSet->GetNumberOfPoints() != m_VectorDimCount)
105-
{
106-
itkExceptionMacro("Point Set count (" << m_PointSet->GetNumberOfPoints()
107-
<< ") does not match vector field count (" << m_VectorDimCount << ").");
108-
return;
109-
}
104+
itkExceptionMacro("Point Set count (" << m_PointSet->GetNumberOfPoints()
105+
<< ") does not match vector field count (" << m_VectorDimCount << ").");
110106
}
111107
}
112108

@@ -323,7 +319,6 @@ VectorFieldPCA<TVectorFieldElementType,
323319
os << indent << "ComponentCount: " << this->m_ComponentCount << std::endl;
324320
os << indent << "SetSize: " << this->m_SetSize << std::endl;
325321
os << indent << "VectorDimCount: " << this->m_VectorDimCount << std::endl;
326-
os << indent << "VertexCount: " << this->m_VertexCount << std::endl;
327322
os << indent << "PointDim: " << this->m_PointDim << std::endl;
328323

329324
os << indent << "V0 : " << this->m_V0 << std::endl;

Modules/Numerics/PrincipalComponentsAnalysis/test/itkVectorKernelPCATest.cxx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "itkVectorFieldPCA.h"
2222
#include "itkTestingMacros.h"
2323
#include "vnl/vnl_vector.h"
24-
#include "vnl/vnl_vector.h"
2524

2625

2726
template <typename TPixel, typename TMesh, typename TVectorContainer>
@@ -192,9 +191,6 @@ itkVectorKernelPCATest(int argc, char * argv[])
192191
pcaCalc->SetKernelFunction(distKernel);
193192

194193

195-
std::ofstream debugOut;
196-
debugOut.precision(15);
197-
198194
// Get the output and perform basic checks
199195
unsigned int computedNumberOfAverageVectorFieldCols = pcaCalc->GetAveVectorField().cols();
200196

0 commit comments

Comments
 (0)