SVR 3D viewer: memory safety + offline tumor segmentation (ONNX)#5
Open
SVR 3D viewer: memory safety + offline tumor segmentation (ONNX)#5
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…arate modules This refactoring improves the SVR codebase by: 1. Creating svrUtils.ts - shared utility functions: - clamp01: Clamps values to [0,1] range - assertNotAborted: Checks abort signal for cancellation - yieldToMain: Yields control for UI responsiveness - withinTrilinearSupport: Bounds checking for trilinear interpolation - clampAbs: Clamps absolute values with NaN handling - formatMiB: Human-readable byte formatting - quantileSorted: Quantile computation from sorted arrays 2. Creating rigidRegistration.ts - well-documented rigid registration module: - Full JSDoc documentation explaining the algorithm - Exported types: Mat3, RigidParams, SeriesSamples, BoundsMm, LoadedSlice - Matrix utilities: mat3FromEulerXYZ, mat3MulVec3 - Transform functions: applyRigidToPoint, applyRigidToSeriesSlices - Registration scoring: scoreNcc (Normalized Cross-Correlation) - Optimization: optimizeRigidNcc (multi-scale coordinate descent) - Main function: rigidAlignSeriesInRoi 3. Updating reconstructionCore.ts to use shared utilities: - Imports from svrUtils.ts instead of local definitions - Reduces code duplication 4. Adding comprehensive test coverage (15 new tests): - mat3FromEulerXYZ: identity, 90° rotations, orthonormality - applyRigidToPoint: identity, translation, rotation, combined - boundsCenterMm: positive and negative coordinates - scoreNcc: empty samples, insufficient samples, perfect correlation
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
This PR hardens the SVR 3D volume workflow for power-user (large
maxVolumeDim) cases by reducing peak allocations, making GPU usage budget-aware, and tightening segmentation tooling so it fails safely instead of crashing the tab.It also upgrades seeded 3D region-growing segmentation to be interactive (live tolerance preview + ROI guidance), so you can iterate quickly without committing labels on every slider tweak.
Key user-visible changes:
What’s in this PR
SVR + 3D viewer memory/stability
SvrVolume3DModalnow rendersSvrVolume3DViewerinstead of maintaining a separate WebGL implementation.Interactive seeded 3D region growing (seed + live tolerance + ROI)
guide(default) vshard.guidemode) to tighten tolerance outside the ROI.regionGrow3D updates
regionGrow3D()returns aUint32Arrayof voxel indices and uses a 1-bit visited bitset (avoidsUint8Array(nvox)masks).seedIndices?: Uint32Arrayso users can grow multiple disjoint islands in one operation.roi?: { min/max, mode: "hard" | "guide", outsideToleranceScale? }:hard: never accepts voxels outside ROI.guide: accepts outside ROI only if the intensity falls within a tighter (seed-centered) range derived fromoutsideToleranceScale.tests/segmentation3d.test.ts).ONNX preflight guardrail
Tooling
npm run prettier/npm run prettier:checkImplementation notes
Render LOD plumbing
frontend/src/utils/svr/renderLod.ts.buildRenderVolumeTexData) with periodic yields for responsiveness.regionGrow3D memory model
mask = new Uint8Array(nvox).visited:Uint32Array((nvox + 31) >>> 5)(1 bit/voxel)queue:Uint32Array(maxVoxels)which is also returned asindices.subarray(0, count)indiceslist.Live preview label overlay
prevIndices+prevValues) before applying the next preview.Uint8Array(nvox)per slider move.ONNX preflight
C=4channels) and blocks by default above a conservative logits budget.How to test
From
frontend/:npm run lintnpm run testManual (SVR 3D viewer):
Notable unit coverage includes:
tests/segmentation3d.test.ts)tests/onnxTumorSegmentation.test.ts,tests/onnxLogitsToLabels.test.ts)