Cornerstone imaging integration
The Cornerstone imaging integration connects OHIF study and viewer services to Cornerstone image, volume, tool, and render services. It turns display sets into interactive viewports while keeping image presentation, measurements, overlays, and viewer state aligned across the application.
Extension boundary
Service registration
The extension is the boundary between OHIF and Cornerstone. When a mode uses it, the extension registers viewport, tool-group, synchronizer, segmentation, cache, colorbar, and viewed-data services. It also exposes the viewport component, commands, toolbar items, panels, hanging protocols, and DICOM handlers to the viewer. This lets the rest of OHIF use stable service contracts instead of calling Cornerstone directly.
The extension package exposes the OHIF extension and type entry points. It declares the Cornerstone codec and loader peers, OHIF workspace peers, and the React 19.2.7 host runtime that the viewer must provide. Its current runtime requires Node 24 or later. Its Cornerstone runtime packages use the 5.18.3 package family for core, tools, loaders, metadata, and adapters. The extension initializes Cornerstone before it connects these services. Initialization sets the image loaders, metadata providers, render settings, worker limits, prefetch support, cine support, measurement support, and error reporting.
On mode entry, the extension also applies retrieval policy from the active data source. Volume retrieval uses interleaved progressive stages, while stack retrieval starts from streaming defaults and can be adjusted by the data source. This keeps data-source retrieval choices inside the Cornerstone boundary instead of spreading them through viewport consumers.
References: extensions/…/index.tsx• L112-188 extensions/…/index.tsx• L230-244 extensions/…/init.tsx• L59-167 extensions/…/init.tsx• L220-270 extensions/…/package.json• L1-17 extensions/…/package.json• L36-70
Viewer integration points
The viewer receives one Cornerstone viewport module named cornerstone. Its component receives display sets and viewport options from OHIF, then passes them to the Cornerstone viewport service. Commands and toolbar evaluators connect user actions to the active viewport, its tool group, and the display sets it shows.
The extension also supplies the study summary used with Cornerstone measurement actions. It reads the study date and description from the first metadata series that has an instance, so the summary stays empty while metadata is still incomplete instead of interrupting the viewer.
Hanging protocols choose how display sets first appear in the viewer. The built-in MPR protocol offers a three-pane axial, sagittal, and coronal view for reconstructable data. It also offers reformat views. Shared VOI and colormap synchronization keeps the panes visually aligned, while frame-of-reference matching supports derived overlays across the panes.
The shared application type contract names the services and data types that the extension adds to OHIF. It also defines extension customizations such as the segmentation undo and redo history limit. This keeps service access and mode configuration consistent for the viewer and related extensions.
The integration also provides panels for measurements and segmentations. Segmentation editing controls are exposed as reusable toolbar capability packs, so a mode can select the controls and layout that fit its workflow. The general Cornerstone toolbar is also exposed as a capability pack that modes can compose and customize. Advanced rendering controls group window and level, colorbar, opacity, and threshold actions. Specialized DICOM SEG, RT, Parametric Map, and SR extensions depend on this shared Cornerstone extension and add focused imaging workflows. The measurement-tracking extension shares the Cornerstone core and tools contract while consuming the SR extension for tracked findings. Specialized imaging pages build on these shared contracts: Cornerstone viewport and tools, DICOM segmentation and RT, and structured reports and measurements.
References: extensions/…/index.tsx• L230-305 extensions/…/index.tsx• L341-342 extensions/…/StudySummaryFromMetadata.tsx• L7-30 extensions/…/StudySummaryFromMetadata.test.ts• L35-47 extensions/…/AppTypes.ts• L19-69 extensions/…/getToolbarModule.tsx• L22-32 extensions/…/getPanelModule.tsx• L10-123 extensions/…/segmentationToolbarCustomization.ts• L945-964 extensions/…/toolbarButtonsCustomization.ts• L714-802 extensions/…/getCustomizationModule.tsx• L21-50 extensions/…/mpr.ts• L51-197 extensions/…/package.json• L1-70 extensions/…/package.json• L1-49 extensions/…/package.json• L1-45 extensions/…/package.json• L1-46 extensions/…/package.json• L1-47
Imaging data flow
Display set to rendered image
A display set is OHIF's description of a series or derived image group. The cache service asks the active data source for image identifiers, then prepares either stack data or volume data. Display sets with their own load operation are loaded independently of a viewport, so derived data can exist before the viewer chooses where to show it. The viewport service applies that data to a Cornerstone viewport and announces when the viewport is ready for other services.
The main flow moves from study data to an image or volume, then to a viewport presentation and a rendered frame.
flowchart LR
A[OHIF display sets] --> B[Viewport data]
B --> C[Image or volume loading]
C --> D[Cornerstone viewport]
D --> E[Tools and overlays]
E --> F[Rendered image]
Stack viewports show ordered images. Volume viewports create or reuse a volume so the viewer can support multiplanar views, projections, fusion, and volume rendering. Additional display sets can act as image overlays instead of replacing the primary image data.
References: extensions/…/CornerstoneCacheService.ts• L34-99 extensions/…/CornerstoneCacheService.ts• L194-345 extensions/…/loadDisplaySetData.ts• L5-46 extensions/…/CornerstoneViewportService.ts• L485-587 extensions/…/CornerstoneViewportService.ts• L1044-1126
Viewport families
The integration supports several kinds of imaging content through one viewport service. The service selects the data path that matches the content and the requested view.
| Content | Viewer purpose |
|---|---|
| Stack | Browse an ordered image series or acquisition |
| Orthographic volume | View reformatted slices and support MPR |
| 3D volume | Show volume-rendered anatomy or data |
| ECG waveform | Display DICOM waveform content |
| Video | Display DICOM video content |
| Whole-slide image | Browse large microscopy images |
The integration supports both the established Cornerstone viewport model and the optional native generic viewport model. An adapter keeps common actions such as presentation changes, view state, data addressing, and capture consistent while the selected rendering path handles the differences between viewport families. Contract tests check the shared behavior across both paths.
References: extensions/…/IViewportBackend.ts• L61-75 extensions/…/IViewportBackend.ts• L91-132 extensions/…/NextViewportAdapter.ts• L40-61 extensions/…/NextViewportAdapter.ts• L93-145 extensions/…/IViewportAdapter.contract.test.ts• L8-16 extensions/…/getSopClassHandlerModule.js• L152-161 extensions/…/getSopClassHandlerModule.js• L239-251
Overlay eligibility
Overlay eligibility decides whether a secondary display set can be shown over a viewport's background. The same rule serves the viewport overlay menu and automatic derived-display-set hydration, so a user choice and a restored presentation use the same view of data compatibility.
The rule accepts a referenced background for SEG and RTSTRUCT data. It also accepts co-registered reconstructable volumes in the same frame of reference. A normal colormap overlay must use valid volume data on both sides, while a non-reconstructable stack does not gain unrelated overlays merely because it shares a frame of reference.
References: extensions/…/isDisplaySetOverlayable.ts• L7-95 extensions/…/utils.ts• L27-75 extensions/…/hydrationUtils.ts• L84-132
Viewport lifecycle
The React viewport component owns the link between an HTML element and the Cornerstone viewport. On mount it enables the viewport and joins its tool and synchronizer groups. On unmount it stores the current presentation, removes group membership, clears overlay representations, disables the element, and unregisters the element reference.
Display-set changes rebuild the viewport data. Metadata invalidation can trigger a reload so that new calibration or scale data reaches the rendered image without losing the camera position. Native generic viewports preserve the stack-versus-volume data shape even when their Cornerstone viewport type does not distinguish those forms.
The component reads and updates Cornerstone's external viewport state, including the enabled element and camera. It therefore remains outside React Compiler memoization so imperative viewport updates are not treated as pure React state.
References: extensions/…/OHIFCornerstoneViewport.tsx• L1-5 extensions/…/OHIFCornerstoneViewport.tsx• L90-91 extensions/…/OHIFCornerstoneViewport.tsx• L129-227 extensions/…/OHIFCornerstoneViewport.tsx• L229-305 extensions/…/CornerstoneViewportService.ts• L265-300 extensions/…/CornerstoneCacheService.ts• L45-99
Image presentation
Presentation state
Presentation state is the user-facing appearance and position of a viewport. It includes the current slice or view reference, pan and zoom, rotation and flip state, window and level, inversion, colormap, and segmentation appearance. The viewport service stores this state when content changes or a viewport leaves the screen, then restores it when the content returns.
Segmentation presentation records whether a derived layer should be shown, removed, or left without a statement. The record is tied to the display set that the segmentation references, while overlay eligibility resolves whether that state also applies to a co-registered viewport. This keeps a user's removal decision from being undone by a later viewport rebuild.
This state is separate from the source display-set data. That separation allows a hanging protocol to choose the initial view while still preserving later user changes.
References: extensions/…/CornerstoneViewportService.ts• L316-404 extensions/…/CornerstoneViewportService.ts• L485-504 extensions/…/Presentation.ts• L37-66 extensions/…/getViewportPresentations.ts• L7-110 extensions/…/OHIFCornerstoneViewport.tsx• L205-223
Rendering controls
Commands provide the common image controls used by the viewer. They change window and level, presets, colormaps, opacity, orientation, rotation, flips, scale, slice position, and viewport reset. Measurement actions can also open a color picker and apply the selected color to the annotation and its text box without changing the measurement identity. The window-level command ignores a stale viewport identifier before it applies a change, while the active viewport command resolves the correct volume binding when needed. The window-level interaction also ignores viewports that have no VOI range, such as ECG viewports, instead of sending an invalid operation to Cornerstone.
Window-level presets are selected by the active image modality. The default CT presets also have number-key bindings in the same order as the preset menu, so the visible menu and keyboard actions share one contract. The toolbar enables these controls only when the active viewport and its display sets support them.
The window-level panel reads volume load state from the cache as well as from load events. This handles volumes that finished before the panel mounted and lets the panel refresh histograms while data is still arriving. An opacity change is applied to compatible viewports that show the same volume set, so linked panes keep a consistent appearance.
Volume presentation can include multiple data bindings. The first base binding supplies the main image and later bindings can supply fusion data. Segmentation and other derived overlays follow their own representation rules so they do not replace the base image.
References: extensions/…/commandsModule.ts• L875-913 extensions/…/commandsModule.ts• L1016-1117 extensions/…/commandsModule.ts• L1167-1327 extensions/…/getCustomizationModule.tsx• L21-50 extensions/…/toolbarButtonsCustomization.ts• L568-583 extensions/…/ViewportWindowLevel.tsx• L18-38 extensions/…/ViewportWindowLevel.tsx• L69-85 extensions/…/ViewportWindowLevel.tsx• L149-165 extensions/…/ViewportWindowLevel.tsx• L167-224 extensions/…/windowLevelPresetHotkeys.test.ts• L1-19 extensions/…/index.ts• L7-13 extensions/…/WindowLevelTool.ts• L1-19 extensions/…/WindowLevelTool.test.ts• L24-55
Rendering backends
The integration can select a rendering backend for a session and can use a CPU fallback when the browser cannot support the preferred GPU path. The viewer can also opt into native generic viewports. These choices affect how Cornerstone renders the same OHIF view, not the meaning of the display set or the viewer commands.
The extension exposes a GPU settings preset customization. A selected preset is applied before volume viewports add their actors and turns on final downsampling. A null preset restores the Cornerstone default and the application downsampling setting. Global and mode customization changes are applied again during the session.
The extension reports a clear limitation when CPU rendering is active because some volume, MPR, and segmentation features need GPU support.
References: extensions/…/init.tsx• L78-139 extensions/…/init.tsx• L166-167 extensions/…/init.tsx• L411-439 extensions/…/gpuSettingsPresetCustomization.ts• L1-8 extensions/…/initGpuSettingsPreset.ts• L1-51 extensions/…/NextViewportBackend.ts• L112-184
Interaction services
Tool groups
Cornerstone tools provide direct interaction with images and volumes. The integration registers navigation, windowing, measurement, annotation, segmentation, and volume tools, then places them in tool groups associated with viewports. A tool group controls which tool is active, enabled, passive, or disabled for its viewports. The integration keeps the standard Cornerstone tool identity for its window-level tool while adding a safe no-op for viewport types that do not support window and level.
Toolbar commands change tool modes and bindings through the tool-group service. The service also keeps user-selected bindings so the same interaction choices can be restored when a tool group is created again. Toolbar capability packs expose the available buttons and their section layout, while modes decide which capabilities to compose and customize.
References: extensions/…/initCornerstoneTools.js• L56-121 extensions/…/ToolGroupService.ts• L137-225 extensions/…/commandsModule.ts• L1118-1243 extensions/…/WindowLevelTool.ts• L5-19 extensions/…/toolbarButtonsCustomization.ts• L714-802
Measurement bridge
The measurement bridge keeps Cornerstone annotations and OHIF measurements in one logical state. When a user completes or edits a supported tool annotation, the bridge creates or updates the matching OHIF measurement. Changes made in the measurement service update the Cornerstone annotation so labels, lock state, visibility, and drawing state remain in step.
This bridge gives measurements a common path for display, selection, navigation, and later export. Segment statistics can add a largest bidirectional measurement to a segment, show its length and width, toggle its annotation, or jump to its image through the same command and measurement path. Users can also change an annotation's color through the measurement actions without losing its existing style or contour shape.
Study actions can download a CSV report, save the selected measurements as a report, or clear them. The measurement service also uses viewport references to move the user to the image that contains a measurement.
References: extensions/…/initMeasurementService.ts• L22-199 extensions/…/initMeasurementService.ts• L202-346 extensions/…/initMeasurementService.ts• L349-551 extensions/…/commandsModule.ts• L875-913 extensions/…/CustomSegmentStatisticsHeader.tsx• L24-65 extensions/…/CustomSegmentStatisticsHeader.tsx• L72-134 extensions/…/StudyMeasurementsActions.tsx• L6-69 extensions/…/commandsModule.ts• L235-307
Synchronizers and cine
Synchronizers coordinate related viewports. They can keep camera position, window and level, zoom and pan, or image slice position aligned. The service supports source and target roles so a group can describe one-way or shared synchronization.
Cine support adds time-based playback for dynamic volumes. A cine source can identify other viewports that show the same dynamic volume so playback can remain consistent across a layout.
References: extensions/…/SyncGroupService.ts• L36-167 extensions/…/SyncGroupService.ts• L170-221 extensions/…/initCineService.ts• L17-72
Segmentation representations
A segmentation is derived image or contour data that can be shown over a source image. The segmentation service turns DICOM SEG data into labelmap representations and RT structure data into contour representations. It also supports surface representations for 3D views, segment colors, visibility, labels, locks, active segments, and style changes.
The service selects the segmentation path for the actual viewport family. The established path can promote a compatible stack to a volume view when needed. The native generic path keeps a labelmap in place and does not promote the viewport, even when the labelmap cannot be mapped at once. This per-viewport choice allows a session to mix native and established viewports without sending native viewports through legacy conversion rules.
When a SEG is loaded before a target viewport exists, the session's native-viewport choice determines how its segmentation data is assembled. Native viewports can retain separate labelmap layers for overlapping segments, while the established path keeps its single-layer behavior. When a representation is later added, the service requires the segmentation to be in Cornerstone state before it reports loading complete. This ordering lets viewport listeners attach the representation on the first load.
When a viewport receives an overlay display set, the viewport service finds the referenced image data and asks the segmentation service to attach the matching representation. The overlay keeps its own presentation state so it can reappear when the source viewport is rebuilt. Automatic hydration can be limited by configured OHIF viewport types, while a user can still add an eligible segmentation from the overlay menu.
Client-created segmentations follow the same display-set path as loaded segmentations. The integration creates an overlay display set for them, adds the representation to the target viewport, and removes that display set when the segmentation is deleted. It supports export as CSV, DICOM SEG, or DICOM RTSTRUCT where the representation allows it. Labelmap export is offered only when the labelmap contains non-zero voxel data and its referenced image belongs to a known display set; contour export requires at least one contour annotation.
References: extensions/…/SegmentationService.ts• L152-169 extensions/…/SegmentationService.ts• L331-429 extensions/…/SegmentationService.ts• L686-714 extensions/…/NextSegmentationBackend.ts• L18-141 extensions/…/LegacySegmentationBackend.ts• L20-123 extensions/…/SegmentationService.test.ts• L918-1010 extensions/…/CornerstoneViewportService.ts• L1329-1493 extensions/…/CornerstoneViewportService.ts• L1700-1781 extensions/…/autoHydrateViewportTypes.ts• L37-69 extensions/…/segmentationHydrationCustomization.ts• L1-15 extensions/…/ExportSegmentationSubMenuItem.tsx• L14-70 extensions/…/segmentationExportUtils.ts• L31-170 extensions/…/setUpSegmentationEventHandlers.ts• L24-105
Segmentation editing controls
Segmentation editing controls connect the toolbar to the active segmentation and its representation type. The shared toolbar packs labelmap tools, contour tools, and utilities so modes can reuse editing capabilities without adopting one fixed mode layout.
The controls cover drawing, erasing, thresholding, contour editing, interpolation, segment measurements, and optional assisted segmentation. Evaluators keep a control unavailable until the active viewport has the required tool and representation. Commands then activate the selected segmentation before the tool starts editing it.
The segmentation panel presents the representations available in the active viewport and chooses utility controls for the selected representation type. Its mode, add behavior, editing policy, menu content, and segment statistics can follow mode customizations after the panel mounts. Export actions remain available only when the segmentation has usable labelmap or contour data.
References: extensions/…/segmentationToolbarCustomization.ts• L26-34 extensions/…/segmentationToolbarCustomization.ts• L867-892 extensions/…/segmentationToolbarCustomization.ts• L945-964 extensions/…/commandsModule.ts• L2341-2355 extensions/…/commandsModule.ts• L2367-2400 extensions/…/PanelSegmentation.tsx• L21-67 extensions/…/PanelSegmentation.tsx• L92-105 extensions/…/PanelSegmentation.tsx• L204-242
Derived display set hydration
Hydration loads a derived display set and records where it should appear without requiring a viewport to exist at load time. The process stores the referenced image position, loads SEG, RTSTRUCT, or SR data, and refreshes every eligible view that can show the result.
Hydration keeps two decisions separate: whether derived data exists and whether it appears automatically in a standard view. This allows a site to avoid costly automatic surface generation in 3D views while still allowing an explicit user overlay action. A shared presentation store carries the desired state across layout changes and viewport remounts.
When hydration requests a viewport type, that request applies to the pane whose background is being set. Other panes matched by frame of reference keep their own render mode. This prevents a compatible MPR or volume pane from being changed to a stack view only because another pane started the hydration.
References: extensions/…/commandsModule.ts• L343-441 extensions/…/commandsModule.ts• L2178-2225 extensions/…/loadDisplaySetData.ts• L5-46 extensions/…/hydrationUtils.ts• L135-185 extensions/…/getViewportPresentations.ts• L28-110
Data access and cleanup
DICOM loading
The DICOM image loader connects Cornerstone requests to the active OHIF data source. It adds the user's authorization information and the source's transfer-syntax preferences to image requests. Cornerstone metadata providers then combine DICOM metadata with OHIF metadata so tools and viewports can use calibration, display, and measurement context.
The image and retrieval pools support separate interaction, thumbnail, prefetch, and compute work. Study prefetch uses the same loader and cache so images can be prepared before the user reaches them. Display sets with custom loaders use the active authorization header whether they are loaded for a viewport or loaded in advance. On mode entry, the active data source can also tune stack retrieval while the extension keeps volume retrieval interleaved for progressive volume work.
ECG and whole-slide DICOM handlers create display sets for their specialized viewport families. The ECG path adds waveform and calibration metadata, while the whole-slide path reuses available DICOMweb metadata to avoid an unnecessary metadata fetch.
References: extensions/…/initWADOImageLoader.js• L11-51 extensions/…/index.tsx• L155-188 extensions/…/init.tsx• L220-263 extensions/…/initStudyPrefetcherService.ts• L3-29 extensions/…/loadDisplaySetData.ts• L26-46 extensions/…/getSopClassHandlerModule.js• L18-30 extensions/…/getSopClassHandlerModule.js• L81-133 extensions/…/getSopClassHandlerModule.js• L181-247
Cache and mode cleanup
The Cornerstone cache service tracks image and volume data needed by viewports. On mode exit the extension clears request queues, metadata that can hold compressed data, enabled elements, presentation stores, viewed data, and segmentation state. This prevents data from one viewer session from changing a later session and limits memory growth during repeated layout changes.
Viewport and tool services also remove their event listeners and group membership. A viewport that is disabled must release its data registration before its OHIF bookkeeping is removed.
References: extensions/…/index.tsx• L191-223 extensions/…/CornerstoneViewportService.ts• L265-300 extensions/…/ToolGroupService.ts• L137-144 extensions/…/SyncGroupService.ts• L170-221
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to viewport data shape or viewport type must preserve stack-versus-volume selection for both legacy and native generic viewports.
- Changes to display-set order must preserve the first base binding and the later overlay or fusion bindings.
- Changes to overlay eligibility must stay consistent between the overlay menu, hydration target selection, and restored viewport presentations.
- Changes to presentation capture or restore must keep windowing, camera position, view reference, and segmentation hydration aligned during viewport reuse.
- Changes to automatic segmentation hydration must use the OHIF viewport-type vocabulary and must not block explicit overlay actions.
- Changes to DICOM loader or custom display-set loading must preserve authorization and the active data source's transfer-syntax contract.
- Changes to retrieval policy must preserve the distinction between data-source stack options and the extension's progressive volume retrieval path.
- Changes to measurement mappings must keep Cornerstone annotation events and OHIF measurement events mapped to the same measurement identity.
- Changes to measurement color actions must update annotation and text-box styles together without dropping existing contour-shape state.
- Changes to study summary metadata reads must tolerate series that have no instances until usable study metadata arrives.
- Changes to viewport mount and unmount order must release synchronizers, tools, overlays, cache work, and native data registrations without leaving session state behind.
- Changes to segmentation loading must add SEG data to Cornerstone state before sending the loading-complete event.
- Changes to segmentation backend selection must dispatch by the actual viewport family. Session-level native-viewer settings only select the SEG data shape when no target viewport exists.
- Changes to overlapping SEG assembly must preserve separate native labelmap layers and the established single-layer behavior.
- Changes to segmentation toolbar packs must preserve the representation-type checks that prevent a labelmap tool from editing contour data and the reverse.
- Changes to client-created segmentation commands must keep the generated display-set identity and the target viewport representation linked.
- Changes to labelmap export checks must preserve the non-zero voxel test, the cache-miss retry behavior, and the display-set lookup for referenced images.
- Changes to single-layer export source selection must keep top-level image IDs as the source when the only layer has no image IDs.
- Changes to window-level commands must keep stale viewport handling, volume binding selection, and the modality preset map aligned.
- Changes to the default CT preset menu must keep its number-key bindings in the same order as the visible presets.
- Changes to the window-level tool or unsupported viewport list must keep the toolbar evaluator and drag guard aligned for ECG and other non-VOI viewports.
- Changes to the extension package peer contract must keep the base and specialized packages aligned with the host React 19.2.7 version, Node 24 runtime, and shared Cornerstone 5.18.3 package family.
- Changes to specialized package dependencies must keep DICOM SEG, RT, SR, and measurement tracking extensions on the shared Cornerstone boundary and preserve measurement tracking's SR peer dependency.
- Changes to the shared
AppTypescontract must keep registered service names and Cornerstone customization names aligned with their consumers. - Changes to the viewport component must preserve its external-state boundary and its explicit registration and unregistration with OHIF.
- Changes to the MPR hanging protocol must preserve reconstructable-data matching, the three pane orientations, and shared VOI and frame-of-reference hydration synchronization.
- Changes to GPU preset customization must apply before volume actors are added and must restore application downsampling settings when the preset is cleared.
- Changes to segment statistics controls must keep bidirectional annotation visibility, segment state, and jump-to-measurement behavior aligned.
- Changes to the window-level panel must distinguish cache-complete volumes from volumes that still need histogram refreshes and must keep opacity changes aligned across compatible volume viewports.
- Changes to the segmentation panel must preserve representation-specific utility controls, live mode customizations, active-segmentation selection, and export eligibility for usable labelmap or contour data.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A stack or volume display set has no usable image identifiers | The viewport has no source data and cannot render the image | Validate the display-set data before mounting and keep the data-source image-ID contract intact |
| A study summary reads the first series before that series has an instance | The measurements panel can fail while metadata is still arriving | Use the first series with an instance and render no summary until one exists |
| A SEG load-complete event is sent before the segmentation enters Cornerstone state | A viewport listener cannot attach the derived representation on the first load | Register the SEG data before broadcasting the load-complete event |
| A derived display set is treated as overlayable on an unrelated background | The overlay can appear in a view with invalid spatial or image data | Use the shared frame-of-reference, reference, and volume eligibility rule |
| Automatic hydration is narrowed for a viewport type | A derived layer is not shown in that standard view even though it remains available | Treat the setting as an automatic-display policy and keep explicit overlay actions separate |
| A native planar viewport receives volume data without its preserved data shape | The service can choose the wrong mount path and show broken or unstable fusion | Preserve the stack-versus-volume data shape independently from the native viewport type |
| A native generic viewport is sent through the legacy segmentation conversion path | The viewport can be changed to an unintended volume type or fail because it lacks legacy view methods | Dispatch segmentation work by the actual viewport family |
| A native labelmap cannot be mapped at mount time and falls through to legacy conversion | The native viewport can be promoted or changed even though it must remain in place | Keep native representation handling in the native path and add it without promotion |
| An overlapping native SEG is shown in a non-volume slice view | Only the primary labelmap layer is visible | Use an MPR or volume layout when all overlapping segments must be shown |
| A segmentation editing tool is enabled without its required representation | The tool can start with no valid target or edit the wrong kind of segmentation | Gate the tool by both tool availability and labelmap or contour representation type |
| The segmentation panel keeps pre-registration customization values | A mode can show the wrong table mode or ignore its add and editing policy | Subscribe to customization changes and use the current mode settings |
| A labelmap has no non-zero voxel data or its referenced image is unknown | The export action is shown for data that cannot produce a valid DICOM SEG | Check voxel data and resolve the referenced image through the display set service |
| A contour-only or empty segmentation is marked exportable without usable data | The export action can produce no valid segmentation output | Check labelmap and contour eligibility before enabling export |
| A labelmap image is not in the cache when export state is checked | Export state can remain false until a later check even though data is loading | Do not cache an indeterminate scan and scan again on the next check |
| A measurement points to an image or orientation that no current viewport can show | Jump-to-measurement cannot place the user at the finding | Select the best navigation-compatible viewport before changing the viewport configuration |
| A measurement color action loses the existing style or contour shape | The annotation or its text box can render with inconsistent appearance | Seed the picker from the effective color and apply the full preserved style through the measurement update path |
| A window-level command receives a stale viewport identifier | The command can throw while trying to apply VOI to a viewport that no longer exists | Return before applying or rendering when the viewport cannot be resolved |
| Window-level interaction runs on an ECG viewport | Cornerstone can reject the operation because the viewport has no VOI range | Keep ECG viewport types in the unsupported list and make the custom tool return without calling Cornerstone |
| A default CT preset changes order without matching hotkeys | A number key applies a different preset from the menu label | Keep the hotkey list keyed to the preset menu order |
| A volume finishes loading before the window-level panel mounts | The panel can keep polling and show stale or missing histogram data | Seed loading state from cached volume status and refresh while incomplete |
| Opacity changes only update the active volume viewport | Linked panes that show the same volumes render with different opacity | Apply the change to all compatible viewports with the same volume set |
| A viewport is disabled without releasing its data registration | Later viewport reuse can retain stale metadata or increase memory use | Release viewport-owned registrations before deleting viewport bookkeeping |
| A custom display-set load fails | The requested overlay or derived data is unavailable while the rest of the viewer can continue | Report the load error and keep the failure local to the display set |
| CPU rendering is selected for a feature that needs GPU support | MPR, volume rendering, or segmentation overlays may be unavailable | Show the CPU fallback state and keep feature controls disabled when the viewport cannot support them |
| A GPU settings preset is applied after a volume actor is added | The actor can keep the wrong texture or downsampling settings | Apply the preset before the mode opens a volume viewport |
| A GPU settings customization names an unknown preset | Rendering keeps the previous setting and the requested preset is not used | Catch the Cornerstone error and warn without replacing the last valid setting |
| The viewport component is compiled as if its Cornerstone state were pure React state | Camera, enabled-element, or graphics updates can be skipped or become stale | Keep the component outside React Compiler memoization |
| A host does not meet the package's Node, React, or Cornerstone peer contract | The extension can fail to load or create duplicate runtime assumptions | Keep the host runtime and shared package versions aligned with extensions/…/package.json |
| A data source supplies invalid stack retrieval options | Stack loading can fail or use an unintended retrieval mode | Apply the supported retrieval update shape before registering stack options |
| An MPR layout is selected for data that is not reconstructable | The expected volume views cannot be created from the active display set | Keep the MPR selector tied to reconstructable display sets |
| An MPR pane loses its orientation or synchronizer | The three panes can show the wrong plane or drift in VOI and derived overlays | Keep pane orientation and shared synchronizer definitions aligned |
| Segment statistics show a bidirectional annotation without matching segment state | The displayed measurement can be hidden, stale, or disconnected from the segment | Update the Cornerstone annotation and segmentation state together |
Key files
| File | Why to read it |
|---|---|
| extensions/…/index.tsx | Extension boundary, retrieval policy, service registration, viewer modules, and mode cleanup |
| extensions/…/package.json | Public extension and type entry points plus the runtime contract with Cornerstone 5.18.3, OHIF, and the host React 19.2.7 and Node 24 runtimes |
| extensions/…/package.json, extensions/…/package.json, extensions/…/package.json | Peer contracts for the specialized DICOM imaging extensions that build on the Cornerstone layer |
| extensions/…/package.json | Runtime relationship between tracked measurements, Cornerstone tools, and the SR extension |
| extensions/…/AppTypes.ts | Shared service, segmentation, viewport, and customization contracts exposed to the OHIF application |
| extensions/…/init.tsx | Cornerstone startup, loaders, metadata, rendering choices, GPU preset setup, and service connections |
| extensions/…/OHIFCornerstoneViewport.tsx | Viewport element lifecycle and the connection from React to the viewport service |
| extensions/…/CornerstoneViewportService.ts | Main coordination point for viewport data, presentation state, navigation, volumes, and overlays |
| extensions/…/CornerstoneCacheService.ts | Conversion of OHIF display sets into stack and volume data |
| extensions/…/IViewportBackend.ts | Shared contract for the established and native rendering paths |
| extensions/…/NextViewportAdapter.ts | Native viewport mapping for view state, per-display-set presentation, and data addressing |
| extensions/…/IViewportAdapter.contract.test.ts | Shared behavior contract for established and native viewport paths |
| extensions/…/isDisplaySetOverlayable.ts | Shared rule for explicit overlays and automatic derived-display-set placement |
| extensions/…/hydrationUtils.ts | Selection of viewports that refresh when a derived display set is hydrated |
| extensions/…/getViewportPresentations.ts | Resolution of stored image and segmentation presentation state for a viewport |
| extensions/…/useSegmentationPresentationStore.ts | Desired segmentation visibility across viewport reuse and co-registered views |
| extensions/…/initCornerstoneTools.js | Registered interaction, measurement, navigation, and segmentation tools |
| extensions/…/WindowLevelTool.ts | Safe window-level interaction for viewports without a VOI range |
| extensions/…/ViewportWindowLevel.tsx | Volume loading, histogram refresh, window-level changes, and shared opacity behavior in the window-level panel |
| extensions/…/toolbarButtonsCustomization.ts | General toolbar capability definitions, advanced rendering controls, layout, and viewport capability guards |
| extensions/…/gpuSettingsPresetCustomization.ts | Public customization name for selecting a Cornerstone GPU settings preset |
| extensions/…/initGpuSettingsPreset.ts | Application of GPU presets and downsampling behavior during customization changes |
| extensions/…/segmentationToolbarCustomization.ts | Reusable segmentation editing controls and toolbar section composition |
| extensions/…/PanelSegmentation.tsx | Active segmentation selection, representation-specific utilities, mode customization, and export eligibility in the segmentation panel |
| extensions/…/CustomSegmentStatisticsHeader.tsx | Segment statistics actions for bidirectional measurements, annotation visibility, and navigation |
| extensions/…/initMeasurementService.ts | Two-way bridge between Cornerstone annotations and OHIF measurements |
| extensions/…/StudySummaryFromMetadata.tsx | Study summary behavior while series metadata arrives at different times |
| extensions/…/StudySummaryFromMetadata.test.ts | Contract for selecting a usable series and rendering no summary before instances exist |
| extensions/…/SegmentationService.ts | Segmentation state, per-viewport representation dispatch, loading order, editing state, and DICOM-derived overlays |
| extensions/…/NextSegmentationBackend.ts | Native viewport behavior for in-place labelmaps and overlapping SEG layers |
| extensions/…/LegacySegmentationBackend.ts | Established viewport behavior for stack-to-volume conversion and single-layer SEG data |
| extensions/…/SegmentationService.test.ts | Behavior contract for segmentation representations across established, native, stack, and volume viewports |
| extensions/…/segmentationExportUtils.ts | Export eligibility and source selection for labelmap and contour representations |
| extensions/…/segmentationExportUtils.test.ts | Behavior contract for voxel checks, cache-miss retries, and single-layer export sources |
| extensions/…/windowLevelPresetHotkeys.test.ts | Contract between default CT window-level preset order and number-key bindings |
| extensions/…/WindowLevelTool.test.ts | Contract for safe window-level behavior across supported and unsupported viewport types |
| extensions/…/createSegmentationForViewport.ts | Shared path for creating a labelmap or contour for a viewport |
| extensions/…/commandsModule.ts | Viewer commands for viewport control, window-level presets, measurement appearance, segmentation creation, hydration, and editing |
| extensions/…/mpr.ts | MPR layouts, pane orientations, and shared VOI and hydration synchronizers |
| extensions/…/getSopClassHandlerModule.js | Cornerstone-supported DICOM waveform and whole-slide display-set entry points |