Read the qform ParaVision actually writes, and run the NIfTI oracle in CI (#182) - #183
Merged
headmeister merged 1 commit intoJul 27, 2026
Conversation
…ixes isi-nmr#182 test_affine_agrees_with_the_paravision_nifti_sform failed its own `assert sform_code > 0` guard before it ever compared a matrix, and skipped entirely in CI, so it reported nothing either way. NIfTI-1 stores the affine two independent ways and a file need only carry one. All 14 PV360_StdData exports write the quaternion (qform_code=1) and leave the sform zeroed, which is method 2 and within the standard; the helper read offset 280 regardless. Decoding the qform instead, the export agrees with the VisuCore-derived affine to 4.8e-07 everywhere -- obliques, the negative determinant UTE3D volume and the diffusion series included -- so the oracle was sound and silently confirming the geometry all along. The helper now takes the sform when there is one, the qform otherwise, and fails only when a file declares neither. Coverage follows what is on disk rather than a list of five, which brings in the four diffusion reconstructions and T2map_MSME, T2star_FID_EPI and T2star_map_MGE: 14 reconstructions, 166 volumes. Every volume of an export is checked rather than whichever one the filesystem yielded first, which also pins the export as internally consistent. conftest smudged only 2dseq/traj/rawdata.job*, so the .nii files stayed LFS pointers in CI and the check skipped itself there. They are 54 MB of a 1.7 GB dataset, and the cache key gains a suffix so the newly required media are fetched once rather than on every run. 2124 passed, 12 skipped, no failures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NuK1cZi8U54WXAdXMmGpzy
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #182.
test_affine_agrees_with_the_paravision_nifti_sformtripped its ownassert sform_code > 0before it ever compared a matrix, and skipped entirely in CI — so it reported nothing either way.Read the form the writer populates
NIfTI-1 stores the affine two independent ways and a file need only carry one. All 14
PV360_StdDataexports write the quaternion (qform_code=1) and leave the sform zeroed — method 2, squarely within the standard — while the helper read offset 280 regardless.Decoding the qform instead, the export agrees with the VisuCore-derived affine to 4.8e-07 everywhere: obliques, the negative-determinant
UTE3Dvolume and the diffusion series included. The oracle was sound the whole time and silently confirming the geometry.nifti_affinenow takes the sform when there is one, the qform otherwise, and fails only if a file declares neither — so it keeps working if a future ParaVision writes both.Cover what is on disk
Coverage follows the
nifti/directories that exist rather than a hardcoded five, which brings in the four diffusion reconstructions plusT2map_MSME,T2star_FID_EPIandT2star_map_MGE: 14 reconstructions, 166 volumes. Every volume of an export is checked instead of whichever oneglobhappened to yield first, which also pins each export as internally consistent (they are — spread 0.0 within every directory).Where no corpus is present the parameter set is empty and the test skips cleanly, rather than erroring on
next()of an empty glob as it did before.Make it run in CI
conftestsmudged only2dseq,trajandrawdata.job*, so the.niifiles stayed LFS pointers andnifti_affinetook its skip branch..niiis now required media — 54 MB of a 1.7 GB dataset.The cache key gains a
-niftisuffix, becauseactions/cachedoes not re-save on a hit: without the bump the newly required files would be re-downloaded on every run instead of once. Drop that hunk if you would rather pay the download than invalidate the cache — the rest of the change works either way.Verification
.niifiles.🤖 Generated with Claude Code
https://claude.ai/code/session_01NuK1cZi8U54WXAdXMmGpzy