Class: VolStack
Defined in: src/display/VolStack.ts:33
VolStack manages multiple VolLayer objects.
A VolLayer stores a single volumetric dataset (DenseNeuroVol) plus its rendering parameters (ColorMap, threshold, opacity, etc.). The VolStack class is a container of these VolLayer objects. You can treat it as a "stack" of 3D volumes, all presumably aligned in space, which can be iterated or manipulated as a group.
Typical uses:
- Holding multiple overlays or volumes for a single viewer (e.g. T1, T2, functional, or label data).
- Querying slices across all layers, to combine or composite them.
Geometry:
- The first layer is the reference: its NeuroSpace is the stack's space and defines slice indices, navigation and image-content space.
- A layer whose axes differ from the reference's is wrapped in a FacadeVolLayer.
- Layers need not share the reference's voxel grid. How a layer on another grid is drawn is decided by the renderer's alignment strategy ('world' places it at its true world position; see ImageLayer.renderSlice).
- Each layer must have a unique string ID.
Constructors
Constructor
new VolStack(...layers): VolStack;Defined in: src/display/VolStack.ts:63
Constructs a VolStack with multiple VolLayers. This enforces that all layers share identical orientation and field of view in the first three dimensions. Each layer in the argument list is added to an internal array.
Parameters
layers
...VolLayer[]
An array of VolLayer instances to initialize the stack.
Returns
VolStack
Throws
Error if no layers are provided, or if two layers share the same ID. (Note: in the code, orientation and field of view checks are commented out, but you may re-enable them to strictly require identical geometry.)
Accessors
layers
Get Signature
get layers(): readonly VolLayer[];Defined in: src/display/VolStack.ts:132
Returns an immutable view of the VolLayer array.
Remarks
This ensures outside code cannot mutate the array structure.
Returns
readonly VolLayer[]
length
Get Signature
get length(): number;Defined in: src/display/VolStack.ts:139
Reports how many VolLayers are in this stack.
Returns
number
space
Get Signature
get space(): NeuroSpace;Defined in: src/display/VolStack.ts:147
The NeuroSpace of the first VolLayer. Usually all VolLayers share the same space, or the stack logic might break.
Returns
layerCount
Get Signature
get layerCount(): number;Defined in: src/display/VolStack.ts:299
Returns the total count of VolLayers in this stack (same as length).
Returns
number
Methods
getLayer()
getLayer(index): VolLayer;Defined in: src/display/VolStack.ts:100
Retrieves a VolLayer by its index in the stack.
Parameters
index
number
The numeric index (0-based) of the desired layer.
Returns
The VolLayer object at that index.
Remarks
No bounds checking is done here; an out-of-range index will simply throw or return undefined.
getLayers()
getLayers(): VolLayer[];Defined in: src/display/VolStack.ts:109
Returns the entire array of VolLayer objects stored in this VolStack.
Returns
VolLayer[]
A standard JavaScript array of VolLayer instances.
getVolume()
getVolume(index): VolLayer;Defined in: src/display/VolStack.ts:120
Retrieves a VolLayer by its index with explicit bounds checking.
Parameters
index
number
The index of the desired layer (0-based).
Returns
The VolLayer at the specified index if valid.
Throws
Error if the index is out of range.
addLayer()
addLayer(layer): void;Defined in: src/display/VolStack.ts:158
Inserts a new VolLayer into the stack, validating that its orientation and field of view match the existing stack, and that its ID is unique.
Parameters
layer
The VolLayer object to add.
Returns
void
Throws
Error if the layer has a duplicate ID or mismatched geometry.
removeLayer()
removeLayer(layer): void;Defined in: src/display/VolStack.ts:188
Removes a specific VolLayer instance from the stack if found.
Parameters
layer
The VolLayer to remove.
Returns
void
getLayerIds()
getLayerIds(): string[];Defined in: src/display/VolStack.ts:200
Retrieves all layer IDs present in the stack.
Returns
string[]
A string array of layer IDs in the order they appear in volLayers.
getLayerById()
getLayerById(id): VolLayer | undefined;Defined in: src/display/VolStack.ts:210
Attempts to find a VolLayer by a string ID.
Parameters
id
string
The unique ID of the layer to retrieve.
Returns
VolLayer | undefined
The matching VolLayer or undefined if none match.
getLayerIndexById()
getLayerIndexById(id): number;Defined in: src/display/VolStack.ts:220
Finds the array index of a given layer ID, returning -1 if not found.
Parameters
id
string
The layer ID to look for.
Returns
number
The 0-based index or -1 if not present.
moveLayer()
moveLayer(fromIndex, toIndex): void;Defined in: src/display/VolStack.ts:227
Move a layer from one index to another.
Parameters
fromIndex
number
toIndex
number
Returns
void
moveLayerById()
moveLayerById(id, toIndex): void;Defined in: src/display/VolStack.ts:239
Move a layer by ID to a new index.
Parameters
id
string
toIndex
number
Returns
void
getSlice()
getSlice(sliceIndex, outAxes): ImageSlice[];Defined in: src/display/VolStack.ts:253
Generates 2D slices (ImageSlice) from every VolLayer in the stack based on an integer slice index and a given set of output axes.
Parameters
sliceIndex
number
The discrete slice index (like z=12).
outAxes
The orientation in which to extract the slice.
Returns
An array of ImageSlice, one per VolLayer, in the same order as volLayers.
getSliceAt()
getSliceAt(
coord,
outAxes,
interpolation?): ImageSlice[];Defined in: src/display/VolStack.ts:266
Creates 2D slices at a specific real-world coordinate, for each VolLayer, optionally with a chosen interpolation method.
Parameters
coord
number[]
A real-valued coordinate [x, y, z], typically in mm within the volume space.
outAxes
Which orientation to reorient the slice (e.g. AXIAL_LPI).
interpolation?
"nearest" | "trilinear"
"nearest" or "trilinear" (default is "trilinear").
Returns
A parallel array of ImageSlice results, one per VolLayer.
getOrthoSliceAt()
getOrthoSliceAt(coord, interpolation?): object;Defined in: src/display/VolStack.ts:280
Obtains orthogonal slices (axial, sagittal, coronal) at the specified coordinate from every VolLayer in the stack. This might be used to quickly get the triple-plane cross-sections for a user-selected point.
Parameters
coord
number[]
The [x, y, z] location in the volume's space.
interpolation?
"nearest" | "trilinear"
Either "nearest" or "trilinear" sampling.
Returns
object
An object with arrays of ImageSlice for each orientation (axial, sagittal, coronal). The length of each array matches the number of layers in the stack.
axial
axial: ImageSlice[];sagittal
sagittal: ImageSlice[];coronal
coronal: ImageSlice[];