Class: SliceModel
Defined in: src/display/SliceModel.ts:32
SliceModel represents the state of a single 2D slice within a 3D volume. It tracks:
currentCoord: The user’s current 3D coordinate in real-world mm (per NeuroSpace).currentSliceIndex: Computed by projectingcurrentCoordonto the pinned dimension.- Methods to move to the next or previous slice.
IMPORTANT:
currentCoordmust be a millimeter-space coordinate ifNeuroSpaceis configured for real-world mm. If you have voxel coords [i,j,k], do: const mmCoord = neuroSpace.gridToCoord(voxelCoord); sliceModel.setCurrentCoord(mmCoord); OtherwisecurrentSliceIndexwill be incorrect.
Implements
Constructors
Constructor
new SliceModel(
totalSlices,
initialCoord,
neuroSpace,
viewAxes): SliceModel;Defined in: src/display/SliceModel.ts:58
Constructs a new SliceModel.
Parameters
totalSlices
number
The number of slices along the movement axis.
initialCoord
number[]
The initial real-world mm 3D coordinate in the volume.
neuroSpace
The NeuroSpace describing dimension, spacing, transform, etc.
viewAxes
Which orientation axes we are using (e.g. AXIAL_LPI), from which we derive the pinned dimension.
Returns
SliceModel
Properties
currentCoord
currentCoord: number[] = [];Defined in: src/display/SliceModel.ts:37
The current 3D coordinate [X, Y, Z], stored in real-world mm space (consistent with the NeuroSpace transform).
Implementation of
totalSlices
totalSlices: number;Defined in: src/display/SliceModel.ts:44
totalSlices is the maximum number of discrete slices along the pinned axis. For example, in a 256×256×128 volume, if the pinned axis is dimension #2, totalSlices might be 128.
Implementation of
Accessors
currentSliceIndex
Get Signature
get currentSliceIndex(): number;Defined in: src/display/SliceModel.ts:82
currentSliceIndex is derived by mapping the real-world currentCoord into voxel/grid space, then extracting the pinned dimension’s coordinate and rounding it.
Returns
number
Current slice index
Implementation of
Methods
setCurrentCoord()
setCurrentCoord(coord): void;Defined in: src/display/SliceModel.ts:97
Sets the model’s 3D coordinate to a new mm coordinate, ensuring MobX reactivity by copying the array.
Parameters
coord
number[]
The new [X, Y, Z] in real-world mm.
Returns
void
Implementation of
setCurrentCoordIfChanged()
setCurrentCoordIfChanged(coord): void;Defined in: src/display/SliceModel.ts:123
Helper to set the coordinate only if it differs from the existing coordinate.
Parameters
coord
number[]
The new [X, Y, Z] in real-world mm.
Returns
void
setCurrentSliceIndex()
setCurrentSliceIndex(index): void;Defined in: src/display/SliceModel.ts:145
Sets the sliceIndex by updating the relevant dimension in voxel space, then converting back to mm (real-world) space for the model’s currentCoord.
Parameters
index
number
The new slice index (integer).
Returns
void
Implementation of
ISliceModel.setCurrentSliceIndex
previousSlice()
previousSlice(): void;Defined in: src/display/SliceModel.ts:173
Move to the previous slice, ensuring we don’t go below 0.
Returns
void
Implementation of
nextSlice()
nextSlice(): void;Defined in: src/display/SliceModel.ts:182
Move to the next slice, ensuring we don’t exceed totalSlices - 1.
Returns
void
Implementation of
getViewAxes()
getViewAxes(): AxisSet3D;Defined in: src/display/SliceModel.ts:190
Returns the AxisSet3D used by this model, e.g. AXIAL_LPI or CORONAL_LIP, etc.
Returns
onCoordChange()
onCoordChange(callback): IReactionDisposer;Defined in: src/display/SliceModel.ts:199
Subscribe to coordinate changes
Parameters
callback
(coord) => void
Function to call when coordinate changes
Returns
IReactionDisposer
Dispose function to unsubscribe
Implementation of
onSliceIndexChange()
onSliceIndexChange(callback): IReactionDisposer;Defined in: src/display/SliceModel.ts:211
Subscribe to slice index changes
Parameters
callback
(index) => void
Function to call when slice index changes
Returns
IReactionDisposer
Dispose function to unsubscribe
Implementation of
ISliceModel.onSliceIndexChange
dispose()
dispose(): void;Defined in: src/display/SliceModel.ts:221
Dispose of the model and clean up resources
Returns
void