Class: ImageLayer
Defined in: src/display/ImageLayer.ts:28
ImageLayer handles retrieving 2D slices from a VolStack and drawing them in a single container, each with a GPU transform so they align visually to the reference slice.
Implements
Constructors
Constructor
new ImageLayer(volStack, alignmentOptions?): ImageLayer;Defined in: src/display/ImageLayer.ts:50
Parameters
volStack
alignmentOptions?
AlignmentManagerOptions
Returns
ImageLayer
Properties
neuroSpace
neuroSpace: NeuroSpace;Defined in: src/display/ImageLayer.ts:29
The NeuroSpace associated with the layer. Ensures spatial coherence with other layers in the viewer.
Implementation of
opacity
opacity: number = 1;Defined in: src/display/ImageLayer.ts:48
Methods
initialize()
initialize(): void;Defined in: src/display/ImageLayer.ts:104
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
addVolLayer()
addVolLayer(volLayer): void;Defined in: src/display/ImageLayer.ts:108
Parameters
volLayer
Returns
void
removeVolLayer()
removeVolLayer(volLayer): void;Defined in: src/display/ImageLayer.ts:114
Parameters
volLayer
Returns
void
createSprite()
createSprite(imageData, cacheKey): Sprite;Defined in: src/display/ImageLayer.ts:125
Creates a PIXI.Sprite from ImageData by drawing onto a Canvas, then returning a Sprite. Uses TextureMemoryConsumer for intelligent caching and memory management. Uses sprite pool to reduce garbage collection pressure.
Parameters
imageData
ImageData
cacheKey
string
Returns
Sprite
renderSlice()
renderSlice(
sliceIndex,
coord,
viewAxes,
parentContainer): Container | null;Defined in: src/display/ImageLayer.ts:187
The crucial method: for each VolLayer, we get the slice, create a sprite, then call alignSpriteToReference(...) to position/scale it.
Parameters
sliceIndex
number
coord
number[]
viewAxes
parentContainer
Container
Returns
Container | null
Implementation of
releaseContainer()
releaseContainer(container): void;Defined in: src/display/ImageLayer.ts:322
Releases a container and its sprites back to the pool
Parameters
container
Container
The container to release
Returns
void
setPosition()
setPosition(coord): void;Defined in: src/display/ImageLayer.ts:350
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[]
The new volume coordinates [x, y, z].
Returns
void
Implementation of
onPointerMove()
onPointerMove(e): boolean;Defined in: src/display/ImageLayer.ts:354
Handles pointer (mouse or touch) move events. Layers can implement this method to provide interactive behaviors, such as displaying tooltips or highlighting regions.
Parameters
e
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
onPointerDown()
onPointerDown(e): boolean;Defined in: src/display/ImageLayer.ts:357
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
e
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
dispose()
dispose(): void;Defined in: src/display/ImageLayer.ts:360
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
getVolStack()
getVolStack(): VolStack;Defined in: src/display/ImageLayer.ts:386
Returns
getLayer()
getLayer(index): VolLayer;Defined in: src/display/ImageLayer.ts:389
Parameters
index
number
Returns
getLayerIds()
getLayerIds(): string[];Defined in: src/display/ImageLayer.ts:392
Returns
string[]
updateLayer()
updateLayer(layerId, params): void;Defined in: src/display/ImageLayer.ts:396
Parameters
layerId
string
params
LayerUpdateParams
Returns
void
replaceVolume()
replaceVolume(
layerId,
newVolume,
opts?): void;Defined in: src/display/ImageLayer.ts:419
Replace the underlying volume data for a specific layer without changing its id. Useful for fast overlay updates (e.g., sigma changes) without add/remove churn.
Parameters
layerId
string
newVolume
opts?
range?
[number, number] | null
threshold?
[number, number]
alpha?
number
colormap?
Returns
void
update()
update(params): void;Defined in: src/display/ImageLayer.ts:438
Optional method to handle layer-specific updates.
Parameters
params
ViewerUpdateParams
Returns
void
Implementation of
getValidSliceRange()
getValidSliceRange(axis): [number, number];Defined in: src/display/ImageLayer.ts:452
Get valid slice range for a given axis
Parameters
axis
Returns
[number, number]
validateSliceAccess()
validateSliceAccess(sliceIndex, axis): SliceAccessResult;Defined in: src/display/ImageLayer.ts:459
Validate slice access and get adjusted indices
Parameters
sliceIndex
number
axis
Returns
getSafeSliceIndices()
getSafeSliceIndices(axis, count?): number[];Defined in: src/display/ImageLayer.ts:466
Get safe slice indices for testing
Parameters
axis
count?
number = 3
Returns
number[]
setSliceAccessConfig()
setSliceAccessConfig(config): void;Defined in: src/display/ImageLayer.ts:473
Set slice access configuration
Parameters
config
Partial<SliceAccessConfig>
Returns
void
getSliceAccessConfig()
getSliceAccessConfig(): SliceAccessConfig;Defined in: src/display/ImageLayer.ts:481
Get current slice access configuration
Returns
getPoolStats()
getPoolStats(): object;Defined in: src/display/ImageLayer.ts:494
Gets pool statistics for monitoring performance
Returns
object
spritePool
spritePool: object;spritePool.poolSize
poolSize: number;spritePool.activeCount
activeCount: number;spritePool.createCount
createCount: number;spritePool.reuseCount
reuseCount: number;spritePool.reuseRatio
reuseRatio: number;containerPool
containerPool: object;containerPool.poolSize
poolSize: number;containerPool.activeCount
activeCount: number;containerPool.createCount
createCount: number;containerPool.reuseCount
reuseCount: number;containerPool.reuseRatio
reuseRatio: number;setAlignmentOptions()
setAlignmentOptions(options): void;Defined in: src/display/ImageLayer.ts:507
Set alignment options
Parameters
options
Partial<AlignmentManagerOptions>
Returns
void
getAlignmentOptions()
getAlignmentOptions(): AlignmentManagerOptions;Defined in: src/display/ImageLayer.ts:515
Get current alignment options
Returns
AlignmentManagerOptions
setAlignmentStrategy()
setAlignmentStrategy(strategy): void;Defined in: src/display/ImageLayer.ts:522
Set alignment strategy
Parameters
strategy
AlignmentStrategyType
Returns
void
getAlignmentCacheStats()
getAlignmentCacheStats(): object;Defined in: src/display/ImageLayer.ts:530
Get alignment cache statistics
Returns
object
size
size: number;enabled
enabled: boolean;clearAlignmentCache()
clearAlignmentCache(): void;Defined in: src/display/ImageLayer.ts:537
Clear alignment cache
Returns
void
getTextureMemoryStats()
getTextureMemoryStats(): object;Defined in: src/display/ImageLayer.ts:544
Get texture memory statistics
Returns
object
count
count: number;size
size: number;maxSize
maxSize: number;usage
usage: number;setTextureCacheSize()
setTextureCacheSize(bytes): void;Defined in: src/display/ImageLayer.ts:556
Set maximum texture cache size
Parameters
bytes
number
Returns
void
getMemoryStats()
getMemoryStats(): object;Defined in: src/display/ImageLayer.ts:563
Get combined memory statistics
Returns
object
textureMemory
textureMemory: object;textureMemory.count
count: number;textureMemory.size
size: number;textureMemory.maxSize
maxSize: number;textureMemory.usage
usage: number;pools
pools: object;pools.spritePool
spritePool: object;pools.spritePool.poolSize
poolSize: number;pools.spritePool.activeCount
activeCount: number;pools.spritePool.createCount
createCount: number;pools.spritePool.reuseCount
reuseCount: number;pools.spritePool.reuseRatio
reuseRatio: number;pools.containerPool
containerPool: object;pools.containerPool.poolSize
poolSize: number;pools.containerPool.activeCount
activeCount: number;pools.containerPool.createCount
createCount: number;pools.containerPool.reuseCount
reuseCount: number;pools.containerPool.reuseRatio
reuseRatio: number;alignment
alignment: object;alignment.size
size: number;alignment.enabled
enabled: boolean;