Skip to content

Class: VolLayer ​

Defined in: src/display/VolLayer.ts:47

Constructors ​

Constructor ​

ts
new VolLayer(
   id, 
   volume, 
   colorMap, 
   range?, 
   threshold?, 
   opacity?, 
   cacheSize?): VolLayer;

Defined in: src/display/VolLayer.ts:152

Constructs a new VolLayer.

Parameters ​

id ​

string

A unique identifier for the layer.

volume ​

NeuroVol

The 3D neuroimaging volume data. Can be any NeuroVol implementation (DenseNeuroVol, SparseNeuroVol, LogicalNeuroVol, ClusteredNeuroVol).

colorMap ​

ColorMap

Instance of a ColorMap used for intensity -> RGBA transformation.

range? ​

Range | null

[Optional] The initial intensity range [min, max]. If not provided, it is inferred from the volume data.

threshold? ​

Threshold = ...

[Optional] The threshold range [low, high]. Defaults to [0, 0].

opacity? ​

number = 1.0

[Optional] The global opacity of this layer (0 to 1). Defaults to 1.0.

cacheSize? ​

number

Returns ​

VolLayer

Properties ​

id ​

ts
id: string;

Defined in: src/display/VolLayer.ts:51

A unique identifier for the layer.


volume ​

ts
volume: NeuroVol;

Defined in: src/display/VolLayer.ts:56

The underlying volume data. Can be any NeuroVol implementation.


colorMap ​

ts
colorMap: ColorMap;

Defined in: src/display/VolLayer.ts:62

Color mapping configuration for this volume layer. Used to transform intensity values to RGBA values.


opacity ​

ts
opacity: number;

Defined in: src/display/VolLayer.ts:67

Global opacity for this layer (0 to 1).


visible ​

ts
visible: boolean;

Defined in: src/display/VolLayer.ts:72

Whether this layer is visible.


range ​

ts
range: Range;

Defined in: src/display/VolLayer.ts:79

The intensity range [min, max] used for visualization. Values outside this range may be clipped or mapped differently, depending on the color map.


threshold ​

ts
threshold: Threshold;

Defined in: src/display/VolLayer.ts:86

The intensity threshold [low, high] used for masking. Intensity values outside this threshold range may be set to transparent, depending on the color map.


version ​

ts
version: number = 0;

Defined in: src/display/VolLayer.ts:92

Version number that increments whenever colormap settings change. Used by ImageLayer to invalidate texture cache.


textureVersion ​

ts
textureVersion: number = 0;

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

Bumped only when the colour-mapped pixels change (not for opacity), so renderers can reuse uploaded textures across opacity changes.


interpolation ​

ts
interpolation: SliceInterpolation = 'linear';

Defined in: src/display/VolLayer.ts:107

Sampling for display. Note: 'smooth' is meant for overlays resampled on the reference (layer 0) grid; the reference layer itself should not use it.


outline ​

ts
outline: number = 0;

Defined in: src/display/VolLayer.ts:114

Strength in [0, 1] of a dark outline drawn on the visible side of every edge between drawn and transparent pixels (i.e. at the threshold contour). 0 disables it.


edgeFade ​

ts
edgeFade: number = 0;

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

Width, in voxels, of an alpha ramp at the slice's outer edges, so a field of view that ends inside tissue fades out instead of stopping at a hard line. 0 disables it.


minOutlineClusterSize ​

ts
minOutlineClusterSize: number = 0;

Defined in: src/display/VolLayer.ts:128

Only suprathreshold clusters with at least this many voxels (3-D, 26-connected, same sign) get the threshold-contour outline; smaller clusters are still drawn, just not outlined. 0 or 1 outlines everything.

Accessors ​

space ​

Get Signature ​

ts
get space(): NeuroSpace;

Defined in: src/display/VolLayer.ts:189

Returns the NeuroSpace of the underlying volume, describing dimensions, spacing, and orientation.

Returns ​

NeuroSpace

Methods ​

getSlice() ​

ts
getSlice(sliceIndex, outAxes): ImageSlice;

Defined in: src/display/VolLayer.ts:201

Retrieves a 2D slice from the volume given a slice index (in voxel coordinates) and an orientation (outAxes). The result is cached to avoid recomputation.

Parameters ​

sliceIndex ​

number

The integer slice index in the volume (voxel coordinate).

outAxes ​

AxisSet3D

The desired orientation axes for the output slice.

Returns ​

ImageSlice

An ImageSlice containing the 2D image data plus spatial metadata.


getTransformationToReference() ​

ts
getTransformationToReference(referenceSpace): Matrix;

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

Retrieves a transformation matrix from this layer's space to a reference space.

Parameters ​

referenceSpace ​

NeuroSpace

The reference NeuroSpace to transform into.

Returns ​

Matrix

A 4x4 transformation Matrix.


getSliceAt() ​

ts
getSliceAt(
   coord, 
   outAxes, 
   interpolation?): ImageSlice;

Defined in: src/display/VolLayer.ts:246

Retrieves a 2D slice by real-world (or continuous) coordinates, rather than integer indices. Uses the specified interpolation mode. Caches the result for faster subsequent retrieval.

Parameters ​

coord ​

number[]

The [x, y, z] coordinate in the volume's space.

outAxes ​

AxisSet3D

The orientation for the output slice.

interpolation? ​

"nearest" | "trilinear"

The interpolation method: 'nearest' or 'trilinear'. Defaults to 'trilinear'.

Returns ​

ImageSlice

An ImageSlice with the processed 2D image data plus spatial metadata.


replaceVolume() ​

ts
replaceVolume(newVolume, opts?): void;

Defined in: src/display/VolLayer.ts:283

Replace the underlying volume while keeping the same layer id and color settings. Faster than removing/re-adding a layer because it preserves viewer references.

Parameters ​

newVolume ​

NeuroVol

A NeuroVol with matching geometry (dim, axes, spacing, origin).

opts? ​

Optional display overrides (range/threshold/opacity/colormap).

range? ​

Range | null

threshold? ​

Threshold

opacity? ​

number

colormap? ​

ColorMap

Returns ​

void


getOrthoSliceAt() ​

ts
getOrthoSliceAt(coord, interpolation?): object;

Defined in: src/display/VolLayer.ts:370

Retrieves three orthogonal slices (axial, sagittal, coronal) at a specific coordinate.

Parameters ​

coord ​

number[]

The [x, y, z] coordinate in the volume's space.

interpolation? ​

"nearest" | "trilinear"

Interpolation method: 'nearest' or 'trilinear'. Defaults to 'trilinear'.

Returns ​

object

An object containing axial, sagittal, and coronal slices.

axial ​
ts
axial: ImageSlice;
sagittal ​
ts
sagittal: ImageSlice;
coronal ​
ts
coronal: ImageSlice;

containsCoord() ​

ts
containsCoord(coord): boolean;

Defined in: src/display/VolLayer.ts:444

Checks if the provided coordinate is within the boundaries of this volume's space.

Parameters ​

coord ​

number[]

A [x, y, z] coordinate in real-world or continuous space.

Returns ​

boolean

True if the coordinate lies within the volume bounds, false otherwise.


setColormap() ​

ts
setColormap(colormap): void;

Defined in: src/display/VolLayer.ts:454

Replaces the current ColorMap with a new one and invalidates the slice cache.

Parameters ​

colormap ​

ColorMap

The new ColorMap to use.

Returns ​

void


getCacheStats() ​

ts
getCacheStats(): object;

Defined in: src/display/VolLayer.ts:476

Gets cache statistics for monitoring performance

Returns ​

object

size ​
ts
size: number;
capacity ​
ts
capacity: number;
hits ​
ts
hits: number;
misses ​
ts
misses: number;
evictions ​
ts
evictions: number;
hitRatio ​
ts
hitRatio: number;

getRange() ​

ts
getRange(): Range;

Defined in: src/display/VolLayer.ts:490

Retrieves the current intensity range used by this layer.

Returns ​

Range


getVolumeRange() ​

ts
getVolumeRange(): [number, number];

Defined in: src/display/VolLayer.ts:498

Retrieves the full intensity range of the underlying volume, as calculated by the volume data itself.

Returns ​

[number, number]


getThreshold() ​

ts
getThreshold(): Threshold;

Defined in: src/display/VolLayer.ts:505

Retrieves the current threshold range used by this layer.

Returns ​

Threshold


setThreshold() ​

ts
setThreshold(threshold): void;

Defined in: src/display/VolLayer.ts:515

Sets a new intensity threshold [low, high] and invalidates the cache.

Parameters ​

threshold ​

Threshold

The new threshold to apply.

Returns ​

void


setOpacity() ​

ts
setOpacity(opacity): void;

Defined in: src/display/VolLayer.ts:527

Sets a new opacity (0-1) for this layer and invalidates the cache.

Parameters ​

opacity ​

number

The new opacity value.

Returns ​

void


setMinOutlineClusterSize() ​

ts
setMinOutlineClusterSize(voxels): void;

Defined in: src/display/VolLayer.ts:572

Sets the minimum 3-D cluster size (voxels) that gets a threshold outline.

Parameters ​

voxels ​

number

Returns ​

void


setEdgeFade() ​

ts
setEdgeFade(voxels): void;

Defined in: src/display/VolLayer.ts:583

Sets the edge fade width in voxels (0 disables).

Parameters ​

voxels ​

number

Returns ​

void


setOutline() ​

ts
setOutline(strength): void;

Defined in: src/display/VolLayer.ts:594

Sets the threshold-contour outline strength (0 disables).

Parameters ​

strength ​

number

Returns ​

void


setInterpolation() ​

ts
setInterpolation(interpolation): void;

Defined in: src/display/VolLayer.ts:605

Sets how the slice is resampled for display; see SliceInterpolation.

Parameters ​

interpolation ​

SliceInterpolation

Returns ​

void


setRange() ​

ts
setRange(range): void;

Defined in: src/display/VolLayer.ts:618

Sets a new intensity range [min, max] for visualization and invalidates the cache.

Parameters ​

range ​

Range

The new intensity range.

Returns ​

void


setVisible() ​

ts
setVisible(visible): void;

Defined in: src/display/VolLayer.ts:630

Sets the visibility of this layer.

Parameters ​

visible ​

boolean

Whether the layer should be visible.

Returns ​

void

Released under the MIT License.