Repository navigation
Add 64-bit integer support and fix intensity windowing for tiny units - #5
Merged
Merged
Conversation
NIfTI datatypes 1024/1280, MIF Int64/UInt64 and NRRD 64-bit integer types were rejected, which broke numpy-generated label maps (int64 is NumPy's default integer dtype). Add them to MiqDatatype, decode them through double -> float like MIQCore, make them label-detection candidates, and give ScanVolume0's binary-mask confirm a 64-bit arm. Port of MIQ 2cf1764. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYbaAXasvPKzEgLcoESA9s
IntensityWindow.GetBounds preferred the |v| > 1e-6 subset, so data in tiny units (an SI-unit ADC map, ~1e-9) had no foreground subset and was windowed over tissue plus background zeros. When the floored subset is too small, exactly-non-zero values now stand in. Ordinary data is unchanged (pinned bit-identical against the previous implementation). Port of MIQ bcf3e18. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYbaAXasvPKzEgLcoESA9s
ScanVolume0 and CollectVolume0Labels took the per-voxel walk whenever ElementStrides was set, and MifParser always sets it, so every MIF mask paid for it. Key off Volume0IsContiguous instead: volume 0 is the first W*H*D elements in some order, which is all these order-independent scans need. A 256^3 MIF mask's BuildSegmentationLut drops from ~750 ms to ~30 ms; layouts with the volume axis faster than a spatial one still walk. Port of the mask-scan part of MIQ 8323423. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYbaAXasvPKzEgLcoESA9s
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.
This PR ports three fixes from MIQCore to enable proper handling of 64-bit integer data and improve intensity windowing for data in tiny units.
Summary
Adds support for 64-bit integer voxel types (Int64/Uint64) which are commonly used by NumPy and scientific imaging tools, fixes intensity window computation for data with very small magnitudes (e.g., SI-unit ADC maps), and optimizes label detection for MIF files with custom memory layouts.
Key Changes
64-bit Integer Support (Int64DatatypeTests.cs)
MiqDatatype.Int64(1024) andMiqDatatype.Uint64(1280) enum valuesMiqVolume.RawVoxelValue()and label scanningIntensity Window Fix for Tiny Units (TinyUnitWindowTests.cs)
IntensityWindow.GetBounds()to use a two-tier approach for selecting the foreground subsetNonZeroFloor(1e-6) to drop interpolation residueBinary Mask Layout Optimization (BinaryMaskLayoutTests.cs)
Volume0IsContiguousproperty to detect when volume 0 occupies the first W·H·D payload elements regardless of axis orderImplementation Details
Volume0IsContiguouschecks that spatial strides (when sorted) follow the pattern 1, d₀, d₀·d₁, independent of axis permutation