Skip to content

ImageFileReader: add diagnostics for reduced-dimensional reads #6942

Open

Description

@agourakis82

Status after #6977 (2026-10-26)

The direction-collapse policy work from #6918 and #6948 is now consolidated in the open draft #6977. That proposal adds reader strategy selection and shares the implementation with the extraction filters. This issue remains the separate diagnostics follow-up; it does not request another collapse-policy implementation.

The outstanding diagnostics are still the input/output dimensions, discarded extents and an actual direction fallback, with an explicit decision for implicit singleton axes and repeated/streamed updates. Those details should follow the API decision in #6977.

Original report

Follow-up requested in the review of #6918:
#6918 (review)

ImageFileReader can read a higher-dimensional file into a lower-dimensional output and select the first slice or volume without warning that trailing axes were discarded. A retained direction may also fall back to identity when it cannot be preserved. The direction correction in #6918 should stay separate from diagnostics for that reduction.

Could the reader emit a diagnostic that identifies the input and output dimensions, the discarded extents, and any direction fallback? The policy for implicit singleton axes should be decided explicitly, so ordinary single-slice reads do not become noisy merely because an ImageIO reports an extra dimension.

Useful regression coverage would distinguish a time-series or volume axis with more than one sample from an implicit singleton axis, and verify any fallback message only when direction is actually replaced. Repeated pipeline updates and streamed reads should not emit the same warning for every chunk.

Relevant paths are GenerateOutputInformation and EnlargeOutputRequestedRegion in Modules/IO/ImageBase/include/itkImageFileReader.hxx. This follow-up proposes diagnostics only; it does not request changing slice selection, pixel values, direction tolerances, or the reduction policy in #6918.

Activity

  1. github-actions commented on Oct 10, 2026

    @github-actions

    Thank you for contributing an issue! 🙏

    Welcome to the ITK community! 🤗👋☀️

    We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜
    Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

    This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.

  2. blowekamp commented on Oct 14, 2026

    @blowekamp
    Member

    This behavior in the ImageFilterReader is very similar to the ExtractImageFilter. That filter has a DirectionCollapseToStrategy member that can be configured: https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1ExtractImageFilter.html#a136c05a8390450c3623e9d2d2d5ef0cb I think the say options, strategy could be adopted by the reader to provide clear user definable behavior.

  3. gdevenyi commented on Oct 14, 2026

    @gdevenyi
    Contributor

    2. This behavior in the ImageFilterReader is very similar to the ExtractImageFilter. That filter has a DirectionCollapseToStrategy member that can be configured: https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1ExtractImageFilter.html#a136c05a8390450c3623e9d2d2d5ef0cb I think the say options, strategy could be adopted by the reader to provide clear user definable behavior.

    This is a great way to standardize. How recently has DirectionCollapseToStrategy been tested?

  4. blowekamp commented on Oct 15, 2026

    @blowekamp
    Member

    There is an existing way to achieve this with ITK. If you connect the ImageFilerReader->ExtractImageFilter where the ImageFileReader is the full dimension of the Image in the file, then the ExtractImageFilter can be configured to collapse the dimensions, or raise an exception as desired with the policy. This is similar to the structure used in SimpleITK for reader, and a the refinement of adding the collapse strategy is proposed here: SimpleITK/SimpleITK#2756

    Second in an effort to reuse code, a refactoring of the ExtractImageFilter was done to expose the method and implementation of the collapse strategy so that it could be reused here in #6948. I didn't explore how that could be used in the ImageFileReader or if there are other parts in ITK where the functionality could be reused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions