Class: VolStack
Defined in: src/display/VolStack.ts:29
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.
Constraints enforced by VolStack:
- All layers must share the same spatial orientation (AxisSet3D).
- All layers must share the same field of view dimensions in the first three axes (width, height, depth).
- Each layer must have a unique string ID.
Constructors
Constructor
new VolStack(...layers): VolStack;Defined in: src/display/VolStack.ts:59
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:128
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:135
Reports how many VolLayers are in this stack.
Returns
number
space
Get Signature
get space(): NeuroSpace;Defined in: src/display/VolStack.ts:143
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:295
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:96
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:105
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:116
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:154
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:184
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:196
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:206
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:216
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:223
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:235
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:249
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
ImageSlice[]
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:262
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
ImageSlice[]
A parallel array of ImageSlice results, one per VolLayer.
getOrthoSliceAt()
getOrthoSliceAt(coord, interpolation?): object;Defined in: src/display/VolStack.ts:276
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[];