Introducing a new way to review your PRs.

Read the announcement

ohif / viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages

View on GitHub

21 documents · Updated Nov 23, 2026

docs / segmentation-and-microscopy-modes

Segmentation and microscopy modes

The segmentation and microscopy modes adapt the viewer to two focused clinical workflows. Segmentation mode supports creation and editing of image segmentations, while microscopy mode presents whole-slide microscopy data with measurement tools and annotation management. Each mode joins a workflow-specific layout to the services and data handlers that its workflow needs.

Segmentation mode

Segmentation mode is an editing workspace for labelmap and contour segmentations. It accepts studies with a usable source image and places the source image, segmentation data, and radiotherapy data in a coordinated viewer layout. The mode keeps the segmentation panel ready for editing and selects the panel that matches the active representation when one first becomes available. modes/…/index.tsx• L17-34 modes/…/index.tsx• L36-60

Segmentation workspace

The workspace combines image review with segmentation editing in one focused view. Its layout provides source-image, segmentation, and radiotherapy areas with a thumbnail view, while shared image controls sit beside segmentation controls. The mode relies on the basic viewer and domain extensions for the panels, display-set handling, and data services that make this workflow usable. modes/…/index.tsx• L42-59 modes/…/index.tsx• L78-117 modes/…/package.json• L33-42

References: modes/…/index.tsx• L36-60 modes/…/index.tsx• L78-117 modes/…/package.json• L33-42

Segmentation representations

A segmentation representation is the form used to show and edit segmentation data. Labelmaps support voxel-based edits such as brush and threshold work. Contours support outline-based edits such as freehand and spline work. The workspace exposes both forms, but it only enables tools that match the active representation and the current image. extensions/…/segmentationToolbarCustomization.ts• L71-357 extensions/…/segmentationToolbarCustomization.ts• L360-490 extensions/…/segmentationPanelCustomization.tsx• L28-42

This separation keeps an edit tied to the data form that can store it. For example, interpolation needs a reconstructable image set, while click-based segmentation needs PET data. These checks prevent a valid tool from being offered in a context where it cannot produce the expected result. extensions/…/segmentationToolbarCustomization.ts• L361-457

References: extensions/…/segmentationToolbarCustomization.ts• L71-357 extensions/…/segmentationToolbarCustomization.ts• L360-490 extensions/…/segmentationToolbarCustomization.ts• L612-742 extensions/…/segmentationPanelCustomization.tsx• L28-42

Segmentation panel selection

Segmentation mode links the active representation to the editing panel. When a labelmap or contour first becomes active, the mode opens the matching panel. If all representations are removed, the next new representation can select a panel again. This is a workflow link, not a data conversion: it changes the editing surface so it matches the data in the active viewport. modes/…/setUpAutoTabSwitchHandler.ts• L1-55 modes/…/index.tsx• L22-34

References: modes/…/setUpAutoTabSwitchHandler.ts• L9-53 modes/…/index.tsx• L22-34

Segmentation data exchange

The segmentation workflow separates the form used in the viewer from the DICOM form used for storage and exchange. The default store path uses labelmap DICOM SEG with RLE Lossless transfer syntax. A data source can select another supported encoding, while the known SOP Class guides how an existing SEG object is read. extensions/…/segmentationConfig.ts• L1-19 extensions/…/segmentationConfig.ts• L53-99

The mode depends on source images for reference space, segmentation services for active representations, and DICOM SEG support for portable results. Its package boundary also includes the core viewer, basic mode, default services, image and radiotherapy support, structured reports, PDF, and video so related study content can remain in the same workflow. modes/…/package.json• L33-42

References: extensions/…/segmentationConfig.ts• L1-19 extensions/…/segmentationConfig.ts• L53-99 modes/…/package.json• L33-42

Microscopy mode

Microscopy mode is a workspace for DICOM VL Whole Slide Microscopy Image data. It is valid only for studies with the SM modality and uses a microscopy viewer to show slide data across whole-slide resolution levels. The mode also supports derived microscopy measurements and related DICOM objects through its display-set handlers and measurement panel. modes/…/index.tsx• L71-83 modes/…/README.md• L1-3

Microscopy workspace

The workspace keeps the series list available but closed by default because whole-slide thumbnails are not reliable for this workflow. It gives the microscopy viewer the main area, with video and PDF areas for related display sets and a measurement panel on the right. The mode directly requires the core viewer and microscopy extension. Other related display-set support is supplied through the host application's shared capabilities. modes/…/index.tsx• L6-35 modes/…/index.tsx• L85-130 modes/…/package.json• L33-35

References: modes/…/index.tsx• L6-35 modes/…/index.tsx• L85-130 modes/…/package.json• L33-35

Whole-slide viewing

The microscopy viewer turns a loaded slide into a navigable whole-slide view. It uses the DICOM web data source for image tiles and keeps the application viewport state linked to the microscopy viewer. The viewer can show an overview and position control while it loads the slide at the needed resolution. extensions/…/DicomMicroscopyViewport.tsx• L41-57 extensions/…/DicomMicroscopyViewport.tsx• L100-157 extensions/…/index.tsx• L59-107

Derived microscopy display sets can point to a source slide. The viewer resolves that source before it loads the derived data, so measurements and annotations appear over the correct image. extensions/…/DicomMicroscopyViewport.tsx• L178-222

References: extensions/…/DicomMicroscopyViewport.tsx• L41-57 extensions/…/DicomMicroscopyViewport.tsx• L100-157 extensions/…/DicomMicroscopyViewport.tsx• L178-222

Microscopy measurements

Microscopy measurements are region-of-interest annotations managed across the viewers for a study. The microscopy service tracks their labels, selection, view state, and changes. It then keeps viewers for the same series in sync, so a measurement remains available when a view is rebuilt or shown in another viewport. extensions/…/MicroscopyService.ts• L51-71 extensions/…/MicroscopyService.ts• L273-325 extensions/…/MicroscopyService.ts• L559-585

The measurement panel turns this shared state into study-level actions. A user can select a measurement to focus the slide, rename it, remove it, or save the set as a DICOM Structured Report through a download or the active data source. extensions/…/MicroscopyPanel.tsx• L88-124 extensions/…/MicroscopyPanel.tsx• L158-227 extensions/…/MicroscopyPanel.tsx• L266-357

References: extensions/…/MicroscopyService.ts• L51-71 extensions/…/MicroscopyService.ts• L273-325 extensions/…/MicroscopyService.ts• L559-585 extensions/…/MicroscopyPanel.tsx• L88-124 extensions/…/MicroscopyPanel.tsx• L158-227

Microscopy controls

Microscopy mode exposes measurement and navigation controls that match the whole-slide workflow. Its measurement group supports line, point, polygon, circle, box, freehand polygon, and freehand line tools. It also provides pan and DICOM tag access. The toolbar asks the microscopy service for tool state, so the visible state follows the microscopy viewer. modes/…/toolbarButtons.ts• L12-139 extensions/…/index.tsx• L111-149

When the mode exits, it closes open dialogs and resets the toolbar. This keeps temporary microscopy controls and annotation prompts from carrying into another mode. modes/…/index.tsx• L46-69

References: modes/…/toolbarButtons.ts• L12-139 extensions/…/index.tsx• L111-149 modes/…/index.tsx• L46-69

Workflow relationships

These modes share the mode-driven viewer model but serve different data contracts. Segmentation mode starts with clinical image data and adds editable segmentation representations. Microscopy mode starts with SM whole-slide data and adds resolution-aware viewing with measurement annotations. The parent page mode-driven-workflows explains how the application selects and assembles these modes with shared viewer services.

The viewing modes in basic-and-longitudinal-viewing provide the wider image-review context. The related workflows in quantitative-and-annotation-modes show how other modes add domain-specific measurements or annotations. Segmentation controls can also be reused by other modes, but segmentation mode is the dedicated workspace that combines those controls with editable segmentation panels. extensions/…/segmentationToolbarCustomization.ts• L26-33 extensions/…/segmentationToolbarCustomization.ts• L944-960

The workflows meet at the mode boundary rather than through one shared viewer. A change to a common service or extension can affect both modes. A change to a layout, validity rule, or toolbar usually affects only its owning mode.

References: modes/…/index.tsx• L69-118 modes/…/index.tsx• L37-132 modes/…/package.json• L33-42 modes/…/package.json• L33-35 extensions/…/segmentationToolbarCustomization.ts• L944-960

Change checklist

When these files or sections are changed, remember to consider these:

  • When a segmentation representation or panel changes, check the auto-selection mapping and the toolbar guards together. A panel can open without exposing tools that match the active representation.
  • When segmentation store defaults change, check app-wide customizations and data-source overrides together. The read path uses the instance SOP Class when known, while the save path resolves the selected store mode and transfer syntax.
  • When microscopy display-set handlers or viewport names change, update the mode route and its SOP Class handler list together. Each supported display-set kind must map to a compatible viewport.
  • When microscopy annotation events change, check service subscriptions, panel refresh, and viewer synchronization as one contract. Missing one event can leave the list, selection, or slide view stale.
  • When microscopy save behavior changes, preserve the distinction between local DICOM download and data-source storage. Both paths must produce the same SR result and completion status.
  • When either mode's peer dependencies or package build configuration changes, check that its layout, handlers, panels, and tool services still have the extensions that provide them. The package build must still follow the shared repository policy.

Important failure modes

TriggerConsequenceGuard
A study contains only modalities excluded by segmentation modeThe workflow is offered without a usable source for segmentationMode validity excludes studies made only of SM, ECG, OT, or DOC data. modes/…/index.tsx• L109-113
A labelmap tool is used without an active labelmap representationThe tool cannot perform its intended editToolbar evaluation requires the matching segmentation representation. extensions/…/segmentationToolbarCustomization.ts• L303-328
Interpolation is requested for a non-reconstructable display setMissing slices cannot be filled through interpolationThe interpolation control checks display-set reconstructability. extensions/…/segmentationToolbarCustomization.ts• L361-390
Microscopy mode is opened for a non-SM studyThe whole-slide viewer has no supported microscopy sourceMode validity requires the SM modality. modes/…/index.tsx• L76-83
A microscopy derived display set is shown before its source slide is readyThe annotation overlay cannot load against its referenced imageThe viewport resolves and requests the source display set before it loads the derived set. extensions/…/DicomMicroscopyViewport.tsx• L178-222
A microscopy save has no active data sourceMeasurements cannot be stored or downloaded through the configured pathThe save flow reports an unspecified server instead of claiming success. extensions/…/MicroscopyPanel.tsx• L195-223

Key files

FileWhy to read it
modes/…/index.tsxDefines the segmentation mode boundary, layout, validity rule, dependencies, and lifecycle.
modes/…/package.jsonDefines the extensions and modes required by the segmentation workspace.
modes/…/rspack.prod.jsDefines the production bundle boundary for the segmentation mode.
modes/…/setUpAutoTabSwitchHandler.tsShows how the active segmentation representation selects the editing panel.
extensions/…/segmentationToolbarCustomization.tsDefines reusable segmentation tools and representation-specific workflow guards.
extensions/…/segmentationPanelCustomization.tsxDefines editable labelmap and contour panel behavior.
extensions/…/segmentationConfig.tsDefines the relationship between DICOM SEG classes, parser choice, and save encoding.
modes/…/index.tsxDefines microscopy mode validity, layout, supported display sets, and dependencies.
modes/…/package.jsonDefines the core and microscopy extension required by the microscopy workspace.
modes/…/toolbarButtons.tsDefines microscopy measurement and navigation controls.
extensions/…/DicomMicroscopyViewport.tsxShows how whole-slide data and derived overlays enter the microscopy viewer.
extensions/…/MicroscopyService.tsCoordinates viewers, region-of-interest annotations, selection, and synchronization.
extensions/…/MicroscopyPanel.tsxShows how measurements are listed, focused, edited, removed, and saved as DICOM SR.