Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
fd9a987
ENH: Initial commit on ITKPCA
May 24, 2016
de390bc
ENH: Move PrincipalComponentsAnalysis to itk-module hierarchy
May 24, 2016
9d24694
ENH: Move PrincipalComponentsAnalysis to itk-module testing hierarchy
May 24, 2016
3752a90
BUG: Fix testing dependencies and main name
May 24, 2016
0d70cac
BUG: Fix itkVectorFieldPCA define style
May 24, 2016
95c32c1
BUG: Fix documentation in itkVectorFieldPCA
May 24, 2016
dedbdc4
ENH: Move test data to midas3.kitware.com
May 24, 2016
a8a0efb
COMP: Add removed option for building the examples and the documentation
May 24, 2016
c7ea838
ENH: Add ITKTestKernel to testing
May 24, 2016
be569ce
ENH: Add python wrapping
May 25, 2016
700993d
ENH: Remove unecessary IO in TEST_DEPENDS
May 25, 2016
5854377
ENH: Add missing ITKMesh
May 25, 2016
5cc3138
COMP: Prepend CMake options with PrincipalComponentAnalysis
May 27, 2016
31e70d9
ENH: Remove unused declarations in itkVectorKernelPCATest.cxx
May 27, 2016
ec58517
BUG: Example (VectorKernelPCA) was missing dependencies
fbudin69500 Jun 23, 2016
91768ad
ENH: Merge pull request #1 from fbudin69500/example_depends
johan-andruejol Jun 23, 2016
8f5a356
ENH: Honor the ITK conventions to name modules, flags and folders.
Apr 11, 2017
34c812d
STYLE: Improve the itkVectorFieldPCA class style.
Apr 22, 2017
a2c4f9d
ENH: Improve code coverage for itk::VectorFieldPCA.
Apr 22, 2017
f4fcf71
ENH: Merge pull request #2 from jhlegarreta/ImproveCodeCoverage
thewtex Apr 24, 2017
cbb07bf
STYLE: Merge pull request #3 from jhlegarreta/ImproveStyle
thewtex Apr 24, 2017
a63ebd3
ENH: Include the ITK_MANUAL_INSTANTIATION macro.
Apr 26, 2017
56a1b73
ENH: Merge pull request #4 from jhlegarreta/AddSupportForExplicitInst…
thewtex Apr 26, 2017
792f289
ENH: Merge pull request #1 from jhlegarreta/HonorITKConventionsForMod…
Apr 26, 2017
266950c
ENH: Require cmake minimum version to be 3.9.5.
Jan 17, 2018
2d48e67
COMP: Merge pull request #6 from jhlegarreta/ChangeRequiredCMakeMinim…
dzenanz Jan 19, 2018
9dab269
COMP: Remove deprecated code usages
hjmjohnson Dec 16, 2017
340c88d
ENH: ITKv5 override consistency
hjmjohnson Dec 17, 2017
5b2d1c9
COMP: Use C++11 override directly
hjmjohnson Dec 17, 2017
956382b
ENH: Remove unused variables.
hjmjohnson Dec 22, 2017
e32c119
ENH: Merge pull request #7 from InsightSoftwareConsortium/ITKv5
hjmjohnson Jan 22, 2018
f09d0f9
COMP: Move ITK_DISALLOW_COPY_AND_ASSIGN calls to public section.
Apr 14, 2018
de012a5
ENH: Merge pull request #8 from jhlegarreta/MoveDISALLOWCOPYANDASSIGN…
thewtex Apr 26, 2018
520b37f
COMP: Set the minimum required CMake version to 3.10.2.
May 5, 2018
3e91364
COMP: Merge pull request #9 from jhlegarreta/UpdateCMakeMinimumRequir…
thewtex May 6, 2018
b6db56e
DOC: Add missing LICENSE file
thewtex Oct 1, 2018
07ff0cf
DOC: Merge pull request #13 from thewtex/license
jhlegarreta Oct 1, 2018
007d67c
STYLE: Prefer C++11 type alias over typedef.
jhlegarreta Oct 20, 2018
5ef7ec7
ENH: Merge pull request #16 from jhlegarreta/PreferC++1TypeAliasOverT…
hjmjohnson Nov 3, 2018
7437995
COMP: Future proof vnl_math_XXX function usage.
hjmjohnson Nov 3, 2018
c2ea9ed
STYLE: Remove unnecessary vcl_XXX.h headers
hjmjohnson Nov 3, 2018
c219e68
STYLE: Cast the binary data to the testing framework.
jhlegarreta Dec 24, 2018
b6ee01b
ENH: Use the ITK CMake macros to build examples.
jhlegarreta Dec 24, 2018
8fe60f1
STYLE: Remove tabs as per ITK style.
jhlegarreta Dec 24, 2018
e0ba1cf
COMP: Merge pull request #23 from jhlegarreta/UseITKCMakeMacros
thewtex Jan 3, 2019
e1cd790
BUG: Rename wrapping/wrapping.cmake to wrapping/CMakeLists.txt
thewtex Jan 3, 2019
f30dcd9
BUG: ITK_EXPORT to ITK_TEMPLATE_EXPORT
thewtex Jan 3, 2019
cc1a3eb
COMP: Allow compiler to find itk::GaussianDistanceKernel definition
thewtex Jan 3, 2019
7ee16b7
COMP: Fix Evaluate argument and return value types
thewtex Jan 3, 2019
ec89207
COMP: Merge pull request #24 from jhlegarreta/RemoveTabsFromCMakeLists
thewtex Jan 3, 2019
d02a58c
ENH: Merge pull request #22 from jhlegarreta/CastDataBinariesToTestin…
thewtex Jan 3, 2019
b145d6f
COMP: Merge pull request #26 from thewtex/wrapping-CMakeLists.txt
thewtex Jan 4, 2019
663e34a
STYLE: Add ITK prefix to testing macros
jhlegarreta Jun 15, 2019
ab04d41
ENH: Add .gitattributes to allow running ITK clang-formatting scripts
hjmjohnson Feb 19, 2020
9cd32ed
STYLE: Convert CMake-language commands to lower case
hjmjohnson Feb 16, 2020
ad96aa8
PERF: emplace_back method results in potentially more efficient code
hjmjohnson Feb 17, 2020
31c44b1
STYLE: Prefer = default to explicitly trivial implementations
hjmjohnson Feb 17, 2020
d6281df
STYLE: Remove redundant void argument lists
hjmjohnson Feb 17, 2020
f890741
STYLE: Use default member initialization
hjmjohnson Feb 17, 2020
db4fa6d
DOC: Update copyright assignment to NumFOCUS
hjmjohnson Feb 19, 2020
529a6a8
STYLE: Rename ITK_DISALLOW_COPY_AND_ASSIGN to ITK_DISALLOW_COPY_AND_MOVE
mseng10 Oct 14, 2020
a0869b4
COMP: Remove inclusion of .hxx files as headers
hjmjohnson Dec 17, 2021
47cef39
ENH: Bump ITK and replace http with https using script
tbirdso May 31, 2022
fd3f895
ENH: Convert from md5 to .cid tags.
hjmjohnson Apr 22, 2026
3b09ee8
ENH: Add v4 whitelist for PrincipalComponentsAnalysis ingest
hjmjohnson May 8, 2026
e41c3c3
ENH: Ingest ITKPrincipalComponentsAnalysis into Modules/Numerics
hjmjohnson May 8, 2026
2909ac5
DOC: Add PrincipalComponentsAnalysis README pointing at upstream
hjmjohnson May 8, 2026
8b54cbb
COMP: Remove PrincipalComponentsAnalysis .remote.cmake (in-tree)
hjmjohnson May 8, 2026
101932c
ENH: Enable Module_PrincipalComponentsAnalysis in configure-ci
hjmjohnson May 8, 2026
c51445a
COMP: Address PrincipalComponentsAnalysis review concerns
hjmjohnson May 8, 2026
79b9244
STYLE: Address Greptile review on PrincipalComponentsAnalysis
hjmjohnson May 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Modules/Numerics/PrincipalComponentsAnalysis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project(PrincipalComponentsAnalysis)

itk_module_impl()
24 changes: 24 additions & 0 deletions Modules/Numerics/PrincipalComponentsAnalysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# PrincipalComponentsAnalysis

In-tree ITK module providing a principal component analysis filter for
scalar, vector, and mesh-vertex data. The flagship class is
`itk::VectorFieldPCA`, which computes the principal components of an
ensemble of vector fields defined on a common mesh, useful for
shape-modeling and multivariate statistics workflows.

## Origin

Ingested from the standalone remote module
[**InsightSoftwareConsortium/ITKPrincipalComponentsAnalysis**](https://github.com/InsightSoftwareConsortium/ITKPrincipalComponentsAnalysis)
on 2026-05-08, following the v4 ingestion guidelines defined in
InsightSoftwareConsortium/ITK#6204. The upstream repository will be
archived read-only after this PR merges; it remains reachable at the
URL above for historical reference (notably the `doc/` and
`examples/` directories, which were intentionally left in the
upstream archive).

## References

- Bowers M., Younes L. *Principal Components Analysis of Scalar,
Vector, and Mesh Vertex Data.* The Insight Journal. August, 2013.
<https://doi.org/10.54294/loekqj>
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* 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
*
* https://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 itkVectorFieldPCA_h
#define itkVectorFieldPCA_h

#include "itkObject.h"
#include "itkPointSet.h"
#include "itkKernelFunctionBase.h"
#include "vnl/vnl_vector.h"
#include "vnl/vnl_matrix.h"

namespace itk
{

/** \class VectorFieldPCA
* \brief Produce the principle components of a vector valued function.
*
* This calculator produces a set of basis functions composed of the
* principal components of a set of vector valued functions.
*
* Specify an itk::KernelFunction for Kernel PCA. The Kernel Function
* can take as input an optional point set.
*
* This class is templated over the types of the vector valued functions,
* the output point types, and optionally the point set type.
*
* \author Michael Bowers, Laurent Younes
*
* This code was contributed in the Insight Journal paper:
*
* "Principal Components Analysis of Scalar, Vector, and Mesh Vertex Data"
* https://www.insight-journal.org/browse/publication/878
*
* \ingroup ITKStatistics
* \ingroup PrincipalComponentsAnalysis
*/

template <typename TRealValueType = double>
class ITK_TEMPLATE_EXPORT GaussianDistanceKernel : public KernelFunctionBase<TRealValueType>
{
public:
/** Standard class type alias. */
using Self = GaussianDistanceKernel;
using Superclass = KernelFunctionBase<TRealValueType>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Run-time type information (and related methods). */
itkTypeMacro(GaussianDistanceKernel, KernelFunction);

/** Method for creation through the object factory. */
itkNewMacro(Self);

/**
* \brief Set and get the Kernel sigma.
*/
void
SetKernelSigma(double s)
{
m_KernelSigma = s;
m_OneOverMinusTwoSigmaSqr = -1.0 / (2.0 * s * s);
}
itkGetMacro(KernelSigma, double);

/**
* \brief Evaluate the function. Input is the squared distance
*/
inline TRealValueType
Evaluate(const TRealValueType & u) const override
{
return (std::exp(u * m_OneOverMinusTwoSigmaSqr));
}

protected:
GaussianDistanceKernel() = default;
~GaussianDistanceKernel() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override
{
Superclass::PrintSelf(os, indent);
}

private:
double m_KernelSigma{ 1.0 };
double m_OneOverMinusTwoSigmaSqr{ -0.5 };
};

template <typename TVectorFieldElementType,
typename TPCType,
typename TPointSetPixelType = float,
typename TPointSetCoordRepType = float,
typename KernelFunctionType = KernelFunctionBase<TPointSetCoordRepType>,
class TPointSetType =
PointSet<TPointSetPixelType, 3, DefaultStaticMeshTraits<TPointSetPixelType, 3, 3, TPointSetCoordRepType>>>
class ITK_TEMPLATE_EXPORT VectorFieldPCA : public Object
{
public:
ITK_DISALLOW_COPY_AND_MOVE(VectorFieldPCA);

/** Standard class type alias. */
using Self = VectorFieldPCA;
using Superclass = Object;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Method for creation through the object factory. */
itkNewMacro(Self);

/** Run-time type information (and related methods). */
itkTypeMacro(VectorFieldPCA, Object);

/** Type definitions for the PointSet. */
using InputPointSetType = TPointSetType;

/** Definitions for points of the PointSet. */
using InputPointType = typename InputPointSetType::PointType;

/** Definitions for the PointsContainer. */
using PointsContainer = typename InputPointSetType::PointsContainer;
using PointsContainerIterator = typename PointsContainer::Iterator;

/** Pointer types for the PointSet. */
using InputPointSetPointer = typename InputPointSetType::Pointer;

/** Const Pointer type for the PointSet. */
using InputPointSetConstPointer = typename InputPointSetType::ConstPointer;

/**
* \brief Input PointSet dimension
*/
itkStaticConstMacro(InputMeshDimension, unsigned int, TPointSetType::PointDimension);

/** type for the vector fields. */
using VectorFieldType = vnl_matrix<TVectorFieldElementType>;
using VectorFieldSetType = VectorContainer<unsigned int, VectorFieldType>;

using VectorFieldSetTypePointer = typename VectorFieldSetType::Pointer;
using VectorFieldSetTypeConstPointer = typename VectorFieldSetType::ConstPointer;

/** types for the output. */
using MatrixType = vnl_matrix<TPCType>;
using VectorType = vnl_vector<TPCType>;

using BasisSetType = VectorContainer<unsigned int, MatrixType>;
using ResSetType = VectorContainer<unsigned int, VectorType>;

using BasisSetTypePointer = typename BasisSetType::Pointer;
using KernelFunctionPointer = typename KernelFunctionType::Pointer;

/**
* \brief Set and get the input point set.
*/
itkSetMacro(PointSet, InputPointSetPointer);
itkGetMacro(PointSet, InputPointSetPointer);

/**
* \brief Set and get the vector fields for the analysis.
*/
itkSetMacro(VectorFieldSet, VectorFieldSetTypePointer);
itkGetMacro(VectorFieldSet, VectorFieldSetTypePointer);

/**
* \brief Set and get the PCA count.
*/
itkSetMacro(ComponentCount, unsigned int);
itkGetMacro(ComponentCount, unsigned int);

/**
* \brief Set pointer to the Kernel object.
*/
itkSetMacro(KernelFunction, KernelFunctionPointer);

/**
* \brief Compute the PCA decomposition of the input point set.
If a Kernel and a Kernel Sigma are set ,
the calculator will perform Kernel PCA.
*/
void
Compute();

/**
* \brief Return the results.
*/
itkGetConstReferenceMacro(AveVectorField, MatrixType);
itkGetConstReferenceMacro(PCAEigenValues, VectorType);
itkGetConstObjectMacro(BasisVectors, BasisSetType);

protected:
VectorFieldPCA();
~VectorFieldPCA() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;

/** Kernel PCA. */
void
KernelPCA();

/** Compute Momentum SCP. */
void
ComputeMomentumSCP();

private:
VectorType m_PCAEigenValues;

BasisSetTypePointer m_BasisVectors;
VectorFieldSetTypePointer m_VectorFieldSet;
InputPointSetPointer m_PointSet;
KernelFunctionPointer m_KernelFunction;

// Problem dimensions
unsigned int m_ComponentCount{ 0 };
unsigned int m_SetSize{ 0 };
unsigned int m_VectorDimCount{ 0 };
unsigned int m_PointDim{ 0 };
Comment thread
hjmjohnson marked this conversation as resolved.

MatrixType m_V0;
MatrixType m_AveVectorField;
MatrixType m_K;

bool m_PCACalculated{ false };
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
# include "itkVectorFieldPCA.hxx"
#endif

#endif
Loading
Loading