ENH: Support genuine 4D (x,y,z,time) MINC images#6586
Conversation
|
@vfonov could you review? This changes MINC time-dimension handling (now genuine 4D |
e8ba066 to
e3e48cb
Compare
The MINC time dimension now maps to a 4th ITK dimension; the vector_dimension maps to components. Component count no longer selects the written dimension kind, so time and vector survive a round-trip. Change-Id: I155561693ee98c5677b2dfa125fc9990e7721bb2
e3e48cb to
4556b1b
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates itk::MINCImageIO to treat MINC files with a true time dimension as genuine 4D ITK images (itk::Image<T,4>) instead of folding time into the component count, while keeping MINC vector_dimension mapped to ITK components. This resolves the time↔vector “flip” on round-trips and lifts the previous 3D-only write limitation to allow 4D (3 spatial + time) volumes.
Changes:
- Read path: map MINC
time(MI_DIMCLASS_TIME) to an additional ITK dimension (highest), and keep MINCvector_dimensionmapped to ITK components. - Write path: always write ITK components as MINC
vector_dimension, and write the 4th ITK dimension as MINCtime(reject >4D). - Tests: migrate the existing “4D” MINC test to
itk::Image<float,4>and add a synthetic 4D round-trip that asserts time origin/spacing preservation; add cleanup for the synthetic output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Modules/IO/MINC/src/itkMINCImageIO.cxx | Implements the dimension-class-based mapping for read/write, enabling genuine 4D time series and fixing time/vector ambiguity. |
| Modules/IO/MINC/include/itkMINCImageIO.h | Updates SupportsDimension to allow up to 4D images (plus degenerate 0 case). |
| Modules/IO/MINC/test/itkMINCImageIOTest2.cxx | Expands the dimension-support expectation to include 4D. |
| Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx | Converts the test to scalar 4D images and adds a synthetic 4D time-geometry/value round-trip check. |
| Modules/IO/MINC/test/CMakeLists.txt | Ensures the new synthetic MINC output is removed as a temporary test file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Filename | Overview |
|---|---|
| Modules/IO/MINC/include/itkMINCImageIO.h | Updates MINC dimension support from 3D to 4D. |
| Modules/IO/MINC/src/itkMINCImageIO.cxx | Maps time to an ITK dimension and keeps vector data as components. |
| Modules/IO/MINC/test/CMakeLists.txt | Adds cleanup for the synthetic 4D test output. |
| Modules/IO/MINC/test/itkMINCImageIOTest2.cxx | Updates the supported-dimension expectation. |
| Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx | Migrates the 4D test to itk::Image<float, 4> and adds time geometry checks. |
Reviews (1): Last reviewed commit: "ENH: Support genuine 4D (x,y,z,time) MIN..." | Re-trigger Greptile
|
It was done this way to handle DWI acquisitions. And something else, that i don't remember now. |
I was updating https://github.com/gdevenyi/minc-diff-labels to use SimpleITK so I can be agnostic to the filetypes and it fell over on the MINC file saving, so I went to investigate. If you expand the design "Design rationale" section in the PR top you'll find this maintains the existing implementation for the example DWI tests included in the repo. |
MINC volumes with a time dimension now map to a genuine
itk::Image<T,4>instead of folding time into components;vector_dimensionstill maps to components. Fixes the time↔vector round-trip flip and the 3D-only write limit.Design rationale
Mapping is now by MINC dimension class rather than component count:
MItime/MItfrequency(MI_DIMCLASS_TIME) → a 4th ITK dimension;tstep→spacing[3],tstart→origin[3], orthogonal direction.MIvector_dimension(MI_DIMCLASS_RECORD) → ITK components (deformation grids, DTI, RGB, tensors — unchanged).MIxspace/MIyspace/MIzspace→ spatial dims.Apparent dimension order is
[time, z, y, x, vector](slowest→fastest), matching theRead()/Write()hyperslab arrays.SupportsDimensionnow allowsdim < 5.Behavior change: a MINC file with a
timedimension previously read asVectorImage<T,3>(time as N components) and now reads asImage<T,4>.vector_dimensionfiles are unchanged.itkMINCImageIOTest_4Dwas migrated fromVectorImage<float,3>toImage<float,4>; the fixturedti_sample.mncis a 32-frame time series.Test results
ctest -R MINCImageIOTest— 119/119 pass (incl. migrated 4D test, multi-component vector round-trips).ITKIOTransformMINCfunctional tests (itkIOTransformMINCTest,itkMINCTransformAdapterTest) — pass; deformation-grid path (Image<Vector<double,3>,3>↔vector_dimension) unaffected.Image<float,4>round-trip assertingspacing[3]/origin[3]map totstep/tstart.AI assistance