copper3d 4.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/ai-index/guides/load-callbacks.md +24 -5
- package/ai-index/guides/orientation.md +163 -0
- package/ai-index/guides/segmentation-module.md +51 -25
- package/ai-index/guides/volume-display.md +1 -1
- package/ai-index/manifest.json +14 -6
- package/ai-index/symbols.json +1 -1
- package/dist/Controls/orbitFraming.d.ts +4 -4
- package/dist/Controls/orbitFraming.js +4 -4
- package/dist/Loader/copperNrrdLoader.d.ts +15 -1
- package/dist/Loader/copperNrrdLoader.js +30 -8
- package/dist/Loader/copperNrrdLoader.js.map +1 -1
- package/dist/Loader/nrrdWorkerCore.d.ts +15 -2
- package/dist/Loader/nrrdWorkerCore.js +47 -3
- package/dist/Loader/nrrdWorkerCore.js.map +1 -1
- package/dist/Loader/rasDimensions.d.ts +9 -0
- package/dist/Loader/rasDimensions.js +12 -0
- package/dist/Loader/rasDimensions.js.map +1 -0
- package/dist/Scene/commonSceneMethod.d.ts +10 -1
- package/dist/Scene/commonSceneMethod.js +11 -3
- package/dist/Scene/commonSceneMethod.js.map +1 -1
- package/dist/Utils/orientation.d.ts +94 -0
- package/dist/Utils/orientation.js +261 -0
- package/dist/Utils/orientation.js.map +1 -0
- package/dist/Utils/segmentation/NrrdTools.d.ts +4 -0
- package/dist/Utils/segmentation/NrrdTools.js +4 -2
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/RenderingUtils.d.ts +0 -5
- package/dist/Utils/segmentation/RenderingUtils.js +3 -23
- package/dist/Utils/segmentation/RenderingUtils.js.map +1 -1
- package/dist/Utils/segmentation/contourPaint.d.ts +5 -0
- package/dist/Utils/segmentation/contourPaint.js +10 -3
- package/dist/Utils/segmentation/contourPaint.js.map +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.d.ts +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.js +38 -38
- package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -1
- package/dist/Utils/segmentation/tools/AiAssistTool.js +10 -10
- package/dist/Utils/segmentation/tools/AiAssistTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ContrastTool.js +1 -1
- package/dist/Utils/segmentation/tools/CrosshairTool.js +30 -22
- package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/DrawingTool.js +14 -14
- package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +3 -5
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js +7 -11
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -1
- package/dist/Utils/segmentation/tools/MaskMirror.js +5 -5
- package/dist/Utils/segmentation/tools/MaskMirror.js.map +1 -1
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.d.ts +28 -4
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +50 -24
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -1
- package/dist/Utils/segmentation/tools/SphereBrushTool.js +5 -4
- package/dist/Utils/segmentation/tools/SphereBrushTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/SphereTool.js +13 -11
- package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -1
- package/dist/bundle.esm.mjs +628 -317
- package/dist/bundle.umd.js +639 -320
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/orientation.cjs +276 -0
- package/dist/orientation.mjs +262 -0
- package/dist/types/Controls/orbitFraming.d.ts +4 -4
- package/dist/types/Loader/copperNrrdLoader.d.ts +15 -1
- package/dist/types/Loader/nrrdWorkerCore.d.ts +15 -2
- package/dist/types/Loader/rasDimensions.d.ts +9 -0
- package/dist/types/Scene/commonSceneMethod.d.ts +10 -1
- package/dist/types/Utils/orientation.d.ts +94 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +4 -0
- package/dist/types/Utils/segmentation/RenderingUtils.d.ts +0 -5
- package/dist/types/Utils/segmentation/contourPaint.d.ts +5 -0
- package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +1 -1
- package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +3 -5
- package/dist/types/Utils/segmentation/tools/SliceRenderPipeline.d.ts +28 -4
- package/dist/types/index.d.ts +5 -2
- package/package.json +6 -1
|
@@ -4,6 +4,7 @@ import { copperScene } from "../Scene/copperScene";
|
|
|
4
4
|
import { GUI } from "dat.gui";
|
|
5
5
|
import { nrrdMeshesType, nrrdSliceType, loadingBarType } from "../types/types";
|
|
6
6
|
import { Copper3dTrackballControls } from "../Controls/Copper3dTrackballControls";
|
|
7
|
+
import { type VolumeOrientation } from "../Utils/orientation";
|
|
7
8
|
/**
|
|
8
9
|
* Real worker in production; a test double can be substituted via
|
|
9
10
|
* `__setNrrdWorkerFactoryForTests` (see that function's doc comment).
|
|
@@ -46,6 +47,8 @@ export interface NrrdVolume extends Omit<Volume, "matrix"> {
|
|
|
46
47
|
max: number;
|
|
47
48
|
windowLow: number;
|
|
48
49
|
windowHigh: number;
|
|
50
|
+
/** How the file reached the canonical voxel order, and its canonical grid in patient space. */
|
|
51
|
+
orientation: VolumeOrientation;
|
|
49
52
|
}
|
|
50
53
|
/** A slice axis, in the sense `Volume.extractSlice` uses. */
|
|
51
54
|
export type NrrdAxis = "x" | "y" | "z";
|
|
@@ -151,7 +154,18 @@ export declare function prepareVolumeSlices(...slices: any[]): void;
|
|
|
151
154
|
* from -- there is no separate "the volume" reference kept around for this.
|
|
152
155
|
*/
|
|
153
156
|
export declare function ensureAxisExtracted(slices: nrrdSliceType, axis: NrrdAxis, meshes?: nrrdMeshesType): any;
|
|
154
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Loads an NRRD in the canonical voxel order (i -> patient Left, j -> Posterior, k -> Superior),
|
|
159
|
+
* whatever order its file stores, so every view comes out in the radiological convention. A file
|
|
160
|
+
* whose patient orientation cannot be established fails through `opts.onError` with an
|
|
161
|
+
* `OrientationError` and is never displayed.
|
|
162
|
+
*/
|
|
163
|
+
export declare function copperNrrdLoader(url: string, loadingBar: loadingBarType, callback?: (volume: any, nrrdMeshes: nrrdMeshesType, nrrdSlices: nrrdSliceType, gui?: GUI) => void, opts?: optsType): void;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Shows the file in its stored voxel order, not the canonical LPS order every other
|
|
166
|
+
* loader uses, with window and threshold values fixed for one demo case. Use
|
|
167
|
+
* `copperNrrdLoader` instead. Will be removed in a future major release.
|
|
168
|
+
*/
|
|
155
169
|
export declare function copperNrrdTexture3dLoader(url: string, scene: THREE.Scene, container: HTMLDivElement, callback?: (volume: any, gui?: GUI) => void): void;
|
|
156
170
|
export declare function getWholeSlices(nrrdSlices: nrrdSliceType, scene: THREE.Scene, gui: GUI, controls: Copper3dTrackballControls): void;
|
|
157
171
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type OrientationTransform, type VolumeGeometry, type VolumeOrientation } from "../Utils/orientation";
|
|
1
2
|
/** A message this module hands back to the caller, in the exact shape `postMessage` expects
|
|
2
3
|
* (payload + a transfer list containing every `Transferable` inside it). */
|
|
3
4
|
export type WorkerEmit = (message: NrrdWorkerMessage, transfer?: Transferable[]) => void;
|
|
@@ -5,7 +6,6 @@ export interface NrrdLoadCommand {
|
|
|
5
6
|
cmd: "load";
|
|
6
7
|
id: string;
|
|
7
8
|
url: string;
|
|
8
|
-
segmentation: boolean;
|
|
9
9
|
knownMinMax?: [number, number];
|
|
10
10
|
}
|
|
11
11
|
export interface NrrdAbortCommand {
|
|
@@ -26,7 +26,7 @@ export interface NrrdWorkerPayload {
|
|
|
26
26
|
spacing: [number, number, number];
|
|
27
27
|
axisOrder: string[];
|
|
28
28
|
RASDimensions: [number, number, number];
|
|
29
|
-
|
|
29
|
+
orientation: VolumeOrientation;
|
|
30
30
|
min: number;
|
|
31
31
|
max: number;
|
|
32
32
|
windowLow: number;
|
|
@@ -51,6 +51,8 @@ export type NrrdWorkerMessage = {
|
|
|
51
51
|
type: "error";
|
|
52
52
|
name: string;
|
|
53
53
|
message: string;
|
|
54
|
+
code?: string;
|
|
55
|
+
detail?: string;
|
|
54
56
|
};
|
|
55
57
|
interface PendingUrlFetch {
|
|
56
58
|
bufferPromise: Promise<ArrayBuffer>;
|
|
@@ -65,6 +67,17 @@ export interface NrrdWorkerState {
|
|
|
65
67
|
callerToUrl: Map<string, string>;
|
|
66
68
|
}
|
|
67
69
|
export declare function createNrrdWorkerState(): NrrdWorkerState;
|
|
70
|
+
/**
|
|
71
|
+
* Puts a just-parsed volume into the canonical voxel order (i -> Left, j -> Posterior,
|
|
72
|
+
* k -> Superior) and rewrites every field derived from the order together, so nothing downstream
|
|
73
|
+
* ever sees the file's own order. With the voxels in this order, three's slice layout under
|
|
74
|
+
* `segmentation = true` plus the engine's fixed per-axis display mapping is the radiological view.
|
|
75
|
+
*
|
|
76
|
+
* `matrix` is written exactly diagonal: three turns a slice position back into an index through
|
|
77
|
+
* `inverseMatrix` and rounds it, and an oblique file's cross terms would drift that index. The
|
|
78
|
+
* true, oblique geometry is kept in `orientation` and `header` instead.
|
|
79
|
+
*/
|
|
80
|
+
export declare function canonicaliseVolume(volume: any, native: VolumeGeometry, transform: OrientationTransform): void;
|
|
68
81
|
/**
|
|
69
82
|
* Handles one `{cmd: "load"}` command. Dedupes the underlying fetch by URL exactly like
|
|
70
83
|
* `copperNrrdLoader.ts`'s old `sharedFetchNrrdArrayBuffer` did (one real request per URL,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* three's `RASDimensions` for a grid: per axis, `(n − 1)·s + 1`.
|
|
3
|
+
*
|
|
4
|
+
* three places the plane for slice index `k·s` at `k·s − (RASDimensions − 1)/2`, and every
|
|
5
|
+
* texture spans `n·s` centred on 0, drawing voxel k's centre at `k·s − (n − 1)·s/2`. This value
|
|
6
|
+
* makes the two the same point. It also makes `RSAMaxIndex = RASDimensions − 1` exactly the last
|
|
7
|
+
* voxel's index `(n − 1)·s`, so a slider stepping `voxel × spacing` reaches it. Not an integer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rasDimensions(dims: ArrayLike<number>, spacing: ArrayLike<number>): [number, number, number];
|
|
@@ -41,8 +41,17 @@ export declare class commonScene {
|
|
|
41
41
|
*/
|
|
42
42
|
addSubView(): HTMLDivElement;
|
|
43
43
|
loadDicom(urls: string | Array<string>, opts?: dicomLoaderOptsType): void;
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Loads an NRRD in the canonical voxel order (i -> patient Left, j -> Posterior,
|
|
46
|
+
* k -> Superior), whatever order its file stores; see `copperNrrdLoader`.
|
|
47
|
+
*/
|
|
48
|
+
loadNrrd(url: string, loadingBar: loadingBarType, callback?: (volume: any, nrrdMeshes: nrrdMeshesType, nrrdSlices: nrrdSliceType, gui?: GUI) => void, opts?: optsType): void;
|
|
45
49
|
updateControls(camera: THREE.PerspectiveCamera | THREE.OrthographicCamera): void;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Shows the file in its stored voxel order, not the canonical LPS order every
|
|
52
|
+
* other loader uses, with window and threshold values fixed for one demo case. Use
|
|
53
|
+
* `loadNrrd` (`copperNrrdLoader`) instead. Will be removed in a future major release.
|
|
54
|
+
*/
|
|
46
55
|
loadNrrdTexture3d(url: string, callback?: (volume: any, gui?: GUI) => void): void;
|
|
47
56
|
loadOBJ(url: string, callback?: (mesh: THREE.Group) => void, opts?: {
|
|
48
57
|
color: string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical voxel order, and the rule that puts any volume into it.
|
|
3
|
+
*
|
|
4
|
+
* Canonical order: voxel index i increases toward the patient's Left, j toward Posterior, k
|
|
5
|
+
* toward Superior. Axis codes use the TOWARD convention of DICOM, nibabel and SimpleITK, so "LPS"
|
|
6
|
+
* names that order (legacy ITK and ITK-SNAP call the same order "RAI").
|
|
7
|
+
*
|
|
8
|
+
* Each native axis is assigned the anatomical axis it is nearest to and flipped when it points the
|
|
9
|
+
* other way. That is a permutation and flips, never a resampling, so obliquity stays in the
|
|
10
|
+
* geometry instead of being snapped away. With the voxels in this order, the fixed per-axis display
|
|
11
|
+
* mapping (SliceRenderPipeline.flipDisplayImageByAxis) shows every volume in the radiological
|
|
12
|
+
* convention, whatever order its file stores.
|
|
13
|
+
*
|
|
14
|
+
* The backend (app/geometry/canonical.py) implements the same rule for everything it reads and
|
|
15
|
+
* writes. The app holds both to one fixture, annotator-backend/tests/fixtures/orientation_cases.json.
|
|
16
|
+
*
|
|
17
|
+
* Pure: no DOM and no three, so it runs inside the NRRD worker as well as on the main thread.
|
|
18
|
+
*/
|
|
19
|
+
export type Vec3 = [number, number, number];
|
|
20
|
+
/** A voxel grid in patient space. */
|
|
21
|
+
export interface VolumeGeometry {
|
|
22
|
+
dims: Vec3;
|
|
23
|
+
/** `directions[a]` is one step along voxel axis a, in LPS millimetres. Its length is the spacing. */
|
|
24
|
+
directions: [Vec3, Vec3, Vec3];
|
|
25
|
+
/** The LPS position of the centre of voxel (0, 0, 0). */
|
|
26
|
+
origin: Vec3;
|
|
27
|
+
}
|
|
28
|
+
/** From the native voxel order to a target order. */
|
|
29
|
+
export interface OrientationTransform {
|
|
30
|
+
/** `perm[c]` is the native axis that becomes axis c. */
|
|
31
|
+
perm: Vec3;
|
|
32
|
+
/** `flip[c]`: index c runs opposite to that native axis (c = n - 1 - native). */
|
|
33
|
+
flip: [boolean, boolean, boolean];
|
|
34
|
+
/** The angle between axis c and its anatomical axis, in degrees. */
|
|
35
|
+
obliquityDeg: Vec3;
|
|
36
|
+
}
|
|
37
|
+
export type OrientationErrorCode = "no_space" | "time_space" | "scanner_space" | "non_anatomical_space" | "unknown_space" | "no_directions" | "not_3d" | "no_origin" | "degenerate" | "ambiguous_oblique";
|
|
38
|
+
/** A volume whose patient orientation cannot be established. It is refused, never guessed. */
|
|
39
|
+
export declare class OrientationError extends Error {
|
|
40
|
+
readonly code: OrientationErrorCode;
|
|
41
|
+
readonly detail: string;
|
|
42
|
+
constructor(code: OrientationErrorCode, detail: string);
|
|
43
|
+
}
|
|
44
|
+
/** How a loaded volume reached the canonical order, and where its canonical grid lies in patient space. */
|
|
45
|
+
export interface VolumeOrientation {
|
|
46
|
+
/** The transform the file's voxels went through. */
|
|
47
|
+
transform: OrientationTransform;
|
|
48
|
+
/** The file's own dims, before reordering. */
|
|
49
|
+
nativeDims: Vec3;
|
|
50
|
+
/** The canonical grid in LPS, obliquity included. Unlike `volume.matrix`, this is never snapped. */
|
|
51
|
+
geometry: VolumeGeometry;
|
|
52
|
+
}
|
|
53
|
+
/** The orientation fields of an NRRD header, as written in the file. */
|
|
54
|
+
export interface NrrdOrientationFields {
|
|
55
|
+
space: string | null;
|
|
56
|
+
sizes: number[];
|
|
57
|
+
/** One vector per axis; `null` where the file says `none` (a non-spatial axis). */
|
|
58
|
+
spaceDirections: (number[] | null)[] | null;
|
|
59
|
+
spaceOrigin: number[] | null;
|
|
60
|
+
}
|
|
61
|
+
export type ViewAxis = "x" | "y" | "z";
|
|
62
|
+
export interface ViewLabels {
|
|
63
|
+
left: string;
|
|
64
|
+
right: string;
|
|
65
|
+
top: string;
|
|
66
|
+
bottom: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The text header of an NRRD document: everything before the first blank line. Read here instead
|
|
70
|
+
* of taken from three's NRRDLoader, which fills in identity directions when a file has none and so
|
|
71
|
+
* makes "no orientation" indistinguishable from "identity".
|
|
72
|
+
*/
|
|
73
|
+
export declare function nrrdHeaderText(buffer: ArrayBuffer): string;
|
|
74
|
+
/** Reads the orientation fields from an NRRD header's text. Comments and `key:=value` pairs are skipped. */
|
|
75
|
+
export declare function readNrrdOrientationFields(headerText: string): NrrdOrientationFields;
|
|
76
|
+
/** An NRRD's geometry in LPS. Throws OrientationError when its patient orientation cannot be established. */
|
|
77
|
+
export declare function geometryFromNrrd(fields: NrrdOrientationFields): VolumeGeometry;
|
|
78
|
+
/** The transform into the voxel order that `codes` names (TOWARD), e.g. "LPS" or "RAI". */
|
|
79
|
+
export declare function orientationTransform(geometry: VolumeGeometry, codes?: string): OrientationTransform;
|
|
80
|
+
/** The transform into the canonical order (i->L, j->P, k->S). */
|
|
81
|
+
export declare function canonicalTransform(geometry: VolumeGeometry): OrientationTransform;
|
|
82
|
+
export declare function isIdentityTransform(transform: OrientationTransform): boolean;
|
|
83
|
+
/** The same grid described in the transform's voxel order. The origin moves to the new first voxel. */
|
|
84
|
+
export declare function reorientedGeometry(geometry: VolumeGeometry, transform: OrientationTransform): VolumeGeometry;
|
|
85
|
+
type VoxelArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
86
|
+
/**
|
|
87
|
+
* Voxels (i fastest, as NRRD stores them) rewritten in the transform's order. The identity
|
|
88
|
+
* returns `data` itself, with no copy; any other transform returns a new array of the same type.
|
|
89
|
+
*/
|
|
90
|
+
export declare function reorientVoxels<T extends VoxelArray>(data: T, dims: Vec3, transform: OrientationTransform): T;
|
|
91
|
+
/** The orientation letters at each screen edge of a view of a canonical grid. */
|
|
92
|
+
export declare function viewLabels(axis: ViewAxis, geometry: VolumeGeometry): ViewLabels;
|
|
93
|
+
export declare function spacingOf(geometry: VolumeGeometry): Vec3;
|
|
94
|
+
export {};
|
|
@@ -471,6 +471,10 @@ export declare class NrrdTools {
|
|
|
471
471
|
*/
|
|
472
472
|
dispose(): void;
|
|
473
473
|
configMouseSliceWheel(): (e: WheelEvent) => void;
|
|
474
|
+
/**
|
|
475
|
+
* Rebuilds the zoom/slice wheel handler for the current wheel setting. It attaches no listener:
|
|
476
|
+
* the EventRouter owns the canvas's `wheel` event and calls this handler in zoom mode only.
|
|
477
|
+
*/
|
|
474
478
|
updateMouseWheelEvent(): void;
|
|
475
479
|
setIsDrawFalse(target: number): void;
|
|
476
480
|
private setShowInMainArea;
|
|
@@ -112,11 +112,6 @@ export declare class RenderingUtils {
|
|
|
112
112
|
* Invalidate the reusable buffer (e.g. when switching datasets).
|
|
113
113
|
*/
|
|
114
114
|
invalidateSliceBuffer(): void;
|
|
115
|
-
/**
|
|
116
|
-
* Apply the same flip transform used by flipDisplayImageByAxis() to any
|
|
117
|
-
* canvas context.
|
|
118
|
-
*/
|
|
119
|
-
applyMaskFlipForAxis(ctx: CanvasRenderingContext2D, width: number, height: number, axis: "x" | "y" | "z"): void;
|
|
120
115
|
/**
|
|
121
116
|
* Composite all layer canvases to the master display canvas.
|
|
122
117
|
* Only draws layers whose visibility is enabled.
|
|
@@ -14,6 +14,11 @@ export interface LabelSlice {
|
|
|
14
14
|
* stay visible against bright tissue.
|
|
15
15
|
*/
|
|
16
16
|
export declare const OUTLINE_WIDTH_PX = 1.5;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a view's slice rows run up the screen. Coronal and sagittal slices store z
|
|
19
|
+
* ascending in their rows and show superior at the top, so their rows are drawn bottom-up.
|
|
20
|
+
*/
|
|
21
|
+
export declare function rowsRunUp(axis: "x" | "y" | "z"): boolean;
|
|
17
22
|
/**
|
|
18
23
|
* One slice's contours, in voxel coordinates. Fill and outline paths are built lazily and side
|
|
19
24
|
* by side, so switching mode costs one extraction the first time and is a cache hit after.
|
|
@@ -165,7 +165,7 @@ export declare class MaskVolume {
|
|
|
165
165
|
* |------|----------|--------|--------|
|
|
166
166
|
* | `z` | Axial | width | height |
|
|
167
167
|
* | `y` | Coronal | width | depth |
|
|
168
|
-
* | `x` | Sagittal | depth |
|
|
168
|
+
* | `x` | Sagittal | height | depth |
|
|
169
169
|
*
|
|
170
170
|
* @param sliceIndex Index along the specified axis.
|
|
171
171
|
* @param axis `'x'` (sagittal), `'y'` (coronal), or `'z'` (axial).
|
|
@@ -27,11 +27,9 @@ export declare class ImageStoreHelper extends BaseTool {
|
|
|
27
27
|
/**
|
|
28
28
|
* Vertically flip an ImageData buffer in-place (swap rows top↔bottom).
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* horizontal Z mapping. This row-swap aligns the Z ordering so that
|
|
34
|
-
* MaskVolume stores data in a consistent coordinate system.
|
|
30
|
+
* Coronal and sagittal show superior at the top, while their slices store z ascending in
|
|
31
|
+
* their rows. The bake canvas is a picture of the display, so its rows are reversed before
|
|
32
|
+
* they are written into the MaskVolume.
|
|
35
33
|
*/
|
|
36
34
|
private flipImageDataVertically;
|
|
37
35
|
/**
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { BaseTool } from "./BaseTool";
|
|
2
2
|
import type { ToolContext } from "./BaseTool";
|
|
3
3
|
import type { SliceRenderHostDeps } from "./ToolHost";
|
|
4
|
+
/**
|
|
5
|
+
* The size three's slice canvas is shown at. The sagittal view turns that canvas a quarter turn
|
|
6
|
+
* (see `flipDisplayImageByAxis`), so its width and height trade places; every other canvas, mask
|
|
7
|
+
* slices included, is laid out at this size.
|
|
8
|
+
*/
|
|
9
|
+
export declare function displaySizeOf(axis: "x" | "y" | "z", canvas: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}): {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
4
16
|
/**
|
|
5
17
|
* Manages slice rendering pipeline: slice setup, canvas rendering, and view helpers.
|
|
6
18
|
*
|
|
@@ -10,6 +22,8 @@ import type { SliceRenderHostDeps } from "./ToolHost";
|
|
|
10
22
|
export declare class SliceRenderPipeline extends BaseTool {
|
|
11
23
|
private callbacks;
|
|
12
24
|
private initState;
|
|
25
|
+
/** The view the layer canvases were last drawn for; a different view must redraw them. */
|
|
26
|
+
private layerCanvasAxis?;
|
|
13
27
|
constructor(ctx: ToolContext, callbacks: SliceRenderHostDeps);
|
|
14
28
|
/**
|
|
15
29
|
* Reset initState to true (called from NrrdTools.reset() when switching datasets).
|
|
@@ -43,10 +57,20 @@ export declare class SliceRenderPipeline extends BaseTool {
|
|
|
43
57
|
redrawDisplayCanvas(): void;
|
|
44
58
|
redrawMianPreOnDisplayCanvas(): void;
|
|
45
59
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
60
|
+
* Maps three's slice canvas onto the display canvas. Callers then draw that canvas into
|
|
61
|
+
* (0, 0, changedWidth, changedHeight).
|
|
62
|
+
*
|
|
63
|
+
* The loader puts every volume in the canonical voxel order (i -> patient Left, j -> Posterior,
|
|
64
|
+
* k -> Superior), and three lays a slice out by voxel index with fixed row reversals. This fixed
|
|
65
|
+
* per-axis transform undoes those reversals, which makes each view the radiological one:
|
|
66
|
+
* - axial (z): screen-right = +i (patient Left), screen-down = +j (Posterior);
|
|
67
|
+
* - coronal (y): screen-right = +i, screen-down = -k (Superior at the top);
|
|
68
|
+
* - sagittal (x): screen-right = +j (Anterior on the left), screen-down = -k.
|
|
69
|
+
* Three's sagittal canvas runs columns along -k and rows along -j, so sagittal is a quarter
|
|
70
|
+
* turn as well as a scale: the drawn rectangle is the display size (`displaySizeOf`), whose
|
|
71
|
+
* width and height are three's height and width.
|
|
72
|
+
* `Utils/orientation.ts` (VIEW_LAYOUT) states the same layout for the orientation letters, so the
|
|
73
|
+
* two change together.
|
|
50
74
|
*/
|
|
51
75
|
flipDisplayImageByAxis(): void;
|
|
52
76
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ import type { PosableScene } from "./Controls/setCameraPose";
|
|
|
45
45
|
import { addVolumeBoundingBox, VOLUME_BOUNDS_NAME } from "./Loader/volumeBoundingBox";
|
|
46
46
|
import type { BoundingBoxHost, VolumeBoundingBoxOpts } from "./Loader/volumeBoundingBox";
|
|
47
47
|
import { DEFAULT_AXES, ensureAxisExtracted, prepareVolumeSlices } from "./Loader/copperNrrdLoader";
|
|
48
|
+
import { rasDimensions } from "./Loader/rasDimensions";
|
|
48
49
|
import type { NrrdAxis } from "./Loader/copperNrrdLoader";
|
|
49
50
|
import { easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle } from "./Controls/cameraTransitions";
|
|
50
51
|
import type { Pose } from "./Controls/cameraTransitions";
|
|
@@ -60,8 +61,10 @@ import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_
|
|
|
60
61
|
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
61
62
|
import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
|
|
62
63
|
import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
|
|
64
|
+
import { OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels } from "./Utils/orientation";
|
|
65
|
+
import type { NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation } from "./Utils/orientation";
|
|
63
66
|
import "./css/style.css";
|
|
64
67
|
export declare const REVISION: string;
|
|
65
|
-
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, DEFAULT_AXES, ensureAxisExtracted, prepareVolumeSlices, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, };
|
|
66
|
-
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, MaskRenderMode, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, };
|
|
68
|
+
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, rasDimensions, DEFAULT_AXES, ensureAxisExtracted, prepareVolumeSlices, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels, };
|
|
69
|
+
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, MaskRenderMode, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation, };
|
|
67
70
|
export type { CameraViewPreset } from "./Controls/orbitFraming";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copper3d",
|
|
3
3
|
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"module": "dist/bundle.esm.mjs",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"import": "./dist/bundle.esm.mjs",
|
|
12
12
|
"require": "./dist/bundle.umd.js"
|
|
13
13
|
},
|
|
14
|
+
"./orientation": {
|
|
15
|
+
"types": "./dist/types/Utils/orientation.d.ts",
|
|
16
|
+
"import": "./dist/orientation.mjs",
|
|
17
|
+
"require": "./dist/orientation.cjs"
|
|
18
|
+
},
|
|
14
19
|
"./dist/css/*": "./dist/css/*",
|
|
15
20
|
"./package.json": "./package.json"
|
|
16
21
|
},
|