@niivue/niivue 0.41.0 → 0.41.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/build/index.d.ts +34 -60
- package/build/index.js +411 -495
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -1
- package/package.json +35 -34
- package/src/niivue/index.ts +141 -178
- package/src/niivue-object3D.ts +42 -13
- package/src/nvconnectome.ts +10 -8
- package/src/nvdocument.ts +4 -1
- package/src/nvimage/index.ts +4 -1
- package/src/nvmesh-loaders.ts +82 -117
- package/src/nvmesh-types.ts +12 -12
- package/src/nvmesh.ts +73 -244
- package/src/shader-srcs.ts +114 -13
- package/src/types.ts +1 -0
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Subject, Subscription } from 'rxjs';
|
|
2
1
|
import { mat4, vec3, vec4, vec2 } from 'gl-matrix';
|
|
3
2
|
import * as nifti from 'nifti-reader-js';
|
|
4
3
|
import { WebSocketSubject } from 'rxjs/webSocket';
|
|
@@ -87,8 +86,8 @@ declare class NiivueObject3D {
|
|
|
87
86
|
fieldOfViewDeObliqueMM?: vec3;
|
|
88
87
|
mm?: vec4;
|
|
89
88
|
constructor(id: number, vertexBuffer: WebGLBuffer, mode: number, indexCount: number, indexBuffer?: WebGLVertexArrayObject | null, vao?: WebGLVertexArrayObject | null);
|
|
90
|
-
static generateCrosshairs: (gl: WebGL2RenderingContext, id: number, xyzMM: vec4, xyzMin: vec3, xyzMax: vec3, radius: number, sides?: number) => NiivueObject3D;
|
|
91
|
-
static generateCrosshairsGeometry: (gl: WebGL2RenderingContext, xyzMM: vec4, xyzMin: vec3, xyzMax: vec3, radius: number, sides?: number) => Geometry;
|
|
89
|
+
static generateCrosshairs: (gl: WebGL2RenderingContext, id: number, xyzMM: vec4, xyzMin: vec3, xyzMax: vec3, radius: number, sides?: number, gap?: number) => NiivueObject3D;
|
|
90
|
+
static generateCrosshairsGeometry: (gl: WebGL2RenderingContext, xyzMM: vec4, xyzMin: vec3, xyzMax: vec3, radius: number, sides?: number, gap?: number) => Geometry;
|
|
92
91
|
static getFirstPerpVector: (v1: vec3) => vec3;
|
|
93
92
|
static subdivide: (verts: number[], faces: number[]) => void;
|
|
94
93
|
static weldVertices: (verts: number[], faces: number[]) => number[];
|
|
@@ -183,6 +182,7 @@ type NiftiHeader = {
|
|
|
183
182
|
intent_name: string;
|
|
184
183
|
magic: string;
|
|
185
184
|
};
|
|
185
|
+
type Volume = Record<string, any>;
|
|
186
186
|
type Point = {
|
|
187
187
|
comments: Array<{
|
|
188
188
|
text: string;
|
|
@@ -226,6 +226,7 @@ type ConnectomeOptions = {
|
|
|
226
226
|
edgeMin: number;
|
|
227
227
|
edgeMax: number;
|
|
228
228
|
edgeScale: number;
|
|
229
|
+
legendLineThickness?: number;
|
|
229
230
|
};
|
|
230
231
|
type Connectome = ConnectomeOptions & {
|
|
231
232
|
nodes: NVConnectomeNode[];
|
|
@@ -247,7 +248,7 @@ type LegacyConnectome = Partial<ConnectomeOptions> & {
|
|
|
247
248
|
|
|
248
249
|
type ValuesArray = Array<{
|
|
249
250
|
id: string;
|
|
250
|
-
vals:
|
|
251
|
+
vals: Float32Array;
|
|
251
252
|
global_min?: number;
|
|
252
253
|
global_max?: number;
|
|
253
254
|
cal_min?: number;
|
|
@@ -257,21 +258,21 @@ type TypedNumberArray = Float64Array | Float32Array | Uint32Array | Uint16Array
|
|
|
257
258
|
type AnyNumberArray = number[] | TypedNumberArray;
|
|
258
259
|
type DefaultMeshType = {
|
|
259
260
|
positions: Float32Array;
|
|
260
|
-
indices:
|
|
261
|
+
indices: Uint32Array;
|
|
261
262
|
colors?: Float32Array;
|
|
262
263
|
};
|
|
263
264
|
type TRACT = {
|
|
264
|
-
pts:
|
|
265
|
-
offsetPt0:
|
|
265
|
+
pts: Float32Array;
|
|
266
|
+
offsetPt0: Uint32Array;
|
|
266
267
|
dps: ValuesArray;
|
|
267
268
|
};
|
|
268
269
|
type TT = {
|
|
269
|
-
pts:
|
|
270
|
-
offsetPt0:
|
|
270
|
+
pts: Float32Array;
|
|
271
|
+
offsetPt0: Uint32Array;
|
|
271
272
|
};
|
|
272
273
|
type TRX = {
|
|
273
|
-
pts:
|
|
274
|
-
offsetPt0:
|
|
274
|
+
pts: Float32Array;
|
|
275
|
+
offsetPt0: Uint32Array;
|
|
275
276
|
dpg: ValuesArray;
|
|
276
277
|
dps: ValuesArray;
|
|
277
278
|
dpv: ValuesArray;
|
|
@@ -297,14 +298,14 @@ type ANNOT = Uint32Array | {
|
|
|
297
298
|
};
|
|
298
299
|
type MZ3 = Float32Array | {
|
|
299
300
|
positions: Float32Array | null;
|
|
300
|
-
indices:
|
|
301
|
+
indices: Uint32Array | null;
|
|
301
302
|
scalars: Float32Array;
|
|
302
303
|
colors: Float32Array | null;
|
|
303
304
|
};
|
|
304
305
|
type GII = {
|
|
305
306
|
scalars: Float32Array;
|
|
306
307
|
positions?: Float32Array;
|
|
307
|
-
indices?:
|
|
308
|
+
indices?: Uint32Array;
|
|
308
309
|
colormapLabel?: LUT;
|
|
309
310
|
anatomicalStructurePrimary: string;
|
|
310
311
|
};
|
|
@@ -314,8 +315,8 @@ type MGH = AnyNumberArray | {
|
|
|
314
315
|
};
|
|
315
316
|
type X3D = {
|
|
316
317
|
positions: Float32Array;
|
|
317
|
-
indices:
|
|
318
|
-
rgba255:
|
|
318
|
+
indices: Uint32Array;
|
|
319
|
+
rgba255: Uint8Array;
|
|
319
320
|
};
|
|
320
321
|
|
|
321
322
|
/** Enum for text alignment
|
|
@@ -357,17 +358,17 @@ declare class NVMeshFromUrlOptions {
|
|
|
357
358
|
gl: WebGL2RenderingContext | null;
|
|
358
359
|
name: string;
|
|
359
360
|
opacity: number;
|
|
360
|
-
rgba255:
|
|
361
|
+
rgba255: Uint8Array;
|
|
361
362
|
visible: boolean;
|
|
362
363
|
layers: NVMeshLayer[];
|
|
363
364
|
colorbarVisible: boolean;
|
|
364
|
-
constructor(url?: string, gl?: null, name?: string, opacity?: number, rgba255?:
|
|
365
|
+
constructor(url?: string, gl?: null, name?: string, opacity?: number, rgba255?: Uint8Array, visible?: boolean, layers?: never[], colorbarVisible?: boolean);
|
|
365
366
|
}
|
|
366
367
|
type BaseLoadParams = {
|
|
367
368
|
gl: WebGL2RenderingContext;
|
|
368
369
|
name: string;
|
|
369
370
|
opacity: number;
|
|
370
|
-
rgba255: number[];
|
|
371
|
+
rgba255: number[] | Uint8Array;
|
|
371
372
|
visible: boolean;
|
|
372
373
|
layers: NVMeshLayer[];
|
|
373
374
|
};
|
|
@@ -395,21 +396,21 @@ declare class NVMesh {
|
|
|
395
396
|
opacity: number;
|
|
396
397
|
visible: boolean;
|
|
397
398
|
meshShaderIndex: number;
|
|
398
|
-
offsetPt0:
|
|
399
|
+
offsetPt0: Uint32Array | null;
|
|
399
400
|
colormapInvert: boolean;
|
|
400
401
|
fiberGroupColormap: ColorMap | null;
|
|
401
402
|
indexBuffer: WebGLBuffer;
|
|
402
403
|
vertexBuffer: WebGLBuffer;
|
|
403
404
|
vao: WebGLVertexArrayObject;
|
|
404
405
|
vaoFiber: WebGLVertexArrayObject;
|
|
405
|
-
pts:
|
|
406
|
-
tris?:
|
|
406
|
+
pts: Float32Array;
|
|
407
|
+
tris?: Uint32Array;
|
|
407
408
|
layers: NVMeshLayer[];
|
|
408
409
|
type: MeshType;
|
|
409
410
|
data_type?: string;
|
|
410
|
-
rgba255:
|
|
411
|
+
rgba255: Uint8Array;
|
|
411
412
|
fiberLength?: number;
|
|
412
|
-
fiberLengths?:
|
|
413
|
+
fiberLengths?: Uint32Array;
|
|
413
414
|
fiberDither: number;
|
|
414
415
|
fiberColor: string;
|
|
415
416
|
fiberDecimationStride: number;
|
|
@@ -427,6 +428,7 @@ declare class NVMesh {
|
|
|
427
428
|
vertexCount: number;
|
|
428
429
|
nodeScale: number;
|
|
429
430
|
edgeScale: number;
|
|
431
|
+
legendLineThickness: number;
|
|
430
432
|
nodeColormap: string;
|
|
431
433
|
edgeColormap: string;
|
|
432
434
|
nodeColormapNegative?: string;
|
|
@@ -453,22 +455,17 @@ declare class NVMesh {
|
|
|
453
455
|
* @param colorbarVisible - does this mesh display a colorbar
|
|
454
456
|
* @param anatomicalStructurePrimary - region for mesh. Default is an empty string
|
|
455
457
|
*/
|
|
456
|
-
constructor(pts:
|
|
458
|
+
constructor(pts: Float32Array, tris: Uint32Array, name: string | undefined, rgba255: Uint8Array | undefined, opacity: number | undefined, visible: boolean | undefined, gl: WebGL2RenderingContext, connectome?: LegacyConnectome | string | null, dpg?: ValuesArray | null, dps?: ValuesArray | null, dpv?: ValuesArray | null, colorbarVisible?: boolean, anatomicalStructurePrimary?: string);
|
|
459
|
+
initValuesArray(va: ValuesArray): ValuesArray;
|
|
457
460
|
linesToCylinders(gl: WebGL2RenderingContext, posClrF32: Float32Array, indices: number[]): void;
|
|
458
461
|
updateFibers(gl: WebGL2RenderingContext): void;
|
|
459
|
-
updateConnectome(gl: WebGL2RenderingContext): void;
|
|
460
462
|
indexNearestXYZmm(Xmm: number, Ymm: number, Zmm: number): number[];
|
|
461
463
|
updateMesh(gl: WebGL2RenderingContext): void;
|
|
462
464
|
reverseFaces(gl: WebGL2RenderingContext): void;
|
|
463
465
|
setLayerProperty(id: number, key: keyof NVMeshLayer, val: number | string | boolean, gl: WebGL2RenderingContext): void;
|
|
464
466
|
setProperty(key: keyof this, val: unknown, gl: WebGL2RenderingContext): void;
|
|
465
|
-
generatePosNormClr(pts:
|
|
466
|
-
static
|
|
467
|
-
points?: Point[];
|
|
468
|
-
data_type: string;
|
|
469
|
-
}, gl: WebGL2RenderingContext, name?: string, opacity?: number, visible?: boolean): NVMesh;
|
|
470
|
-
static loadConnectomeFromJSON(json: Record<string, unknown>, gl: WebGL2RenderingContext, name?: string, opacity?: number, visible?: boolean): NVMesh;
|
|
471
|
-
static readMesh(buffer: ArrayBuffer, name: string, gl: WebGL2RenderingContext, opacity?: number, rgba255?: number[], visible?: boolean): NVMesh;
|
|
467
|
+
generatePosNormClr(pts: Float32Array, tris: Uint32Array, rgba255: Uint8Array): Float32Array;
|
|
468
|
+
static readMesh(buffer: ArrayBuffer, name: string, gl: WebGL2RenderingContext, opacity?: number, rgba255?: Uint8Array, visible?: boolean): NVMesh;
|
|
472
469
|
static loadLayer(layer: NVMeshLayer, nvmesh: NVMesh): Promise<void>;
|
|
473
470
|
/**
|
|
474
471
|
* factory function to load and return a new NVMesh instance from a given URL
|
|
@@ -845,7 +842,6 @@ type FreeSurferConnectome = {
|
|
|
845
842
|
declare class NVConnectome extends NVMesh {
|
|
846
843
|
gl: WebGL2RenderingContext;
|
|
847
844
|
nodesChanged: EventTarget;
|
|
848
|
-
legendLineThickness?: number;
|
|
849
845
|
constructor(gl: WebGL2RenderingContext, connectome: LegacyConnectome);
|
|
850
846
|
static convertLegacyConnectome(json: LegacyConnectome): Connectome;
|
|
851
847
|
static convertFreeSurferConnectome(json: FreeSurferConnectome, colormap?: string): Connectome;
|
|
@@ -897,6 +893,7 @@ type NVConfigOptions = {
|
|
|
897
893
|
textHeight: number;
|
|
898
894
|
colorbarHeight: number;
|
|
899
895
|
crosshairWidth: number;
|
|
896
|
+
crosshairGap: number;
|
|
900
897
|
rulerWidth: number;
|
|
901
898
|
show3Dcrosshair: boolean;
|
|
902
899
|
backColor: number[];
|
|
@@ -1525,7 +1522,6 @@ type UIData = {
|
|
|
1525
1522
|
dragClipPlaneStartDepthAziElev: number[];
|
|
1526
1523
|
lastTwoTouchDistance: number;
|
|
1527
1524
|
multiTouchGesture: boolean;
|
|
1528
|
-
loading$: Subject<unknown>;
|
|
1529
1525
|
dpr?: number;
|
|
1530
1526
|
};
|
|
1531
1527
|
type SaveImageOptions = {
|
|
@@ -1614,7 +1610,6 @@ declare class Niivue {
|
|
|
1614
1610
|
syncOpts: Record<string, unknown>;
|
|
1615
1611
|
readyForSync: boolean;
|
|
1616
1612
|
uiData: UIData;
|
|
1617
|
-
eventsToSubjects: Record<string, Subject<unknown>>;
|
|
1618
1613
|
back: NVImage | null;
|
|
1619
1614
|
overlays: NVImage[];
|
|
1620
1615
|
deferredVolumes: ImageFromUrlOptions[];
|
|
@@ -1826,6 +1821,7 @@ declare class Niivue {
|
|
|
1826
1821
|
textHeight: number;
|
|
1827
1822
|
colorbarHeight: number;
|
|
1828
1823
|
crosshairWidth: number;
|
|
1824
|
+
crosshairGap: number;
|
|
1829
1825
|
rulerWidth: number;
|
|
1830
1826
|
show3Dcrosshair: boolean;
|
|
1831
1827
|
backColor: number[];
|
|
@@ -1906,7 +1902,6 @@ declare class Niivue {
|
|
|
1906
1902
|
initialized: boolean;
|
|
1907
1903
|
currentDrawUndoBitmap: number;
|
|
1908
1904
|
loadingText: string;
|
|
1909
|
-
subscriptions: Array<Record<string, Subscription>>;
|
|
1910
1905
|
/**
|
|
1911
1906
|
* @param options - options object to set modifiable Niivue properties
|
|
1912
1907
|
*/
|
|
@@ -1935,28 +1930,6 @@ declare class Niivue {
|
|
|
1935
1930
|
* @see {@link https://niivue.github.io/niivue/features/multiplanar.html|live demo usage}
|
|
1936
1931
|
*/
|
|
1937
1932
|
attachTo(id: string, isAntiAlias?: null): Promise<this>;
|
|
1938
|
-
/**
|
|
1939
|
-
* register a callback function to run when known Niivue events happen
|
|
1940
|
-
* @param event - the name of the event to watch for. Event names are shown in the type column
|
|
1941
|
-
* @param callback - the function to call when the event happens
|
|
1942
|
-
* @example
|
|
1943
|
-
* niivue = new Niivue()
|
|
1944
|
-
*
|
|
1945
|
-
* // 'location' update event is fired when the crosshair changes position via user input
|
|
1946
|
-
* function doSomethingWithLocationData(data)\{
|
|
1947
|
-
* // data has the shape \{mm: [N, N, N], vox: [N, N, N], frac: [N, N, N], values: this.volumes.map(v =\> \{return val\})\}
|
|
1948
|
-
* //...
|
|
1949
|
-
* \}
|
|
1950
|
-
*/
|
|
1951
|
-
on(event: string, callback: (data: unknown) => void): void;
|
|
1952
|
-
/**
|
|
1953
|
-
* off unsubscribes events and subjects (the opposite of on)
|
|
1954
|
-
* @param event - the name of the event to watch for. Event names are shown in the type column
|
|
1955
|
-
* @example
|
|
1956
|
-
* niivue = new Niivue()
|
|
1957
|
-
* niivue.off('location')
|
|
1958
|
-
*/
|
|
1959
|
-
off(event: string): void;
|
|
1960
1933
|
/**
|
|
1961
1934
|
* attach the Niivue instance to a canvas element directly
|
|
1962
1935
|
* @param canvas - the canvas element reference
|
|
@@ -2586,6 +2559,7 @@ declare class Niivue {
|
|
|
2586
2559
|
node: NVConnectomeNode;
|
|
2587
2560
|
};
|
|
2588
2561
|
}): void;
|
|
2562
|
+
loadConnectomeAsMesh(json: Connectome | LegacyConnectome | FreeSurferConnectome): NVMesh;
|
|
2589
2563
|
/**
|
|
2590
2564
|
* load a connectome specified by json
|
|
2591
2565
|
* @param connectome - model
|
|
@@ -2794,7 +2768,7 @@ declare class Niivue {
|
|
|
2794
2768
|
/**
|
|
2795
2769
|
* modulate intensity of one image based on intensity of another
|
|
2796
2770
|
* @param idTarget - the ID of the NVImage to be biased
|
|
2797
|
-
* @param idModulation - the ID of the NVImage that controls bias (
|
|
2771
|
+
* @param idModulation - the ID of the NVImage that controls bias (empty string to disable modulation)
|
|
2798
2772
|
* @param modulateAlpha - does the modulation influence alpha transparency (values greater than 1).
|
|
2799
2773
|
* @example niivue.setModulationImage(niivue.volumes[0].id, niivue.volumes[1].id);
|
|
2800
2774
|
* @see {@link https://niivue.github.io/niivue/features/modulate.html|live demo scalar usage}
|
|
@@ -2950,4 +2924,4 @@ declare class Niivue {
|
|
|
2950
2924
|
set gl(gl: WebGL2RenderingContext | null);
|
|
2951
2925
|
}
|
|
2952
2926
|
|
|
2953
|
-
export { DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type ExportDocumentData, LabelLineTerminator, LabelTextAlignment, MULTIPLANAR_TYPE, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLoaders, NVUtilities, Niivue, SLICE_TYPE, cmapper, ColorTables as colortables };
|
|
2927
|
+
export { type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type ExportDocumentData, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConnectomeEdge, type NVConnectomeNode, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLoaders, NVUtilities, type NiftiHeader, Niivue, type Point, SLICE_TYPE, type Volume, cmapper, ColorTables as colortables };
|