copper3d 4.0.0 → 4.1.0
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 -3
- package/ai-index/guides/load-callbacks.md +24 -5
- package/ai-index/guides/orientation.md +155 -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 +611 -312
- package/dist/bundle.umd.js +618 -311
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- 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 +1 -1
package/README.md
CHANGED
|
@@ -43,13 +43,15 @@ reference, in English and 简体中文.
|
|
|
43
43
|
| | |
|
|
44
44
|
|---|---|
|
|
45
45
|
| [Upgrading to 4.0](https://linkungao.github.io/copper3d_visualisation/guide/upgrading-to-4) | **Start here if you are on 3.x** — three is now a peer dependency |
|
|
46
|
+
| [Patient Orientation](https://linkungao.github.io/copper3d_visualisation/guide/orientation) | Canonical LPS order, `OrientationError`, view labels |
|
|
46
47
|
| [NrrdTools Usage Guide](https://linkungao.github.io/copper3d_visualisation/guide/nrrd-tools) | The segmentation engine, end to end |
|
|
47
48
|
| [Segmentation Module](https://linkungao.github.io/copper3d_visualisation/guide/segmentation-module) | Its architecture and internals |
|
|
48
49
|
| [Load Progress & Errors](https://linkungao.github.io/copper3d_visualisation/guide/load-callbacks) | `loadNrrd` / `loadGltf` options and callbacks |
|
|
49
50
|
| [AI Coding Assistants (MCP)](https://linkungao.github.io/copper3d_visualisation/guide/mcp-server) | Point your assistant at the real API |
|
|
50
51
|
| [API reference](https://linkungao.github.io/copper3d_visualisation/apidist/modules) | Generated from source by TypeDoc |
|
|
51
52
|
|
|
52
|
-
The site is built from [`apidocs/`](apidocs
|
|
53
|
+
The site is built from [`apidocs/`](https://github.com/LinkunGao/copper3d_visualisation/tree/main/apidocs)
|
|
54
|
+
with VitePress and deploys to GitHub Pages.
|
|
53
55
|
|
|
54
56
|
> The old Sphinx site on readthedocs was retired at 3.11.6. It had not been updated since
|
|
55
57
|
> v2.0.7 (December 2023) and documented an API that no longer exists — `Copper.Renderer`
|
|
@@ -248,16 +250,27 @@ CameraViewPoint {
|
|
|
248
250
|
|
|
249
251
|
### Loading NRRD volumes
|
|
250
252
|
|
|
251
|
-
`scene.loadNrrd(url, loadingBar,
|
|
253
|
+
`scene.loadNrrd(url, loadingBar, callback, opts?)` fetches, gunzips and parses
|
|
252
254
|
the volume **in a shared Web Worker**; the pixel buffer comes back as a transferable and the
|
|
253
255
|
main thread only rehydrates a `Volume` around it. Two concurrent loads of the same URL share
|
|
254
256
|
one network transfer. The worker is inlined into the bundle, so there is no second asset file
|
|
255
257
|
to serve.
|
|
256
258
|
|
|
259
|
+
Every volume comes back in the **canonical voxel order** (`i` → patient Left, `j` → Posterior,
|
|
260
|
+
`k` → Superior), whatever order its file stores, so each view is the radiological one without
|
|
261
|
+
you doing anything. `volume.orientation` records how the file got there. A file whose patient
|
|
262
|
+
orientation cannot be established is refused through `onError` with an `OrientationError`,
|
|
263
|
+
never guessed at — see [Patient Orientation](https://linkungao.github.io/copper3d_visualisation/guide/orientation).
|
|
264
|
+
|
|
265
|
+
> **Breaking in 4.1.0:** the `segmentation` argument was removed —
|
|
266
|
+
> `loadNrrd(url, loadingBar, segmentation, callback, opts)` is now
|
|
267
|
+
> `loadNrrd(url, loadingBar, callback, opts)`. The canonical order makes the flag meaningless,
|
|
268
|
+
> so it is always on; leaving it in shifts your other arguments by one.
|
|
269
|
+
|
|
257
270
|
```ts
|
|
258
271
|
const controller = new AbortController();
|
|
259
272
|
|
|
260
|
-
scene.loadNrrd(url, loadingBar,
|
|
273
|
+
scene.loadNrrd(url, loadingBar, (volume, meshes, slices) => { /* ... */ }, {
|
|
261
274
|
openGui: false,
|
|
262
275
|
axes: ["z"], // extract only the planes you show
|
|
263
276
|
knownMinMax: [min, max], // skip three's whole-volume intensity scan
|
|
@@ -37,10 +37,29 @@ Available on `copperSceneOnDemond`, `copperScene` and `copperMScene`. (
|
|
|
37
37
|
|
|
38
38
|
## `scene.loadNrrd`
|
|
39
39
|
|
|
40
|
+
::: warning Breaking in 4.1.0: the `segmentation` argument is gone
|
|
41
|
+
```ts
|
|
42
|
+
scene.loadNrrd(url, loadingBar, segmentation, callback, opts); // before
|
|
43
|
+
scene.loadNrrd(url, loadingBar, callback, opts); // 4.1.0
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
It no longer means anything. The loader now puts every volume in the
|
|
47
|
+
[canonical voxel order](./orientation) and lays slices out by voxel index, which is what the
|
|
48
|
+
flag used to approximate — so it is always on, and passing it would only shift your other
|
|
49
|
+
arguments by one.
|
|
50
|
+
|
|
51
|
+
Two more things come with that:
|
|
52
|
+
|
|
53
|
+
- **`volume.orientation`** is new on the loaded volume: how the file reached the canonical
|
|
54
|
+
order, and its canonical grid in patient space.
|
|
55
|
+
- **A volume whose patient orientation cannot be established is refused**, through `onError`
|
|
56
|
+
with an `OrientationError`. It is never guessed at and never displayed.
|
|
57
|
+
:::
|
|
58
|
+
|
|
40
59
|
The callbacks go on the existing `opts` object:
|
|
41
60
|
|
|
42
61
|
```ts
|
|
43
|
-
scene.loadNrrd(url, loadingBar,
|
|
62
|
+
scene.loadNrrd(url, loadingBar, callback, {
|
|
44
63
|
openGui: false,
|
|
45
64
|
onProgress: (event) => { /* ... */ },
|
|
46
65
|
onError: (error) => showFailure(error),
|
|
@@ -68,7 +87,7 @@ buffer plus a geometry, a material and a canvas-backed texture that nothing
|
|
|
68
87
|
frees.
|
|
69
88
|
|
|
70
89
|
```ts
|
|
71
|
-
scene.loadNrrd(url, loadingBar,
|
|
90
|
+
scene.loadNrrd(url, loadingBar, callback, {
|
|
72
91
|
openGui: false,
|
|
73
92
|
axes: ["z"], // an axial-only viewer
|
|
74
93
|
});
|
|
@@ -123,7 +142,7 @@ decompressed the same bytes to write its headers.
|
|
|
123
142
|
```ts
|
|
124
143
|
const { min, max } = await fetch(`/files/${caseId}/headers`).then((r) => r.json());
|
|
125
144
|
|
|
126
|
-
scene.loadNrrd(url, loadingBar,
|
|
145
|
+
scene.loadNrrd(url, loadingBar, callback, {
|
|
127
146
|
openGui: false,
|
|
128
147
|
knownMinMax: [min, max],
|
|
129
148
|
});
|
|
@@ -144,7 +163,7 @@ function loadCase(url: string) {
|
|
|
144
163
|
inflight?.abort(); // stop the previous download
|
|
145
164
|
inflight = new AbortController();
|
|
146
165
|
|
|
147
|
-
scene.loadNrrd(url, loadingBar,
|
|
166
|
+
scene.loadNrrd(url, loadingBar, onLoaded, {
|
|
148
167
|
openGui: false,
|
|
149
168
|
signal: inflight.signal,
|
|
150
169
|
onError: (error) => {
|
|
@@ -234,7 +253,7 @@ function armStallTimer() {
|
|
|
234
253
|
}
|
|
235
254
|
|
|
236
255
|
armStallTimer();
|
|
237
|
-
scene.loadNrrd(url, loadingBar,
|
|
256
|
+
scene.loadNrrd(url, loadingBar, (volume, meshes, slices) => {
|
|
238
257
|
clearTimeout(timer);
|
|
239
258
|
/* ... */
|
|
240
259
|
}, {
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Patient Orientation <Badge type="tip" text="4.1.0" />
|
|
2
|
+
|
|
3
|
+
Every volume `loadNrrd` returns is in the **canonical voxel order**, whatever order its file
|
|
4
|
+
stores. That is what makes each view come out in the radiological convention without the
|
|
5
|
+
caller doing anything.
|
|
6
|
+
|
|
7
|
+
## The canonical order
|
|
8
|
+
|
|
9
|
+
| Voxel index | increases toward |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `i` | the patient's **L**eft |
|
|
12
|
+
| `j` | **P**osterior |
|
|
13
|
+
| `k` | **S**uperior |
|
|
14
|
+
|
|
15
|
+
Axis codes use the **TOWARD** convention of DICOM, nibabel and SimpleITK, so this order is
|
|
16
|
+
named `LPS`.
|
|
17
|
+
|
|
18
|
+
::: warning The same order has two names
|
|
19
|
+
Legacy ITK and **ITK-SNAP call this exact order `RAI`** — they name the axis each index comes
|
|
20
|
+
*from* rather than the one it goes *toward*. If you are comparing against ITK-SNAP, `RAI`
|
|
21
|
+
there and `LPS` here are the same thing, not a mismatch.
|
|
22
|
+
:::
|
|
23
|
+
|
|
24
|
+
Reaching it is a **permutation and flips, never a resampling**. Each native axis is assigned
|
|
25
|
+
the anatomical axis it is nearest to and reversed if it points the other way. Obliquity is
|
|
26
|
+
therefore preserved in the geometry rather than snapped away — nothing is interpolated and no
|
|
27
|
+
voxel value changes.
|
|
28
|
+
|
|
29
|
+
## What you get back
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
scene.loadNrrd(url, loadingBar, (volume, meshes, slices) => {
|
|
33
|
+
volume.orientation.transform; // how the file's voxels were reordered
|
|
34
|
+
volume.orientation.nativeDims; // the file's own dims, before reordering
|
|
35
|
+
volume.orientation.geometry; // the canonical grid in LPS, obliquity included
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`volume.orientation.geometry` is **never snapped**, unlike `volume.matrix`. Use it when you
|
|
40
|
+
need true patient-space positions.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
interface VolumeOrientation {
|
|
44
|
+
transform: OrientationTransform;
|
|
45
|
+
nativeDims: [number, number, number];
|
|
46
|
+
geometry: VolumeGeometry;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface OrientationTransform {
|
|
50
|
+
/** perm[c] is the native axis that became axis c. */
|
|
51
|
+
perm: [number, number, number];
|
|
52
|
+
/** flip[c]: index c runs opposite to that native axis. */
|
|
53
|
+
flip: [boolean, boolean, boolean];
|
|
54
|
+
/** Angle between axis c and its anatomical axis, in degrees. */
|
|
55
|
+
obliquityDeg: [number, number, number];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface VolumeGeometry {
|
|
59
|
+
dims: [number, number, number];
|
|
60
|
+
/** directions[a] is one step along voxel axis a, in LPS millimetres; its length is the spacing. */
|
|
61
|
+
directions: [Vec3, Vec3, Vec3];
|
|
62
|
+
/** LPS position of the centre of voxel (0, 0, 0). */
|
|
63
|
+
origin: [number, number, number];
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## A volume with no establishable orientation is refused
|
|
68
|
+
|
|
69
|
+
It is never guessed at. The load fails through `opts.onError` with an `OrientationError`,
|
|
70
|
+
and nothing is displayed:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { OrientationError } from "copper3d";
|
|
74
|
+
|
|
75
|
+
scene.loadNrrd(url, loadingBar, onLoaded, {
|
|
76
|
+
openGui: false,
|
|
77
|
+
onError: (err) => {
|
|
78
|
+
if (err instanceof OrientationError) {
|
|
79
|
+
showFailure(`This file cannot be oriented: ${err.detail}`); // err.code is stable
|
|
80
|
+
} else {
|
|
81
|
+
showFailure(err); // network, parse, abort
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`OrientationError` crosses the worker boundary intact, so it arrives as the engine's own error
|
|
88
|
+
type rather than a plain `Error` — which is how you can tell a refused orientation from a
|
|
89
|
+
failed fetch.
|
|
90
|
+
|
|
91
|
+
| `err.code` | Means |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `no_space` | The header has no `space` field |
|
|
94
|
+
| `unknown_space` / `non_anatomical_space` | `space` names something not anatomical (`3d-right-handed`, …) |
|
|
95
|
+
| `time_space` | A time-varying space (`rast`, `last`, `lpst`, `*-time`) |
|
|
96
|
+
| `scanner_space` | Scanner-relative, not patient-relative |
|
|
97
|
+
| `no_directions` / `no_origin` / `not_3d` | Required geometry fields missing, or not a 3-D volume |
|
|
98
|
+
| `degenerate` | Direction vectors do not span 3-D |
|
|
99
|
+
| `ambiguous_oblique` | A voxel axis sits ~45° from every anatomical axis, so it has no nearest one |
|
|
100
|
+
|
|
101
|
+
## Orientation letters for a view
|
|
102
|
+
|
|
103
|
+
`viewLabels` gives the letters to put at each edge of a view, following 3D Slicer's rule — an
|
|
104
|
+
axis more than 1° off an anatomical axis also gets that axis's letter:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { viewLabels } from "copper3d";
|
|
108
|
+
|
|
109
|
+
const labels = viewLabels("z", volume.orientation.geometry);
|
|
110
|
+
// { left: "R", right: "L", top: "A", bottom: "P" } for an axial view
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The layout it assumes is the same one `SliceRenderPipeline.flipDisplayImageByAxis` draws, and
|
|
114
|
+
the two are kept in step deliberately — see
|
|
115
|
+
[the flip mechanism](./segmentation-module#_6-flip-mechanism).
|
|
116
|
+
|
|
117
|
+
| View | screen-right | screen-down |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| axial (`z`) | `+i` (patient Left) | `+j` (Posterior) |
|
|
120
|
+
| coronal (`y`) | `+i` | `−k` (Superior at the top) |
|
|
121
|
+
| sagittal (`x`) | `+j` (Anterior on the left) | `−k` |
|
|
122
|
+
|
|
123
|
+
## Working with headers yourself
|
|
124
|
+
|
|
125
|
+
The module is pure — no DOM and no three — so it runs in the NRRD worker and on the main
|
|
126
|
+
thread alike.
|
|
127
|
+
|
|
128
|
+
| Function | Does |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `readNrrdOrientationFields(headerText)` | Pulls `space`, `sizes`, `space directions`, `space origin` out of an NRRD header's text |
|
|
131
|
+
| `geometryFromNrrd(fields)` | Those fields as a `VolumeGeometry` in LPS. Throws `OrientationError` |
|
|
132
|
+
| `canonicalTransform(geometry)` | The transform into the canonical order |
|
|
133
|
+
| `reorientedGeometry(geometry, transform)` | The same grid described in the new order; the origin moves to the new first voxel |
|
|
134
|
+
| `reorientVoxels(data, dims, transform)` | Applies the permutation and flips to a typed array |
|
|
135
|
+
| `viewLabels(axis, geometry)` | The letters at each screen edge |
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import {
|
|
139
|
+
readNrrdOrientationFields, geometryFromNrrd,
|
|
140
|
+
canonicalTransform, reorientVoxels, reorientedGeometry,
|
|
141
|
+
} from "copper3d";
|
|
142
|
+
|
|
143
|
+
const fields = readNrrdOrientationFields(headerText);
|
|
144
|
+
const geometry = geometryFromNrrd(fields); // throws OrientationError if unestablishable
|
|
145
|
+
const t = canonicalTransform(geometry);
|
|
146
|
+
const voxels = reorientVoxels(raw, geometry.dims, t);
|
|
147
|
+
const grid = reorientedGeometry(geometry, t);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
::: tip Masks must be reoriented the same way
|
|
151
|
+
A mask you bring in from elsewhere is in *its* file's order. Put it through the same
|
|
152
|
+
`canonicalTransform` / `reorientVoxels` pair before handing it to `setMasksFromNIfTI`, or it
|
|
153
|
+
will land on the right grid in the wrong order. `registerNiftiMaskGrid` catches a mismatched
|
|
154
|
+
*grid*, not a mismatched *order*.
|
|
155
|
+
:::
|
|
@@ -907,7 +907,7 @@ Underlying data structure: a single contiguous `Uint8Array`
|
|
|
907
907
|
|------|-------------|--------------|-------|
|
|
908
908
|
| z (Axial) | width | height | Most common, contiguous memory |
|
|
909
909
|
| y (Coronal) | width | depth | Extracted row by row |
|
|
910
|
-
| x (Sagittal) |
|
|
910
|
+
| x (Sagittal) | height | depth | Columns along `y`, rows along `z` (changed in 4.1.0) |
|
|
911
911
|
|
|
912
912
|
emptyCanvas size configuration: `SliceRenderPipeline.setEmptyCanvasSize()` → `tools/SliceRenderPipeline.ts`
|
|
913
913
|
|
|
@@ -1045,47 +1045,73 @@ fill considers solid.
|
|
|
1045
1045
|
|
|
1046
1046
|
## 6. Flip Mechanism
|
|
1047
1047
|
|
|
1048
|
-
### 6.1 Display
|
|
1048
|
+
### 6.1 Display Mapping (CT/MRI image only) <Badge type="tip" text="4.1.0" />
|
|
1049
1049
|
|
|
1050
1050
|
**`flipDisplayImageByAxis()`** — `SliceRenderPipeline.flipDisplayImageByAxis()`
|
|
1051
1051
|
|
|
1052
|
-
|
|
1052
|
+
The loader puts every volume in the [canonical voxel order](./orientation) (`i` → patient
|
|
1053
|
+
Left, `j` → Posterior, `k` → Superior), and three lays a slice out by voxel index with fixed
|
|
1054
|
+
row reversals. This per-axis transform undoes those reversals, which is what makes each view
|
|
1055
|
+
the radiological one:
|
|
1056
|
+
|
|
1057
|
+
| Axis | screen-right | screen-down | Transform |
|
|
1058
|
+
|------|--------------|-------------|-----------|
|
|
1059
|
+
| z (Axial) | `+i` (patient Left) | `+j` (Posterior) | `scale(1, -1)` + `translate(0, -h)` |
|
|
1060
|
+
| y (Coronal) | `+i` | `−k` (Superior at the top) | `scale(1, -1)` + `translate(0, -h)` |
|
|
1061
|
+
| x (Sagittal) | `+j` (Anterior on the left) | `−k` | `transform(0, h/w, -w/h, 0, w, 0)` |
|
|
1062
|
+
|
|
1063
|
+
::: warning Sagittal is a quarter turn, not a flip
|
|
1064
|
+
three's sagittal canvas runs columns along `−k` and rows along `−j`, so the view is a **90°
|
|
1065
|
+
rotation as well as a scale**. Its drawn rectangle is the *display* size — width and height
|
|
1066
|
+
swapped relative to three's canvas — which is what `displaySizeOf(axis, canvas)` returns.
|
|
1067
|
+
Every other canvas, mask slices included, is laid out at that same display size.
|
|
1068
|
+
|
|
1069
|
+
Before 4.1.0 sagittal was `scale(-1, -1)` + `translate(-w, -h)`, a 180° flip, which was only
|
|
1070
|
+
correct for volumes already stored in one particular order.
|
|
1071
|
+
:::
|
|
1053
1072
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
| x (Sagittal) | `scale(-1, -1)` + `translate(-w, -h)` |
|
|
1057
|
-
| y (Coronal) | `scale(1, -1)` + `translate(0, -h)` |
|
|
1058
|
-
| z (Axial) | `scale(1, -1)` + `translate(0, -h)` |
|
|
1073
|
+
`Utils/orientation.ts`'s `VIEW_LAYOUT` states the same layout for the orientation letters, so
|
|
1074
|
+
the two are changed in the same commit.
|
|
1059
1075
|
|
|
1060
1076
|
Called from: `SliceRenderPipeline.redrawDisplayCanvas()`
|
|
1061
1077
|
|
|
1062
|
-
### 6.2 Mask Flip (Coronal
|
|
1078
|
+
### 6.2 Mask Flip (Coronal **and** Sagittal) <Badge type="tip" text="4.1.0" />
|
|
1063
1079
|
|
|
1064
|
-
|
|
1080
|
+
Mask contours are drawn bottom-up for any view whose slice rows run up the screen, which
|
|
1081
|
+
`contourPaint.rowsRunUp(axis)` decides:
|
|
1065
1082
|
|
|
1066
1083
|
```ts
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1084
|
+
/** Coronal and sagittal slices store z ascending in their rows and show superior at
|
|
1085
|
+
* the top, so their rows are drawn bottom-up. */
|
|
1086
|
+
export function rowsRunUp(axis: "x" | "y" | "z"): boolean {
|
|
1087
|
+
return axis !== "z";
|
|
1071
1088
|
}
|
|
1072
|
-
targetCtx.drawImage(emptyCanvas, 0, 0, scaledWidth, scaledHeight);
|
|
1073
|
-
if (axis === 'y') targetCtx.restore();
|
|
1074
1089
|
```
|
|
1075
1090
|
|
|
1076
|
-
| Axis | Mask
|
|
1077
|
-
|
|
1078
|
-
| z (Axial) | **None** |
|
|
1079
|
-
| y (Coronal) |
|
|
1080
|
-
| x (Sagittal) |
|
|
1091
|
+
| Axis | Mask flip | Why |
|
|
1092
|
+
|------|-----------|-----|
|
|
1093
|
+
| z (Axial) | **None** | Rows already run down the screen |
|
|
1094
|
+
| y (Coronal) | `scale(1, -1)` | Rows store `k` ascending; Superior belongs at the top |
|
|
1095
|
+
| x (Sagittal) | `scale(1, -1)` | Same — rows run along `k` |
|
|
1081
1096
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1097
|
+
It is applied in both drawing paths: on the `DOMMatrix` for outline mode, and on the context
|
|
1098
|
+
for fill mode, in each case *before* the voxel→display scale so the flip happens in display
|
|
1099
|
+
coordinates.
|
|
1100
|
+
|
|
1101
|
+
::: warning Changed in 4.1.0
|
|
1102
|
+
Sagittal previously had **no** mask flip, and sagittal slices were laid out `depth × height`.
|
|
1103
|
+
Both changed together: slices are now `height × depth` (columns along `y`, rows along `z`),
|
|
1104
|
+
and the flip applies. A caller reading `getSliceUint8` for the sagittal axis gets the
|
|
1105
|
+
transposed layout from 4.1.0 on.
|
|
1084
1106
|
:::
|
|
1085
1107
|
|
|
1086
|
-
### 6.3 applyMaskFlipForAxis
|
|
1108
|
+
### 6.3 `applyMaskFlipForAxis` was removed <Badge type="warning" text="removed in 4.1.0" />
|
|
1087
1109
|
|
|
1088
|
-
`RenderingUtils.applyMaskFlipForAxis()`
|
|
1110
|
+
`RenderingUtils.applyMaskFlipForAxis()` no longer exists. It duplicated the per-axis transform
|
|
1111
|
+
as a third copy, which could — and did — drift from the display path and the contour path.
|
|
1112
|
+
The two remaining copies are kept in step deliberately:
|
|
1113
|
+
`SliceRenderPipeline.flipDisplayImageByAxis` for the image, `contourPaint.rowsRunUp` for the
|
|
1114
|
+
masks.
|
|
1089
1115
|
|
|
1090
1116
|
---
|
|
1091
1117
|
|
|
@@ -151,7 +151,7 @@ plane spatial context — without it the plane floats in an unbounded void and
|
|
|
151
151
|
nothing tells the reader how far through the volume they have scrubbed.
|
|
152
152
|
|
|
153
153
|
```ts
|
|
154
|
-
scene.loadNrrd(url, loadingBar,
|
|
154
|
+
scene.loadNrrd(url, loadingBar, (volume, meshes) => {
|
|
155
155
|
scene.addObject(meshes.z);
|
|
156
156
|
Copper.addVolumeBoundingBox(scene, volume.RASDimensions, { color: 0x8a7f84 });
|
|
157
157
|
});
|
package/ai-index/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"copper3dVersion": "4.
|
|
4
|
-
"generatedAt": "2026-10-
|
|
5
|
-
"symbolCount":
|
|
3
|
+
"copper3dVersion": "4.1.0",
|
|
4
|
+
"generatedAt": "2026-10-14T04:44:40.265Z",
|
|
5
|
+
"symbolCount": 1204,
|
|
6
6
|
"guides": [
|
|
7
7
|
{
|
|
8
8
|
"id": "4D-MRI-LV-rendering",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"title": "Load Progress & Errors",
|
|
75
75
|
"summary": "Every loader in copper3d gained `onProgress` and `onError` in **3.9.0**. Before that there was no way to find out that a load had failed — a broken URL, a 404, a corrupt file and a very slow download all looked identical from outside: the …",
|
|
76
76
|
"lang": "en",
|
|
77
|
-
"bytes":
|
|
77
|
+
"bytes": 11891
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"id": "mcp-server",
|
|
@@ -100,6 +100,14 @@
|
|
|
100
100
|
"lang": "en",
|
|
101
101
|
"bytes": 6195
|
|
102
102
|
},
|
|
103
|
+
{
|
|
104
|
+
"id": "orientation",
|
|
105
|
+
"file": "orientation.md",
|
|
106
|
+
"title": "Patient Orientation <Badge type=\"tip\" text=\"4.1.0\" />",
|
|
107
|
+
"summary": "Every volume `loadNrrd` returns is in the **canonical voxel order**, whatever order its file stores. That is what makes each view come out in the radiological convention without the caller doing anything.",
|
|
108
|
+
"lang": "en",
|
|
109
|
+
"bytes": 6103
|
|
110
|
+
},
|
|
103
111
|
{
|
|
104
112
|
"id": "rotation-pivot",
|
|
105
113
|
"file": "rotation-pivot.md",
|
|
@@ -122,7 +130,7 @@
|
|
|
122
130
|
"title": "Segmentation Module Documentation",
|
|
123
131
|
"summary": "⚠️ **Note**: All line number references in this document are from historical versions. After multiple rounds of refactoring (State Management Refactor, NrrdTools God Class Split, inheritance → composition refactor), these references are ou…",
|
|
124
132
|
"lang": "en",
|
|
125
|
-
"bytes":
|
|
133
|
+
"bytes": 84465
|
|
126
134
|
},
|
|
127
135
|
{
|
|
128
136
|
"id": "surface-annotation-api",
|
|
@@ -146,7 +154,7 @@
|
|
|
146
154
|
"title": "copper3d — Volume Slice Display",
|
|
147
155
|
"summary": "Two functions for the greyscale a volume slice actually comes out as: one that makes scrubbing cheap, one that makes dark studies readable.",
|
|
148
156
|
"lang": "en",
|
|
149
|
-
"bytes":
|
|
157
|
+
"bytes": 7754
|
|
150
158
|
}
|
|
151
159
|
]
|
|
152
160
|
}
|