Skip to content

Class: SimpleOrthogonalViewer ​

Defined in: src/display/SimpleOrthogonalViewer.ts:77

Simple wrapper around OrthogonalImageViewer that exposes a minimal, programmatic API suitable for embedding in external applications without shipping UI widgets.

This is the recommended (canonical) high-level 3-up orthogonal viewer. For custom layouts or finer control, compose SingleSliceViewer instances with ViewSynchronizer instead. See the architecture note on SliceViewer.

Methods ​

getLegendElement() ​

ts
getLegendElement(): HTMLElement | null;

Defined in: src/display/SimpleOrthogonalViewer.ts:102

The empty fourth cell of the 'ortho' layout, for a host-supplied legend or readout. Null for other layouts.

Returns ​

HTMLElement | null


setFitBounds() ​

ts
setFitBounds(bounds): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:110

Fits all views to a box of reference-grid voxel indices (inclusive), e.g. the head's bounding box; null restores the full field of view.

Parameters ​

bounds ​

| { min: number[]; max: number[]; } | null

Returns ​

void


setStackedView() ​

ts
setStackedView(view): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:115

Chooses the view shown when a stacked 'ortho' layout is in 'single' mode.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

Returns ​

void


isStacked() ​

ts
isStacked(): boolean;

Defined in: src/display/SimpleOrthogonalViewer.ts:120

Whether the 'ortho' layout is currently stacked.

Returns ​

boolean


create() ​

ts
static create(
   container, 
   volStack, 
   options?): Promise<SimpleOrthogonalViewer>;

Defined in: src/display/SimpleOrthogonalViewer.ts:124

Parameters ​

container ​

HTMLElement

volStack ​

VolStack

options? ​

SimpleOrthogonalViewerOptions

Returns ​

Promise<SimpleOrthogonalViewer>


setWorldCoord() ​

ts
setWorldCoord(coord): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:176

Parameters ​

coord ​

number[]

Returns ​

void


getWorldCoord() ​

ts
getWorldCoord(): number[];

Defined in: src/display/SimpleOrthogonalViewer.ts:180

Returns ​

number[]


setLPICoord() ​

ts
setLPICoord(lpiCoord): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:190

Set position through the legacy axis-aligned LPI grid mapping. This equals world coordinates only for LPI-stored, axis-aligned volumes.

Parameters ​

lpiCoord ​

[number, number, number]

Returns ​

void

Deprecated ​

Use setWorldCoord with RAS+ millimetres. This method maps through voxel indices and depends on the volume's storage orientation.


getLPICoord() ​

ts
getLPICoord(): [number, number, number];

Defined in: src/display/SimpleOrthogonalViewer.ts:206

Read current position through the legacy axis-aligned LPI grid mapping.

Returns ​

[number, number, number]

Deprecated ​

Use getWorldCoord for RAS+ millimetres independent of storage.


setSliceIndex() ​

ts
setSliceIndex(view, index): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:225

Set the discrete slice index for a specific orthogonal view. This is often more convenient than computing a world coordinate.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

index ​

number

Returns ​

void


getSliceIndex() ​

ts
getSliceIndex(view): number;

Defined in: src/display/SimpleOrthogonalViewer.ts:233

Get the current slice index for a specific view.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

Returns ​

number


addLayer() ​

ts
addLayer(layer): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:238

Parameters ​

layer ​

VolLayer

Returns ​

void


removeLayer() ​

ts
removeLayer(layerId): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:244

Parameters ​

layerId ​

string

Returns ​

void


updateLayer() ​

ts
updateLayer(layerId, params): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:253

Parameters ​

layerId ​

string

params ​
colormap? ​

string | ColorMap

range? ​

[number, number]

threshold? ​

[number, number]

alpha? ​

number

visible? ​

boolean

Returns ​

void


updateLayerVolume() ​

ts
updateLayerVolume(
   layerId, 
   volume, 
   opts?): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:281

Replace the underlying volume for an existing layer (keeps z-order and id). Handy for fast overlay updates (e.g., sigma changes) without add/remove.

Parameters ​

layerId ​

string

volume ​

NeuroVol

opts? ​
range? ​

[number, number] | null

threshold? ​

[number, number]

alpha? ​

number

colormap? ​

string | ColorMap

Returns ​

void


getValue() ​

ts
getValue(layerId, worldCoord?): number | null;

Defined in: src/display/SimpleOrthogonalViewer.ts:309

Read the nearest raw voxel value for a layer at a world coordinate. Each layer is read on its own voxel grid, so layers on different grids each report their own voxel at the same world position. Returns null when the coordinate is outside the volume or the voxel is not finite.

Parameters ​

layerId ​

string

worldCoord? ​

number[] = ...

Returns ​

number | null


getCanvas() ​

ts
getCanvas(view): HTMLCanvasElement;

Defined in: src/display/SimpleOrthogonalViewer.ts:323

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

Returns ​

HTMLCanvasElement


setBackground() ​

ts
setBackground(color, alpha?): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:333

Changes the canvas clear colour of every view in place, without a rebuild.

Parameters ​

color ​

number

PIXI numeric colour, e.g. 0x111619.

alpha? ​

number

Optional clear alpha in [0, 1].

Returns ​

void


setCrosshairStyle() ​

ts
setCrosshairStyle(options): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:352

Restyles the crosshair in every view (colour, alpha, halo, width, gap). Omitted fields keep their current value.

Parameters ​

options ​

CrossHairOptions

Returns ​

void


setOrientationLabelStyle() ​

ts
setOrientationLabelStyle(options): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:360

Restyles the orientation labels in every view (colour, alpha, stroke, shadow, font). Omitted fields keep their current value.

Parameters ​

options ​

OrientationLabelOptions

Returns ​

void


setTheme() ​

ts
setTheme(theme): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:369

Applies a (partial) theme — background, crosshair and orientation-label styling — in place. Switching a viewer between a light and a dark ground no longer requires disposing and re-creating it.

Parameters ​

theme ​

ViewerTheme

Returns ​

void


setCrosshairVisible() ​

ts
setCrosshairVisible(visible): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:375

Parameters ​

visible ​

boolean

Returns ​

void


onReady() ​

ts
onReady(handler): () => void;

Defined in: src/display/SimpleOrthogonalViewer.ts:380

Parameters ​

handler ​

() => void

Returns ​

() => void


onCoordChange() ​

ts
onCoordChange(handler): () => void;

Defined in: src/display/SimpleOrthogonalViewer.ts:383

Parameters ​

handler ​

(coord) => void

Returns ​

() => void


onSliceChange() ​

ts
onSliceChange(handler): () => void;

Defined in: src/display/SimpleOrthogonalViewer.ts:386

Parameters ​

handler ​

(p) => void

Returns ​

() => void


setAlignmentOptions() ​

ts
setAlignmentOptions(options): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:391

Parameters ​

options ​

Partial<AlignmentManagerOptions>

Returns ​

void


setAlignmentStrategy() ​

ts
setAlignmentStrategy(strategy): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:396

Parameters ​

strategy ​

AlignmentStrategyType

Returns ​

void


moveLayer() ​

ts
moveLayer(layerId, toIndex): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:404

Change z-order of a layer (0 = back/reference). Emits layerOrderChanged.

Parameters ​

layerId ​

string

toIndex ​

number

Returns ​

void


setFocusedView() ​

ts
setFocusedView(view): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:412

Parameters ​

view ​

"axial" | "coronal" | "sagittal" | null

Returns ​

void


setOrientationLabelsVisible() ​

ts
setOrientationLabelsVisible(visible, options?): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:422

Toggle anatomical orientation labels (L/R/A/P/S/I) across all three views.

Parameters ​

visible ​

boolean

Whether the labels should be shown.

options? ​

OrientationLabelOptions

Optional styling applied to every sub-view.

Returns ​

void


listLayers() ​

ts
listLayers(): object[];

Defined in: src/display/SimpleOrthogonalViewer.ts:439

Enumerate layers with display state for external systems.

Returns ​

object[]


getState() ​

ts
getState(): object;

Defined in: src/display/SimpleOrthogonalViewer.ts:464

Snapshot minimal viewer state for persistence.

Returns ​

object

worldCoord ​
ts
worldCoord: number[];
lpiCoord ​
ts
lpiCoord: [number, number, number];
slices ​
ts
slices: object;
slices.axial ​
ts
axial: number;
slices.coronal ​
ts
coronal: number;
slices.sagittal ​
ts
sagittal: number;
layers ​
ts
layers: object[];

applyState() ​

ts
applyState(state): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:485

Restore viewer state (best-effort). Does not alter layout.

Parameters ​

state ​

Partial<ReturnType<SimpleOrthogonalViewer["getState"]>>

Returns ​

void


toDataURL() ​

ts
toDataURL(
   view, 
   type?, 
   quality?): string;

Defined in: src/display/SimpleOrthogonalViewer.ts:514

Export a PNG/JPEG of a specific view's canvas.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

type? ​

string = 'image/png'

quality? ​

number

Returns ​

string


setZoom() ​

ts
setZoom(view, level): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:532

Set the zoom level for a specific view.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

level ​

number

Returns ​

void


getZoom() ​

ts
getZoom(view): number;

Defined in: src/display/SimpleOrthogonalViewer.ts:543

Get the current zoom level for a specific view.

Parameters ​

view ​

"axial" | "coronal" | "sagittal"

Returns ​

number


resetAllViews() ​

ts
resetAllViews(): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:552

Reset zoom and pan for all views.

Returns ​

void


dispose() ​

ts
dispose(): void;

Defined in: src/display/SimpleOrthogonalViewer.ts:562

Returns ​

void

Released under the MIT License.