Class: VolLayer
Defined in: src/display/VolLayer.ts:34
VolLayer is a wrapper around a NeuroVol (3D neuroimaging volume) that manages slice extraction, caching, and color/opacity settings for visualization.
Supports any volume type implementing NeuroVol interface:
- DenseNeuroVol: Dense typed array storage
- SparseNeuroVol: Sparse voxel storage (memory efficient for masks/ROIs)
- LogicalNeuroVol: Boolean mask volumes
- ClusteredNeuroVol: Labeled/parcellated volumes
Constructors
Constructor
new VolLayer(
id,
volume,
colorMap,
range?,
threshold?,
opacity?,
cacheSize?): VolLayer;Defined in: src/display/VolLayer.ts:101
Constructs a new VolLayer.
Parameters
id
string
A unique identifier for the layer.
volume
The 3D neuroimaging volume data. Can be any NeuroVol implementation (DenseNeuroVol, SparseNeuroVol, LogicalNeuroVol, ClusteredNeuroVol).
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
id: string;Defined in: src/display/VolLayer.ts:38
A unique identifier for the layer.
volume
volume: NeuroVol;Defined in: src/display/VolLayer.ts:43
The underlying volume data. Can be any NeuroVol implementation.
colorMap
colorMap: ColorMap;Defined in: src/display/VolLayer.ts:49
Color mapping configuration for this volume layer. Used to transform intensity values to RGBA values.
opacity
opacity: number;Defined in: src/display/VolLayer.ts:54
Global opacity for this layer (0 to 1).
visible
visible: boolean;Defined in: src/display/VolLayer.ts:59
Whether this layer is visible.
range
range: Range;Defined in: src/display/VolLayer.ts:66
The intensity range [min, max] used for visualization. Values outside this range may be clipped or mapped differently, depending on the color map.
threshold
threshold: Threshold;Defined in: src/display/VolLayer.ts:73
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
version: number = 0;Defined in: src/display/VolLayer.ts:79
Version number that increments whenever colormap settings change. Used by ImageLayer to invalidate texture cache.
Accessors
space
Get Signature
get space(): NeuroSpace;Defined in: src/display/VolLayer.ts:135
Returns the NeuroSpace of the underlying volume, describing dimensions, spacing, and orientation.
Returns
Methods
getSlice()
getSlice(sliceIndex, outAxes): ImageSlice;Defined in: src/display/VolLayer.ts:147
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
The desired orientation axes for the output slice.
Returns
ImageSlice
An ImageSlice containing the 2D image data plus spatial metadata.
getTransformationToReference()
getTransformationToReference(referenceSpace): Matrix;Defined in: src/display/VolLayer.ts:178
Retrieves a transformation matrix from this layer's space to a reference space.
Parameters
referenceSpace
The reference NeuroSpace to transform into.
Returns
Matrix
A 4x4 transformation Matrix.
getSliceAt()
getSliceAt(
coord,
outAxes,
interpolation?): ImageSlice;Defined in: src/display/VolLayer.ts:191
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
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()
replaceVolume(newVolume, opts?): void;Defined in: src/display/VolLayer.ts:226
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
A NeuroVol with matching geometry (dim, axes, spacing, origin).
opts?
Optional display overrides (range/threshold/opacity/colormap).
range?
Range | null
threshold?
opacity?
number
colormap?
Returns
void
getOrthoSliceAt()
getOrthoSliceAt(coord, interpolation?): object;Defined in: src/display/VolLayer.ts:298
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
axial: ImageSlice;sagittal
sagittal: ImageSlice;coronal
coronal: ImageSlice;containsCoord()
containsCoord(coord): boolean;Defined in: src/display/VolLayer.ts:372
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()
setColormap(colormap): void;Defined in: src/display/VolLayer.ts:382
Replaces the current ColorMap with a new one and invalidates the slice cache.
Parameters
colormap
The new ColorMap to use.
Returns
void
getCacheStats()
getCacheStats(): object;Defined in: src/display/VolLayer.ts:404
Gets cache statistics for monitoring performance
Returns
object
size
size: number;capacity
capacity: number;hits
hits: number;misses
misses: number;evictions
evictions: number;hitRatio
hitRatio: number;getRange()
getRange(): Range;Defined in: src/display/VolLayer.ts:418
Retrieves the current intensity range used by this layer.
Returns
getVolumeRange()
getVolumeRange(): [number, number];Defined in: src/display/VolLayer.ts:426
Retrieves the full intensity range of the underlying volume, as calculated by the volume data itself.
Returns
[number, number]
getThreshold()
getThreshold(): Threshold;Defined in: src/display/VolLayer.ts:433
Retrieves the current threshold range used by this layer.
Returns
setThreshold()
setThreshold(threshold): void;Defined in: src/display/VolLayer.ts:443
Sets a new intensity threshold [low, high] and invalidates the cache.
Parameters
threshold
The new threshold to apply.
Returns
void
setOpacity()
setOpacity(opacity): void;Defined in: src/display/VolLayer.ts:455
Sets a new opacity (0-1) for this layer and invalidates the cache.
Parameters
opacity
number
The new opacity value.
Returns
void
setRange()
setRange(range): void;Defined in: src/display/VolLayer.ts:467
Sets a new intensity range [min, max] for visualization and invalidates the cache.
Parameters
range
The new intensity range.
Returns
void
setVisible()
setVisible(visible): void;Defined in: src/display/VolLayer.ts:479
Sets the visibility of this layer.
Parameters
visible
boolean
Whether the layer should be visible.
Returns
void