Skip to content

Class: OrientationLabelLayer ​

Defined in: src/display/OrientationLabelLayer.ts:80

OrientationLabelLayer renders anatomical direction labels (L/R/A/P/S/I) pinned to the four edges of the viewport, at a fixed screen size — exactly as typical neuroimaging viewers (FSLeyes, MRIcron) display them.

Why this is a screen-space layer ​

The slice image is rendered into a container that is scaled to fit and Y-flipped. Anything placed in that container scales and flips with the image. Orientation labels must instead stay a constant pixel size and stay pinned to the viewport edges through zoom/pan/resize, so this layer declares screenSpace and is rendered by SliceView into an unscaled, stage-level overlay container.

How the letters are assigned to edges (correctness) ​

The letters for the in-plane axes (viewAxes.i, viewAxes.j) come from the orientation, but which screen edge each letter belongs to is derived from the live image transform via ScreenLayoutContext.project. We project the endpoints of the i- and j-axes to screen pixels and assign each label to the edge it actually points to. This guarantees the labels can never disagree with the rendered image, regardless of axis flips, zoom, or pan — which is essential because mislabeling Left/Right is a serious error in neuroimaging.

Implements ​

Constructors ​

Constructor ​

ts
new OrientationLabelLayer(neuroSpace, options?): OrientationLabelLayer;

Defined in: src/display/OrientationLabelLayer.ts:98

Parameters ​

neuroSpace ​

NeuroSpace

options? ​

OrientationLabelOptions

Returns ​

OrientationLabelLayer

Properties ​

screenSpace ​

ts
readonly screenSpace: true = true;

Defined in: src/display/OrientationLabelLayer.ts:81

If true, this layer renders in screen-pixel space rather than in the scaled/Y-flipped image content space.

The container returned by renderSlice is added to a dedicated, unscaled overlay container that sits on top of the image. Such layers are excluded from the image's fit-to-screen bounds (so they never affect the image scale) and must position their content using viewport pixel coordinates via layoutScreen.

Use this for overlays that should stay a constant size and stay pinned to the viewport (orientation labels, scale bars, fixed HUD text) instead of tracking the anatomy.

Implementation of ​

SliceLayer.screenSpace


neuroSpace ​

ts
neuroSpace: NeuroSpace;

Defined in: src/display/OrientationLabelLayer.ts:82

The NeuroSpace associated with the layer. Ensures spatial coherence with other layers in the viewer.

Implementation of ​

SliceLayer.neuroSpace

Methods ​

initialize() ​

ts
initialize(): void;

Defined in: src/display/OrientationLabelLayer.ts:117

Initializes the layer, loading any necessary data or resources. This method is called once when the layer is added to the SliceViewer. It can perform asynchronous operations if needed.

Returns ​

void

Implementation of ​

SliceLayer.initialize


renderSlice() ​

ts
renderSlice(
   _sliceIndex, 
   _coord, 
   viewAxes, 
   _parentContainer): Container<ContainerChild> | null;

Defined in: src/display/OrientationLabelLayer.ts:121

Renders the slice for the current slice index and view axes. This method is called whenever the SliceViewer updates the slice index or the view orientation.

Parameters ​

_sliceIndex ​

number

_coord ​

number[]

viewAxes ​

AxisSet3D

The AxisSet3D defining the view orientation.

_parentContainer ​

Container

Returns ​

Container<ContainerChild> | null

A PIXI.Container or PIXI.DisplayObject containing the rendered content. Returns null if the layer has nothing to render for the given slice.

Implementation of ​

SliceLayer.renderSlice


layoutScreen() ​

ts
layoutScreen(ctx): void;

Defined in: src/display/OrientationLabelLayer.ts:162

Pin the four labels to the viewport edges. The edge each label belongs to is derived from the live image transform so the labels always match the image.

Parameters ​

ctx ​

ScreenLayoutContext

Returns ​

void

Implementation of ​

SliceLayer.layoutScreen


setStyle() ​

ts
setStyle(options): void;

Defined in: src/display/OrientationLabelLayer.ts:305

Updates any subset of the label styling in place (e.g. to follow a light/dark theme switch). Existing Text objects are restyled rather than rebuilt, so the shared PIXI text pool is not churned. Layout-affecting options (margin, anchor, font size) take effect on the next layout pass; SliceViewer.setOrientationLabelStyle triggers one.

Parameters ​

options ​

OrientationLabelOptions

Returns ​

void


getStyle() ​

ts
getStyle(): Required<OrientationLabelOptions>;

Defined in: src/display/OrientationLabelLayer.ts:320

The styling currently in effect.

Returns ​

Required<OrientationLabelOptions>


setPosition() ​

ts
setPosition(_coord): void;

Defined in: src/display/OrientationLabelLayer.ts:331

Updates the layer's state based on the new volume coordinates. This method is called whenever the SliceViewer's position changes, ensuring that the layer remains in sync with the current view.

Parameters ​

_coord ​

number[]

Returns ​

void

Implementation of ​

SliceLayer.setPosition


onPointerMove() ​

ts
onPointerMove(_event): boolean;

Defined in: src/display/OrientationLabelLayer.ts:335

Handles pointer (mouse or touch) move events. Layers can implement this method to provide interactive behaviors, such as displaying tooltips or highlighting regions.

Parameters ​

_event ​

SlicePointerEvent

Returns ​

boolean

A boolean indicating whether the event has been fully handled. If true, the event propagation stops, preventing other layers from handling it.

Implementation of ​

SliceLayer.onPointerMove


onPointerDown() ​

ts
onPointerDown(_event): boolean;

Defined in: src/display/OrientationLabelLayer.ts:339

Handles pointer (mouse or touch) down events. Layers can implement this method to provide interactive behaviors, such as selecting regions or initiating drag operations.

Parameters ​

_event ​

SlicePointerEvent

Returns ​

boolean

A boolean indicating whether the event has been fully handled. If true, the event propagation stops, preventing other layers from handling it.

Implementation of ​

SliceLayer.onPointerDown


dispose() ​

ts
dispose(): void;

Defined in: src/display/OrientationLabelLayer.ts:343

Disposes of the layer, cleaning up any resources or event listeners. This method is called when the layer is removed from the SliceViewer or when the SliceViewer itself is disposed.

Returns ​

void

Implementation of ​

SliceLayer.dispose

Released under the MIT License.