Skip to content

ENH: Ingest ITKIOFDF into Modules/IO#6215

Merged
hjmjohnson merged 65 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-iofdf
May 5, 2026
Merged

ENH: Ingest ITKIOFDF into Modules/IO#6215
hjmjohnson merged 65 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-iofdf

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Ingests ITKIOFDF (read support for the FDF flexible-data-format files produced by Varian / Agilent MR scanners — itk::FDFImageIO + factory) into Modules/IO/IOFDF/ using the v4 ingestion pipeline. Tier-A Wave-1 candidate from #6160. Upstream: InsightSoftwareConsortium/ITKIOFDF at 3a3ff84c; will be archived after this lands.

Sanitizer report (Phase A)
Final history:  100 → 55 commits, 32 → 14 merges
README.rst -> .md fixes: 0
standalone-guard rm:     0

One small post-Phase-A STYLE: follow-up was needed: Modules/IO/IOFDF/src/CMakeLists.txt (3 lines) was sniffed as text rather than cmake by the sanitizer's content classifier and bypassed gersemi. Manual gersemi-format applied in commit fc131e87. Future refinement to sanitize-history.py:sniff_kind() could force any path basename matching CMakeLists.txt or *.cmake to kind=cmake regardless of content sniff.

Topology and CI expectations
Property Value
Total PR commits 60 (55 rewritten upstream + 4 ITK-side follow-ups + 1 STYLE gate-fixup)
Merge commits preserved 15
Root commits 1 (unavoidable upstream root — see v4 strategy doc)
Branch base upstream/main @ 777a69ffab (zero commits behind at push time)

Expected CI state: all green except ghostflow-check-main's single root-commit error — accepted per INGESTION_STRATEGY_v4.md §"Known artifacts at PR-review time".

Local verification
  • pre-commit run --all-files → exit 0
  • cmake -DModule_IOFDF:BOOL=ON . configure clean
  • ninja IOFDFTestDriver 9/9 build steps OK
  • ctest -R IOFDF: 3/3 tests pass (no ExternalData fetches required)
    • IOFDFKWStyleTest
    • IOFDFInDoxygenGroup
    • itkFDFImageIOTest
Phase B (post-merge) plan

Once this PR lands on main:

~/src/ITK-ingest-v4/Utilities/Maintenance/RemoteModuleIngest/archive-remote-module.sh IOFDF

Phase B publishes the upstream-side removal commit (whitelisted files deleted, MIGRATION_README.md promoted to README.md) directly to InsightSoftwareConsortium/ITKIOFDF's main and flips archived=true on the GitHub repo settings, per feedback_ingest_archive_readme.md.

Kent Williams and others added 30 commits May 15, 2014 13:34
FDF files seem to have 3D rotation matrices even
if the image is 2D. This can give them degenerate
directions cosines.  If that's the case punt and
use identity direction cosines.
This method is expected and with out it a link error is generated.
The modules name is inconsistent and causing not to be used as a
module in ITK. Previously ITK was calling itk FDFImageIO, while
internally it was called ITKFDFImageIO. Neither name followed ITK
conventions. The correct name for an external module does not begin
with the ITK prefix and for this case should be: IOFDF

The name of the module and related variable, libraries, export
specifications etc, have been rename consistently.
Exclude from default. When this remote module was already downloaded, it was automatically turned enabled by default.

Remove modules should not be enable by default
Moved "common" code to itk namespace.

Fixed variable alignment and header guarders.
STYLE: fixes according to KWStyle
Set the required doxygen ingroup.
BUG: Fix IOFDFInDoxygenGroup test
BUG: Correct test function signature for windows
Suggested-by: Hans Johnson <hans-johnson@uiowa.edu>
Add Hans' style fixes and remove old internal copy.
Assign copyright to the Insight Software Consortium and use the Apache 2
license, ITK's current license.

This will be merged pending approval by Glenn Pierce.
ENH: Update the license header to the ISC copyright.
This commit updates CMakeLists.txt to ensure built library is shared. It
also uses "RegisterFactoryInternal" to make sure the factory is
registered once into the ImageIOFactory.

See InsightSoftwareConsortium/ITK@39b4ab3 (BUG: Internal factory must
use RegisterFactoryInternal method) for more details.

See ITK issue InsightSoftwareConsortium#3393
https://issues.itk.org/jira/browse/ITK-3393
STYLE: Use Macro for Function Deletion
This new parameter allows ITK to be aware any object that needs to be registered
to the ITK factory. Remote modules that offer IO capabilities can be more easily
integrated in ITK.
ENH: Add FACTORY_NAMES parameter to itk_module() declaration
Require CMake minimum version to be 3.9.5 following ITKv5 requiring
C++11:
https://discourse.itk.org/t/minimum-cmake-version-update/585
…mumVersio

n

ENH: Require cmake minimum version to be 3.9.5.
Comment thread Modules/IO/IOFDF/src/itkFDFImageIO.cxx
Comment thread Modules/IO/IOFDF/src/itkFDFImageIO.cxx
Comment thread Modules/IO/IOFDF/itk-module.cmake
Comment thread Modules/IO/IOFDF/src/ImageReadWrite.cxx Outdated
Comment thread Modules/IO/IOFDF/include/itkFDFImageIOFactory.h Outdated
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
The Phase A sanitizer's text/cmake classifier did not pick this small
file up as 'cmake' (its sniff treated it as 'text'), so gersemi's pass
was skipped.  Apply the formatter now to satisfy ITK's pre-commit
gersemi hook.  Same one-off observed on PR InsightSoftwareConsortium#6215 (IOFDF).
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
Three upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6215:

1. CanReadFile threw an ITK ExceptionObject when the file couldn't be
   opened.  ITK's ImageIOFactory contract requires CanReadFile to
   return false for unreadable files; throwing aborts every probe of
   non-FDF files in itk::ImageIOFactory::CreateImageIO.  Replaced the
   throw with a return false.

2. ReadImageInformation() iterated 'i < GetNumberOfDimensions()' and
   indexed m_Roi[i] without checking m_Roi.size().  Files lacking a
   'roi' header field would silently read out-of-bounds.  Added an
   itkExceptionMacro guard that surfaces the missing entries.

3. itk-module.cmake DEPENDS listed ITKNIFTI as a copy-paste artefact;
   no FDF source includes any NIFTI header or uses any NIFTI type.
   Removed the spurious dependency.
@hjmjohnson hjmjohnson marked this pull request as ready for review May 5, 2026 15:08
Comment thread Modules/IO/IOFDF/src/itkFDFImageIO.cxx
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good on a glance.

Comment thread Modules/IO/IOFDF/CMakeLists.txt Outdated
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
Upstream remote modules typically begin their top-level CMakeLists.txt
with their own cmake_minimum_required(VERSION X.Y.Z) declaration, often
3.10.2 or earlier.  ITK's top-level CMakeLists pins a higher minimum,
so the per-module line is redundant and frequently *lower* than ITK's
floor.  @dzenanz flagged it on every ingest with the comment 'Version
behind, not needed.' — most recently on PR InsightSoftwareConsortium#6215 (IOFDF).

Add patch_drop_cmake_minimum_required() that detects the idiom and
removes the matching line via a multiline regex.  Track count via
sanitizer.cmake_min_required_drops and print it in the run summary.
Apply alongside patch_standalone_build_guard() in the cmake-blob
branch of blob_callback.
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on a glance.

@hjmjohnson hjmjohnson added this to the ITK 6.0 Release Candidate 1 milestone May 5, 2026
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
The Phase A sanitizer's text/cmake classifier did not pick this small
file up as 'cmake' (its sniff treated it as 'text'), so gersemi's pass
was skipped.  Apply the formatter now to satisfy ITK's pre-commit
gersemi hook.  Same one-off observed on PR InsightSoftwareConsortium#6215 (IOFDF).
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
Three upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6215:

1. CanReadFile threw an ITK ExceptionObject when the file couldn't be
   opened.  ITK's ImageIOFactory contract requires CanReadFile to
   return false for unreadable files; throwing aborts every probe of
   non-FDF files in itk::ImageIOFactory::CreateImageIO.  Replaced the
   throw with a return false.

2. ReadImageInformation() iterated 'i < GetNumberOfDimensions()' and
   indexed m_Roi[i] without checking m_Roi.size().  Files lacking a
   'roi' header field would silently read out-of-bounds.  Added an
   itkExceptionMacro guard that surfaces the missing entries.

3. itk-module.cmake DEPENDS listed ITKNIFTI as a copy-paste artefact;
   no FDF source includes any NIFTI header or uses any NIFTI type.
   Removed the spurious dependency.
hjmjohnson and others added 10 commits May 5, 2026 12:12
Brings IOFDF from a configure-time remote fetch into the ITK
source tree at Modules/IO/IOFDF/ using the v4 ingestion
pipeline (whitelist filter-repo + per-commit clang-format + black +
commit-prefix sanitization).

Upstream repo:  https://github.com/InsightSoftwareConsortium/ITKIOFDF.git
Upstream tip:   3a3ff84c803d4226176078d32ddd0760c71a5b2c
Ingest date:    2026-05-05
Whitelist:      IOFDF.list

Per-commit transforms applied across all 55 commits:
  - filter-repo --paths-from-file (whitelist)
  - filter-repo --to-subdirectory-filter Modules/IO/IOFDF
  - 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: 32 -> 14 merge(s).

Primary author: Hans Johnson <hans-johnson@uiowa.edu>

Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov>
Co-authored-by: Dženan Zukić <dzenan.zukic@kitware.com>
Co-authored-by: Francois Budin <francois.budin@kitware.com>
Co-authored-by: Gaëtan Lehmann <gaetan.lehmann@gmail.com>
Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Co-authored-by: Jon Haitz Legarreta <jhlegarreta@vicomtech.org>
Co-authored-by: Jon Haitz Legarreta Gorroño <jon.haitz.legarreta@gmail.com>
Co-authored-by: Kent Williams <norman-k-williams@uiowa.edu>
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: Tom Birdsong <tom.birdsong@kitware.com>
Co-authored-by: Zach Williamson <zachary-williamson@uiowa.edu>
The Phase A sanitizer's text/cmake classifier did not pick this small
file up as 'cmake' (its sniff treated it as 'text'), so gersemi's pass
was skipped.  Apply the formatter now to satisfy ITK's pre-commit
gersemi hook.
Three upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6215:

1. CanReadFile threw an ITK ExceptionObject when the file couldn't be
   opened.  ITK's ImageIOFactory contract requires CanReadFile to
   return false for unreadable files; throwing aborts every probe of
   non-FDF files in itk::ImageIOFactory::CreateImageIO.  Replaced the
   throw with a return false.

2. ReadImageInformation() iterated 'i < GetNumberOfDimensions()' and
   indexed m_Roi[i] without checking m_Roi.size().  Files lacking a
   'roi' header field would silently read out-of-bounds.  Added an
   itkExceptionMacro guard that surfaces the missing entries.

3. itk-module.cmake DEPENDS listed ITKNIFTI as a copy-paste artefact;
   no FDF source includes any NIFTI header or uses any NIFTI type.
   Removed the spurious dependency.
Not listed in src/CMakeLists.txt (so the build is unaffected by its
presence), but carries a hardcoded /home/glenn absolute path, imports
VTK headers the IOFDF module does not declare as dependencies, and
runs an infinite while(1) viewer->Render() loop.  Pure noise from the
upstream remote module's developer environment.
itkFDFImageIO.h had \ingroup IOIOFDF (typo), itkFDFImageIOFactory.h
had \ingroup ITKIOFDF (the old upstream remote-module name).  The
in-tree module is named 'IOFDF', so both must use \ingroup IOFDF for
the classes to appear in the module's Doxygen group.
The line cmake_minimum_required(VERSION 3.10.2) survived the upstream
ingest.  ITK's top-level CMakeLists already pins a higher minimum (and
the project's policy is that ingested module CMakeLists do not declare
their own minimum), so the per-module line is dead code.  Address
@dzenanz review comment.
ReadImageInformation() guarded its parsing block on tokens.size() == 4,
which silently drops every header line whose value contains a space —
notably 'unsigned char' / 'unsigned short' / 'unsigned int' / 'unsigned
long' storage types.  ParseLine strips the FDF C-style decoration and
Tokenize splits on ' ;', producing five tokens for those values; the
== 4 check then filtered them out and the value-comparison branches
that handled them became unreachable.

Loosen the guard to tokens.size() >= 4 and re-join tokens[3..N-1] into
a single space-separated value so the existing 'unsigned char' /
'unsigned short' / etc. branches actually fire.  Header lines with
multi-word vector values (e.g. orientation, span, origin, roi) were
already handled correctly because their parsers split on ',' /
StringToVector, which tokenize the value internally; the only
behaviour change is that previously-skipped scalar 'unsigned X'
storage types now reach the SetComponentType dispatch.
@hjmjohnson hjmjohnson merged commit ce991b3 into InsightSoftwareConsortium:main May 5, 2026
14 of 17 checks passed
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
The Phase A sanitizer's text/cmake classifier did not pick this small
file up as 'cmake' (its sniff treated it as 'text'), so gersemi's pass
was skipped.  Apply the formatter now to satisfy ITK's pre-commit
gersemi hook.  Same one-off observed on PR InsightSoftwareConsortium#6215 (IOFDF).
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
Three upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6215:

1. CanReadFile threw an ITK ExceptionObject when the file couldn't be
   opened.  ITK's ImageIOFactory contract requires CanReadFile to
   return false for unreadable files; throwing aborts every probe of
   non-FDF files in itk::ImageIOFactory::CreateImageIO.  Replaced the
   throw with a return false.

2. ReadImageInformation() iterated 'i < GetNumberOfDimensions()' and
   indexed m_Roi[i] without checking m_Roi.size().  Files lacking a
   'roi' header field would silently read out-of-bounds.  Added an
   itkExceptionMacro guard that surfaces the missing entries.

3. itk-module.cmake DEPENDS listed ITKNIFTI as a copy-paste artefact;
   no FDF source includes any NIFTI header or uses any NIFTI type.
   Removed the spurious dependency.
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…est-iofdf

ENH: Ingest ITKIOFDF into Modules/IO
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 7, 2026
Upstream remote modules typically begin their top-level CMakeLists.txt
with their own cmake_minimum_required(VERSION X.Y.Z) declaration, often
3.10.2 or earlier.  ITK's top-level CMakeLists pins a higher minimum,
so the per-module line is redundant and frequently *lower* than ITK's
floor.  @dzenanz flagged it on every ingest with the comment 'Version
behind, not needed.' — most recently on PR InsightSoftwareConsortium#6215 (IOFDF).

Add patch_drop_cmake_minimum_required() that detects the idiom and
removes the matching line via a multiline regex.  Track count via
sanitizer.cmake_min_required_drops and print it in the run summary.
Apply alongside patch_standalone_build_guard() in the cmake-blob
branch of blob_callback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module area:Python wrapping Python bindings for a class area:Remotes Issues affecting the Remote module type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants