Repository navigation
Fix black previews of off-center masks and >4 GiB .nii.gz expansion - #2
Merged
Merged
Conversation
Off-center masks: when the three center slices hold only background, the segmentation LUT and intensity window were derived from zeros, so every slice rendered black and window/level drag was inert. Now: - label detection collects labels from all of volume 0 when the center sample is empty (single label -> white mask LUT, several -> colour LUT); - a null or degenerate center-slice window falls back to a window over the whole volume at that timepoint (strided to at most 1M samples, widened to include the background value); - the window/level drag reference span falls back to a non-zero value. .nii.gz > 4 GiB: ParsePartial decided ExpansionBlocked from the gzip ISIZE footer, which is the size mod 2^32. A >4 GiB series could report a small ISIZE, be offered an expansion that cannot fit a byte[], and end on a permanent "loading..." after a multi-GB decompression. The decision now uses the header-derived file size (NiftiFileExtent), and a stream that ends inside volume 0 goes to the full parse, which reports the truncation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XqBwhnTRsqxk3SEvp9z4T9
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.
Summary
1. Masks whose foreground misses the center slices rendered black everywhere
The segmentation LUT and the intensity window were derived only from the three center slices. For a lesion or single-ROI mask that misses all three, the labels were empty (no LUT) and the window was
Bounds(0,0), so every slice rendered black, and window/level drag was inert (_winRefSpan == 0).MiqVolume.DetectSegmentationLut(shared by the initial load and post-expansion): when the center sample is all background, collect labels from all of volume 0. A single label gives the white mask LUT; several give a colour LUT.MiqVolume.WindowFromSlices: a null or degenerate center-slice window falls back toVolumeWindow, a window over the whole volume at that timepoint (two passes, at most 1M strided samples), widened to include the background value. Used byCenterInteractiveStateand the per-volumeSharedWindow.MiqTriPlanarControl: the W/L reference span falls back to a non-zero value, so right-drag works on a constant volume.2.
.nii.gzover 4 GiB uncompressed was offered an expansion that cannot succeedParsePartialdecidedExpansionBlockedfrom the gzip ISIZE footer, which is the size mod 2^32. Example: a 91×109×91×1200 float32 series (4,332,619,552 B) reports ISIZE 37,652,256, so it was not blocked. The first scrub then decompressed toward 2 GB, threw, and the swallowed error left "loading…" on screen permanently.MiqParser.NiftiFileExtent: vox_offset + every dim × bytes per voxel). ISIZE is no longer used inParsePartial.Behaviour changes
.nii.gzthat holds exactly one volume of data now loads as a partial preview instead of a full parse. Missing volumes render black, as they already did in the full parse.Tests
SegmentationDetectionTests: off-center binary mask (white LUT), off-center multi-label (colour LUT), window fallback with theOffsetting (window [0,1], mask pixels visible), all-zero volume stays degenerate.GzipPartialBlockingTests(non-parallel collection, because it lowersMaxArrayBytes): wrapped ISIZE with too-large header is blocked, fitting header is expandable, few-volume too-large file stays blocked, truncated volume 0 throws,NiftiFileExtent.Not yet built or run: the authoring environment had no .NET SDK (download blocked by network policy), and CI builds only the plugin, not
MIQ.Tests. Please rundotnet buildanddotnet testlocally before merging.🤖 Generated with Claude Code
https://claude.ai/code/session_01XqBwhnTRsqxk3SEvp9z4T9
Generated by Claude Code