copper3d / Modules / Loader/copperNrrdLoader
Module: Loader/copperNrrdLoader
Table of contents
Interfaces
Type Aliases
Variables
Functions
- __setNrrdWorkerFactoryForTests
- addBoxHelper
- copperNrrdLoader
- copperNrrdTexture3dLoader
- ensureAxisExtracted
- getWholeSlices
- prepareVolumeSlices
Type Aliases
NrrdAxis
Ƭ NrrdAxis: "x" | "y" | "z"
A slice axis, in the sense Volume.extractSlice uses.
Defined in
src/Loader/copperNrrdLoader.ts:225
Variables
DEFAULT_AXES
• Const DEFAULT_AXES: readonly NrrdAxis[]
All three, which is what loadNrrd has always extracted.
Defined in
src/Loader/copperNrrdLoader.ts:228
Functions
__setNrrdWorkerFactoryForTests
▸ __setNrrdWorkerFactoryForTests(factory): void
Test-only seam. Production code always goes through createRealNrrdWorker, which constructs a real Worker (?worker&inline, so the plugin build never needs a second asset file at an unpredictable base path). jsdom (this repo's test environment) has no Worker implementation at all, so tests substitute an in-process double that drives the exact same nrrdWorkerCore.ts logic the real worker entry uses -- see __tests__/helpers/fakeNrrdWorker.ts. Passing null restores the real worker factory.
Parameters
| Name | Type |
|---|---|
factory | null | () => NrrdWorkerLike |
Returns
void
Defined in
src/Loader/copperNrrdLoader.ts:47
addBoxHelper
▸ addBoxHelper(scene, volume, boxCube?): void
Parameters
| Name | Type |
|---|---|
scene | copperScene |
volume | any |
boxCube? | Object3D<Object3DEventMap> |
Returns
void
Deprecated
Since 3.9.0, use addVolumeBoundingBox(scene, rasDimensions).
Kept unchanged for callers passing their own boxCube, which works. The two-argument form does not: cube is declared in this module and never assigned, so it reaches new THREE.BoxHelper(undefined). This also cannot take a copperSceneOnDemond -- a sibling of copperScene, not a descendant -- and sizes the box from volume.matrix rather than its RAS dimensions.
Defined in
src/Loader/copperNrrdLoader.ts:829
copperNrrdLoader
▸ copperNrrdLoader(url, loadingBar, callback?, opts?): void
Loads an NRRD in the canonical voxel order (i -> patient Left, j -> Posterior, k -> Superior), whatever order its file stores, so every view comes out in the radiological convention. A file whose patient orientation cannot be established fails through opts.onError with an OrientationError and is never displayed.
Parameters
| Name | Type |
|---|---|
url | string |
loadingBar | loadingBarType |
callback? | (volume: any, nrrdMeshes: nrrdMeshesType, nrrdSlices: nrrdSliceType, gui?: GUI) => void |
opts? | optsType |
Returns
void
Defined in
src/Loader/copperNrrdLoader.ts:383
copperNrrdTexture3dLoader
▸ copperNrrdTexture3dLoader(url, scene, container, callback?): void
Parameters
| Name | Type |
|---|---|
url | string |
scene | Scene<Object3DEventMap> |
container | HTMLDivElement |
callback? | (volume: any, gui?: GUI) => void |
Returns
void
Deprecated
Shows the file in its stored voxel order, not the canonical LPS order every other loader uses, with window and threshold values fixed for one demo case. Use copperNrrdLoader instead. Will be removed in a future major release.
Defined in
src/Loader/copperNrrdLoader.ts:562
ensureAxisExtracted
▸ ensureAxisExtracted(slices, axis, meshes?): any
Extracts a slice plane a narrower axes load skipped, the first time something asks for it (see NrrdTools.setSliceOrientation). Mutates slices (and meshes, if given) in place so every existing reference to the same object -- there is exactly one per volume -- picks up the new plane; callers do not need to replace anything. A no-op if the axis is already present.
All three axes' slices share one Volume instance (see onLoad below), so whichever axis IS already extracted is where the volume, dimensions, spacing and RAS dimensions are read from -- there is no separate "the volume" reference kept around for this.
Parameters
| Name | Type |
|---|---|
slices | nrrdSliceType |
axis | NrrdAxis |
meshes? | nrrdMeshesType |
Returns
any
Defined in
src/Loader/copperNrrdLoader.ts:345
getWholeSlices
▸ getWholeSlices(nrrdSlices, scene, gui, controls): void
Parameters
| Name | Type |
|---|---|
nrrdSlices | nrrdSliceType |
scene | Scene<Object3DEventMap> |
gui | GUI |
controls | Copper3dTrackballControls |
Returns
void
Defined in
src/Loader/copperNrrdLoader.ts:720
prepareVolumeSlices
▸ prepareVolumeSlices(...slices): void
Post-extraction fixups every VolumeSlice needs. Run it on each slice right after Volume.extractSlice; undefined (an axis not extracted) is skipped.
Readback-friendly buffer
Stock VolumeSlice.repaint reads ctxBuffer back with getImageData on every repaint. three creates that context in the constructor without willReadFrequently, so the canvas may live on the GPU and each repaint copies it back to the CPU (Chrome warns once per such context). A context's attributes are fixed by the first getContext call on its canvas, so the buffer is replaced by a canvas whose context is created with the flag; updateGeometry re-fetching it later gets that same context.
three.js regression (present from r175 through at least r185)
VolumeSlice's constructor calls updateGeometry() and then repaint(), but afterwards assigns the JSDoc default values:
this.iLength = 0; this.jLength = 0; this.sliceAccess = null;
which wipe the values updateGeometry() just computed. repaint() only recomputes them when geometryNeedsUpdate is true (i.e. after index was assigned), so any repaint that is not preceded by an index change calls ctx.getImageData(0, 0, 0, 0) and throws IndexSizeError: The source width is 0.
Recomputing the geometry right after extraction restores the correct values. It is a harmless recompute on three <= r174, where the bug does not exist.
Parameters
| Name | Type |
|---|---|
...slices | any[] |
Returns
void