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 / study-and-display-set-lifecycle

Study and display set lifecycle

The study and display set lifecycle turns incoming imaging metadata into stable viewer data. It groups data by study and series, creates display sets that the viewer can show as units, applies a viewing protocol, and publishes the resulting state to the rest of the platform. For the wider service map, see Core platform services. For service event and API coordination, see Core service orchestration.

Lifecycle overview

The lifecycle moves from source metadata to a study model, then to display sets, and finally to protocol matches that identify what each viewport should show. The metadata store and display set service keep ownership of the data while the hanging protocol service decides how to use it.

This diagram shows how imaging data becomes a protocol-ready viewport plan.

flowchart LR
    Source[Study metadata source] --> Store[Metadata store]
    Store --> Study[Study and series model]
    Study --> Handlers[SOP class handlers]
    Handlers --> Sets[Display sets]
    Sets --> Protocol[Hanging protocol matching]
    Study --> Protocol
    Protocol --> Plan[Viewport and display-set plan]
    Sets --> Consumers[Platform consumers]
    Plan --> Consumers

Lifecycle boundaries

The metadata store owns the study model. The display set service owns the viewer-facing display units. The hanging protocol service owns the rules that choose those units and map them to viewport plans. These boundaries let new metadata arrive without forcing every consumer to understand the source format.

References: platform/…/DicomMetadataStore.ts• L14-48 platform/…/DisplaySetService.ts• L29-59 platform/…/HangingProtocolService.ts• L23-68

Metadata representation

The metadata store is the in-session record of the studies used by the viewer. It preserves the DICOM hierarchy so later services can reason about a study, a series, or an individual instance without depending on the order in which data arrived.

Study hierarchy

A study is identified by its StudyInstanceUID and contains series. Each series is identified by its SeriesInstanceUID and contains unique instances identified by SOPInstanceUID. This hierarchy gives protocol rules and display creation a common path from a study-level choice to the image or object that supports it.

The store also keeps summary fields such as the study description and modalities. These fields can be present before all instances arrive, so the viewer can begin work while retrieval continues. platform/…/StudyMetadata.ts• L5-24

References: platform/…/StudyMetadata.ts• L5-24 platform/…/createStudyMetadata.js• L3-10 platform/…/createSeriesMetadata.js• L1-24

Incremental metadata intake

Metadata can enter as individual instances, groups of instances, series summaries, or study summaries. The store merges each form into the same study hierarchy and emits an event when new instances or series data become available. This lets downstream work start before the full study has loaded.

The store normalizes raw DICOM data before it adds it to the model. For multiframe data, it provides fallback access to shared image-plane fields so later display and matching work can use one metadata view. platform/…/DicomMetadataStore.ts• L176-238

References: platform/…/DicomMetadataStore.ts• L176-238 platform/…/DicomMetadataStore.ts• L240-302

Image metadata access

platform/…/MetadataProvider.ts is the image-facing metadata boundary. It resolves an image identifier to the study, series, instance, and frame that own the data, then returns the stored instance or a normalized metadata module for image consumers.

The provider supports web retrieval identifiers and locally registered identifiers. A frame in the image identifier takes precedence over a stored frame value, and a frame-specific registration takes precedence over a base-image registration. This keeps multiframe image access tied to the exact frame while preserving the shared study hierarchy.

The provider also keeps module ownership clear. For example, the General Image module supplies the instance number, while the SOP Common module supplies both the SOP class and SOP instance identifiers. Custom metadata remains available for data such as modality-specific scaling values. These rules give loaders and view components one stable access path without changing the source instance.

References: platform/…/MetadataProvider.ts• L21-40 platform/…/MetadataProvider.ts• L42-124 platform/…/MetadataProvider.ts• L452-485 platform/…/MetadataProvider.test.ts• L12-109

Display set normalization

A display set is the viewer's unit of display. It groups related instances and carries the study and series identity, display form, image or content references, and any known limits or warnings. It can also describe how its data is loaded and whether it belongs in the standard view. Display sets also carry the date and time used to order display units. For derived content, that value can describe when the displayed content was created rather than when its source series was created, so it remains separate from series metadata. platform/…/DisplaySet.ts• L13-103

Handler-based display units

The display set service converts series instances into one or more display sets through registered SOP class handlers. A SOP class handler is an extension capability that knows how a class of DICOM objects should become viewer data. This boundary allows image stacks, reports, overlays, derived data, and unsupported objects to follow the same platform path without forcing the core service to know each data type.

The service separates instances by SOP class before asking handlers to create display sets. It removes instances already handled by an existing display set, so repeated or partial metadata loads update existing units instead of creating duplicates. If no specialized handler accepts the data, the configured unsupported-data handler creates a marked fallback unit. A handler can also provide a load operation for content that metadata alone cannot display. platform/…/DisplaySetService.ts• L302-438, platform/…/index.tsx• L51-56, platform/…/DisplaySet.ts• L79-101

References: platform/…/DisplaySetService.ts• L302-438 platform/…/index.tsx• L51-56 platform/…/DisplaySet.ts• L13-32 platform/…/DisplaySet.ts• L79-101

Display set identity and status

Each display set has a displaySetInstanceUID that acts as its platform identity. The identity is separate from the series identity because one series can produce more than one display unit, and a client can create derived or overlay units that need their own place in the viewer.

Display sets can describe their relation to other data. An overlay can reference a display set, a derived unit can mark that it was created from another source, and display properties can tell consumers how to render it. Display-set messages carry user-facing reasons when a unit cannot fully support viewing. platform/…/DisplaySet.ts• L27-77, platform/…/DisplaySetMessage.ts• L7-27

Display-set date and time describe the content represented by that display set. Image display sets normally use the source image date and time, while derived display sets can use the creation date and time of the displayed object. Consumers must not copy these values back into series or instance metadata. When several display sets come from one series, their sort value can keep them together or order them by the content they show. platform/…/DisplaySet.ts• L67-103

Load and hydration are separate states. A loaded display set has the data needed for use, while a hydrated display set is included in the standard study view. A display set can be loaded but not hydrated, which lets derived content be ready for a dedicated viewport without adding it to ordinary viewports. Loading is a data operation, not a viewport assignment, so a handler can prepare content before the viewport that shows it is chosen. platform/…/DisplaySet.ts• L115-155

References: platform/…/DisplaySet.ts• L13-163 platform/…/DisplaySetMessage.ts• L7-56

Active display set access

The display set service keeps both a cache of known display sets and an ordered active list for the current mode. The cache supports lookup by display-set identity or by referenced series and instances. The active list is the set that current viewer work considers for sorting, protocol matching, and display.

The service publishes additions, changes, removals, and metadata invalidation. These events make the display set layer a stable boundary for consumers that must react as retrieval and client-created data change. platform/…/DisplaySetService.ts• L61-107, platform/…/EVENTS.js• L1-7

References: platform/…/DisplaySetService.ts• L61-107 platform/…/DisplaySetService.ts• L114-173 platform/…/EVENTS.js• L1-7

Protocol selection

A hanging protocol is a viewing plan that selects display sets and maps them to viewport layouts. The hanging protocol service receives studies and display sets, evaluates registered rules, and returns match details that describe the selected display sets and the viewports that should use them.

Protocol matching

Protocol matching considers the active study, other studies such as priors, and the display sets associated with each study. Study rules narrow the eligible studies, while series rules rank the display sets that can fill a protocol selector. Required rules can remove a candidate from consideration, while weighted rules contribute to its match score.

Custom attributes extend matching with values derived from the current studies or display sets. Examples include the number of series, the modalities in a study, whether a display set is reconstructable, and whether a display set was named in the URL. platform/…/HPMatcher.js• L12-125, platform/…/HangingProtocolService.ts• L70-114

References: platform/…/HPMatcher.js• L12-125 platform/…/HangingProtocolService.ts• L1508-1624 platform/…/HangingProtocolService.ts• L70-114

Protocol and stage application

The protocol engine ranks protocols by their study match and uses the highest score. If no protocol matches, the service uses the registered default protocol or the first available protocol. The chosen protocol contains stages, and each stage defines a layout plus selectors that identify the display sets for its viewports. platform/…/ProtocolEngine.js• L18-23, platform/…/ProtocolEngine.js• L107-173

The service marks stages as disabled, passive, or enabled. A disabled stage lacks required matches, a passive stage can be selected but is not the default choice, and an enabled stage can take part in normal selection. It then publishes match details and the selected stage so the viewport system can apply the plan. platform/…/HangingProtocol.ts• L231-237, platform/…/HangingProtocolService.ts• L963-998, platform/…/HangingProtocolService.ts• L1034-1103

References: platform/…/ProtocolEngine.js• L107-173 platform/…/HangingProtocol.ts• L134-158 platform/…/HangingProtocol.ts• L231-237 platform/…/HangingProtocolService.ts• L963-998

Retrieval and initial application

The default route listens for instance additions, creates display sets as series metadata arrives, and applies the hanging protocol after the required data is ready. It can start with only the series needed to run a protocol, then start the remaining retrieval work after the first layout is chosen.

URL-selected series or instances change this timing. In that case, the route waits for all retrieved series so the protocol can find the requested display set and image position. The route sorts active display sets before it builds the study list and runs protocol matching. platform/…/defaultRouteInit.ts• L26-55, platform/…/defaultRouteInit.ts• L57-155

References: platform/…/defaultRouteInit.ts• L26-55 platform/…/defaultRouteInit.ts• L57-155 platform/…/isDisplaySetFromUrl.ts• L3-45

Platform exposure

The lifecycle exposes two kinds of results: data objects that consumers can look up and events that tell consumers when those objects change. This separation lets the viewport, prefetch, study browser, and extensions respond to the same display-set state without owning its creation.

Service boundaries

DicomMetadataStore owns the study, series, and instance model. DisplaySetService owns display units and their active state. HangingProtocolService owns the selected viewing plan and its match details. The service registry exposes these owners through the shared service names used by the application and extensions. platform/…/index.ts• L7-21, platform/…/Services.ts• L23-39

The viewport layer receives display-set identifiers and display options rather than copies of display-set data. It can therefore resolve the current object from the display set service while the protocol service remains responsible for deciding which identifiers belong in each viewport. platform/…/HangingProtocol.ts• L3-25, platform/…/HangingProtocol.ts• L225-229

References: platform/…/index.ts• L7-21 platform/…/Services.ts• L23-39 platform/…/HangingProtocol.ts• L3-25 platform/…/HangingProtocol.ts• L225-229

Event boundaries

Metadata events signal that the source model has new study, series, or instance information. Display-set events signal that the viewer's display units were added, changed, removed, or need metadata invalidation. A consumer should use the event payload to decide when to read the owning service again rather than copy ownership into its own state.

Mode exit clears the active display-set cache and list. This makes display sets temporary viewer state, while the metadata store and an extension can provide the data again when a later mode needs it. platform/…/DisplaySetService.ts• L280-290

References: platform/…/DicomMetadataStore.ts• L7-12 platform/…/DicomMetadataStore.ts• L230-282 platform/…/EVENTS.js• L1-7 platform/…/DisplaySetService.ts• L280-290

Change checklist

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

  • When a metadata field or its type changes, check both protocol matching rules and the SOP class handlers that read it.
  • When image identifier parsing or frame precedence changes, check multiframe retrieval and every local image-ID registration path.
  • When metadata module ownership changes, check consumers that read General Image and SOP Common values as separate contracts.
  • When display-set identity or reference fields change, check viewport assignments, overlay lookup, and URL-selected display sets together.
  • When display-set date or time fields change, check series-list ordering and derived-content ordering without changing source series metadata.
  • When display-set creation becomes incremental, preserve the rule that repeated instances update existing units instead of creating duplicates.
  • When display-set loading or hydration state changes, check both dedicated derived-data views and standard study view selection.
  • When metadata or display-set event payloads change, check the route listener and every consumer that re-reads the owning service.
  • When protocol selector or stage rules change, check match scores, stage status, viewport match details, and saved protocol state as one contract.
  • When mode reset timing changes, check display-set retention and the point at which protocol matching starts.

Important failure modes

TriggerConsequenceGuard
A study, series, or instance lacks the identifier used to group itMetadata merges into the wrong level or cannot be found by later servicesPreserve StudyInstanceUID, SeriesInstanceUID, and SOPInstanceUID through metadata normalization
An image identifier has the wrong study, series, instance, or frame mappingThe viewer reads the wrong instance or frame, even though the image can still loadResolve web and local identifiers through the metadata provider and keep exact-frame mappings ahead of base mappings
A metadata consumer reads an identifier from the wrong DICOM moduleA module contract returns incomplete or misleading metadataKeep SOP class and SOP instance values in the SOP Common view and instance number in the General Image view
A specialized SOP class handler does not accept incoming instances and no fallback handler is availableThe instances do not become a display unitRegister the handler for the supported SOP classes and keep the unsupported-data handler available
A repeated metadata load creates a second display set for the same contentProtocol matching and viewport lists can show duplicate dataKeep display-set creation idempotent and update existing units when they support new instances
A derived display set uses its source series date as its display dateThe series list places the derived content by the wrong work dateKeep display-set date and time separate from series and instance metadata
A display set is loaded but treated as hydrated, or is hydrated without its required dataDerived content can appear in the wrong viewport or a standard viewport can try to show unavailable dataKeep data readiness (isLoaded) separate from standard-view selection (isHydrated)
A protocol selector has no matching display set or fails a required ruleIts viewport remains empty or its stage becomes unavailableProvide required series data before applying the protocol and inspect match details when a stage is disabled
A viewport receives a display-set identity that the service cannot resolveThe viewport has a plan but no display dataCreate or restore display sets before applying viewport assignments
A URL selects a series or instance before all candidate display sets existThe requested data is not selected or the initial image position is lostWait for the required retrieval set before applying URL-driven protocol selection

Key files

FileWhy to read it
platform/…/DicomMetadataStore.tsMain study, series, and instance data boundary
platform/…/createStudyMetadata.jsStudy grouping and incremental series intake
platform/…/createSeriesMetadata.jsSeries grouping and instance identity rules
platform/…/StudyMetadata.tsShared study, series, and instance shape
platform/…/MetadataProvider.tsImage-ID resolution and normalized metadata access
platform/…/MetadataProvider.test.tsContract examples for frame resolution and module boundaries
platform/…/DisplaySetService.tsDisplay-set creation, active state, lookup, and change events
platform/…/DisplaySet.tsDisplay-set identity, references, display ordering, loading state, and view state
platform/…/DisplaySetMessage.tsDisplay-set warning and error categories
platform/…/defaultRouteInit.tsRetrieval-to-display-set and initial protocol flow
platform/…/HangingProtocolService.tsProtocol matching, stage activation, and viewport match results
platform/…/ProtocolEngine.jsProtocol ranking and fallback selection
platform/…/HPMatcher.jsStudy and display-set rule scoring
platform/…/HangingProtocol.tsProtocol, selector, stage, and viewport contracts