-
-
Notifications
You must be signed in to change notification settings - Fork 727
ENH: Ingest ITKPrincipalComponentsAnalysis into Modules/Numerics #6240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hjmjohnson
merged 71 commits into
InsightSoftwareConsortium:main
from
hjmjohnson:ingest-PrincipalComponentsAnalysis
May 9, 2026
Merged
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
de390bc
ENH: Move PrincipalComponentsAnalysis to itk-module hierarchy
9d24694
ENH: Move PrincipalComponentsAnalysis to itk-module testing hierarchy
3752a90
BUG: Fix testing dependencies and main name
0d70cac
BUG: Fix itkVectorFieldPCA define style
95c32c1
BUG: Fix documentation in itkVectorFieldPCA
dedbdc4
ENH: Move test data to midas3.kitware.com
a8a0efb
COMP: Add removed option for building the examples and the documentation
c7ea838
ENH: Add ITKTestKernel to testing
be569ce
ENH: Add python wrapping
700993d
ENH: Remove unecessary IO in TEST_DEPENDS
5854377
ENH: Add missing ITKMesh
5cc3138
COMP: Prepend CMake options with PrincipalComponentAnalysis
31e70d9
ENH: Remove unused declarations in itkVectorKernelPCATest.cxx
ec58517
BUG: Example (VectorKernelPCA) was missing dependencies
fbudin69500 91768ad
ENH: Merge pull request #1 from fbudin69500/example_depends
johan-andruejol 8f5a356
ENH: Honor the ITK conventions to name modules, flags and folders.
34c812d
STYLE: Improve the itkVectorFieldPCA class style.
a2c4f9d
ENH: Improve code coverage for itk::VectorFieldPCA.
f4fcf71
ENH: Merge pull request #2 from jhlegarreta/ImproveCodeCoverage
thewtex cbb07bf
STYLE: Merge pull request #3 from jhlegarreta/ImproveStyle
thewtex a63ebd3
ENH: Include the ITK_MANUAL_INSTANTIATION macro.
56a1b73
ENH: Merge pull request #4 from jhlegarreta/AddSupportForExplicitInst…
thewtex 792f289
ENH: Merge pull request #1 from jhlegarreta/HonorITKConventionsForMod…
266950c
ENH: Require cmake minimum version to be 3.9.5.
2d48e67
COMP: Merge pull request #6 from jhlegarreta/ChangeRequiredCMakeMinim…
dzenanz 9dab269
COMP: Remove deprecated code usages
hjmjohnson 340c88d
ENH: ITKv5 override consistency
hjmjohnson 5b2d1c9
COMP: Use C++11 override directly
hjmjohnson 956382b
ENH: Remove unused variables.
hjmjohnson e32c119
ENH: Merge pull request #7 from InsightSoftwareConsortium/ITKv5
hjmjohnson f09d0f9
COMP: Move ITK_DISALLOW_COPY_AND_ASSIGN calls to public section.
de012a5
ENH: Merge pull request #8 from jhlegarreta/MoveDISALLOWCOPYANDASSIGN…
thewtex 520b37f
COMP: Set the minimum required CMake version to 3.10.2.
3e91364
COMP: Merge pull request #9 from jhlegarreta/UpdateCMakeMinimumRequir…
thewtex b6db56e
DOC: Add missing LICENSE file
thewtex 07ff0cf
DOC: Merge pull request #13 from thewtex/license
jhlegarreta 007d67c
STYLE: Prefer C++11 type alias over typedef.
jhlegarreta 5ef7ec7
ENH: Merge pull request #16 from jhlegarreta/PreferC++1TypeAliasOverT…
hjmjohnson 7437995
COMP: Future proof vnl_math_XXX function usage.
hjmjohnson c2ea9ed
STYLE: Remove unnecessary vcl_XXX.h headers
hjmjohnson c219e68
STYLE: Cast the binary data to the testing framework.
jhlegarreta b6ee01b
ENH: Use the ITK CMake macros to build examples.
jhlegarreta 8fe60f1
STYLE: Remove tabs as per ITK style.
jhlegarreta e0ba1cf
COMP: Merge pull request #23 from jhlegarreta/UseITKCMakeMacros
thewtex e1cd790
BUG: Rename wrapping/wrapping.cmake to wrapping/CMakeLists.txt
thewtex f30dcd9
BUG: ITK_EXPORT to ITK_TEMPLATE_EXPORT
thewtex cc1a3eb
COMP: Allow compiler to find itk::GaussianDistanceKernel definition
thewtex 7ee16b7
COMP: Fix Evaluate argument and return value types
thewtex ec89207
COMP: Merge pull request #24 from jhlegarreta/RemoveTabsFromCMakeLists
thewtex d02a58c
ENH: Merge pull request #22 from jhlegarreta/CastDataBinariesToTestin…
thewtex b145d6f
COMP: Merge pull request #26 from thewtex/wrapping-CMakeLists.txt
thewtex 663e34a
STYLE: Add ITK prefix to testing macros
jhlegarreta ab04d41
ENH: Add .gitattributes to allow running ITK clang-formatting scripts
hjmjohnson 9cd32ed
STYLE: Convert CMake-language commands to lower case
hjmjohnson ad96aa8
PERF: emplace_back method results in potentially more efficient code
hjmjohnson 31c44b1
STYLE: Prefer = default to explicitly trivial implementations
hjmjohnson d6281df
STYLE: Remove redundant void argument lists
hjmjohnson f890741
STYLE: Use default member initialization
hjmjohnson db4fa6d
DOC: Update copyright assignment to NumFOCUS
hjmjohnson 529a6a8
STYLE: Rename ITK_DISALLOW_COPY_AND_ASSIGN to ITK_DISALLOW_COPY_AND_MOVE
mseng10 a0869b4
COMP: Remove inclusion of .hxx files as headers
hjmjohnson 47cef39
ENH: Bump ITK and replace http with https using script
tbirdso fd3f895
ENH: Convert from md5 to .cid tags.
hjmjohnson 3b09ee8
ENH: Add v4 whitelist for PrincipalComponentsAnalysis ingest
hjmjohnson e41c3c3
ENH: Ingest ITKPrincipalComponentsAnalysis into Modules/Numerics
hjmjohnson 2909ac5
DOC: Add PrincipalComponentsAnalysis README pointing at upstream
hjmjohnson 8b54cbb
COMP: Remove PrincipalComponentsAnalysis .remote.cmake (in-tree)
hjmjohnson 101932c
ENH: Enable Module_PrincipalComponentsAnalysis in configure-ci
hjmjohnson c51445a
COMP: Address PrincipalComponentsAnalysis review concerns
hjmjohnson 79b9244
STYLE: Address Greptile review on PrincipalComponentsAnalysis
hjmjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| project(PrincipalComponentsAnalysis) | ||
|
|
||
| itk_module_impl() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
245 changes: 245 additions & 0 deletions
245
Modules/Numerics/PrincipalComponentsAnalysis/include/itkVectorFieldPCA.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; | ||
|
|
||
| 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.