@fideus-labs/fidnii 0.1.0 → 0.2.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/dist/BufferManager.d.ts.map +1 -1
- package/dist/BufferManager.js +2 -5
- package/dist/BufferManager.js.map +1 -1
- package/dist/ClipPlanes.d.ts.map +1 -1
- package/dist/ClipPlanes.js +11 -15
- package/dist/ClipPlanes.js.map +1 -1
- package/dist/OMEZarrNVImage.d.ts +33 -3
- package/dist/OMEZarrNVImage.d.ts.map +1 -1
- package/dist/OMEZarrNVImage.js +129 -50
- package/dist/OMEZarrNVImage.js.map +1 -1
- package/dist/RegionCoalescer.d.ts.map +1 -1
- package/dist/RegionCoalescer.js +1 -1
- package/dist/RegionCoalescer.js.map +1 -1
- package/dist/ResolutionSelector.d.ts.map +1 -1
- package/dist/ResolutionSelector.js +2 -4
- package/dist/ResolutionSelector.js.map +1 -1
- package/dist/ViewportBounds.d.ts.map +1 -1
- package/dist/ViewportBounds.js +7 -5
- package/dist/ViewportBounds.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/affine.d.ts +1 -1
- package/dist/utils/affine.d.ts.map +1 -1
- package/dist/utils/affine.js.map +1 -1
- package/dist/utils/coordinates.d.ts +1 -1
- package/dist/utils/coordinates.d.ts.map +1 -1
- package/dist/utils/coordinates.js.map +1 -1
- package/package.json +1 -1
- package/src/BufferManager.ts +45 -45
- package/src/ClipPlanes.ts +131 -130
- package/src/OMEZarrNVImage.ts +685 -606
- package/src/RegionCoalescer.ts +48 -47
- package/src/ResolutionSelector.ts +66 -67
- package/src/ViewportBounds.ts +120 -118
- package/src/events.ts +36 -35
- package/src/index.ts +59 -69
- package/src/types.ts +95 -94
- package/src/utils/affine.ts +65 -65
- package/src/utils/coordinates.ts +70 -70
package/src/index.ts
CHANGED
|
@@ -34,30 +34,13 @@
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export type {
|
|
42
|
-
AttachedNiivueState,
|
|
43
|
-
ChunkAlignedRegion,
|
|
44
|
-
ChunkCache,
|
|
45
|
-
ClipPlane,
|
|
46
|
-
ClipPlanes,
|
|
47
|
-
OMEZarrNVImageOptions,
|
|
48
|
-
PixelRegion,
|
|
49
|
-
RegionFetchResult,
|
|
50
|
-
ResolutionSelection,
|
|
51
|
-
SlabBufferState,
|
|
52
|
-
SlabSliceType,
|
|
53
|
-
TypedArray,
|
|
54
|
-
VolumeBounds,
|
|
55
|
-
ZarrDtype,
|
|
56
|
-
} from "./types.js";
|
|
57
|
-
|
|
58
|
-
// Re-export SLICE_TYPE from types (which re-exports from niivue)
|
|
59
|
-
export { SLICE_TYPE } from "./types.js";
|
|
37
|
+
// Re-export Methods enum so consumers can check isLabelImage or compare method values
|
|
38
|
+
export { Methods } from "@fideus-labs/ngff-zarr"
|
|
39
|
+
// Worker pool lifecycle (re-exported from ngff-zarr)
|
|
40
|
+
export { terminateWorkerPool } from "@fideus-labs/ngff-zarr/browser"
|
|
60
41
|
|
|
42
|
+
// Buffer manager
|
|
43
|
+
export { BufferManager } from "./BufferManager.js"
|
|
61
44
|
// Clip planes utilities
|
|
62
45
|
export {
|
|
63
46
|
alignToChunks,
|
|
@@ -77,8 +60,20 @@ export {
|
|
|
77
60
|
normalToAzimuthElevation,
|
|
78
61
|
pointToPlaneDistance,
|
|
79
62
|
validateClipPlanes,
|
|
80
|
-
} from "./ClipPlanes.js"
|
|
81
|
-
|
|
63
|
+
} from "./ClipPlanes.js"
|
|
64
|
+
export type {
|
|
65
|
+
OMEZarrNVImageEventListener,
|
|
66
|
+
OMEZarrNVImageEventListenerOptions,
|
|
67
|
+
OMEZarrNVImageEventMap,
|
|
68
|
+
PopulateTrigger,
|
|
69
|
+
} from "./events.js"
|
|
70
|
+
// Event system (browser-native EventTarget API)
|
|
71
|
+
export { OMEZarrNVImageEvent } from "./events.js"
|
|
72
|
+
// Main class
|
|
73
|
+
export { OMEZarrNVImage } from "./OMEZarrNVImage.js"
|
|
74
|
+
// Region coalescer
|
|
75
|
+
export { RegionCoalescer } from "./RegionCoalescer.js"
|
|
76
|
+
export type { OrthogonalAxis } from "./ResolutionSelector.js"
|
|
82
77
|
// Resolution selector utilities
|
|
83
78
|
export {
|
|
84
79
|
alignRegionToChunks,
|
|
@@ -89,16 +84,43 @@ export {
|
|
|
89
84
|
getVolumeShape,
|
|
90
85
|
select2DResolution,
|
|
91
86
|
selectResolution,
|
|
92
|
-
} from "./ResolutionSelector.js"
|
|
93
|
-
|
|
94
|
-
export type {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
} from "./ResolutionSelector.js"
|
|
88
|
+
// Types
|
|
89
|
+
export type {
|
|
90
|
+
AttachedNiivueState,
|
|
91
|
+
ChunkAlignedRegion,
|
|
92
|
+
ChunkCache,
|
|
93
|
+
ClipPlane,
|
|
94
|
+
ClipPlanes,
|
|
95
|
+
OMEZarrNVImageOptions,
|
|
96
|
+
PixelRegion,
|
|
97
|
+
RegionFetchResult,
|
|
98
|
+
ResolutionSelection,
|
|
99
|
+
SlabBufferState,
|
|
100
|
+
SlabSliceType,
|
|
101
|
+
TypedArray,
|
|
102
|
+
VolumeBounds,
|
|
103
|
+
ZarrDtype,
|
|
104
|
+
} from "./types.js"
|
|
105
|
+
// Re-export SLICE_TYPE from types (which re-exports from niivue)
|
|
106
|
+
// Type utilities
|
|
107
|
+
export {
|
|
108
|
+
getBytesPerPixel,
|
|
109
|
+
getNiftiDataType,
|
|
110
|
+
getTypedArrayConstructor,
|
|
111
|
+
NiftiDataType,
|
|
112
|
+
parseZarritaDtype,
|
|
113
|
+
SLICE_TYPE,
|
|
114
|
+
} from "./types.js"
|
|
115
|
+
// Affine utilities
|
|
116
|
+
export {
|
|
117
|
+
affineToNiftiSrows,
|
|
118
|
+
calculateWorldBounds,
|
|
119
|
+
createAffineFromNgffImage,
|
|
120
|
+
createAffineFromOMEZarr,
|
|
121
|
+
getPixelDimensions,
|
|
122
|
+
updateAffineForRegion,
|
|
123
|
+
} from "./utils/affine.js"
|
|
102
124
|
// Coordinate utilities
|
|
103
125
|
export {
|
|
104
126
|
ceilPixelCoord,
|
|
@@ -111,43 +133,11 @@ export {
|
|
|
111
133
|
worldToNormalized,
|
|
112
134
|
worldToPixel,
|
|
113
135
|
worldToPixelAffine,
|
|
114
|
-
} from "./utils/coordinates.js"
|
|
115
|
-
|
|
116
|
-
// Affine utilities
|
|
117
|
-
export {
|
|
118
|
-
affineToNiftiSrows,
|
|
119
|
-
calculateWorldBounds,
|
|
120
|
-
createAffineFromNgffImage,
|
|
121
|
-
createAffineFromOMEZarr,
|
|
122
|
-
getPixelDimensions,
|
|
123
|
-
updateAffineForRegion,
|
|
124
|
-
} from "./utils/affine.js";
|
|
125
|
-
|
|
126
|
-
// Type utilities
|
|
127
|
-
export {
|
|
128
|
-
getBytesPerPixel,
|
|
129
|
-
getNiftiDataType,
|
|
130
|
-
getTypedArrayConstructor,
|
|
131
|
-
NiftiDataType,
|
|
132
|
-
parseZarritaDtype,
|
|
133
|
-
} from "./types.js";
|
|
134
|
-
|
|
135
|
-
// Worker pool lifecycle (re-exported from ngff-zarr)
|
|
136
|
-
export { terminateWorkerPool } from "@fideus-labs/ngff-zarr/browser";
|
|
137
|
-
|
|
136
|
+
} from "./utils/coordinates.js"
|
|
138
137
|
// Viewport bounds utilities
|
|
139
138
|
export {
|
|
140
139
|
boundsApproxEqual,
|
|
141
140
|
computeViewportBounds2D,
|
|
142
141
|
computeViewportBounds3D,
|
|
143
142
|
intersectBounds,
|
|
144
|
-
} from "./ViewportBounds.js"
|
|
145
|
-
|
|
146
|
-
// Event system (browser-native EventTarget API)
|
|
147
|
-
export { OMEZarrNVImageEvent } from "./events.js";
|
|
148
|
-
export type {
|
|
149
|
-
OMEZarrNVImageEventListener,
|
|
150
|
-
OMEZarrNVImageEventListenerOptions,
|
|
151
|
-
OMEZarrNVImageEventMap,
|
|
152
|
-
PopulateTrigger,
|
|
153
|
-
} from "./events.js";
|
|
143
|
+
} from "./ViewportBounds.js"
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Copyright (c) Fideus Labs LLC
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import type { Multiscales } from "@fideus-labs/ngff-zarr"
|
|
5
|
-
import type { Niivue, NVImage } from "@niivue/niivue"
|
|
6
|
-
import { SLICE_TYPE } from "@niivue/niivue"
|
|
7
|
-
|
|
8
|
-
import type {
|
|
4
|
+
import type { Multiscales } from "@fideus-labs/ngff-zarr"
|
|
5
|
+
import type { Niivue, NVImage } from "@niivue/niivue"
|
|
6
|
+
import { SLICE_TYPE } from "@niivue/niivue"
|
|
7
|
+
|
|
8
|
+
import type { BufferManager } from "./BufferManager.js"
|
|
9
|
+
import type { PopulateTrigger } from "./events.js"
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A single clip plane defined by a point and normal vector.
|
|
@@ -14,9 +15,9 @@ import type { PopulateTrigger } from "./events.js";
|
|
|
14
15
|
*/
|
|
15
16
|
export interface ClipPlane {
|
|
16
17
|
/** A point on the plane (center of volume projected to plane) [x, y, z] in world coordinates */
|
|
17
|
-
point: [number, number, number]
|
|
18
|
+
point: [number, number, number]
|
|
18
19
|
/** Unit normal vector pointing toward visible region [x, y, z] */
|
|
19
|
-
normal: [number, number, number]
|
|
20
|
+
normal: [number, number, number]
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -24,14 +25,14 @@ export interface ClipPlane {
|
|
|
24
25
|
* Each plane clips away the half-space on the negative side of its normal.
|
|
25
26
|
* Maximum 6 planes (NiiVue limit). Empty array = full volume visible.
|
|
26
27
|
*/
|
|
27
|
-
export type ClipPlanes = ClipPlane[]
|
|
28
|
+
export type ClipPlanes = ClipPlane[]
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Volume bounds in world space.
|
|
31
32
|
*/
|
|
32
33
|
export interface VolumeBounds {
|
|
33
|
-
min: [number, number, number]
|
|
34
|
-
max: [number, number, number]
|
|
34
|
+
min: [number, number, number]
|
|
35
|
+
max: [number, number, number]
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -40,9 +41,9 @@ export interface VolumeBounds {
|
|
|
40
41
|
*/
|
|
41
42
|
export interface PixelRegion {
|
|
42
43
|
/** Start indices [z, y, x] (inclusive) */
|
|
43
|
-
start: [number, number, number]
|
|
44
|
+
start: [number, number, number]
|
|
44
45
|
/** End indices [z, y, x] (exclusive) */
|
|
45
|
-
end: [number, number, number]
|
|
46
|
+
end: [number, number, number]
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -50,11 +51,11 @@ export interface PixelRegion {
|
|
|
50
51
|
*/
|
|
51
52
|
export interface ChunkAlignedRegion extends PixelRegion {
|
|
52
53
|
/** Chunk-aligned start indices [z, y, x] */
|
|
53
|
-
chunkAlignedStart: [number, number, number]
|
|
54
|
+
chunkAlignedStart: [number, number, number]
|
|
54
55
|
/** Chunk-aligned end indices [z, y, x] */
|
|
55
|
-
chunkAlignedEnd: [number, number, number]
|
|
56
|
+
chunkAlignedEnd: [number, number, number]
|
|
56
57
|
/** True if the original region didn't align with chunk boundaries */
|
|
57
|
-
needsClipping: boolean
|
|
58
|
+
needsClipping: boolean
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -62,11 +63,11 @@ export interface ChunkAlignedRegion extends PixelRegion {
|
|
|
62
63
|
*/
|
|
63
64
|
export interface ResolutionSelection {
|
|
64
65
|
/** Index into multiscales.images array */
|
|
65
|
-
levelIndex: number
|
|
66
|
+
levelIndex: number
|
|
66
67
|
/** Dimensions of the buffer [z, y, x] */
|
|
67
|
-
dimensions: [number, number, number]
|
|
68
|
+
dimensions: [number, number, number]
|
|
68
69
|
/** Total pixel count */
|
|
69
|
-
pixelCount: number
|
|
70
|
+
pixelCount: number
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
@@ -93,9 +94,9 @@ export interface ResolutionSelection {
|
|
|
93
94
|
*/
|
|
94
95
|
export interface ChunkCache {
|
|
95
96
|
/** Look up a cached decoded chunk by key. */
|
|
96
|
-
get(key: string): unknown | undefined
|
|
97
|
+
get(key: string): unknown | undefined
|
|
97
98
|
/** Store a decoded chunk under the given key. */
|
|
98
|
-
set(key: string, value: unknown): void
|
|
99
|
+
set(key: string, value: unknown): void
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
/**
|
|
@@ -103,36 +104,36 @@ export interface ChunkCache {
|
|
|
103
104
|
*/
|
|
104
105
|
export interface OMEZarrNVImageOptions {
|
|
105
106
|
/** The OME-Zarr multiscales data */
|
|
106
|
-
multiscales: Multiscales
|
|
107
|
+
multiscales: Multiscales
|
|
107
108
|
/** Reference to the NiiVue instance for rendering updates */
|
|
108
|
-
niivue: Niivue
|
|
109
|
+
niivue: Niivue
|
|
109
110
|
/** Maximum number of pixels to use (default: 50,000,000) */
|
|
110
|
-
maxPixels?: number
|
|
111
|
+
maxPixels?: number
|
|
111
112
|
/** Debounce delay for clip plane data refetch in milliseconds (default: 300) */
|
|
112
|
-
clipPlaneDebounceMs?: number
|
|
113
|
+
clipPlaneDebounceMs?: number
|
|
113
114
|
/**
|
|
114
115
|
* Automatically add to NiiVue and start progressive loading (default: true).
|
|
115
116
|
* Set to false to manually control when populateVolume() is called.
|
|
116
117
|
* Listen to 'populateComplete' event to know when loading finishes.
|
|
117
118
|
*/
|
|
118
|
-
autoLoad?: boolean
|
|
119
|
+
autoLoad?: boolean
|
|
119
120
|
/**
|
|
120
121
|
* Maximum 3D render zoom level for scroll-wheel zoom (default: 10.0).
|
|
121
122
|
* NiiVue's built-in 3D zoom is hardcoded to [0.5, 2.0]. This option
|
|
122
123
|
* overrides the scroll-wheel zoom handler to allow zooming beyond that limit.
|
|
123
124
|
*/
|
|
124
|
-
max3DZoom?: number
|
|
125
|
+
max3DZoom?: number
|
|
125
126
|
/**
|
|
126
127
|
* Minimum 3D render zoom level for scroll-wheel zoom (default: 0.3).
|
|
127
128
|
* @see max3DZoom
|
|
128
129
|
*/
|
|
129
|
-
min3DZoom?: number
|
|
130
|
+
min3DZoom?: number
|
|
130
131
|
/**
|
|
131
132
|
* Enable viewport-aware resolution selection (default: true).
|
|
132
133
|
* When enabled, zoom/pan interactions constrain the fetch region to the
|
|
133
134
|
* visible viewport, allowing higher resolution within the same maxPixels budget.
|
|
134
135
|
*/
|
|
135
|
-
viewportAware?: boolean
|
|
136
|
+
viewportAware?: boolean
|
|
136
137
|
/**
|
|
137
138
|
* Maximum number of decoded-chunk cache entries (default: 200).
|
|
138
139
|
*
|
|
@@ -142,7 +143,7 @@ export interface OMEZarrNVImageOptions {
|
|
|
142
143
|
*
|
|
143
144
|
* Set to `0` to disable caching entirely.
|
|
144
145
|
*/
|
|
145
|
-
maxCacheEntries?: number
|
|
146
|
+
maxCacheEntries?: number
|
|
146
147
|
/**
|
|
147
148
|
* Optional pre-built decoded-chunk cache. When provided, overrides the
|
|
148
149
|
* internal LRU cache created from `maxCacheEntries`.
|
|
@@ -152,7 +153,7 @@ export interface OMEZarrNVImageOptions {
|
|
|
152
153
|
*
|
|
153
154
|
* @see {@link ChunkCache}
|
|
154
155
|
*/
|
|
155
|
-
cache?: ChunkCache
|
|
156
|
+
cache?: ChunkCache
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
/**
|
|
@@ -160,11 +161,11 @@ export interface OMEZarrNVImageOptions {
|
|
|
160
161
|
*/
|
|
161
162
|
export interface RegionFetchResult {
|
|
162
163
|
/** The pixel data as a typed array */
|
|
163
|
-
data: TypedArray
|
|
164
|
+
data: TypedArray
|
|
164
165
|
/** Shape of the fetched data [z, y, x] */
|
|
165
|
-
shape: number[]
|
|
166
|
+
shape: number[]
|
|
166
167
|
/** Stride of the fetched data */
|
|
167
|
-
stride: number[]
|
|
168
|
+
stride: number[]
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
/**
|
|
@@ -178,7 +179,7 @@ export type ZarrDtype =
|
|
|
178
179
|
| "int16"
|
|
179
180
|
| "int32"
|
|
180
181
|
| "float32"
|
|
181
|
-
| "float64"
|
|
182
|
+
| "float64"
|
|
182
183
|
|
|
183
184
|
/**
|
|
184
185
|
* Union of all typed array types we support.
|
|
@@ -191,7 +192,7 @@ export type TypedArray =
|
|
|
191
192
|
| Int16Array
|
|
192
193
|
| Int32Array
|
|
193
194
|
| Float32Array
|
|
194
|
-
| Float64Array
|
|
195
|
+
| Float64Array
|
|
195
196
|
|
|
196
197
|
/**
|
|
197
198
|
* Typed arrays supported by NiiVue.
|
|
@@ -202,10 +203,10 @@ export type NiiVueTypedArray =
|
|
|
202
203
|
| Uint16Array
|
|
203
204
|
| Int16Array
|
|
204
205
|
| Float32Array
|
|
205
|
-
| Float64Array
|
|
206
|
+
| Float64Array
|
|
206
207
|
|
|
207
208
|
// Re-export SLICE_TYPE for convenience
|
|
208
|
-
export { SLICE_TYPE }
|
|
209
|
+
export { SLICE_TYPE }
|
|
209
210
|
|
|
210
211
|
/**
|
|
211
212
|
* The 2D slice types that use slab-based loading.
|
|
@@ -214,7 +215,7 @@ export { SLICE_TYPE };
|
|
|
214
215
|
export type SlabSliceType =
|
|
215
216
|
| typeof SLICE_TYPE.AXIAL
|
|
216
217
|
| typeof SLICE_TYPE.CORONAL
|
|
217
|
-
| typeof SLICE_TYPE.SAGITTAL
|
|
218
|
+
| typeof SLICE_TYPE.SAGITTAL
|
|
218
219
|
|
|
219
220
|
/**
|
|
220
221
|
* State for a per-slice-type slab buffer.
|
|
@@ -225,37 +226,37 @@ export type SlabSliceType =
|
|
|
225
226
|
*/
|
|
226
227
|
export interface SlabBufferState {
|
|
227
228
|
/** The NVImage instance for this slab */
|
|
228
|
-
nvImage: NVImage
|
|
229
|
+
nvImage: NVImage
|
|
229
230
|
/** Buffer manager for this slab's pixel data */
|
|
230
|
-
bufferManager: BufferManager
|
|
231
|
+
bufferManager: BufferManager
|
|
231
232
|
/** Current resolution level index for this slab */
|
|
232
|
-
levelIndex: number
|
|
233
|
+
levelIndex: number
|
|
233
234
|
/** Target resolution level index for this slab */
|
|
234
|
-
targetLevelIndex: number
|
|
235
|
+
targetLevelIndex: number
|
|
235
236
|
/** Start index of the currently loaded slab in the orthogonal axis (pixel coords at current level) */
|
|
236
|
-
slabStart: number
|
|
237
|
+
slabStart: number
|
|
237
238
|
/** End index of the currently loaded slab in the orthogonal axis (pixel coords at current level) */
|
|
238
|
-
slabEnd: number
|
|
239
|
+
slabEnd: number
|
|
239
240
|
/** Whether this slab is currently loading */
|
|
240
|
-
isLoading: boolean
|
|
241
|
+
isLoading: boolean
|
|
241
242
|
/** Data type of the slab */
|
|
242
|
-
dtype: ZarrDtype
|
|
243
|
+
dtype: ZarrDtype
|
|
243
244
|
/**
|
|
244
245
|
* The affine normalization scale applied to the slab NVImage header.
|
|
245
246
|
* NiiVue mm values = world * normalizationScale.
|
|
246
247
|
* This is 1/maxVoxelSize where maxVoxelSize = max(sx, sy, sz).
|
|
247
248
|
* Used to convert NiiVue 2D FOV coordinates back to physical world coords.
|
|
248
249
|
*/
|
|
249
|
-
normalizationScale: number
|
|
250
|
+
normalizationScale: number
|
|
250
251
|
/**
|
|
251
252
|
* Pending reload request queued while this slab was loading.
|
|
252
253
|
* Latest-wins semantics: only the most recent request is kept.
|
|
253
254
|
* Auto-drained when the current load completes.
|
|
254
255
|
*/
|
|
255
256
|
pendingReload: {
|
|
256
|
-
worldCoord: [number, number, number]
|
|
257
|
-
trigger: PopulateTrigger
|
|
258
|
-
} | null
|
|
257
|
+
worldCoord: [number, number, number]
|
|
258
|
+
trigger: PopulateTrigger
|
|
259
|
+
} | null
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
/**
|
|
@@ -263,25 +264,25 @@ export interface SlabBufferState {
|
|
|
263
264
|
*/
|
|
264
265
|
export interface AttachedNiivueState {
|
|
265
266
|
/** The Niivue instance */
|
|
266
|
-
nv: Niivue
|
|
267
|
+
nv: Niivue
|
|
267
268
|
/** The current slice type of this NV instance */
|
|
268
|
-
currentSliceType: SLICE_TYPE
|
|
269
|
+
currentSliceType: SLICE_TYPE
|
|
269
270
|
/** Previous onLocationChange callback (to chain) */
|
|
270
|
-
previousOnLocationChange?: (location: unknown) => void
|
|
271
|
+
previousOnLocationChange?: (location: unknown) => void
|
|
271
272
|
/** Previous onOptsChange callback (to chain) */
|
|
272
273
|
previousOnOptsChange?: (
|
|
273
274
|
propertyName: string,
|
|
274
275
|
newValue: unknown,
|
|
275
276
|
oldValue: unknown,
|
|
276
|
-
) => void
|
|
277
|
+
) => void
|
|
277
278
|
/** Previous onMouseUp callback (to chain, for viewport-aware mode) */
|
|
278
|
-
previousOnMouseUp?: (data: unknown) => void
|
|
279
|
+
previousOnMouseUp?: (data: unknown) => void
|
|
279
280
|
/** Previous onZoom3DChange callback (to chain, for viewport-aware mode) */
|
|
280
|
-
previousOnZoom3DChange?: (zoom: number) => void
|
|
281
|
+
previousOnZoom3DChange?: (zoom: number) => void
|
|
281
282
|
/** AbortController for viewport-aware event listeners (wheel, etc.) */
|
|
282
|
-
viewportAbortController?: AbortController
|
|
283
|
+
viewportAbortController?: AbortController
|
|
283
284
|
/** AbortController for the 3D zoom override wheel listener */
|
|
284
|
-
zoomOverrideAbortController?: AbortController
|
|
285
|
+
zoomOverrideAbortController?: AbortController
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
/**
|
|
@@ -295,7 +296,7 @@ export type TypedArrayConstructor =
|
|
|
295
296
|
| Int16ArrayConstructor
|
|
296
297
|
| Int32ArrayConstructor
|
|
297
298
|
| Float32ArrayConstructor
|
|
298
|
-
| Float64ArrayConstructor
|
|
299
|
+
| Float64ArrayConstructor
|
|
299
300
|
|
|
300
301
|
/**
|
|
301
302
|
* NIfTI data type codes.
|
|
@@ -309,10 +310,10 @@ export const NiftiDataType = {
|
|
|
309
310
|
INT8: 256,
|
|
310
311
|
UINT16: 512,
|
|
311
312
|
UINT32: 768,
|
|
312
|
-
} as const
|
|
313
|
+
} as const
|
|
313
314
|
|
|
314
315
|
export type NiftiDataTypeCode =
|
|
315
|
-
(typeof NiftiDataType)[keyof typeof NiftiDataType]
|
|
316
|
+
(typeof NiftiDataType)[keyof typeof NiftiDataType]
|
|
316
317
|
|
|
317
318
|
/**
|
|
318
319
|
* Map zarr dtype to typed array constructor.
|
|
@@ -322,23 +323,23 @@ export function getTypedArrayConstructor(
|
|
|
322
323
|
): TypedArrayConstructor {
|
|
323
324
|
switch (dtype) {
|
|
324
325
|
case "uint8":
|
|
325
|
-
return Uint8Array
|
|
326
|
+
return Uint8Array
|
|
326
327
|
case "uint16":
|
|
327
|
-
return Uint16Array
|
|
328
|
+
return Uint16Array
|
|
328
329
|
case "uint32":
|
|
329
|
-
return Uint32Array
|
|
330
|
+
return Uint32Array
|
|
330
331
|
case "int8":
|
|
331
|
-
return Int8Array
|
|
332
|
+
return Int8Array
|
|
332
333
|
case "int16":
|
|
333
|
-
return Int16Array
|
|
334
|
+
return Int16Array
|
|
334
335
|
case "int32":
|
|
335
|
-
return Int32Array
|
|
336
|
+
return Int32Array
|
|
336
337
|
case "float32":
|
|
337
|
-
return Float32Array
|
|
338
|
+
return Float32Array
|
|
338
339
|
case "float64":
|
|
339
|
-
return Float64Array
|
|
340
|
+
return Float64Array
|
|
340
341
|
default:
|
|
341
|
-
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
342
|
+
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
342
343
|
}
|
|
343
344
|
}
|
|
344
345
|
|
|
@@ -349,18 +350,18 @@ export function getBytesPerPixel(dtype: ZarrDtype): number {
|
|
|
349
350
|
switch (dtype) {
|
|
350
351
|
case "uint8":
|
|
351
352
|
case "int8":
|
|
352
|
-
return 1
|
|
353
|
+
return 1
|
|
353
354
|
case "uint16":
|
|
354
355
|
case "int16":
|
|
355
|
-
return 2
|
|
356
|
+
return 2
|
|
356
357
|
case "uint32":
|
|
357
358
|
case "int32":
|
|
358
359
|
case "float32":
|
|
359
|
-
return 4
|
|
360
|
+
return 4
|
|
360
361
|
case "float64":
|
|
361
|
-
return 8
|
|
362
|
+
return 8
|
|
362
363
|
default:
|
|
363
|
-
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
364
|
+
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
367
|
|
|
@@ -370,23 +371,23 @@ export function getBytesPerPixel(dtype: ZarrDtype): number {
|
|
|
370
371
|
export function getNiftiDataType(dtype: ZarrDtype): NiftiDataTypeCode {
|
|
371
372
|
switch (dtype) {
|
|
372
373
|
case "uint8":
|
|
373
|
-
return NiftiDataType.UINT8
|
|
374
|
+
return NiftiDataType.UINT8
|
|
374
375
|
case "uint16":
|
|
375
|
-
return NiftiDataType.UINT16
|
|
376
|
+
return NiftiDataType.UINT16
|
|
376
377
|
case "uint32":
|
|
377
|
-
return NiftiDataType.UINT32
|
|
378
|
+
return NiftiDataType.UINT32
|
|
378
379
|
case "int8":
|
|
379
|
-
return NiftiDataType.INT8
|
|
380
|
+
return NiftiDataType.INT8
|
|
380
381
|
case "int16":
|
|
381
|
-
return NiftiDataType.INT16
|
|
382
|
+
return NiftiDataType.INT16
|
|
382
383
|
case "int32":
|
|
383
|
-
return NiftiDataType.INT32
|
|
384
|
+
return NiftiDataType.INT32
|
|
384
385
|
case "float32":
|
|
385
|
-
return NiftiDataType.FLOAT32
|
|
386
|
+
return NiftiDataType.FLOAT32
|
|
386
387
|
case "float64":
|
|
387
|
-
return NiftiDataType.FLOAT64
|
|
388
|
+
return NiftiDataType.FLOAT64
|
|
388
389
|
default:
|
|
389
|
-
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
390
|
+
throw new Error(`Unsupported dtype: ${dtype}`)
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
|
|
@@ -396,34 +397,34 @@ export function getNiftiDataType(dtype: ZarrDtype): NiftiDataTypeCode {
|
|
|
396
397
|
*/
|
|
397
398
|
export function parseZarritaDtype(dtype: string): ZarrDtype {
|
|
398
399
|
// Remove endianness prefix if present
|
|
399
|
-
const normalized = dtype.replace(/^[|<>]/, "")
|
|
400
|
+
const normalized = dtype.replace(/^[|<>]/, "")
|
|
400
401
|
|
|
401
402
|
switch (normalized) {
|
|
402
403
|
case "u1":
|
|
403
404
|
case "uint8":
|
|
404
|
-
return "uint8"
|
|
405
|
+
return "uint8"
|
|
405
406
|
case "u2":
|
|
406
407
|
case "uint16":
|
|
407
|
-
return "uint16"
|
|
408
|
+
return "uint16"
|
|
408
409
|
case "u4":
|
|
409
410
|
case "uint32":
|
|
410
|
-
return "uint32"
|
|
411
|
+
return "uint32"
|
|
411
412
|
case "i1":
|
|
412
413
|
case "int8":
|
|
413
|
-
return "int8"
|
|
414
|
+
return "int8"
|
|
414
415
|
case "i2":
|
|
415
416
|
case "int16":
|
|
416
|
-
return "int16"
|
|
417
|
+
return "int16"
|
|
417
418
|
case "i4":
|
|
418
419
|
case "int32":
|
|
419
|
-
return "int32"
|
|
420
|
+
return "int32"
|
|
420
421
|
case "f4":
|
|
421
422
|
case "float32":
|
|
422
|
-
return "float32"
|
|
423
|
+
return "float32"
|
|
423
424
|
case "f8":
|
|
424
425
|
case "float64":
|
|
425
|
-
return "float64"
|
|
426
|
+
return "float64"
|
|
426
427
|
default:
|
|
427
|
-
throw new Error(`Unsupported zarrita dtype: ${dtype}`)
|
|
428
|
+
throw new Error(`Unsupported zarrita dtype: ${dtype}`)
|
|
428
429
|
}
|
|
429
430
|
}
|