Repository navigation
ENH: Ingest ITKTotalVariation into Modules/Filtering (with ITKproxTV third-party module) - #6381
Conversation
Remove some placeholders
find_package(proxTV REQUIRED CONFIG)
Wrapped two methods: DR2_TV for 2D and the general PD_TV for 3D Weights (ie. lambdas) and norms can be changed by the user.
ExternalProject or FetchContent?
Uses ${_proxTV_lib} to handle both cases:
- using find_package(proxTV) -> proxTV::prox
- using add_subdirectory(proxTV_folder) -> proxTV
Export the targets to the module targets file:
TotalVariationTargets.cmake
The nice thing about targets, is that we only have to worry about the
proxTV targets, all its dependencies, even if built internally, are
handled.
Note that install is not handled.
TODO: Manage Eigen3 Options: system or internal with ITKEigen3
```cmake
set(_internal_cmake_eigen3)
list(GET ITKEigen3_INCLUDE_DIRS 0 _internal_cmake_eigen3)
set(Eigen3_DIR "${_internal_cmake_eigen3}/itkeigen")
```
With azure-pipelines
Also re-arranges to avoid duplication
Add itk-module-init.cmake WIP: Remove debug CMake messages SWIG is not reading the TotalVariationTargets.cmake file, where proxTV library is set, with include dirs, interface libraries and compile definitions. This creates erorrs, the first sign is missing the INCLUDE_DIRSs. (TVopt.h not found). This can be solved hacking the INCLUDE_DIRS of the ITK Module TotalVariation_INCLUDE_DIRS. Once that's fixed, the next error is missing mex.h file, this is because the compile definition NO_MATLAB is not applied. In Eigen3 I faced the same problems, but because it is header only, fixing INCLUDE_DIRS and adding the compile definitions in the Eigen3-ITK Header (itkEigen3.h) was enough. In this case, the compile definitions of proxTV (NO_MATLAB, USE_LAPACK=0) are ignored.
COMP: CMake, add INCLUDE_DIRS for swig to work
Requires ITK with patch: InsightSoftwareConsortium#707
BUG: Add compile definitions for wrapping to work
Set TotalVariation_LIBRARIES to proxTV directly
BUG: Remove src folder
Addresses Issue InsightSoftwareConsortium#26 Copy image infromation from input
…r/Issue26-ImageAxes-Change FIX: Image Axes Change
dzenanz
left a comment
There was a problem hiding this comment.
Looks good after a relatively quick look.
|
@hans May I take over this work? The modern CMake usage now available in ITK is to use the interface modules as opposed to the legacy cmake variables. Changes were made in the proxTV library fork to support this. It would be good to use the modern best practices with new code integration opposed to the older approaches (that the agents may be picking up on). Please let me know if I can continue this effort with the modern approach. |
@blowekamp YES! We're very close to closing issue #6160 for remote module ingestions. Once the open PR's are included, we will be able to close that issue! My only request is that (a) the improvements are made in the next few days, or (b) we include the minimally working ingestion as is, and follow up with improvements. Hans |
blowekamp
left a comment
There was a problem hiding this comment.
I will be taking over this PR. Mostly to work on the proxTV integration as a third party.
Awesome! Thank you. |
2ca7e11 to
cf0be3d
Compare
dzenanz
left a comment
There was a problem hiding this comment.
A significant simplification.
| itk_module_impl() | ||
| else() | ||
| # 3.23 Required for proxTV FILE_SETS, which allows for implicit installation of header files with the library target. | ||
| cmake_minimum_required(VERSION 3.23.0) |
There was a problem hiding this comment.
Ubuntu 24.04 comes with CMake 3.28.3, and Ubuntu 26.04 was released recently. Should we bump general CMake version requirement, instead of just here? Or wait for ITK 6.1 to do that?
There was a problem hiding this comment.
Version details here: https://linuxcapable.com/how-to-install-cmake-on-ubuntu-linux/
There was a problem hiding this comment.
@hjmjohnson What do you think of updating ITK's CMake version? May make some of the fetch content work easier if we are going down that route further.
There was a problem hiding this comment.
I think that getting modern CMake versions is so easy for all developers that we should be more aggressive in updating the versions. New versions of cmake can be easily downloaded via pixi, uv, simple shell commands,.
CMake version 3.28.3 seems like a great floor.
My one concern is the Slicer support. That codebase is already littered with many conditionals, so they may be receptive to bumping the cmake minimum version as well:
┌─[johnsonhj@hj] - [~/src/Slicer] - [2026-06-05 07:34:18]
└─[0] rg CMAKE_VERSION (main|✔)
Extensions/CMake/SlicerBlockBuildPackageAndUploadExtensions.cmake
230: if(CMAKE_VERSION GREATER_EQUAL "3.28")
CMakeLists.txt
6:# OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION (used for this build)
8:# between the OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION.
17:if("${CMAKE_VERSION}" VERSION_EQUAL "3.21.0")
18: message(FATAL_ERROR "CMake version is ${CMAKE_VERSION} and using CMake==3.21.0 is not supported.\nSee https://gitlab.kitware.com/cmake/cmake/-/issues/22476")
21:if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.25.0" AND "${CMAKE_VERSION}" VERSION_LESS_EQUAL "3.25.2")
22: message(FATAL_ERROR "CMake version is ${CMAKE_VERSION} and using CMake >=3.25.0,<=3.25.2 is not supported.\nSee https://gitlab.kitware.com/cmake/cmake/-/issues/24567")
912:if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.29.0")
CMake/SlicerMacroBuildScriptedCLI.cmake
47: if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
CMake/ExternalProjectDependency.cmake
469: if(NOT CMAKE_VERSION VERSION_LESS "3.16")
487: if(NOT CMAKE_VERSION VERSION_LESS "3.16")
516: if(CMAKE_VERSION VERSION_GREATER "3.0")
520: if(CMAKE_VERSION VERSION_EQUAL "3.4" OR CMAKE_VERSION VERSION_GREATER "3.4")
528: if(CMAKE_VERSION VERSION_EQUAL "3.24" OR CMAKE_VERSION VERSION_GREATER "3.24")
532: if(CMAKE_VERSION VERSION_EQUAL "3.28" OR CMAKE_VERSION VERSION_GREATER "3.28")
SuperBuild/External_python.cmake
60: if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
There was a problem hiding this comment.
@blowekamp At a worst case, if building ITKTtotalVariaion, REQUIRE cmake 3.28 or greater as a stopgap until the rest of the community hits the same floor.
|
@hjmjohnson I think I am done with the PR. It looks like it needs to be rebased due to a conflict, but with the merge and the orphan branch a simple rebase will now work. |
|
@blowekamp I will rebase this morning. |
Brings TotalVariation from a configure-time remote fetch into the ITK source tree at Modules/Filtering/TotalVariation/ using the v4 ingestion pipeline (whitelist filter-repo + per-commit clang-format + black + commit-prefix sanitization). Upstream repo: https://github.com/InsightSoftwareConsortium/ITKTotalVariation.git Upstream tip: a776d94799b7204d19b1c69c331458ed59fd0a3f Ingest date: 2026-06-02 Whitelist: default.list Per-commit transforms applied across all 55 commits: - filter-repo --paths-from-file (whitelist) - filter-repo --to-subdirectory-filter Modules/Filtering/TotalVariation - clang-format -style=file (ITK main's .clang-format) for *.cxx/.h/.hxx/... - black for *.py - heuristic ITK prefix added to commit subjects without one Merge topology preserved: 33 -> 10 merge(s). Primary author: Pablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com> Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov> Co-authored-by: Bryn Lloyd <lloyd@itis.swiss> Co-authored-by: Dženan Zukić <dzenan.zukic@kitware.com> Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu> Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com> Co-authored-by: Jon Haitz Legarreta Gorroño <jon.haitz.legarreta@gmail.com> Co-authored-by: Mathew Seng <mathewseng@gmail.com> Co-authored-by: Matt McCormick <matt.mccormick@kitware.com> Co-authored-by: Matt McCormick <matt@mmmccormick.com> Co-authored-by: Samuel Gerber <samuel.gerber@kitware.com> Co-authored-by: Tom Birdsong <tom.birdsong@kitware.com>
Add Modules/ThirdParty/proxTV, a third-party module that builds the proxTV library via FetchContent from the InsightSoftwareConsortium fork (pinned in proxTVGitTag.cmake). The module is EXCLUDE_FROM_DEFAULT and only configured when a dependent module is enabled. ITK_USE_SYSTEM_proxTV selects an external build. Uses FetchContent_MakeAvailable so proxTV is built as a proper CMake subdirectory target, giving correct export and install behavior. proxTV builds with the Eigen backend against ITK's in-tree Eigen3, under ITK's C++17 standard. Rewrite the ingested TotalVariation CMakeLists.txt for the in-tree build (itk_module_impl, no project()/ITKModuleExternal), add ITKproxTV to its dependencies, and use a literal module description.
TotalVariation is now ingested in-tree at Modules/Filtering/TotalVariation; drop the configure-time fetch declaration.
Build the in-tree TotalVariation module (EXCLUDE_FROM_DEFAULT) in CI.
OutputImageType aliased TInputImage, so the second template parameter (and the Superclass alias) silently ignored the requested output type; use TOutputImage. Cast the image size to int explicitly for the proxTV PD_TV dims argument, and fix the closing header-guard comment.
cf0be3d to
f185688
Compare
|
@blowekamp Rebased onto latest Verification |
The fetched proxTV uses find_package(Eigen3) only as a fallback when proxTV_Eigen_LIBRARIES is unset; the in-tree module left it empty (the header-only ITKEigen3_LIBRARIES), so the fallback ran and failed during the ITK build. Pass the ITK::ITKEigen3Module interface target instead, and add the itkeigen include directory so proxTV's <Eigen/...> includes resolve against ITK's prefixed Eigen headers.
|
@blowekamp Fixed the proxTV/Eigen3 in-tree wiring ( Root cause + fixYour fork only calls
Local validation (Ninja, internal Eigen3): configure clean → |
|
@blowekamp Some additional changes needed to get the builds to pass. |
blowekamp
left a comment
There was a problem hiding this comment.
Yea, this is fine it works.
I should have uninstalled the system Eigen locally to see this error mode.
The added ITK::ITKEigen3Module rep doesn't really add libraries or include or anything. And adding that manual path should really happen. I guess ideally there should be an "ITK::Eigen3"interface library that is the raw unguarded headers... or provTV should be updated to use the ITKEIGEN(x) macro.
But this is fine for now.
3609b55
into
InsightSoftwareConsortium:main
The TotalVariation module is now maintained in ITK main at Modules/Filtering/TotalVariation (ingested via InsightSoftwareConsortium/ITK#6381; the bundled proxTV dependency now lives at Modules/ThirdParty/proxTV). Delete whitelisted sources, rename README.rst to info.rst, and promote the migration notice to README.md so the GitHub landing page shows archived status.
Ingests the TotalVariation remote module into
Modules/Filtering/TotalVariation, and adds a newModules/ThirdParty/proxTVthird-party module (DCMTK-style:ExternalProject-built at build time from the ISC proxTV fork,EXCLUDE_FROM_DEFAULT, no vendored source). Builds and tests under C++17 against currentmain. Part of #6160; consumes blowekamp's ITKTotalVariation#57 (ISC-forked proxTV).Local validation:
Module_TotalVariation=ONconfigures, proxTV builds via ExternalProject under C++17 (Eigen backend), and 3/3 tests pass includingitkProxTVImageFilterTest.pre-commit run --all-filesis clean.proxTV integration model ("like DCMTK")
Modules/ThirdParty/proxTV/holds only CMake glue — proxTV source is not vendored into ITK git. It is git-cloned + built at build time viaExternalProjectfromInsightSoftwareConsortium/proxTV(tag pinned inproxTVGitTag.cmake).EXCLUDE_FROM_DEFAULT: only configured/built when a dependent module (TotalVariation) is enabled.ITK_USE_SYSTEM_proxTVselects an external build.proxTV_USE_LAPACK=OFF) against ITK's internal Eigen3, under ITK's C++17 standard (-DCMAKE_CXX_STANDARD=17). The proxTV fork needed no change for C++17.IMPORTED_LOCATION, the sourcesrc/include dir,NOMATLAB(guards proxTV'smex.h), andThreads::Threads.EXPORT_CODEso external consumers of an installed ITK resolveproxTVandTVopt.h.Commits
ENH:Ingest merge — merge-preserving filter-repo (122→56 commits, upstream merge topology + authorship preserved).COMP:Add ITKproxTV third-party module; wire TotalVariation in-tree.COMP:RemoveTotalVariation.remote.cmake.ENH:EnableModule_TotalVariationin configure-ci.DOC:Module README.STYLE:gersemi-format ingested test CMakeLists.BUG:CorrectProxTVImageFilterOutputImageType(TOutputImage, notTInputImage); explicit size→int cast; header-guard fix.Reviewer notes
cmake_install.cmake; a realmake install+ downstream-consume pass in CI would be a good confirmation..wrapcovers 2DWRAP_ITK_REAL.--comparebaseline was commented out); not added here.Per ingest workflow, upstream
ITKTotalVariationarchival is a separate post-merge follow-up.