fix: Use the image loader for dicom-seg to allow compressed images#2611
Conversation
* fix(security): Update lodash to 4.17.23 using a resolution to address CVE-2025-13465. * Removed lodash from the dev dependencies since it is in the resolutions now. * Update lodash to 4.17.23 in the docs package. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joe Boccanfuso <joe.boccanfuso@radicalimaging.com>
* refactor: replace string literals with OrientationAxis enums for better type safety and clarity in BaseVolumeViewport and getCameraVectors * feat(rendering): Add function to calculate acquisition plane reformat orientation based on image orientation patient values * feat: enhance reformat orientation handling in VolumeViewport and BaseVolumeViewport, allowing for specific axial, sagittal, and coronal reformats while maintaining base orientation references * feat: add buttons for setting viewport orientations to non-reformat, reformat, and acquisition types, enhancing user control over viewport display * fix: suppress events during camera reset in VolumeViewport to prevent premature rendering * fix(getCameraVectors): import OrientationVectors type * fix(tests): update button text in MPR Reformat visual tests * fix(tests): update MPR Reformat screenshots for Chromium and WebKit --------- Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
--------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joe Boccanfuso <joe.boccanfuso@radicalimaging.com>
* refactor the solution given * fix fetch color tables * important refactors to optimize worker functionality * refactor fetch palette data * fix clearly wrong test values * refactor as reviewer suggestions * fix: Convert 16 bit declared as 8 palette color data * fix: or condition on setting 16 bit palette data --------- Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
…eehandROI open U-shape contours (#2615) * feat(tools): implement orthogonalT and lineSegment modes for PlanarFreehandROI open U-shape contours Add two new rendering modes for the open U-shaped contour T-overlay: - 'orthogonalT': computes the T-line endpoint as the perpendicular ray-contour intersection from the chord midpoint, instead of the farthest point. Useful for LA cardiac workflows where the T must be perpendicular to the chord. - 'lineSegment': draws only the dashed chord connecting endpoints without any T-line, closing the contour visually. Also adds optional shaded fill for the enclosed region (contour + chord) when fillOpacity > 0, and centralizes variant dispatch into a single resolveVectorToPeak function to eliminate duplicated branching across drawLoop, openContourEditLoop, and renderMethods. * fix(tools): address PR review for PlanarFreehandROI U-shape modes - Use vec2.sub instead of create+set for chord vector - Replace double-loop ray intersection with single-pass dot-product approach for orthogonalT peak finding - Return null with console.warn instead of falling back to farthestT when no orthogonal intersection is found - Add 'none' option to U-shape dropdown to remove U-shape rendering - Auto-apply U-shape mode on dropdown change, remove separate button - Apply configured U-shape mode to newly drawn open contours - Add fill opacity dropdown using tool configuration - Read fillOpacity from tool config in renderMethods * refactor(tools): use vec2.dot for orthogonal T dot product calculation * Move open u shaped to utils helper --------- Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
* fix(security): Various dependency updates as a result of CVE-2026-26996. Ultimately the vulnerability was ignored because it is only exposed in itk-wasm via CLI and it is limited to build/dev environments.
* refactor: update getTextBoxCoordsCanvas function to accept element and textLines parameters for improved textbox placement across multiple annotation tools * fix: correct bounding box calculations in _drawTextGroup function to accurately reflect text box position and size * feat: implement text box overlap management with registry for improved placement accuracy - Added a text box overlap registry to track rendered text box positions. - Integrated overlap avoidance logic in getTextBoxCoordsCanvas to prevent occlusion of existing text boxes. - Updated draw and drawTextBox functions to clear and register text boxes during rendering. * refactor: enhance overlap detection in getTextBoxCoordsCanvas using AABB intersection - Replaced the previous rectangle overlap logic with a more accurate AABB intersection method. - Introduced a new utility function to convert text box rectangles to AABB format, allowing for better handling of overlap checks. - Updated the overlap detection functions to utilize the new intersection logic for improved accuracy in text box placement. * test: add unit tests for getTextBoxCoordsCanvas to validate positioning logic - Introduced a new test suite for getTextBoxCoordsCanvas to ensure correct coordinate calculations for text boxes. - Added tests for default positioning, overlap handling, and fallback mechanisms when space is limited. - Utilized a mock viewport element to simulate various scenarios for accurate testing. * style: format getTextBoxCoordsCanvas test cases for improved readability - Reformatted the test cases in getTextBoxCoordsCanvas.spec.ts to enhance code clarity. - Adjusted the indentation and line breaks for better visual structure without altering functionality. * refactor: update type assertions in getTextBoxCoordsCanvas tests for better type safety - Changed type assertions from any to unknown in getTextBoxCoordsCanvas test cases to enhance type safety and maintain code quality. - Ensured consistency in type handling across the test suite without altering existing functionality. * refactor: remove unnecessary type assertions in getTextBoxCoordsCanvas tests - Updated test cases in getTextBoxCoordsCanvas.spec.ts to eliminate type assertions from unknown to the actual type for annotationPoints and related variables. - Improved code clarity and type safety without changing the existing functionality of the tests. * chore: update tsconfig.json to exclude test files from compilation - Added an "exclude" property to tsconfig.json to prevent test files from being included in the TypeScript compilation process. - This change helps streamline the build process by omitting unnecessary test files. * refactor: integrate getTextBoxCoordsCanvas into ArrowAnnotateTool for improved text box positioning - Replaced direct canvas coordinate assignment with a call to getTextBoxCoordsCanvas to enhance the accuracy of text box placement. - This change ensures that text box coordinates are calculated based on the current canvas state and element, improving overall annotation functionality. * refactor: streamline text box rendering across annotation tools - Replaced direct text box rendering logic with a unified renderLinkedTextBoxAnnotation method in multiple annotation tools. - This change enhances code maintainability and consistency in text box visibility and positioning logic. - Improved handling of text box state and coordinates, ensuring better integration with existing annotation functionalities. --------- Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
* fix: Continuous flicker on viewer redraw * fix: Comment on size 0
…kfile changes. (#2629) Disabled all dependabot pull requests for bun and npm version updates.
Loading a multiframe SEG awaited each frame's fetch/decode before issuing the next, so only one request was ever in flight. For 800+ frame SEGs this serialized hundreds of round trips and made the imageLoader-based load slow. Decode frames through a bounded-concurrency worker pool (default N=16), preserving frame order and fail-fast behavior. Concurrency is configurable via the new `concurrency` option on createLabelmapsFromSegImageIds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sedghi
left a comment
There was a problem hiding this comment.
putting this as request changes until we figure out the regresssions
createFromDicomSegImageId dropped the concurrency option, so callers could not control SEG frame fetch/decode parallelism. Thread it through to createLabelmapsFromSegImageIds (defaults to the loader's own default when omitted). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…or-seg # Conflicts: # packages/metadata/package.json # pnpm-lock.yaml
…or-seg Resolve packages/metadata/package.json: take main's @cornerstonejs/utils version bump (5.3.0) while keeping the branch's deliberate dcmjs 0.52.0 upgrade. Lockfile regenerated to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…or-seg # Conflicts: # packages/metadata/package.json
PR #2611 — Review Remediation PlanPR: Use the image loader for dicom-seg to allow compressed images Every item below was verified against the current source on this branch (5 parallel Work through items one at a time. Check the box and fill in Legend: Notes on scope (corrected)The dev-script Softened / corrected claims from the review, confirmed during verification:
Phase 1 — Critical: silent data corruption (block merge)
[x] 1a. Positional frame fallback paints frames onto wrong slices
[x] 1b.
|
|
@sedghi # PR #5806 — Review Remediation Plan (OHIF side) PR: feat: Add support for labelmap seg images in any supported tsuid (also for compressed bitmap) Every item below was verified against the current checkout (top commit Work through items one at a time. Check the box and fill in Legend: Notes on scope (corrections to the review, confirmed during verification)
Phase 1 — Confirmed bugs (block merge)[x] 1a. Garbage (0000,0000) element written into every saved file's meta group
[x] 1b. rsbuild config crashes for any fresh clone (
|
sedghi
left a comment
There was a problem hiding this comment.
Looks great thanks, merge after green CI
…or-seg # Conflicts: # packages/metadata/package.json
Context
The previous segmentation loader claimed labelmap + RLE support but neither actually worked, and it loaded SEG by retrieving the entire DICOM object. This PR makes SEG load through the image loader (per-frame imageIds, so standard back ends' SEG frame retrieve is used and compressed frames are supported), and fixes/extends storage to write labelmap or bitmap with correct RLE.
Faster loading from back ends that support frame retrieve, and significantly smaller storage since RLE compresses segmentation images extremely well.
Changes & Results
SEG load via image loader (adapters)
createFromDicomSegImageId/createLabelmapsFromSegImageIdsbuild labelmaps from per-frame imageIds + a decode callback (defaults to the image loader), replacing the whole-object decode path. Legacy buffer path retained.decodeSegPixelDataFromFrameIdsfetches/decodes frames with bounded concurrency (default 16, configurable viaconcurrency) so per-frame requests overlap; order preserved, fail-fast unchanged.encodePixelDataplusperFrameFunctionalGroupsnormalization; broadSegmentation_4X/generateToolState/generateSegmentationupdates.RLE encoder / decoder fix
Full-instance Part 10 prefetch (single uniform frame registry)
prefetchPart10Instanceregisters a fetched Part 10 instance into the@cornerstonejs/metadataNATURALIZED /COMPRESSED_FRAME_DATAframework (parsed by the dcmjs async reader).loadImagenow consults that registry first (wadors/loadImageFromRegistry.ts) and falls through to the normal/frames/Nrequest when nothing is registered — so WADO-RS and WADO-URI share one registry and one decode path.Metadata / transfer syntaxes
TransferSyntaxesenum andisVideoTransferSyntaxupdates.Stack-labelmap rendering fix
viewportReferencesSegmentationImagesguardssyncStackLabelmapActorsso a labelmap is only mounted on viewports that actually display its source images. It resolves the labelmap's referenced source imageIds from each labelmap image'sreferencedImageIdin cache (not the labelmap's own imageIds), which fixes the previously failing stack-segmentation render unit tests while still excluding unrelated series that merely share a frame of reference.Tests & docs
encodePixelData,fillSegmentationFrames,perFrameFunctionalGroups,resolveFrameImageIds,segBufferMetadataRoundTrip; migration notes added.Testing