@niivue/niivue 0.58.0 → 0.59.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/build/index.d.ts +1100 -167
- package/build/index.js +1507 -550
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -1
- package/build/metafile-esm.json +1 -1
- package/dist/index.d.ts +1100 -167
- package/dist/index.js +1507 -550
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/niivue.umd.js +115 -90
- package/package.json +6 -4
- package/src/colortables.ts +2 -9
- package/src/index.html +1 -1
- package/src/niivue/index.ts +1364 -478
- package/src/niivue-object3D.ts +3 -2
- package/src/nvdocument.ts +73 -3
- package/src/nvimage/index.ts +4 -71
- package/src/nvmesh.ts +41 -16
- package/src/shader-srcs.ts +30 -5
package/build/index.d.ts
CHANGED
|
@@ -52,8 +52,9 @@ type Geometry = {
|
|
|
52
52
|
vao: WebGLVertexArrayObject | null;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
55
|
+
* Represents a 3D object rendered with WebGL, including geometry, transformations, and rendering state.
|
|
56
|
+
* Used internally by Niivue for rendering meshes and crosshairs.
|
|
57
|
+
*/
|
|
57
58
|
declare class NiivueObject3D {
|
|
58
59
|
static BLEND: number;
|
|
59
60
|
static CULL_FACE: number;
|
|
@@ -295,7 +296,7 @@ declare const NVImageFromUrlOptions: (url: string, urlImageData?: string, name?:
|
|
|
295
296
|
|
|
296
297
|
type TypedVoxelArray = Float32Array | Uint8Array | Int16Array | Float64Array | Uint16Array;
|
|
297
298
|
/**
|
|
298
|
-
* a NVImage encapsulates some
|
|
299
|
+
* a NVImage encapsulates some image data and provides methods to query and operate on images
|
|
299
300
|
*/
|
|
300
301
|
declare class NVImage {
|
|
301
302
|
name: string;
|
|
@@ -361,33 +362,6 @@ declare class NVImage {
|
|
|
361
362
|
urlImgData?: string;
|
|
362
363
|
isManifest?: boolean;
|
|
363
364
|
limitFrames4D?: number;
|
|
364
|
-
/**
|
|
365
|
-
*
|
|
366
|
-
* @param dataBuffer - an array buffer of image data to load (there are also methods that abstract this more. See loadFromUrl, and loadFromFile)
|
|
367
|
-
* @param name - a name for this image. Default is an empty string
|
|
368
|
-
* @param colormap - a color map to use. default is gray
|
|
369
|
-
* @param opacity - the opacity for this image. default is 1
|
|
370
|
-
* @param pairedImgData - Allows loading formats where header and image are separate files (e.g. nifti.hdr, nifti.img)
|
|
371
|
-
* @param cal_min - minimum intensity for color brightness/contrast
|
|
372
|
-
* @param cal_max - maximum intensity for color brightness/contrast
|
|
373
|
-
* @param trustCalMinMax - whether or not to trust cal_min and cal_max from the nifti header (trusting results in faster loading)
|
|
374
|
-
* @param percentileFrac - the percentile to use for setting the robust range of the display values (smart intensity setting for images with large ranges)
|
|
375
|
-
* @param ignoreZeroVoxels - whether or not to ignore zero voxels in setting the robust range of display values
|
|
376
|
-
* @param useQFormNotSForm - give precedence to QForm (Quaternion) or SForm (Matrix)
|
|
377
|
-
* @param colormapNegative - a color map to use for symmetrical negative intensities
|
|
378
|
-
* @param frame4D - volume displayed, 0 indexed, must be less than nFrame4D
|
|
379
|
-
*
|
|
380
|
-
* FIXME the following params are documented but not included in the actual constructor
|
|
381
|
-
* @param onColormapChange - callback for color map change
|
|
382
|
-
* @param onOpacityChange -callback for color map change
|
|
383
|
-
*
|
|
384
|
-
* TODO the following parameters were not documented
|
|
385
|
-
* @param imageType - TODO
|
|
386
|
-
* @param cal_minNeg - TODO
|
|
387
|
-
* @param cal_maxNeg - TODO
|
|
388
|
-
* @param colorbarVisible - TODO
|
|
389
|
-
* @param colormapLabel - TODO
|
|
390
|
-
*/
|
|
391
365
|
constructor(dataBuffer?: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name?: string, colormap?: string, opacity?: number, pairedImgData?: ArrayBuffer | null, cal_min?: number, cal_max?: number, trustCalMinMax?: boolean, percentileFrac?: number, ignoreZeroVoxels?: boolean, useQFormNotSForm?: boolean, colormapNegative?: string, frame4D?: number, imageType?: ImageType, cal_minNeg?: number, cal_maxNeg?: number, colorbarVisible?: boolean, colormapLabel?: LUT | null, colormapType?: number);
|
|
392
366
|
init(dataBuffer?: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name?: string, colormap?: string, opacity?: number, _pairedImgData?: ArrayBuffer | null, cal_min?: number, cal_max?: number, trustCalMinMax?: boolean, percentileFrac?: number, ignoreZeroVoxels?: boolean, useQFormNotSForm?: boolean, colormapNegative?: string, frame4D?: number, imageType?: ImageType, cal_minNeg?: number, cal_maxNeg?: number, colorbarVisible?: boolean, colormapLabel?: LUT | null, colormapType?: number, imgRaw?: ArrayBuffer | ArrayBufferLike | null): void;
|
|
393
367
|
static new(dataBuffer: ArrayBuffer | ArrayBuffer[] | ArrayBufferLike | null, name: string, colormap: string, opacity: number, pairedImgData: ArrayBuffer | null, cal_min: number, cal_max: number, trustCalMinMax: boolean, percentileFrac: number, ignoreZeroVoxels: boolean, useQFormNotSForm: boolean, colormapNegative: string, frame4D: number, imageType: ImageType, cal_minNeg: number, cal_maxNeg: number, colorbarVisible: boolean, colormapLabel: LUT | null, colormapType: number, zarrData: null | unknown): Promise<NVImage>;
|
|
@@ -430,7 +404,7 @@ declare class NVImage {
|
|
|
430
404
|
* @param vol - volume for estimate (use -1 to use estimate on all loaded volumes; use INFINITY for current volume)
|
|
431
405
|
* @param isBorder - if true (default) only center of volume used for estimate
|
|
432
406
|
* @returns volume brightness and returns array [pct2, pct98, mnScale, mxScale]
|
|
433
|
-
* @see {@link https://niivue.
|
|
407
|
+
* @see {@link https://niivue.com/demos/features/timeseries2.html | live demo usage}
|
|
434
408
|
*/
|
|
435
409
|
calMinMax(vol?: number, isBorder?: boolean): number[];
|
|
436
410
|
intensityRaw2Scaled(raw: number): number;
|
|
@@ -438,17 +412,11 @@ declare class NVImage {
|
|
|
438
412
|
/**
|
|
439
413
|
* Converts NVImage to NIfTI compliant byte array, potentially compressed.
|
|
440
414
|
* Delegates to ImageWriter.saveToUint8Array.
|
|
441
|
-
* @param fnm - Filename (determines if compression is needed via .gz suffix)
|
|
442
|
-
* @param drawing8 - Optional Uint8Array drawing overlay
|
|
443
|
-
* @returns Promise<Uint8Array>
|
|
444
415
|
*/
|
|
445
416
|
saveToUint8Array(fnm: string, drawing8?: Uint8Array | null): Promise<Uint8Array>;
|
|
446
417
|
/**
|
|
447
418
|
* save image as NIfTI volume and trigger download.
|
|
448
419
|
* Delegates to ImageWriter.saveToDisk.
|
|
449
|
-
* @param fnm - Filename for download. If empty, returns data without download.
|
|
450
|
-
* @param drawing8 - Optional Uint8Array drawing overlay
|
|
451
|
-
* @returns Promise<Uint8Array>
|
|
452
420
|
*/
|
|
453
421
|
saveToDisk(fnm?: string, drawing8?: Uint8Array | null): Promise<Uint8Array>;
|
|
454
422
|
static fetchDicomData(url: string, headers?: Record<string, string>): Promise<Array<{
|
|
@@ -461,7 +429,6 @@ declare class NVImage {
|
|
|
461
429
|
static loadInitialVolumes(url?: string, headers?: {}, limitFrames4D?: number): Promise<ArrayBuffer | null>;
|
|
462
430
|
/**
|
|
463
431
|
* factory function to load and return a new NVImage instance from a given URL
|
|
464
|
-
* @returns NVImage instance
|
|
465
432
|
*/
|
|
466
433
|
static loadFromUrl({ url, urlImgData, headers, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, useQFormNotSForm, colormapNegative, frame4D, isManifest, limitFrames4D, imageType, colorbarVisible, buffer }?: Partial<Omit<ImageFromUrlOptions, 'url'>> & {
|
|
467
434
|
url?: string | Uint8Array | ArrayBuffer;
|
|
@@ -484,48 +451,31 @@ declare class NVImage {
|
|
|
484
451
|
static createNiftiHeader(dims?: number[], pixDims?: number[], affine?: number[], datatypeCode?: NiiDataType): NIFTI1;
|
|
485
452
|
/**
|
|
486
453
|
* read a 3D slab of voxels from a volume
|
|
487
|
-
* @
|
|
488
|
-
* @param voxEnd - final row, column and slice (RAS order) for selection
|
|
489
|
-
* @param dataType - array data type. Options: 'same' (default), 'uint8', 'float32', 'scaled', 'normalized', 'windowed'
|
|
490
|
-
* @returns the an array where ret[0] is the voxel values and ret[1] is dimension of selection
|
|
491
|
-
* @see {@link https://niivue.github.io/niivue/features/slab_selection.html | live demo usage}
|
|
454
|
+
* @see {@link https://niivue.com/demos/features/slab_selection.html | live demo usage}
|
|
492
455
|
*/
|
|
493
456
|
/**
|
|
494
457
|
* read a 3D slab of voxels from a volume, specified in RAS coordinates.
|
|
495
458
|
* Delegates to VolumeUtils.getVolumeData.
|
|
496
|
-
* @param voxStart - first row, column and slice (RAS order) for selection
|
|
497
|
-
* @param voxEnd - final row, column and slice (RAS order) for selection
|
|
498
|
-
* @param dataType - array data type. Options: 'same' (default), 'uint8', 'float32', 'scaled', 'normalized', 'windowed'
|
|
499
|
-
* @returns the an array where ret[0] is the voxel values and ret[1] is dimension of selection
|
|
500
459
|
*/
|
|
501
460
|
getVolumeData(voxStart?: number[], voxEnd?: number[], dataType?: string): [TypedVoxelArray, number[]];
|
|
502
461
|
/**
|
|
503
462
|
* write a 3D slab of voxels from a volume
|
|
504
|
-
* @
|
|
505
|
-
* @param voxEnd - final row, column and slice (RAS order) for selection
|
|
506
|
-
* @param img - array of voxel values to insert (RAS order)
|
|
507
|
-
* @see {@link https://niivue.github.io/niivue/features/slab_selection.html | live demo usage}
|
|
463
|
+
* @see {@link https://niivue.com/demos/features/slab_selection.html | live demo usage}
|
|
508
464
|
*/
|
|
509
465
|
/**
|
|
510
466
|
* write a 3D slab of voxels from a volume, specified in RAS coordinates.
|
|
511
467
|
* Delegates to VolumeUtils.setVolumeData.
|
|
512
468
|
* Input slabData is assumed to be in the correct raw data type for the target image.
|
|
513
|
-
* @param voxStart - first row, column and slice (RAS order) for selection
|
|
514
|
-
* @param voxEnd - final row, column and slice (RAS order) for selection
|
|
515
|
-
* @param img - array of voxel values to insert (RAS order, raw data type)
|
|
516
469
|
*/
|
|
517
470
|
setVolumeData(voxStart?: number[], voxEnd?: number[], img?: TypedVoxelArray): void;
|
|
518
471
|
/**
|
|
519
472
|
* factory function to load and return a new NVImage instance from a base64 encoded string
|
|
520
|
-
*
|
|
521
|
-
* @returns NVImage instance
|
|
522
473
|
* @example
|
|
523
474
|
* myImage = NVImage.loadFromBase64('SomeBase64String')
|
|
524
475
|
*/
|
|
525
476
|
static loadFromBase64({ base64, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, useQFormNotSForm, colormapNegative, frame4D, imageType, cal_minNeg, cal_maxNeg, colorbarVisible, colormapLabel }: ImageFromBase64): Promise<NVImage>;
|
|
526
477
|
/**
|
|
527
478
|
* make a clone of a NVImage instance and return a new NVImage
|
|
528
|
-
* @returns NVImage instance
|
|
529
479
|
* @example
|
|
530
480
|
* myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
|
|
531
481
|
* clonedImage = myImage.clone()
|
|
@@ -544,9 +494,6 @@ declare class NVImage {
|
|
|
544
494
|
getImageMetadata(): ImageMetadata;
|
|
545
495
|
/**
|
|
546
496
|
* a factory function to make a zero filled image given a NVImage as a reference
|
|
547
|
-
* @param nvImage - an existing NVImage as a reference
|
|
548
|
-
* @param dataType - the output data type. Options: 'same', 'uint8'
|
|
549
|
-
* @returns new NVImage filled with zeros for the image data
|
|
550
497
|
* @example
|
|
551
498
|
* myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
|
|
552
499
|
* newZeroImage = NVImage.zerosLike(myImage)
|
|
@@ -555,12 +502,6 @@ declare class NVImage {
|
|
|
555
502
|
/**
|
|
556
503
|
* Returns voxel intensity at specific native coordinates.
|
|
557
504
|
* Delegates to VolumeUtils.getValue.
|
|
558
|
-
* @param x - Native X coordinate (0-indexed)
|
|
559
|
-
* @param y - Native Y coordinate (0-indexed)
|
|
560
|
-
* @param z - Native Z coordinate (0-indexed)
|
|
561
|
-
* @param frame4D - 4D frame index (0-indexed)
|
|
562
|
-
* @param isReadImaginary - Flag to read from imaginary data array
|
|
563
|
-
* @returns Scaled voxel intensity
|
|
564
505
|
*/
|
|
565
506
|
getValue(x: number, y: number, z: number, frame4D?: number, isReadImaginary?: boolean): number;
|
|
566
507
|
/**
|
|
@@ -572,8 +513,6 @@ declare class NVImage {
|
|
|
572
513
|
* Converts NVImage to NIfTI compliant byte array.
|
|
573
514
|
* Handles potential re-orientation of drawing data.
|
|
574
515
|
* Delegates to ImageWriter.toUint8Array.
|
|
575
|
-
* @param drawingBytes - Optional Uint8Array drawing overlay
|
|
576
|
-
* @returns Uint8Array
|
|
577
516
|
*/
|
|
578
517
|
toUint8Array(drawingBytes?: Uint8Array | null): Uint8Array;
|
|
579
518
|
convertVox2Frac(vox: vec3): vec3;
|
|
@@ -683,6 +622,8 @@ declare enum COLORMAP_TYPE {
|
|
|
683
622
|
*/
|
|
684
623
|
type NVConfigOptions = {
|
|
685
624
|
textHeight: number;
|
|
625
|
+
fontSizeScaling: number;
|
|
626
|
+
fontMinPx: number;
|
|
686
627
|
colorbarHeight: number;
|
|
687
628
|
colorbarWidth: number;
|
|
688
629
|
showColorbarBorder: boolean;
|
|
@@ -709,6 +650,7 @@ type NVConfigOptions = {
|
|
|
709
650
|
keyDebounceTime: number;
|
|
710
651
|
isNearestInterpolation: boolean;
|
|
711
652
|
atlasOutline: number;
|
|
653
|
+
atlasActiveIndex: number;
|
|
712
654
|
isRuler: boolean;
|
|
713
655
|
isColorbar: boolean;
|
|
714
656
|
isOrientCube: boolean;
|
|
@@ -863,6 +805,8 @@ declare class NVDocument {
|
|
|
863
805
|
drawBitmap: Uint8Array | null;
|
|
864
806
|
imageOptionsMap: Map<any, any>;
|
|
865
807
|
meshOptionsMap: Map<any, any>;
|
|
808
|
+
private _optsProxy;
|
|
809
|
+
private _optsChangeCallback;
|
|
866
810
|
constructor();
|
|
867
811
|
/**
|
|
868
812
|
* Title of the document
|
|
@@ -973,6 +917,18 @@ declare class NVDocument {
|
|
|
973
917
|
* Factory method to return an instance of NVDocument from JSON
|
|
974
918
|
*/
|
|
975
919
|
static oldloadFromJSON(data: DocumentData): NVDocument;
|
|
920
|
+
/**
|
|
921
|
+
* Sets the callback function to be called when opts properties change
|
|
922
|
+
*/
|
|
923
|
+
setOptsChangeCallback(callback: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void): void;
|
|
924
|
+
/**
|
|
925
|
+
* Removes the opts change callback
|
|
926
|
+
*/
|
|
927
|
+
removeOptsChangeCallback(): void;
|
|
928
|
+
/**
|
|
929
|
+
* Creates a Proxy wrapper around the opts object to detect changes
|
|
930
|
+
*/
|
|
931
|
+
private _createOptsProxy;
|
|
976
932
|
}
|
|
977
933
|
|
|
978
934
|
type NiftiHeader = {
|
|
@@ -1257,12 +1213,21 @@ declare class NVMeshFromUrlOptions {
|
|
|
1257
1213
|
colorbarVisible: boolean;
|
|
1258
1214
|
constructor(url?: string, gl?: any, name?: string, opacity?: number, rgba255?: Uint8Array, visible?: boolean, layers?: any[], colorbarVisible?: boolean);
|
|
1259
1215
|
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Parameters for loading a base mesh or volume.
|
|
1218
|
+
*/
|
|
1260
1219
|
type BaseLoadParams = {
|
|
1220
|
+
/** WebGL rendering context. */
|
|
1261
1221
|
gl: WebGL2RenderingContext;
|
|
1222
|
+
/** Name for this image. Default is an empty string. */
|
|
1262
1223
|
name: string;
|
|
1224
|
+
/** Opacity for this image. Default is 1. */
|
|
1263
1225
|
opacity: number;
|
|
1226
|
+
/** Base color of the mesh in RGBA [0-255]. Default is white. */
|
|
1264
1227
|
rgba255: number[] | Uint8Array;
|
|
1228
|
+
/** Whether this image is visible. */
|
|
1265
1229
|
visible: boolean;
|
|
1230
|
+
/** Layers of the mesh to load. */
|
|
1266
1231
|
layers: NVMeshLayer[];
|
|
1267
1232
|
};
|
|
1268
1233
|
type LoadFromUrlParams = Partial<BaseLoadParams> & {
|
|
@@ -1507,6 +1472,9 @@ declare class NVMeshUtilities {
|
|
|
1507
1472
|
static generateNormals(pts: number[] | Float32Array, tris: number[] | Uint32Array): Float32Array;
|
|
1508
1473
|
}
|
|
1509
1474
|
|
|
1475
|
+
/**
|
|
1476
|
+
* Entry representing a single colormap with display properties.
|
|
1477
|
+
*/
|
|
1510
1478
|
type ColormapListEntry = {
|
|
1511
1479
|
name: string;
|
|
1512
1480
|
min: number;
|
|
@@ -1633,6 +1601,7 @@ declare class Niivue {
|
|
|
1633
1601
|
volumeTexture: WebGLTexture | null;
|
|
1634
1602
|
gradientTexture: WebGLTexture | null;
|
|
1635
1603
|
gradientTextureAmount: number;
|
|
1604
|
+
useCustomGradientTexture: boolean;
|
|
1636
1605
|
renderGradientValues: boolean;
|
|
1637
1606
|
drawTexture: WebGLTexture | null;
|
|
1638
1607
|
drawUndoBitmaps: Uint8Array[];
|
|
@@ -1695,6 +1664,8 @@ declare class Niivue {
|
|
|
1695
1664
|
private DEFAULT_FONT_METRICS;
|
|
1696
1665
|
private fontMetrics?;
|
|
1697
1666
|
private fontMets;
|
|
1667
|
+
private fontPx;
|
|
1668
|
+
private legendFontScaling;
|
|
1698
1669
|
backgroundMasksOverlays: number;
|
|
1699
1670
|
overlayOutlineWidth: number;
|
|
1700
1671
|
overlayAlphaShader: number;
|
|
@@ -1931,12 +1902,32 @@ declare class Niivue {
|
|
|
1931
1902
|
* }
|
|
1932
1903
|
*/
|
|
1933
1904
|
onDocumentLoaded: (document: NVDocument) => void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Callback for when any configuration option changes.
|
|
1907
|
+
* @param propertyName - The name of the option that changed.
|
|
1908
|
+
* @param newValue - The new value of the option.
|
|
1909
|
+
* @param oldValue - The previous value of the option.
|
|
1910
|
+
*/
|
|
1911
|
+
onOptsChange: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void;
|
|
1934
1912
|
document: NVDocument;
|
|
1913
|
+
/** Get the current scene configuration. */
|
|
1935
1914
|
get scene(): Scene;
|
|
1915
|
+
/** Get the current visualization options. */
|
|
1936
1916
|
get opts(): NVConfigOptions;
|
|
1917
|
+
/** Get the slice mosaic layout string. */
|
|
1937
1918
|
get sliceMosaicString(): string;
|
|
1919
|
+
/** Set the slice mosaic layout string. */
|
|
1938
1920
|
set sliceMosaicString(newSliceMosaicString: string);
|
|
1921
|
+
/**
|
|
1922
|
+
* Get whether voxels below minimum intensity are drawn as dark or transparent.
|
|
1923
|
+
* @returns {boolean} True if dark voxels are opaque, false if transparent.
|
|
1924
|
+
*/
|
|
1939
1925
|
get isAlphaClipDark(): boolean;
|
|
1926
|
+
/**
|
|
1927
|
+
* Set whether voxels below minimum intensity are drawn as dark or transparent.
|
|
1928
|
+
* @param {boolean} newVal - True to make dark voxels opaque, false for transparent.
|
|
1929
|
+
* @see {@link https://niivue.com/demos/features/segment.html | live demo usage}
|
|
1930
|
+
*/
|
|
1940
1931
|
set isAlphaClipDark(newVal: boolean);
|
|
1941
1932
|
mediaUrlMap: Map<NVImage | NVMesh, string>;
|
|
1942
1933
|
initialized: boolean;
|
|
@@ -1964,7 +1955,7 @@ declare class Niivue {
|
|
|
1964
1955
|
* save webgl2 canvas as png format bitmap
|
|
1965
1956
|
* @param filename - filename for screen capture
|
|
1966
1957
|
* @example niivue.saveScene('test.png');
|
|
1967
|
-
* @see {@link https://niivue.
|
|
1958
|
+
* @see {@link https://niivue.com/demos/features/ui.html | live demo usage}
|
|
1968
1959
|
*/
|
|
1969
1960
|
saveScene(filename?: string): Promise<void>;
|
|
1970
1961
|
/**
|
|
@@ -1973,7 +1964,7 @@ declare class Niivue {
|
|
|
1973
1964
|
* @param isAntiAlias - determines if anti-aliasing is requested (if not specified, AA usage depends on hardware)
|
|
1974
1965
|
* @example niivue = new Niivue().attachTo('gl')
|
|
1975
1966
|
* @example await niivue.attachTo('gl')
|
|
1976
|
-
* @see {@link https://niivue.
|
|
1967
|
+
* @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
|
|
1977
1968
|
*/
|
|
1978
1969
|
attachTo(id: string, isAntiAlias?: any): Promise<this>;
|
|
1979
1970
|
/**
|
|
@@ -1982,6 +1973,7 @@ declare class Niivue {
|
|
|
1982
1973
|
* @example
|
|
1983
1974
|
* niivue = new Niivue()
|
|
1984
1975
|
* await niivue.attachToCanvas(document.getElementById(id))
|
|
1976
|
+
* @see {@link https://niivue.com/demos/features/dsistudio.html | live demo usage}
|
|
1985
1977
|
*/
|
|
1986
1978
|
attachToCanvas(canvas: HTMLCanvasElement, isAntiAlias?: boolean | null): Promise<this>;
|
|
1987
1979
|
/**
|
|
@@ -1992,7 +1984,7 @@ declare class Niivue {
|
|
|
1992
1984
|
* niivue2 = new Niivue()
|
|
1993
1985
|
* niivue2.syncWith(niivue1)
|
|
1994
1986
|
* @deprecated use broadcastTo instead
|
|
1995
|
-
* @see {@link https://niivue.
|
|
1987
|
+
* @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
|
|
1996
1988
|
*/
|
|
1997
1989
|
syncWith(otherNV: Niivue | Niivue[], syncOpts?: {
|
|
1998
1990
|
'2d': boolean;
|
|
@@ -2007,20 +1999,52 @@ declare class Niivue {
|
|
|
2007
1999
|
* niivue3 = new Niivue()
|
|
2008
2000
|
* niivue1.broadcastTo(niivue2)
|
|
2009
2001
|
* niivue1.broadcastTo([niivue2, niivue3])
|
|
2010
|
-
* @see {@link https://niivue.
|
|
2002
|
+
* @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
|
|
2011
2003
|
*/
|
|
2012
2004
|
broadcastTo(otherNV: Niivue | Niivue[], syncOpts?: {
|
|
2013
2005
|
'2d': boolean;
|
|
2014
2006
|
'3d': boolean;
|
|
2015
2007
|
}): void;
|
|
2008
|
+
/**
|
|
2009
|
+
* Synchronizes 3D view settings (azimuth, elevation, scale) with another Niivue instance.
|
|
2010
|
+
* @internal
|
|
2011
|
+
*/
|
|
2016
2012
|
doSync3d(otherNV: Niivue): void;
|
|
2013
|
+
/**
|
|
2014
|
+
* Synchronizes 2D crosshair position and pan settings with another Niivue instance.
|
|
2015
|
+
* @internal
|
|
2016
|
+
*/
|
|
2017
2017
|
doSync2d(otherNV: Niivue): void;
|
|
2018
2018
|
doSyncGamma(otherNV: Niivue): void;
|
|
2019
|
+
/**
|
|
2020
|
+
* Synchronizes gamma correction setting with another Niivue instance.
|
|
2021
|
+
* @internal
|
|
2022
|
+
*/
|
|
2019
2023
|
doSyncZoomPan(otherNV: Niivue): void;
|
|
2024
|
+
/**
|
|
2025
|
+
* Synchronizes crosshair position with another Niivue instance.
|
|
2026
|
+
* @internal
|
|
2027
|
+
*/
|
|
2020
2028
|
doSyncCrosshair(otherNV: Niivue): void;
|
|
2029
|
+
/**
|
|
2030
|
+
* Synchronizes cal_min with another Niivue instance, updating GPU volume only if needed.
|
|
2031
|
+
* @internal
|
|
2032
|
+
*/
|
|
2021
2033
|
doSyncCalMin(otherNV: Niivue): void;
|
|
2034
|
+
/**
|
|
2035
|
+
* Synchronizes cal_max with another Niivue instance, updating GPU volume only if needed.
|
|
2036
|
+
* @internal
|
|
2037
|
+
*/
|
|
2022
2038
|
doSyncCalMax(otherNV: Niivue): void;
|
|
2039
|
+
/**
|
|
2040
|
+
* Synchronizes slice view type with another Niivue instance.
|
|
2041
|
+
* @internal
|
|
2042
|
+
*/
|
|
2023
2043
|
doSyncSliceType(otherNV: Niivue): void;
|
|
2044
|
+
/**
|
|
2045
|
+
* Synchronizes clip plane settings with another Niivue instance.
|
|
2046
|
+
* @internal
|
|
2047
|
+
*/
|
|
2024
2048
|
doSyncClipPlane(otherNV: Niivue): void;
|
|
2025
2049
|
/**
|
|
2026
2050
|
* Sync the scene controls (orientation, crosshair location, etc.) from one Niivue instance to another. useful for using one canvas to drive another.
|
|
@@ -2033,6 +2057,7 @@ declare class Niivue {
|
|
|
2033
2057
|
*/
|
|
2034
2058
|
sync(): void;
|
|
2035
2059
|
/** Not documented publicly for now
|
|
2060
|
+
* @internal
|
|
2036
2061
|
* test if two arrays have equal values for each element
|
|
2037
2062
|
* @param a - the first array
|
|
2038
2063
|
* @param b - the second array
|
|
@@ -2041,6 +2066,13 @@ declare class Niivue {
|
|
|
2041
2066
|
* TODO this should maybe just use array-equal from NPM
|
|
2042
2067
|
*/
|
|
2043
2068
|
arrayEquals(a: unknown[], b: unknown[]): boolean;
|
|
2069
|
+
/**
|
|
2070
|
+
* @internal
|
|
2071
|
+
* Compute point size for screen text that scales with resolution and screen size.
|
|
2072
|
+
* - Keeps physical font size consistent across different DPIs.
|
|
2073
|
+
* - Uses fontSizeScaling to scale with canvas size above a reference threshold.
|
|
2074
|
+
*/
|
|
2075
|
+
textSizePoints(): void;
|
|
2044
2076
|
/**
|
|
2045
2077
|
* callback function to handle resize window events, redraws the scene.
|
|
2046
2078
|
* @internal
|
|
@@ -2055,65 +2087,189 @@ declare class Niivue {
|
|
|
2055
2087
|
x: number;
|
|
2056
2088
|
y: number;
|
|
2057
2089
|
} | undefined;
|
|
2090
|
+
/**
|
|
2091
|
+
* Returns mouse position relative to the canvas, excluding padding and borders.
|
|
2092
|
+
* @internal
|
|
2093
|
+
*/
|
|
2058
2094
|
getNoPaddingNoBorderCanvasRelativeMousePosition(event: MouseEvent, target: EventTarget): {
|
|
2059
2095
|
x: number;
|
|
2060
2096
|
y: number;
|
|
2061
2097
|
} | undefined;
|
|
2098
|
+
/**
|
|
2099
|
+
* Disables the default context menu to allow custom right-click behavior.
|
|
2100
|
+
* @internal
|
|
2101
|
+
*/
|
|
2062
2102
|
mouseContextMenuListener(e: MouseEvent): void;
|
|
2103
|
+
/**
|
|
2104
|
+
* Handles mouse down events for interaction, segmentation, and connectome label selection.
|
|
2105
|
+
* Routes to appropriate button handler based on click type.
|
|
2106
|
+
* @internal
|
|
2107
|
+
*/
|
|
2063
2108
|
mouseDownListener(e: MouseEvent): void;
|
|
2109
|
+
/**
|
|
2110
|
+
* Handles left mouse button actions for crosshair or windowing mode.
|
|
2111
|
+
* @internal
|
|
2112
|
+
*/
|
|
2064
2113
|
mouseLeftButtonHandler(e: MouseEvent): void;
|
|
2114
|
+
/**
|
|
2115
|
+
* Handles center mouse button drag to initiate 2D panning or clip plane adjustment.
|
|
2116
|
+
* @internal
|
|
2117
|
+
*/
|
|
2065
2118
|
mouseCenterButtonHandler(e: MouseEvent): void;
|
|
2119
|
+
/**
|
|
2120
|
+
* Handles right mouse button drag to enable 2D panning or clip plane control.
|
|
2121
|
+
* @internal
|
|
2122
|
+
*/
|
|
2066
2123
|
mouseRightButtonHandler(e: MouseEvent): void;
|
|
2067
2124
|
/**
|
|
2068
2125
|
* calculate the the min and max voxel indices from an array of two values (used in selecting intensities with the selection box)
|
|
2126
|
+
* @internal
|
|
2069
2127
|
* @param array - an array of two values
|
|
2070
2128
|
* @returns an array of two values representing the min and max voxel indices
|
|
2071
2129
|
*/
|
|
2072
2130
|
calculateMinMaxVoxIdx(array: number[]): number[];
|
|
2131
|
+
/**
|
|
2132
|
+
* Updates cal_min and cal_max based on intensity range within the drag-selected voxel region.
|
|
2133
|
+
* Skips if no drag occurred, volume is missing, or selection has no variation.
|
|
2134
|
+
* @internal
|
|
2135
|
+
*/
|
|
2073
2136
|
calculateNewRange({ volIdx }?: {
|
|
2074
2137
|
volIdx?: number;
|
|
2075
2138
|
}): void;
|
|
2139
|
+
/**
|
|
2140
|
+
* Triggers a drag-release callback with voxel, mm, and tile info from the drag gesture.
|
|
2141
|
+
* @internal
|
|
2142
|
+
*/
|
|
2076
2143
|
generateMouseUpCallback(fracStart: vec3, fracEnd: vec3): void;
|
|
2144
|
+
/**
|
|
2145
|
+
* Handles mouse up events, finalizing drag actions, invoking callbacks, and updating contrast if needed.
|
|
2146
|
+
* @internal
|
|
2147
|
+
*/
|
|
2077
2148
|
mouseUpListener(): void;
|
|
2149
|
+
/**
|
|
2150
|
+
* Handles initial touch event to simulate mouse click if not in a multi-touch gesture.
|
|
2151
|
+
* @internal
|
|
2152
|
+
*/
|
|
2078
2153
|
checkMultitouch(e: TouchEvent): void;
|
|
2154
|
+
/**
|
|
2155
|
+
* Handles touch start events, detecting double taps and preparing for gesture or contrast reset.
|
|
2156
|
+
* @internal
|
|
2157
|
+
*/
|
|
2079
2158
|
touchStartListener(e: TouchEvent): void;
|
|
2159
|
+
/**
|
|
2160
|
+
* Handles touch end events, finalizing gestures and contrast adjustments, then triggers mouse up logic.
|
|
2161
|
+
* @internal
|
|
2162
|
+
*/
|
|
2080
2163
|
touchEndListener(e: TouchEvent): void;
|
|
2164
|
+
/**
|
|
2165
|
+
* Adjusts window/level (cal_min and cal_max) based on mouse or touch drag direction.
|
|
2166
|
+
* @internal
|
|
2167
|
+
*/
|
|
2081
2168
|
windowingHandler(x: number, y: number, volIdx?: number): void;
|
|
2169
|
+
/**
|
|
2170
|
+
* Handles mouse leaving the canvas, resetting segmentation, drawing, and drag states.
|
|
2171
|
+
* @internal
|
|
2172
|
+
*/
|
|
2082
2173
|
mouseLeaveListener(): void;
|
|
2174
|
+
/**
|
|
2175
|
+
* Handles mouse move events for dragging, crosshair movement, windowing, and click-to-segment preview.
|
|
2176
|
+
* @internal
|
|
2177
|
+
*/
|
|
2083
2178
|
mouseMoveListener(e: MouseEvent): void;
|
|
2179
|
+
/**
|
|
2180
|
+
* Resets brightness and contrast to robust min/max unless in render mode or during interaction.
|
|
2181
|
+
* @internal
|
|
2182
|
+
*/
|
|
2084
2183
|
resetBriCon(msg?: TouchEvent | MouseEvent | null): void;
|
|
2184
|
+
/**
|
|
2185
|
+
* Sets the drag start position in canvas coordinates.
|
|
2186
|
+
* @internal
|
|
2187
|
+
*/
|
|
2085
2188
|
setDragStart(x: number, y: number): void;
|
|
2189
|
+
/**
|
|
2190
|
+
* Sets the drag end position in canvas coordinates.
|
|
2191
|
+
* @internal
|
|
2192
|
+
*/
|
|
2086
2193
|
setDragEnd(x: number, y: number): void;
|
|
2194
|
+
/**
|
|
2195
|
+
* Handles touch movement for crosshair, windowing, and pinch-to-zoom interactions.
|
|
2196
|
+
* @internal
|
|
2197
|
+
*/
|
|
2087
2198
|
touchMoveListener(e: TouchEvent): void;
|
|
2199
|
+
/**
|
|
2200
|
+
* Handles pinch-to-zoom gestures for scrolling 2D slices.
|
|
2201
|
+
* @internal
|
|
2202
|
+
*/
|
|
2088
2203
|
handlePinchZoom(e: TouchEvent): void;
|
|
2204
|
+
/**
|
|
2205
|
+
* Handles keyboard shortcuts for toggling clip planes and slice view modes with debounce logic.
|
|
2206
|
+
* @internal
|
|
2207
|
+
*/
|
|
2089
2208
|
keyUpListener(e: KeyboardEvent): void;
|
|
2209
|
+
/**
|
|
2210
|
+
* Handles key down events for navigation, rendering controls, slice movement, and mode switching.
|
|
2211
|
+
* @internal
|
|
2212
|
+
*/
|
|
2090
2213
|
keyDownListener(e: KeyboardEvent): void;
|
|
2214
|
+
/**
|
|
2215
|
+
* Handles scroll wheel events for slice scrolling, ROI box resizing, zooming, or segmentation thresholding.
|
|
2216
|
+
* @internal
|
|
2217
|
+
*/
|
|
2091
2218
|
wheelListener(e: WheelEvent): void;
|
|
2219
|
+
/**
|
|
2220
|
+
* Registers all mouse, touch, keyboard, and drag event listeners for canvas interaction.
|
|
2221
|
+
* n.b. any event listeners registered here should also be removed in `cleanup()`
|
|
2222
|
+
* @internal
|
|
2223
|
+
*/
|
|
2092
2224
|
registerInteractions(): void;
|
|
2225
|
+
/**
|
|
2226
|
+
* Prevents default behavior when a dragged item enters the canvas.
|
|
2227
|
+
* @internal
|
|
2228
|
+
*/
|
|
2093
2229
|
dragEnterListener(e: MouseEvent): void;
|
|
2230
|
+
/**
|
|
2231
|
+
* Prevents default behavior when a dragged item is over the canvas.
|
|
2232
|
+
* @internal
|
|
2233
|
+
*/
|
|
2094
2234
|
dragOverListener(e: MouseEvent): void;
|
|
2235
|
+
/**
|
|
2236
|
+
* Extracts and normalizes the file extension, handling special cases like .gz and .cbor.
|
|
2237
|
+
* @internal
|
|
2238
|
+
*/
|
|
2095
2239
|
getFileExt(fullname: string, upperCase?: boolean): string;
|
|
2096
2240
|
/**
|
|
2097
2241
|
* Add an image and notify subscribers
|
|
2098
|
-
* @see {@link https://niivue.
|
|
2242
|
+
* @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
|
|
2099
2243
|
*/
|
|
2100
2244
|
addVolumeFromUrl(imageOptions: ImageFromUrlOptions): Promise<NVImage>;
|
|
2101
2245
|
addVolumesFromUrl(imageOptionsArray: ImageFromUrlOptions[]): Promise<NVImage[]>;
|
|
2102
2246
|
/**
|
|
2103
|
-
*
|
|
2247
|
+
* Returns the media object associated with the given URL, if any.
|
|
2248
|
+
* @internal
|
|
2104
2249
|
*/
|
|
2105
2250
|
getMediaByUrl(url: string): NVImage | NVMesh | undefined;
|
|
2106
2251
|
/**
|
|
2107
2252
|
* Remove volume by url
|
|
2108
2253
|
* @param url - Volume added by url to remove
|
|
2109
|
-
* @see {@link https://niivue.
|
|
2254
|
+
* @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
|
|
2110
2255
|
*/
|
|
2111
2256
|
removeVolumeByUrl(url: string): void;
|
|
2257
|
+
/**
|
|
2258
|
+
* Recursively traverses a file tree, populating file paths for directory uploads.
|
|
2259
|
+
* Adds `_webkitRelativePath` to each file for compatibility with tools like dcm2niix.
|
|
2260
|
+
* @internal
|
|
2261
|
+
*/
|
|
2112
2262
|
traverseFileTree(item: any, path: string, fileArray: any): Promise<File[]>;
|
|
2263
|
+
/**
|
|
2264
|
+
* Recursively reads a directory and logs the File objects contained within.
|
|
2265
|
+
* Used for processing dropped folders via drag-and-drop.
|
|
2266
|
+
* @internal
|
|
2267
|
+
*/
|
|
2113
2268
|
readDirectory(directory: FileSystemDirectoryEntry): FileSystemEntry[];
|
|
2114
2269
|
/**
|
|
2115
2270
|
* Returns boolean: true if filename ends with mesh extension (TRK, pial, etc)
|
|
2116
2271
|
* @param url - filename
|
|
2272
|
+
* @internal
|
|
2117
2273
|
*/
|
|
2118
2274
|
isMeshExt(url: string): boolean;
|
|
2119
2275
|
/**
|
|
@@ -2124,46 +2280,87 @@ declare class Niivue {
|
|
|
2124
2280
|
*/
|
|
2125
2281
|
loadFromArrayBuffer(buffer: ArrayBuffer, name: string): Promise<void>;
|
|
2126
2282
|
/**
|
|
2127
|
-
* Load a mesh or image from a
|
|
2128
|
-
* @param file - File object
|
|
2283
|
+
* Load a mesh or image volume from a File object
|
|
2284
|
+
* @param file - File object selected by the user (e.g. from an HTML input element)
|
|
2285
|
+
* @returns a Promise that resolves when the file has been loaded and added to the scene
|
|
2286
|
+
* @see {@link https://niivue.com/demos/features/selectfont.html | live demo usage}
|
|
2129
2287
|
*/
|
|
2130
2288
|
loadFromFile(file: File): Promise<void>;
|
|
2289
|
+
/**
|
|
2290
|
+
* Registers a custom external file loader for handling specific file types in Niivue.
|
|
2291
|
+
*
|
|
2292
|
+
* This method allows you to define how certain file extensions are handled when loaded into Niivue.
|
|
2293
|
+
* The provided `loader` function should return an object containing an `ArrayBuffer` of the file's contents
|
|
2294
|
+
* and the file extension (used for inferring how Niivue should process the data).
|
|
2295
|
+
*
|
|
2296
|
+
* Optionally, `positions` and `indices` can be returned to support loading mesh data (e.g. `.mz3` format).
|
|
2297
|
+
*
|
|
2298
|
+
* @example
|
|
2299
|
+
* const myCustomLoader = async (file) => {
|
|
2300
|
+
* const arrayBuffer = await file.arrayBuffer()
|
|
2301
|
+
* return {
|
|
2302
|
+
* arrayBuffer,
|
|
2303
|
+
* fileExt: 'iwi.cbor',
|
|
2304
|
+
* positions: new Float32Array(...),
|
|
2305
|
+
* indices: new Uint32Array(...)
|
|
2306
|
+
* }
|
|
2307
|
+
* }
|
|
2308
|
+
*
|
|
2309
|
+
* nv.useLoader(myCustomLoader, 'iwi.cbor', 'nii')
|
|
2310
|
+
*
|
|
2311
|
+
* @param loader - A function that accepts a `File` or `ArrayBuffer` and returns an object with `arrayBuffer` and `fileExt` properties. May also return `positions` and `indices` for meshes.
|
|
2312
|
+
* @param fileExt - The original file extension (e.g. 'iwi.cbor') to associate with this loader.
|
|
2313
|
+
* @param toExt - The target file extension Niivue should treat the file as (e.g. 'nii' or 'mz3').
|
|
2314
|
+
*/
|
|
2131
2315
|
useLoader(loader: unknown, fileExt: string, toExt: string): void;
|
|
2316
|
+
/**
|
|
2317
|
+
* Set a custom loader for handling DICOM files.
|
|
2318
|
+
*/
|
|
2132
2319
|
useDicomLoader(loader: DicomLoader): void;
|
|
2320
|
+
/**
|
|
2321
|
+
* Get the currently assigned DICOM loader.
|
|
2322
|
+
*/
|
|
2133
2323
|
getDicomLoader(): DicomLoader;
|
|
2324
|
+
/**
|
|
2325
|
+
* Handles file and URL drag-and-drop events on the canvas.
|
|
2326
|
+
* Supports loading of volumes, meshes, NVD documents, and DICOM directories.
|
|
2327
|
+
* Honors modifier keys (e.g., Shift to replace, Alt for drawing overlays).
|
|
2328
|
+
* @internal
|
|
2329
|
+
*/
|
|
2134
2330
|
dropListener(e: DragEvent): Promise<void>;
|
|
2135
2331
|
/**
|
|
2136
2332
|
* insert a gap between slices of a mutliplanar view.
|
|
2137
2333
|
* @param pixels - spacing between tiles of multiplanar view
|
|
2138
2334
|
* @example niivue.setMultiplanarPadPixels(4)
|
|
2139
|
-
* @see {@link https://niivue.
|
|
2335
|
+
* @see {@link https://niivue.com/demos/features/atlas.html | live demo usage}
|
|
2140
2336
|
*/
|
|
2141
2337
|
setMultiplanarPadPixels(pixels: number): void;
|
|
2142
2338
|
/**
|
|
2143
2339
|
* control placement of 2D slices.
|
|
2144
2340
|
* @param layout - AUTO: 0, COLUMN: 1, GRID: 2, ROW: 3,
|
|
2145
2341
|
* @example niivue.setMultiplanarLayout(2)
|
|
2146
|
-
* @see {@link https://niivue.
|
|
2342
|
+
* @see {@link https://niivue.com/demos/features/layout.html | live demo usage}
|
|
2147
2343
|
*/
|
|
2148
2344
|
setMultiplanarLayout(layout: number): void;
|
|
2149
2345
|
/**
|
|
2150
2346
|
* determine if text appears at corner (true) or sides of 2D slice.
|
|
2151
2347
|
* @param isCornerOrientationText - controls position of text
|
|
2152
2348
|
* @example niivue.setCornerOrientationText(true)
|
|
2153
|
-
* @see {@link https://niivue.
|
|
2349
|
+
* @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
|
|
2154
2350
|
*/
|
|
2155
2351
|
setCornerOrientationText(isCornerOrientationText: boolean): void;
|
|
2156
2352
|
/**
|
|
2157
|
-
*
|
|
2158
|
-
* @param isOrientationTextVisible -
|
|
2353
|
+
* Show or hide orientation labels (e.g., L/R, A/P) in 2D slice views
|
|
2354
|
+
* @param isOrientationTextVisible - whether orientation text should be displayed
|
|
2159
2355
|
* @example niivue.setIsOrientationTextVisible(false)
|
|
2356
|
+
* @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
|
|
2160
2357
|
*/
|
|
2161
2358
|
setIsOrientationTextVisible(isOrientationTextVisible: boolean): void;
|
|
2162
2359
|
/**
|
|
2163
2360
|
* determine proportion of screen real estate devoted to rendering in multiplanar view.
|
|
2164
2361
|
* @param fraction - proportion of screen devoted to primary (hero) image (0 to disable)
|
|
2165
2362
|
* @example niivue.setHeroImage(0.5)
|
|
2166
|
-
* @see {@link https://niivue.
|
|
2363
|
+
* @see {@link https://niivue.com/demos/features/layout.html | live demo usage}
|
|
2167
2364
|
*/
|
|
2168
2365
|
setHeroImage(fraction: number): void;
|
|
2169
2366
|
/**
|
|
@@ -2214,7 +2411,7 @@ declare class Niivue {
|
|
|
2214
2411
|
* control whether 2D slices use radiological or neurological convention.
|
|
2215
2412
|
* @param isRadiologicalConvention - new display convention
|
|
2216
2413
|
* @example niivue.setRadiologicalConvention(true)
|
|
2217
|
-
* @see {@link https://niivue.
|
|
2414
|
+
* @see {@link https://niivue.com/demos/features/worldspace.html | live demo usage}
|
|
2218
2415
|
*/
|
|
2219
2416
|
setRadiologicalConvention(isRadiologicalConvention: boolean): void;
|
|
2220
2417
|
/**
|
|
@@ -2222,35 +2419,35 @@ declare class Niivue {
|
|
|
2222
2419
|
* @param options - @see NiiVueOptions
|
|
2223
2420
|
* @param resetBriCon - also reset contrast (default false).
|
|
2224
2421
|
* @example niivue.nv1.setDefaults(opts, true);
|
|
2225
|
-
* @see {@link https://niivue.
|
|
2422
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2226
2423
|
*/
|
|
2227
2424
|
setDefaults(options?: Partial<NVConfigOptions>, resetBriCon?: boolean): void;
|
|
2228
2425
|
/**
|
|
2229
2426
|
* Limit visibility of mesh in front of a 2D image. Requires world-space mode.
|
|
2230
2427
|
* @param meshThicknessOn2D - distance from voxels for clipping mesh. Use Infinity to show entire mesh or 0.0 to hide mesh.
|
|
2231
2428
|
* @example niivue.setMeshThicknessOn2D(42)
|
|
2232
|
-
* @see {@link https://niivue.
|
|
2429
|
+
* @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
|
|
2233
2430
|
*/
|
|
2234
2431
|
setMeshThicknessOn2D(meshThicknessOn2D: number): void;
|
|
2235
2432
|
/**
|
|
2236
2433
|
* Create a custom multi-slice mosaic (aka lightbox, montage) view.
|
|
2237
2434
|
* @param str - description of mosaic.
|
|
2238
2435
|
* @example niivue.setSliceMosaicString("A 0 20 C 30 S 42")
|
|
2239
|
-
* @see {@link https://niivue.
|
|
2436
|
+
* @see {@link https://niivue.com/demos/features/mosaics.html | live demo usage}
|
|
2240
2437
|
*/
|
|
2241
2438
|
setSliceMosaicString(str: string): void;
|
|
2242
2439
|
/**
|
|
2243
2440
|
* control 2D slice view mode.
|
|
2244
2441
|
* @param isSliceMM - control whether 2D slices use world space (true) or voxel space (false). Beware that voxel space mode limits properties like panning, zooming and mesh visibility.
|
|
2245
2442
|
* @example niivue.setSliceMM(true)
|
|
2246
|
-
* @see {@link https://niivue.
|
|
2443
|
+
* @see {@link https://niivue.com/demos/features/worldspace2.html | live demo usage}
|
|
2247
2444
|
*/
|
|
2248
2445
|
setSliceMM(isSliceMM: boolean): void;
|
|
2249
2446
|
/**
|
|
2250
2447
|
* control whether voxel overlays are combined using additive (emission) or traditional (transmission) blending.
|
|
2251
2448
|
* @param isAdditiveBlend - emission (true) or transmission (false) mixing
|
|
2252
2449
|
* @example niivue.isAdditiveBlend(true)
|
|
2253
|
-
* @see {@link https://niivue.
|
|
2450
|
+
* @see {@link https://niivue.com/demos/features/additive.voxels.html | live demo usage}
|
|
2254
2451
|
*/
|
|
2255
2452
|
setAdditiveBlend(isAdditiveBlend: boolean): void;
|
|
2256
2453
|
/**
|
|
@@ -2263,16 +2460,34 @@ declare class Niivue {
|
|
|
2263
2460
|
* Force WebGL canvas to use high resolution display, regardless of browser defaults.
|
|
2264
2461
|
* @param forceDevicePixelRatio - -1: block high DPI; 0= allow high DPI: >0 use specified pixel ratio
|
|
2265
2462
|
* @example niivue.setHighResolutionCapable(true);
|
|
2266
|
-
* @see {@link https://niivue.
|
|
2463
|
+
* @see {@link https://niivue.com/demos/features/sync.mesh.html | live demo usage}
|
|
2267
2464
|
*/
|
|
2268
2465
|
setHighResolutionCapable(forceDevicePixelRatio: number | boolean): void;
|
|
2466
|
+
/**
|
|
2467
|
+
* Start watching for changes to configuration options.
|
|
2468
|
+
* This is a convenience method that sets up the onOptsChange callback.
|
|
2469
|
+
* @param callback - Function to call when any option changes
|
|
2470
|
+
* @example
|
|
2471
|
+
* niivue.watchOptsChanges((propertyName, newValue, oldValue) => {
|
|
2472
|
+
* console.log(`Option ${propertyName} changed from ${oldValue} to ${newValue}`)
|
|
2473
|
+
* })
|
|
2474
|
+
* @see {@link https://niivue.com/demos/ | live demo usage}
|
|
2475
|
+
*/
|
|
2476
|
+
watchOptsChanges(callback: (propertyName: keyof NVConfigOptions, newValue: NVConfigOptions[keyof NVConfigOptions], oldValue: NVConfigOptions[keyof NVConfigOptions]) => void): void;
|
|
2477
|
+
/**
|
|
2478
|
+
* Stop watching for changes to configuration options.
|
|
2479
|
+
* This removes the current onOptsChange callback.
|
|
2480
|
+
* @example niivue.unwatchOptsChanges()
|
|
2481
|
+
* @see {@link https://niivue.com/demos/ | live demo usage}
|
|
2482
|
+
*/
|
|
2483
|
+
unwatchOptsChanges(): void;
|
|
2269
2484
|
/**
|
|
2270
2485
|
* add a new volume to the canvas
|
|
2271
2486
|
* @param volume - the new volume to add to the canvas
|
|
2272
2487
|
* @example
|
|
2273
2488
|
* niivue = new Niivue()
|
|
2274
2489
|
* niivue.addVolume(NVImage.loadFromUrl({url:'../someURL.nii.gz'}))
|
|
2275
|
-
* @see {@link https://niivue.
|
|
2490
|
+
* @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
|
|
2276
2491
|
*/
|
|
2277
2492
|
addVolume(volume: NVImage): void;
|
|
2278
2493
|
/**
|
|
@@ -2281,7 +2496,7 @@ declare class Niivue {
|
|
|
2281
2496
|
* @example
|
|
2282
2497
|
* niivue = new Niivue()
|
|
2283
2498
|
* niivue.addMesh(NVMesh.loadFromUrl({url:'../someURL.gii'}))
|
|
2284
|
-
* @see {@link https://niivue.
|
|
2499
|
+
* @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
|
|
2285
2500
|
*/
|
|
2286
2501
|
addMesh(mesh: NVMesh): void;
|
|
2287
2502
|
/**
|
|
@@ -2292,30 +2507,57 @@ declare class Niivue {
|
|
|
2292
2507
|
* niivue.getVolumeIndexByID(someVolume.id)
|
|
2293
2508
|
*/
|
|
2294
2509
|
getVolumeIndexByID(id: string): number;
|
|
2510
|
+
/**
|
|
2511
|
+
* Saves the current drawing state as an RLE-compressed bitmap for undo history.
|
|
2512
|
+
* Uses a circular buffer to limit undo memory usage.
|
|
2513
|
+
* @internal
|
|
2514
|
+
*/
|
|
2295
2515
|
drawAddUndoBitmap(): void;
|
|
2516
|
+
/**
|
|
2517
|
+
* Clears all stored drawing undo bitmaps and resets the undo index.
|
|
2518
|
+
* @internal
|
|
2519
|
+
*/
|
|
2296
2520
|
drawClearAllUndoBitmaps(): void;
|
|
2297
2521
|
/**
|
|
2298
2522
|
* Restore drawing to previous state
|
|
2299
2523
|
* @example niivue.drawUndo();
|
|
2300
|
-
* @see {@link https://niivue.
|
|
2524
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2301
2525
|
*/
|
|
2302
2526
|
drawUndo(): void;
|
|
2527
|
+
/**
|
|
2528
|
+
* Loads a drawing overlay and aligns it with the current background image.
|
|
2529
|
+
* Converts the input image to match the background's orientation and stores it as a drawable bitmap.
|
|
2530
|
+
* Initializes the undo history and prepares the drawing texture.
|
|
2531
|
+
*
|
|
2532
|
+
* @param drawingBitmap - A `NVImage` object representing the drawing to load. Must match the dimensions of the background image.
|
|
2533
|
+
* @returns `true` if the drawing was successfully loaded and aligned; `false` if dimensions are incompatible.
|
|
2534
|
+
*/
|
|
2303
2535
|
loadDrawing(drawingBitmap: NVImage): boolean;
|
|
2536
|
+
/**
|
|
2537
|
+
* Binarize a volume by converting all non-zero voxels to 1
|
|
2538
|
+
* @param volume - the image volume to modify in place
|
|
2539
|
+
* @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
|
|
2540
|
+
*/
|
|
2304
2541
|
binarize(volume: NVImage): void;
|
|
2305
2542
|
/**
|
|
2306
2543
|
* Open drawing
|
|
2307
2544
|
* @param fnm - filename of NIfTI format drawing
|
|
2308
2545
|
* @param isBinarize - if true will force drawing voxels to be either 0 or 1.
|
|
2309
2546
|
* @example niivue.loadDrawingFromUrl("../images/lesion.nii.gz");
|
|
2310
|
-
* @see {@link https://niivue.
|
|
2547
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2311
2548
|
*/
|
|
2312
2549
|
loadDrawingFromUrl(fnm: string, isBinarize?: boolean): Promise<boolean>;
|
|
2550
|
+
/**
|
|
2551
|
+
* Computes one or more Otsu threshold levels for the primary volume.
|
|
2552
|
+
* Returns raw intensity values corresponding to bin-based thresholds.
|
|
2553
|
+
* @internal
|
|
2554
|
+
*/
|
|
2313
2555
|
findOtsu(mlevel?: number): number[];
|
|
2314
2556
|
/**
|
|
2315
2557
|
* remove dark voxels in air
|
|
2316
2558
|
* @param levels - (2-4) segment brain into this many types. For example drawOtsu(2) will create a binary drawing where bright voxels are colored and dark voxels are clear.
|
|
2317
2559
|
* @example niivue.drawOtsu(3);
|
|
2318
|
-
* @see {@link https://niivue.
|
|
2560
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2319
2561
|
*/
|
|
2320
2562
|
drawOtsu(levels?: number): void;
|
|
2321
2563
|
/**
|
|
@@ -2323,7 +2565,7 @@ declare class Niivue {
|
|
|
2323
2565
|
* @param level - (1-5) larger values for more preserved voxels
|
|
2324
2566
|
* @param volIndex - volume to dehaze
|
|
2325
2567
|
* @example niivue.removeHaze(3, 0);
|
|
2326
|
-
* @see {@link https://niivue.
|
|
2568
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2327
2569
|
*/
|
|
2328
2570
|
removeHaze(level?: number, volIndex?: number): void;
|
|
2329
2571
|
/**
|
|
@@ -2338,9 +2580,15 @@ declare class Niivue {
|
|
|
2338
2580
|
* @example
|
|
2339
2581
|
* niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
|
|
2340
2582
|
* niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
|
|
2341
|
-
* @see {@link https://niivue.
|
|
2583
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2342
2584
|
*/
|
|
2343
2585
|
saveImage(options?: SaveImageOptions): Promise<boolean | Uint8Array>;
|
|
2586
|
+
/**
|
|
2587
|
+
* Returns the index of a mesh given its ID or index.
|
|
2588
|
+
*
|
|
2589
|
+
* @param id - The mesh ID as a string, or an index number.
|
|
2590
|
+
* @returns The mesh index, or -1 if not found or out of range.
|
|
2591
|
+
*/
|
|
2344
2592
|
getMeshIndexByID(id: string | number): number;
|
|
2345
2593
|
/**
|
|
2346
2594
|
* change property of mesh, tractogram or connectome
|
|
@@ -2348,7 +2596,7 @@ declare class Niivue {
|
|
|
2348
2596
|
* @param key - attribute to change
|
|
2349
2597
|
* @param val - for attribute
|
|
2350
2598
|
* @example niivue.setMeshProperty(niivue.meshes[0].id, 'fiberLength', 42)
|
|
2351
|
-
* @see {@link https://niivue.
|
|
2599
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2352
2600
|
*/
|
|
2353
2601
|
setMeshProperty(id: number, key: keyof NVMesh, val: number | string | boolean | Uint8Array | number[] | ColorMap | LegacyConnectome | Float32Array): void;
|
|
2354
2602
|
/**
|
|
@@ -2359,7 +2607,7 @@ declare class Niivue {
|
|
|
2359
2607
|
* @param Zmm - location in foot/head dimension
|
|
2360
2608
|
* @returns the an array where ret[0] is the mesh index and ret[1] is distance from vertex to coordinates
|
|
2361
2609
|
* @example niivue.indexNearestXYZmm(niivue.meshes[0].id, -22, 42, 13)
|
|
2362
|
-
* @see {@link https://niivue.
|
|
2610
|
+
* @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
|
|
2363
2611
|
*/
|
|
2364
2612
|
indexNearestXYZmm(mesh: number, Xmm: number, Ymm: number, Zmm: number): number[];
|
|
2365
2613
|
/**
|
|
@@ -2368,14 +2616,14 @@ declare class Niivue {
|
|
|
2368
2616
|
* @param order - decimation order 0..6
|
|
2369
2617
|
* @example niivue.decimateHierarchicalMesh(niivue.meshes[0].id, 4)
|
|
2370
2618
|
* @returns boolean false if mesh is not hierarchical or of lower order
|
|
2371
|
-
* @see {@link https://niivue.
|
|
2619
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2372
2620
|
*/
|
|
2373
2621
|
decimateHierarchicalMesh(mesh: number, order?: number): boolean;
|
|
2374
2622
|
/**
|
|
2375
2623
|
* reverse triangle winding of mesh (swap front and back faces)
|
|
2376
2624
|
* @param mesh - identity of mesh to change
|
|
2377
2625
|
* @example niivue.reverseFaces(niivue.meshes[0].id)
|
|
2378
|
-
* @see {@link https://niivue.
|
|
2626
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2379
2627
|
*/
|
|
2380
2628
|
reverseFaces(mesh: number): void;
|
|
2381
2629
|
/**
|
|
@@ -2385,7 +2633,7 @@ declare class Niivue {
|
|
|
2385
2633
|
* @param key - attribute to change
|
|
2386
2634
|
* @param val - value for attribute
|
|
2387
2635
|
* @example niivue.setMeshLayerProperty(niivue.meshes[0].id, 0, 'frame4D', 22)
|
|
2388
|
-
* @see {@link https://niivue.
|
|
2636
|
+
* @see {@link https://niivue.com/demos/features/mesh.4D.html | live demo usage}
|
|
2389
2637
|
*/
|
|
2390
2638
|
setMeshLayerProperty(mesh: number, layer: number, key: keyof NVMeshLayer, val: number): Promise<void>;
|
|
2391
2639
|
/**
|
|
@@ -2397,7 +2645,7 @@ declare class Niivue {
|
|
|
2397
2645
|
/**
|
|
2398
2646
|
* set rotation of 3D render view
|
|
2399
2647
|
* @example niivue.setRenderAzimuthElevation(45, 15)
|
|
2400
|
-
* @see {@link https://niivue.
|
|
2648
|
+
* @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
|
|
2401
2649
|
*/
|
|
2402
2650
|
setRenderAzimuthElevation(a: number, e: number): void;
|
|
2403
2651
|
/**
|
|
@@ -2418,6 +2666,15 @@ declare class Niivue {
|
|
|
2418
2666
|
* niivue.setVolume(someVolume, 1) // move it to the second position in the array of loaded volumes (0 is the first position)
|
|
2419
2667
|
*/
|
|
2420
2668
|
setVolume(volume: NVImage, toIndex?: number): void;
|
|
2669
|
+
/**
|
|
2670
|
+
* Reorders a mesh within the internal mesh list.
|
|
2671
|
+
*
|
|
2672
|
+
* @param mesh - The `NVMesh` instance to reposition.
|
|
2673
|
+
* @param toIndex - Target index to move the mesh to.
|
|
2674
|
+
* - If `0`, moves mesh to the front.
|
|
2675
|
+
* - If `< 0`, removes the mesh.
|
|
2676
|
+
* - If within bounds, inserts mesh at the specified index.
|
|
2677
|
+
*/
|
|
2421
2678
|
setMesh(mesh: NVMesh, toIndex?: number): void;
|
|
2422
2679
|
/**
|
|
2423
2680
|
* Remove a volume
|
|
@@ -2425,12 +2682,14 @@ declare class Niivue {
|
|
|
2425
2682
|
* @example
|
|
2426
2683
|
* niivue = new Niivue()
|
|
2427
2684
|
* niivue.removeVolume(this.volumes[3])
|
|
2428
|
-
* @see {@link https://niivue.
|
|
2685
|
+
* @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
|
|
2429
2686
|
*/
|
|
2430
2687
|
removeVolume(volume: NVImage): void;
|
|
2431
2688
|
/**
|
|
2432
|
-
* Remove a volume by index
|
|
2433
|
-
* @param index - of volume to remove
|
|
2689
|
+
* Remove a volume from the scene by its index
|
|
2690
|
+
* @param index - index of the volume to remove
|
|
2691
|
+
* @throws if the index is out of bounds
|
|
2692
|
+
* @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
|
|
2434
2693
|
*/
|
|
2435
2694
|
removeVolumeByIndex(index: number): void;
|
|
2436
2695
|
/**
|
|
@@ -2439,7 +2698,7 @@ declare class Niivue {
|
|
|
2439
2698
|
* @example
|
|
2440
2699
|
* niivue = new Niivue()
|
|
2441
2700
|
* niivue.removeMesh(this.meshes[3])
|
|
2442
|
-
* @see {@link https://niivue.
|
|
2701
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2443
2702
|
*/
|
|
2444
2703
|
removeMesh(mesh: NVMesh): void;
|
|
2445
2704
|
/**
|
|
@@ -2481,7 +2740,16 @@ declare class Niivue {
|
|
|
2481
2740
|
* niivue.moveVolumeToTop(this.volumes[0]) // move the background image to the top layer position
|
|
2482
2741
|
*/
|
|
2483
2742
|
moveVolumeToTop(volume: NVImage): void;
|
|
2743
|
+
/**
|
|
2744
|
+
* Records the current mouse position in screen space (adjusted for device pixel ratio).
|
|
2745
|
+
* @internal
|
|
2746
|
+
*/
|
|
2484
2747
|
mouseDown(x: number, y: number): void;
|
|
2748
|
+
/**
|
|
2749
|
+
* Updates mouse position and modifies 3D render view if the pointer is in the render tile.
|
|
2750
|
+
*
|
|
2751
|
+
* @internal
|
|
2752
|
+
*/
|
|
2485
2753
|
mouseMove(x: number, y: number): void;
|
|
2486
2754
|
/**
|
|
2487
2755
|
* convert spherical AZIMUTH, ELEVATION to Cartesian
|
|
@@ -2502,7 +2770,7 @@ declare class Niivue {
|
|
|
2502
2770
|
* @example
|
|
2503
2771
|
* niivue = new Niivue()
|
|
2504
2772
|
* niivue.setClipPlane([42, 42])
|
|
2505
|
-
* @see {@link https://niivue.
|
|
2773
|
+
* @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
|
|
2506
2774
|
*/
|
|
2507
2775
|
setClipPlane(depthAzimuthElevation: number[]): void;
|
|
2508
2776
|
/**
|
|
@@ -2511,13 +2779,13 @@ declare class Niivue {
|
|
|
2511
2779
|
* @example
|
|
2512
2780
|
* niivue = new Niivue()
|
|
2513
2781
|
* niivue.setCrosshairColor([0, 1, 0, 0.5]) // set crosshair to transparent green
|
|
2514
|
-
* @see {@link https://niivue.
|
|
2782
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2515
2783
|
*/
|
|
2516
2784
|
setCrosshairColor(color: number[]): void;
|
|
2517
2785
|
/**
|
|
2518
2786
|
* set thickness of crosshair
|
|
2519
2787
|
* @example niivue.crosshairWidth(2)
|
|
2520
|
-
* @see {@link https://niivue.
|
|
2788
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2521
2789
|
*/
|
|
2522
2790
|
setCrosshairWidth(crosshairWidth: number): void;
|
|
2523
2791
|
setDrawColormap(name: string): void;
|
|
@@ -2525,7 +2793,7 @@ declare class Niivue {
|
|
|
2525
2793
|
* does dragging over a 2D slice create a drawing?
|
|
2526
2794
|
* @param trueOrFalse - enabled (true) or not (false)
|
|
2527
2795
|
* @example niivue.setDrawingEnabled(true)
|
|
2528
|
-
* @see {@link https://niivue.
|
|
2796
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2529
2797
|
*/
|
|
2530
2798
|
setDrawingEnabled(trueOrFalse: boolean): void;
|
|
2531
2799
|
/**
|
|
@@ -2533,14 +2801,14 @@ declare class Niivue {
|
|
|
2533
2801
|
* @param penValue - sets the color of the pen
|
|
2534
2802
|
* @param isFilledPen - determines if dragging creates flood-filled shape
|
|
2535
2803
|
* @example niivue.setPenValue(1, true)
|
|
2536
|
-
* @see {@link https://niivue.
|
|
2804
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2537
2805
|
*/
|
|
2538
2806
|
setPenValue(penValue: number, isFilledPen?: boolean): void;
|
|
2539
2807
|
/**
|
|
2540
2808
|
* control whether drawing is transparent (0), opaque (1) or translucent (between 0 and 1).
|
|
2541
2809
|
* @param opacity - translucency of drawing
|
|
2542
2810
|
* @example niivue.setDrawOpacity(0.7)
|
|
2543
|
-
* @see {@link https://niivue.
|
|
2811
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2544
2812
|
*/
|
|
2545
2813
|
setDrawOpacity(opacity: number): void;
|
|
2546
2814
|
/**
|
|
@@ -2549,9 +2817,13 @@ declare class Niivue {
|
|
|
2549
2817
|
* @example
|
|
2550
2818
|
* niivue = new Niivue()
|
|
2551
2819
|
* niivue.setSelectionBoxColor([0, 1, 0, 0.5]) // set to transparent green
|
|
2552
|
-
* @see {@link https://niivue.
|
|
2820
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2553
2821
|
*/
|
|
2554
2822
|
setSelectionBoxColor(color: number[]): void;
|
|
2823
|
+
/**
|
|
2824
|
+
* Handles mouse wheel or trackpad scroll to change slices, zoom, or frame depending on context.
|
|
2825
|
+
* @internal
|
|
2826
|
+
*/
|
|
2555
2827
|
sliceScroll2D(posChange: number, x: number, y: number, isDelta?: boolean): void;
|
|
2556
2828
|
/**
|
|
2557
2829
|
* set the slice type. This changes the view mode
|
|
@@ -2559,7 +2831,7 @@ declare class Niivue {
|
|
|
2559
2831
|
* @example
|
|
2560
2832
|
* niivue = new Niivue()
|
|
2561
2833
|
* niivue.setSliceType(Niivue.sliceTypeMultiplanar)
|
|
2562
|
-
* @see {@link https://niivue.
|
|
2834
|
+
* @see {@link https://niivue.com/demos/features/basic.multiplanar.html | live demo usage}
|
|
2563
2835
|
*/
|
|
2564
2836
|
setSliceType(st: SLICE_TYPE): this;
|
|
2565
2837
|
/**
|
|
@@ -2569,7 +2841,7 @@ declare class Niivue {
|
|
|
2569
2841
|
* @example
|
|
2570
2842
|
* niivue = new Niivue()
|
|
2571
2843
|
* niivue.setOpacity(0, 0.5) // make the first volume transparent
|
|
2572
|
-
* @see {@link https://niivue.
|
|
2844
|
+
* @see {@link https://niivue.com/demos/features/atlas.html | live demo usage}
|
|
2573
2845
|
*/
|
|
2574
2846
|
setOpacity(volIdx: number, newOpacity: number): void;
|
|
2575
2847
|
/**
|
|
@@ -2577,7 +2849,7 @@ declare class Niivue {
|
|
|
2577
2849
|
* @param scale - the new scale value
|
|
2578
2850
|
* @example
|
|
2579
2851
|
* niivue.setScale(2) // zoom some
|
|
2580
|
-
* @see {@link https://niivue.
|
|
2852
|
+
* @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
|
|
2581
2853
|
*/
|
|
2582
2854
|
setScale(scale: number): void;
|
|
2583
2855
|
/**
|
|
@@ -2585,7 +2857,7 @@ declare class Niivue {
|
|
|
2585
2857
|
* @param color - the new color. expects an array of RGBA values. values can range from 0 to 1
|
|
2586
2858
|
* @example
|
|
2587
2859
|
* niivue.setClipPlaneColor([1, 1, 1, 0.5]) // white, transparent
|
|
2588
|
-
* @see {@link https://niivue.
|
|
2860
|
+
* @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
|
|
2589
2861
|
*/
|
|
2590
2862
|
setClipPlaneColor(color: number[]): void;
|
|
2591
2863
|
/**
|
|
@@ -2593,7 +2865,7 @@ declare class Niivue {
|
|
|
2593
2865
|
* @param thick - thickness of slab. Value 0..1.73 (cube opposite corner length is sqrt(3)).
|
|
2594
2866
|
* @example
|
|
2595
2867
|
* niivue.setClipPlaneThick(0.3) // thin slab
|
|
2596
|
-
* @see {@link https://niivue.
|
|
2868
|
+
* @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
|
|
2597
2869
|
*/
|
|
2598
2870
|
setClipPlaneThick(thick: number): void;
|
|
2599
2871
|
/**
|
|
@@ -2602,7 +2874,7 @@ declare class Niivue {
|
|
|
2602
2874
|
* @param high - 3-component array specifying the upper bound of the clipping region along the X, Y, and Z axes. Values range from 0 to 1.
|
|
2603
2875
|
* @example
|
|
2604
2876
|
* niivue.setClipPlaneColor([0.0, 0.0, 0.2], [1.0, 1.0, 0.7]) // remove inferior 20% and superior 30%
|
|
2605
|
-
* @see {@link https://niivue.
|
|
2877
|
+
* @see {@link https://niivue.com/demos/features/clipplanes.html | live demo usage}
|
|
2606
2878
|
*/
|
|
2607
2879
|
setClipVolume(low: number[], high: number[]): void;
|
|
2608
2880
|
/**
|
|
@@ -2610,8 +2882,8 @@ declare class Niivue {
|
|
|
2610
2882
|
* @param gradientAmount - amount of matcap (NaN or 0..1), default 0 (matte, surface normal does not influence color). NaN renders the gradients.
|
|
2611
2883
|
* @example
|
|
2612
2884
|
* niivue.setVolumeRenderIllumination(0.6);
|
|
2613
|
-
* @see {@link https://niivue.
|
|
2614
|
-
* @see {@link https://niivue.
|
|
2885
|
+
* @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
|
|
2886
|
+
* @see {@link https://niivue.com/demos/features/gradient.order.html | live demo usage}
|
|
2615
2887
|
*/
|
|
2616
2888
|
setVolumeRenderIllumination(gradientAmount?: number): Promise<void>;
|
|
2617
2889
|
/**
|
|
@@ -2620,10 +2892,19 @@ declare class Niivue {
|
|
|
2620
2892
|
* @param renderSilhouette - make core transparent to enhance rims (0..1), default 0 (no-influence)
|
|
2621
2893
|
* @example
|
|
2622
2894
|
* niivue.setGradientOpacity(0.6);
|
|
2623
|
-
* @see {@link https://niivue.
|
|
2895
|
+
* @see {@link https://niivue.com/demos/features/gradient.opacity.html | live demo usage}
|
|
2624
2896
|
*/
|
|
2625
2897
|
setGradientOpacity(gradientOpacity?: number, renderSilhouette?: number): Promise<void>;
|
|
2898
|
+
/**
|
|
2899
|
+
* Generates a placeholder RGBA overlay of a green sphere for testing purposes only.
|
|
2900
|
+
* @internal
|
|
2901
|
+
* @remarks Marked for future removal — creates a test sphere, not intended for production use.
|
|
2902
|
+
*/
|
|
2626
2903
|
overlayRGBA(volume: NVImage): Uint8ClampedArray;
|
|
2904
|
+
/**
|
|
2905
|
+
* Convert voxel coordinates to millimeters using a transformation matrix.
|
|
2906
|
+
* @internal
|
|
2907
|
+
*/
|
|
2627
2908
|
vox2mm(XYZ: number[], mtx: mat4): vec3;
|
|
2628
2909
|
/**
|
|
2629
2910
|
* clone a volume and return a new volume
|
|
@@ -2635,14 +2916,13 @@ declare class Niivue {
|
|
|
2635
2916
|
*/
|
|
2636
2917
|
cloneVolume(index: number): NVImage;
|
|
2637
2918
|
/**
|
|
2638
|
-
*
|
|
2639
|
-
* @param url - URL of NVDocument
|
|
2919
|
+
* Loads an NVDocument from a URL and integrates it into the scene.
|
|
2640
2920
|
*/
|
|
2641
2921
|
loadDocumentFromUrl(url: string): Promise<void>;
|
|
2642
2922
|
/**
|
|
2643
2923
|
* Loads an NVDocument
|
|
2644
2924
|
* @returns Niivue instance
|
|
2645
|
-
* @see {@link https://niivue.
|
|
2925
|
+
* @see {@link https://niivue.com/demos/features/document.load.html | live demo usage}
|
|
2646
2926
|
*/
|
|
2647
2927
|
loadDocument(document: NVDocument): Promise<this>;
|
|
2648
2928
|
/**
|
|
@@ -2653,6 +2933,7 @@ declare class Niivue {
|
|
|
2653
2933
|
* const javascript = this.generateLoadDocumentJavaScript("gl1");
|
|
2654
2934
|
* const html = `<html><body><canvas id="gl1"></canvas><script type="module" async>
|
|
2655
2935
|
${javascript}</script></body></html>`;
|
|
2936
|
+
* @see {@link https://niivue.com/demos/features/save.custom.html.html | live demo usage}
|
|
2656
2937
|
*/
|
|
2657
2938
|
generateLoadDocumentJavaScript(canvasId: string, esm: string): Promise<string>;
|
|
2658
2939
|
/**
|
|
@@ -2667,10 +2948,12 @@ declare class Niivue {
|
|
|
2667
2948
|
*/
|
|
2668
2949
|
generateHTML(canvasId: string, esm: string): Promise<string>;
|
|
2669
2950
|
/**
|
|
2670
|
-
*
|
|
2671
|
-
* @param fileName -
|
|
2672
|
-
* @param canvasId -
|
|
2673
|
-
* @param esm - bundled
|
|
2951
|
+
* Save the current scene as a standalone HTML file
|
|
2952
|
+
* @param fileName - name of the HTML file to save (default: "untitled.html")
|
|
2953
|
+
* @param canvasId - ID of the canvas element NiiVue will attach to
|
|
2954
|
+
* @param esm - bundled ES module source for NiiVue
|
|
2955
|
+
* @returns a Promise that resolves when the file is downloaded
|
|
2956
|
+
* @see {@link https://niivue.com/demos/features/save.html.html | live demo usage}
|
|
2674
2957
|
*/
|
|
2675
2958
|
saveHTML(fileName: string, canvasId: string, esm: string): Promise<void>;
|
|
2676
2959
|
/**
|
|
@@ -2689,11 +2972,19 @@ declare class Niivue {
|
|
|
2689
2972
|
* @example
|
|
2690
2973
|
* // smallest possible file – no preview, just metadata
|
|
2691
2974
|
* await nv.saveDocument('scene.nvd', true, { embedImages:false, embedPreview:false });
|
|
2975
|
+
* @see {@link https://niivue.com/demos/features/document.3d.html | live demo usage}
|
|
2692
2976
|
*/
|
|
2693
2977
|
saveDocument(fileName?: string, compress?: boolean, options?: {
|
|
2694
2978
|
embedImages?: boolean;
|
|
2695
2979
|
embedPreview?: boolean;
|
|
2696
2980
|
}): Promise<void>;
|
|
2981
|
+
/**
|
|
2982
|
+
* Load an array of image or mesh URLs using appropriate handlers
|
|
2983
|
+
* @param images - array of image or mesh descriptors (with URL and optional name)
|
|
2984
|
+
* @returns a Promise resolving to the current NiiVue instance after loading completes
|
|
2985
|
+
* @remarks Automatically dispatches each item to either volume or mesh loader based on file extension or registered custom loader
|
|
2986
|
+
* @see {@link https://niivue.com/demos/features/timeseries2.html | live demo usage}
|
|
2987
|
+
*/
|
|
2697
2988
|
loadImages(images: Array<ImageFromUrlOptions | LoadFromUrlParams>): Promise<this>;
|
|
2698
2989
|
loadDicoms(dicomList: ImageFromUrlOptions[]): Promise<this>;
|
|
2699
2990
|
/**
|
|
@@ -2703,7 +2994,7 @@ declare class Niivue {
|
|
|
2703
2994
|
* @example
|
|
2704
2995
|
* niivue = new Niivue()
|
|
2705
2996
|
* niivue.loadVolumes([{url: 'someImage.nii.gz}, {url: 'anotherImage.nii.gz'}])
|
|
2706
|
-
* @see {@link https://niivue.
|
|
2997
|
+
* @see {@link https://niivue.com/demos/features/mask.html | live demo usage}
|
|
2707
2998
|
*/
|
|
2708
2999
|
loadVolumes(volumeList: ImageFromUrlOptions[]): Promise<this>;
|
|
2709
3000
|
/**
|
|
@@ -2721,7 +3012,7 @@ declare class Niivue {
|
|
|
2721
3012
|
* @example
|
|
2722
3013
|
* niivue = new Niivue()
|
|
2723
3014
|
* niivue.loadMeshes([{url: 'someMesh.gii'}])
|
|
2724
|
-
* @see {@link https://niivue.
|
|
3015
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2725
3016
|
*/
|
|
2726
3017
|
loadMeshes(meshList: LoadFromUrlParams[]): Promise<this>;
|
|
2727
3018
|
/**
|
|
@@ -2730,7 +3021,7 @@ declare class Niivue {
|
|
|
2730
3021
|
* @param url - the URL to a JSON-formatted connectome definition
|
|
2731
3022
|
* @param headers - optional HTTP headers to include with the request (e.g. for authorization)
|
|
2732
3023
|
* @returns the `Niivue` instance (for method chaining)
|
|
2733
|
-
* @see {@link https://niivue.
|
|
3024
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2734
3025
|
*/
|
|
2735
3026
|
loadConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
|
|
2736
3027
|
/**
|
|
@@ -2738,44 +3029,67 @@ declare class Niivue {
|
|
|
2738
3029
|
* @param url - the URL of the JSON-formatted connectome file
|
|
2739
3030
|
* @param headers - optional HTTP headers to include in the fetch request (e.g. for authorization)
|
|
2740
3031
|
* @returns the `Niivue` instance (for method chaining)
|
|
2741
|
-
* @see {@link https://niivue.
|
|
3032
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2742
3033
|
*/
|
|
2743
3034
|
loadFreeSurferConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
|
|
2744
3035
|
/**
|
|
2745
3036
|
* load a connectome specified by json
|
|
2746
3037
|
* @param json - freesurfer model
|
|
2747
3038
|
* @returns Niivue instance
|
|
2748
|
-
* @see {@link https://niivue.
|
|
3039
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2749
3040
|
*/
|
|
2750
3041
|
loadFreeSurferConnectome(json: FreeSurferConnectome): Promise<this>;
|
|
3042
|
+
/**
|
|
3043
|
+
* Handles addition of a connectome node by adding a corresponding label and redrawing.
|
|
3044
|
+
* @internal
|
|
3045
|
+
*/
|
|
2751
3046
|
handleNodeAdded(event: {
|
|
2752
3047
|
detail: {
|
|
2753
3048
|
node: NVConnectomeNode;
|
|
2754
3049
|
};
|
|
2755
3050
|
}): void;
|
|
3051
|
+
/**
|
|
3052
|
+
* Converts various connectome JSON formats to a standardized mesh representation.
|
|
3053
|
+
*
|
|
3054
|
+
* @param json - Connectome data in current or legacy format.
|
|
3055
|
+
* @returns The connectome as an `NVMesh`.
|
|
3056
|
+
* @internal
|
|
3057
|
+
*/
|
|
2756
3058
|
loadConnectomeAsMesh(json: Connectome | LegacyConnectome | FreeSurferConnectome): NVMesh;
|
|
2757
3059
|
/**
|
|
2758
3060
|
* load a connectome specified by json
|
|
2759
3061
|
* @param json - connectome model
|
|
2760
3062
|
* @returns Niivue instance
|
|
2761
|
-
* @see {@link https://niivue.
|
|
3063
|
+
* @see {@link https://niivue.com/demos/features/connectome.html | live demo usage}
|
|
2762
3064
|
*/
|
|
2763
3065
|
loadConnectome(json: Connectome | LegacyConnectome): this;
|
|
2764
3066
|
/**
|
|
2765
3067
|
* generate a blank canvas for the pen tool
|
|
2766
3068
|
* @example niivue.createEmptyDrawing()
|
|
2767
|
-
* @see {@link https://niivue.
|
|
3069
|
+
* @see {@link https://niivue.com/demos/features/cactus.html | live demo usage}
|
|
2768
3070
|
*/
|
|
2769
3071
|
createEmptyDrawing(): void;
|
|
3072
|
+
/**
|
|
3073
|
+
* Creates or updates a 1-component 16-bit signed integer 3D texture on the GPU.
|
|
3074
|
+
* @internal
|
|
3075
|
+
*/
|
|
2770
3076
|
r16Tex(texID: WebGLTexture | null, activeID: number, dims: number[], img16: Int16Array): WebGLTexture;
|
|
2771
3077
|
/**
|
|
2772
3078
|
* dilate drawing so all voxels are colored.
|
|
2773
3079
|
* works on drawing with multiple colors
|
|
2774
3080
|
* @example niivue.drawGrowCut();
|
|
2775
|
-
* @see {@link https://niivue.
|
|
3081
|
+
* @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
|
|
2776
3082
|
*/
|
|
2777
3083
|
drawGrowCut(): void;
|
|
3084
|
+
/**
|
|
3085
|
+
* Sets the color value of a voxel and its neighbors in the drawing bitmap.
|
|
3086
|
+
* @internal
|
|
3087
|
+
*/
|
|
2778
3088
|
drawPt(x: number, y: number, z: number, penValue: number, drawBitmap?: Uint8Array | null): void;
|
|
3089
|
+
/**
|
|
3090
|
+
* Draws a 3D line between two voxels in the drawing bitmap using Bresenham's algorithm.
|
|
3091
|
+
* @internal
|
|
3092
|
+
*/
|
|
2779
3093
|
drawPenLine(ptA: number[], ptB: number[], penValue: number): void;
|
|
2780
3094
|
/**
|
|
2781
3095
|
* Performs a 1-voxel binary dilation on a connected cluster within the drawing mask using the drawFloodFillCore function.
|
|
@@ -2785,39 +3099,100 @@ declare class Niivue {
|
|
|
2785
3099
|
*/
|
|
2786
3100
|
drawingBinaryDilationWithSeed(seedXYZ: number[], // seed voxel x,y,z
|
|
2787
3101
|
neighbors?: 6 | 18 | 26): void;
|
|
3102
|
+
/**
|
|
3103
|
+
* Flood fill to cluster connected voxels based on neighbor connectivity (6, 18, or 26 neighbors).
|
|
3104
|
+
* Voxels with value 1 are included in the cluster and set to 2.
|
|
3105
|
+
* Uses a queue-based breadth-first search.
|
|
3106
|
+
*
|
|
3107
|
+
* @internal
|
|
3108
|
+
*/
|
|
2788
3109
|
drawFloodFillCore(img: Uint8Array, seedVx: number, neighbors?: number): void;
|
|
3110
|
+
/**
|
|
3111
|
+
* Performs a flood fill on the drawing bitmap starting from a seed voxel, recoloring all connected voxels
|
|
3112
|
+
* based on spatial connectivity, intensity constraints, and other parameters.
|
|
3113
|
+
* Supports 2D or 3D fills, cluster growing, distance constraints, and preview mode for clickToSegment.
|
|
3114
|
+
*
|
|
3115
|
+
* @internal
|
|
3116
|
+
*/
|
|
2789
3117
|
drawFloodFill(seedXYZ: number[], newColor?: number, growSelectedCluster?: number, forceMin?: number, forceMax?: number, neighbors?: number, maxDistanceMM?: number, is2D?: boolean, targetBitmap?: Uint8Array | null, isGrowClusterTool?: boolean): void;
|
|
3118
|
+
/**
|
|
3119
|
+
* Connects and fills the interior of drawn line segments in 2D slice space.
|
|
3120
|
+
* @internal
|
|
3121
|
+
*/
|
|
2790
3122
|
drawPenFilled(): void;
|
|
2791
3123
|
/**
|
|
2792
3124
|
* close drawing: make sure you have saved any changes before calling this!
|
|
2793
3125
|
* @example niivue.closeDrawing();
|
|
2794
|
-
* @see {@link https://niivue.
|
|
3126
|
+
* @see {@link https://niivue.com/demos/features/draw.ui.html | live demo usage}
|
|
2795
3127
|
*/
|
|
2796
3128
|
closeDrawing(): void;
|
|
2797
3129
|
/**
|
|
2798
3130
|
* copy drawing bitmap from CPU to GPU storage and redraw the screen
|
|
2799
3131
|
* @param isForceRedraw - refreshes scene immediately (default true)
|
|
2800
3132
|
* @example niivue.refreshDrawing();
|
|
2801
|
-
* @see {@link https://niivue.
|
|
3133
|
+
* @see {@link https://niivue.com/demos/features/cactus.html | live demo usage}
|
|
2802
3134
|
*/
|
|
2803
3135
|
refreshDrawing(isForceRedraw?: boolean, useClickToSegmentBitmap?: boolean): void;
|
|
3136
|
+
/**
|
|
3137
|
+
* Creates a 2D 1-component uint8 texture on the GPU with given dimensions.
|
|
3138
|
+
* @internal
|
|
3139
|
+
*/
|
|
2804
3140
|
r8Tex2D(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
|
|
3141
|
+
/**
|
|
3142
|
+
* Creates a 3D 1-component uint8 texture on the GPU with given dimensions.
|
|
3143
|
+
* @internal
|
|
3144
|
+
*/
|
|
2805
3145
|
r8Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
|
|
3146
|
+
/**
|
|
3147
|
+
* Creates a 2D 4-component (RGBA) uint8 texture on the GPU with optional vertical flip.
|
|
3148
|
+
* @internal
|
|
3149
|
+
*/
|
|
2806
3150
|
rgbaTex2D(texID: WebGLTexture | null, activeID: number, dims: number[], data?: Uint8Array | null, isFlipVertical?: boolean): WebGLTexture | null;
|
|
3151
|
+
/**
|
|
3152
|
+
* Creates a 3D 4-component (RGBA) uint8 texture on the GPU, optionally initializing with empty data.
|
|
3153
|
+
* @internal
|
|
3154
|
+
*/
|
|
2807
3155
|
rgbaTex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
|
|
3156
|
+
/**
|
|
3157
|
+
* Create or recreate a 3D RGBA16UI texture on the GPU with given dimensions.
|
|
3158
|
+
* Deletes existing texture if provided, then allocates storage and optionally initializes with zeros.
|
|
3159
|
+
* @internal
|
|
3160
|
+
*/
|
|
2808
3161
|
rgba16Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
|
|
3162
|
+
/**
|
|
3163
|
+
* Remove cross-origin attribute from image if its URL is not from the same origin as the current page.
|
|
3164
|
+
* @internal
|
|
3165
|
+
*/
|
|
2809
3166
|
requestCORSIfNotSameOrigin(img: HTMLImageElement, url: string): void;
|
|
3167
|
+
/**
|
|
3168
|
+
* Loads a PNG image from a URL and creates a 4-component (RGBA) uint8 WebGL texture.
|
|
3169
|
+
* Binds texture to a specific texture unit depending on textureNum and sets texture parameters.
|
|
3170
|
+
* Automatically handles CORS and draws scene if needed.
|
|
3171
|
+
* @internal
|
|
3172
|
+
*/
|
|
2810
3173
|
loadPngAsTexture(pngUrl: string, textureNum: number): Promise<WebGLTexture | null>;
|
|
3174
|
+
/**
|
|
3175
|
+
* Loads a font stored as a PNG bitmap into texture unit 3.
|
|
3176
|
+
* @internal
|
|
3177
|
+
*/
|
|
2811
3178
|
loadFontTexture(fontUrl: string): Promise<WebGLTexture | null>;
|
|
2812
|
-
|
|
3179
|
+
/**
|
|
3180
|
+
* Loads a PNG bitmap into texture unit 4.
|
|
3181
|
+
* @internal
|
|
3182
|
+
*/
|
|
3183
|
+
loadBmpTexture(bmpUrl: string): Promise<WebGLTexture | null>;
|
|
2813
3184
|
/**
|
|
2814
3185
|
* Load matcap for illumination model.
|
|
2815
3186
|
* @param bmpUrl - name of matcap to load ("Shiny", "Cortex", "Cream")
|
|
2816
3187
|
* @example
|
|
2817
3188
|
* niivue.loadMatCapTexture("Cortex");
|
|
2818
|
-
* @see {@link https://niivue.
|
|
3189
|
+
* @see {@link https://niivue.com/demos/features/shiny.volumes.html | live demo usage}
|
|
2819
3190
|
*/
|
|
2820
3191
|
loadMatCapTexture(bmpUrl: string): Promise<WebGLTexture | null>;
|
|
3192
|
+
/**
|
|
3193
|
+
* Initializes font metrics from loaded font data.
|
|
3194
|
+
* @internal
|
|
3195
|
+
*/
|
|
2821
3196
|
initFontMets(): void;
|
|
2822
3197
|
/**
|
|
2823
3198
|
* Load typeface for colorbars, measurements and orientation text.
|
|
@@ -2825,8 +3200,8 @@ declare class Niivue {
|
|
|
2825
3200
|
* @param metricsUrl - URL to the corresponding font metrics JSON (defines character bounds and spacing)
|
|
2826
3201
|
* @returns a Promise that resolves when the font is loaded
|
|
2827
3202
|
* @example
|
|
2828
|
-
* niivue.
|
|
2829
|
-
* @see {@link https://niivue.
|
|
3203
|
+
* niivue.loadFont("./Roboto.png","./Roboto.json")
|
|
3204
|
+
* @see {@link https://niivue.com/demos/features/selectfont.html | live demo usage}
|
|
2830
3205
|
*/
|
|
2831
3206
|
loadFont(fontSheetUrl?: any, metricsUrl?: {
|
|
2832
3207
|
atlas: {
|
|
@@ -2868,16 +3243,33 @@ declare class Niivue {
|
|
|
2868
3243
|
})[];
|
|
2869
3244
|
kerning: any[];
|
|
2870
3245
|
}): Promise<void>;
|
|
3246
|
+
/**
|
|
3247
|
+
* Loads the default MatCap texture.
|
|
3248
|
+
* @internal
|
|
3249
|
+
*/
|
|
2871
3250
|
loadDefaultMatCap(): Promise<WebGLTexture | null>;
|
|
3251
|
+
/**
|
|
3252
|
+
* Loads the default font texture and initializes font metrics.
|
|
3253
|
+
* @internal
|
|
3254
|
+
*/
|
|
2872
3255
|
loadDefaultFont(): Promise<void>;
|
|
3256
|
+
/**
|
|
3257
|
+
* Initializes text rendering by setting up font shader, loading default font and matcap texture,
|
|
3258
|
+
* and drawing the loading text.
|
|
3259
|
+
* @internal
|
|
3260
|
+
*/
|
|
2873
3261
|
initText(): Promise<void>;
|
|
3262
|
+
/**
|
|
3263
|
+
* Maps a mesh shader name to its corresponding index number.
|
|
3264
|
+
* @internal
|
|
3265
|
+
*/
|
|
2874
3266
|
meshShaderNameToNumber(meshShaderName?: string): number | undefined;
|
|
2875
3267
|
/**
|
|
2876
3268
|
* select new shader for triangulated meshes and connectomes. Note that this function requires the mesh is fully loaded: you may want use `await` with loadMeshes (as seen in live demo).
|
|
2877
3269
|
* @param id - id of mesh to change
|
|
2878
3270
|
* @param meshShaderNameOrNumber - identify shader for usage
|
|
2879
3271
|
* @example niivue.setMeshShader('toon');
|
|
2880
|
-
* @see {@link https://niivue.
|
|
3272
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2881
3273
|
*/
|
|
2882
3274
|
setMeshShader(id: number, meshShaderNameOrNumber?: number): void;
|
|
2883
3275
|
/**
|
|
@@ -2896,7 +3288,7 @@ declare class Niivue {
|
|
|
2896
3288
|
* @param fragmentShaderText - the GLSL source code for the custom fragment shader
|
|
2897
3289
|
* @param name - a descriptive label for the shader (used in menus or debugging)
|
|
2898
3290
|
* @returns the index of the new shader (use with {@link setMeshShader})
|
|
2899
|
-
* @see {@link https://niivue.
|
|
3291
|
+
* @see {@link https://niivue.com/demos/features/mesh.atlas.html | live demo usage}
|
|
2900
3292
|
*/
|
|
2901
3293
|
setCustomMeshShader(fragmentShaderText?: string, name?: string): number;
|
|
2902
3294
|
/**
|
|
@@ -2904,18 +3296,65 @@ declare class Niivue {
|
|
|
2904
3296
|
* @param sort - sort output alphabetically
|
|
2905
3297
|
* @returns list of available mesh shader names
|
|
2906
3298
|
* @example niivue.meshShaderNames();
|
|
2907
|
-
* @see {@link https://niivue.
|
|
3299
|
+
* @see {@link https://niivue.com/demos/features/meshes.html | live demo usage}
|
|
2908
3300
|
*/
|
|
2909
3301
|
meshShaderNames(sort?: boolean): string[];
|
|
3302
|
+
/**
|
|
3303
|
+
* Initializes a rendering shader with texture units and uniforms.
|
|
3304
|
+
* @internal
|
|
3305
|
+
*/
|
|
2910
3306
|
initRenderShader(shader: Shader, gradientAmount?: number): void;
|
|
3307
|
+
/**
|
|
3308
|
+
* Initializes WebGL state, shaders, textures, buffers, and sets up the rendering pipeline.
|
|
3309
|
+
* Also loads default fonts, matcap textures, and thumbnail if specified.
|
|
3310
|
+
* @internal
|
|
3311
|
+
* @returns {Promise<this>} Resolves to this instance after initialization completes.
|
|
3312
|
+
*/
|
|
2911
3313
|
init(): Promise<this>;
|
|
3314
|
+
/**
|
|
3315
|
+
* Generates gradient texture from volume data using GPU shaders and framebuffers.
|
|
3316
|
+
* @internal
|
|
3317
|
+
*/
|
|
2912
3318
|
gradientGL(hdr: NiftiHeader): void;
|
|
3319
|
+
/**
|
|
3320
|
+
* Get the gradient texture produced by gradientGL as a TypedArray
|
|
3321
|
+
* @returns Float32Array containing the gradient texture data, or null if no gradient texture exists
|
|
3322
|
+
* @example
|
|
3323
|
+
* niivue = new Niivue()
|
|
3324
|
+
* niivue.loadVolumes([{url: './someImage.nii'}])
|
|
3325
|
+
* // ... after volume is loaded and gradient is computed
|
|
3326
|
+
* const gradientData = niivue.getGradientTextureData()
|
|
3327
|
+
* if (gradientData) {
|
|
3328
|
+
* console.log('Gradient texture dimensions:', gradientData.length)
|
|
3329
|
+
* }
|
|
3330
|
+
* @see {@link https://niivue.com/demos/features/gradient.custom.html | live demo usage}
|
|
3331
|
+
*/
|
|
3332
|
+
getGradientTextureData(): Float32Array | null;
|
|
3333
|
+
/**
|
|
3334
|
+
* Set a custom gradient texture to use instead of the one produced by gradientGL
|
|
3335
|
+
* When a custom gradient texture is set, the useCustomGradientTexture flag is set to true
|
|
3336
|
+
* to prevent gradientGL from overwriting the custom texture during volume updates.
|
|
3337
|
+
* @param data - Float32Array or Uint8Array containing RGBA gradient data, or null to revert to auto-generated gradient
|
|
3338
|
+
* @param dims - Optional dimensions array [width, height, depth]. If not provided, uses current volume dimensions
|
|
3339
|
+
* @example
|
|
3340
|
+
* niivue = new Niivue()
|
|
3341
|
+
* niivue.loadVolumes([{url: './someImage.nii'}])
|
|
3342
|
+
* // Create custom gradient data
|
|
3343
|
+
* const customGradient = new Float32Array(256 * 256 * 256 * 4) // example dimensions
|
|
3344
|
+
* // ... fill customGradient with desired values
|
|
3345
|
+
* niivue.setCustomGradientTexture(customGradient, [256, 256, 256])
|
|
3346
|
+
*
|
|
3347
|
+
* // To revert to auto-generated gradient:
|
|
3348
|
+
* niivue.setCustomGradientTexture(null)
|
|
3349
|
+
* @see {@link https://niivue.com/demos/features/gradient.custom.html | live demo usage}
|
|
3350
|
+
*/
|
|
3351
|
+
setCustomGradientTexture(data: Float32Array | Uint8Array | null, dims?: number[]): void;
|
|
2913
3352
|
/**
|
|
2914
3353
|
* update the webGL 2.0 scene after making changes to the array of volumes. It's always good to call this method after altering one or more volumes manually (outside of Niivue setter methods)
|
|
2915
3354
|
* @example
|
|
2916
3355
|
* niivue = new Niivue()
|
|
2917
3356
|
* niivue.updateGLVolume()
|
|
2918
|
-
* @see {@link https://niivue.
|
|
3357
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2919
3358
|
*/
|
|
2920
3359
|
updateGLVolume(): void;
|
|
2921
3360
|
/**
|
|
@@ -2937,7 +3376,7 @@ declare class Niivue {
|
|
|
2937
3376
|
* startVox: [10, 20, 30], // ignored if roiIsMask is false
|
|
2938
3377
|
* endVox: [40, 50, 60] // ignored if roiIsMask is false
|
|
2939
3378
|
* });
|
|
2940
|
-
* @see {@link https://niivue.
|
|
3379
|
+
* @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
|
|
2941
3380
|
*/
|
|
2942
3381
|
getDescriptives(options: {
|
|
2943
3382
|
layer?: number;
|
|
@@ -2947,6 +3386,10 @@ declare class Niivue {
|
|
|
2947
3386
|
startVox?: number[];
|
|
2948
3387
|
endVox?: number[];
|
|
2949
3388
|
}): Descriptive;
|
|
3389
|
+
/**
|
|
3390
|
+
* Updates textures, shaders, and GPU state for a given overlay layer based on image properties and rendering options.
|
|
3391
|
+
* @internal
|
|
3392
|
+
*/
|
|
2950
3393
|
refreshLayers(overlayItem: NVImage, layer: number): void;
|
|
2951
3394
|
/**
|
|
2952
3395
|
* query all available color maps that can be applied to volumes
|
|
@@ -2954,14 +3397,14 @@ declare class Niivue {
|
|
|
2954
3397
|
* @example
|
|
2955
3398
|
* niivue = new Niivue()
|
|
2956
3399
|
* colormaps = niivue.colormaps()
|
|
2957
|
-
* @see {@link https://niivue.
|
|
3400
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2958
3401
|
*/
|
|
2959
3402
|
colormaps(): string[];
|
|
2960
3403
|
/**
|
|
2961
3404
|
* create a new colormap
|
|
2962
3405
|
* @param key - name of new colormap
|
|
2963
3406
|
* @param cmap - colormap properties (Red, Green, Blue, Alpha and Indices)
|
|
2964
|
-
* @see {@link https://niivue.
|
|
3407
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2965
3408
|
*/
|
|
2966
3409
|
addColormap(key: string, cmap: ColorMap): void;
|
|
2967
3410
|
/**
|
|
@@ -2970,23 +3413,97 @@ declare class Niivue {
|
|
|
2970
3413
|
* @param colormap - the name of the colormap to use
|
|
2971
3414
|
* @example
|
|
2972
3415
|
* niivue.setColormap(niivue.volumes[0].id,, 'red')
|
|
2973
|
-
* @see {@link https://niivue.
|
|
3416
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
2974
3417
|
*/
|
|
2975
3418
|
setColormap(id: string, colormap: string): void;
|
|
3419
|
+
/**
|
|
3420
|
+
* Computes the linear voxel index from 3D coordinates using image dimensions.
|
|
3421
|
+
* @internal
|
|
3422
|
+
*/
|
|
2976
3423
|
idx(A: number, B: number, C: number, DIM: Uint32Array): number;
|
|
3424
|
+
/**
|
|
3425
|
+
* Checks if voxels below the given voxel have labels matching its value, returning the first matching label or 0.
|
|
3426
|
+
* @internal
|
|
3427
|
+
*/
|
|
2977
3428
|
check_previous_slice(bw: Uint32Array, il: Uint32Array, r: number, c: number, sl: number, dim: Uint32Array, conn: number, tt: Uint32Array): number;
|
|
3429
|
+
/**
|
|
3430
|
+
* Performs provisional labeling of connected voxels in a volume using specified connectivity.
|
|
3431
|
+
* @internal
|
|
3432
|
+
*/
|
|
2978
3433
|
do_initial_labelling(bw: Uint32Array, dim: Uint32Array, conn: number): [number, Uint32Array, Uint32Array];
|
|
3434
|
+
/**
|
|
3435
|
+
* Merges multiple provisional labels into a unified class using a translation table.
|
|
3436
|
+
* @internal
|
|
3437
|
+
*/
|
|
2979
3438
|
fill_tratab(tt: Uint32Array, nabo: Uint32Array, nr_set: number): void;
|
|
3439
|
+
/**
|
|
3440
|
+
* Removes gaps in label indices to produce a dense labeling.
|
|
3441
|
+
* @internal
|
|
3442
|
+
*/
|
|
2980
3443
|
translate_labels(il: Uint32Array, dim: Uint32Array, tt: Uint32Array, ttn: number): [number, Uint32Array];
|
|
3444
|
+
/**
|
|
3445
|
+
* Retains only the largest cluster for each region in a labeled volume.
|
|
3446
|
+
* @internal
|
|
3447
|
+
*/
|
|
2981
3448
|
largest_original_cluster_labels(bw: Uint32Array, cl: number, ls: Uint32Array): [number, Uint32Array];
|
|
3449
|
+
/**
|
|
3450
|
+
* Computes connected components labeling on a 3D image.
|
|
3451
|
+
* @internal
|
|
3452
|
+
*/
|
|
2982
3453
|
bwlabel(img: Uint32Array, dim: Uint32Array, conn?: number, binarize?: boolean, onlyLargestClusterPerClass?: boolean): [number, Uint32Array];
|
|
3454
|
+
/**
|
|
3455
|
+
* Create a connected component label map from a volume
|
|
3456
|
+
* @param id - ID of the input volume
|
|
3457
|
+
* @param conn - connectivity for clustering (6 = faces, 18 = faces + edges, 26 = faces + edges + corners)
|
|
3458
|
+
* @param binarize - whether to binarize the volume before labeling
|
|
3459
|
+
* @param onlyLargestClusterPerClass - retain only the largest cluster for each label
|
|
3460
|
+
* @returns a new NVImage with labeled clusters, using random colormap
|
|
3461
|
+
* @see {@link https://niivue.com/demos/features/clusterize.html | live demo usage}
|
|
3462
|
+
*/
|
|
2983
3463
|
createConnectedLabelImage(id: string, conn?: number, binarize?: boolean, onlyLargestClusterPerClass?: boolean): Promise<NVImage>;
|
|
3464
|
+
/**
|
|
3465
|
+
* Scales and crops a Float32 image to Uint8 range.
|
|
3466
|
+
* @internal
|
|
3467
|
+
*/
|
|
2984
3468
|
scalecropUint8(img32: Float32Array, dst_min: number, dst_max: number, src_min: number, scale: number): Promise<Uint8Array>;
|
|
3469
|
+
/**
|
|
3470
|
+
* Scales and crops a Float32 image to a specified range.
|
|
3471
|
+
* @internal
|
|
3472
|
+
*/
|
|
2985
3473
|
scalecropFloat32(img32: Float32Array, dst_min: number, dst_max: number, src_min: number, scale: number): Promise<Float32Array>;
|
|
3474
|
+
/**
|
|
3475
|
+
* Computes offset and scale to robustly rescale image intensities to a target range.
|
|
3476
|
+
* @internal
|
|
3477
|
+
*/
|
|
2986
3478
|
getScale(volume: NVImage, dst_min?: number, dst_max?: number, f_low?: number, f_high?: number): [number, number];
|
|
3479
|
+
/**
|
|
3480
|
+
* Computes output affine, voxel-to-voxel transform, and its inverse for resampling.
|
|
3481
|
+
* @internal
|
|
3482
|
+
*/
|
|
2987
3483
|
conformVox2Vox(inDims: number[], inAffine: number[], outDim?: number, outMM?: number, toRAS?: boolean): [mat4, mat4, mat4];
|
|
3484
|
+
/**
|
|
3485
|
+
* Create a binary NIfTI file as a Uint8Array, including header and image data
|
|
3486
|
+
* @param dims - image dimensions [x, y, z]
|
|
3487
|
+
* @param pixDims - voxel dimensions in mm [x, y, z]
|
|
3488
|
+
* @param affine - 4×4 affine transformation matrix in row-major order
|
|
3489
|
+
* @param datatypeCode - NIfTI datatype code (e.g., DT_UINT8, DT_FLOAT32)
|
|
3490
|
+
* @param img - image data buffer (optional)
|
|
3491
|
+
* @returns a Uint8Array representing a complete NIfTI file
|
|
3492
|
+
* @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
|
|
3493
|
+
*/
|
|
2988
3494
|
createNiftiArray(dims?: number[], pixDims?: number[], affine?: number[], datatypeCode?: NiiDataType, img?: Uint8Array): Promise<Uint8Array>;
|
|
2989
|
-
|
|
3495
|
+
/**
|
|
3496
|
+
* Convert a binary NIfTI file (as a Uint8Array) to an NVImage object
|
|
3497
|
+
* @param bytes - binary contents of a NIfTI file
|
|
3498
|
+
* @returns a Promise resolving to an NVImage object
|
|
3499
|
+
* @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
|
|
3500
|
+
*/ niftiArray2NVImage(bytes?: Uint8Array): Promise<NVImage>;
|
|
3501
|
+
/**
|
|
3502
|
+
* Load a NIfTI image from a URL and convert it to an NVImage object
|
|
3503
|
+
* @param fnm - URL of the NIfTI file to load
|
|
3504
|
+
* @returns a Promise resolving to an NVImage (not yet added to GPU or scene)
|
|
3505
|
+
* @see {@link https://niivue.com/demos/features/conform.html | live demo usage}
|
|
3506
|
+
*/
|
|
2990
3507
|
loadFromUrl(fnm: string): Promise<NVImage>;
|
|
2991
3508
|
/**
|
|
2992
3509
|
* FreeSurfer-style conform reslices any image to a 256x256x256 volume with 1mm voxels
|
|
@@ -2995,15 +3512,20 @@ declare class Niivue {
|
|
|
2995
3512
|
* @param isLinear - reslice with linear rather than nearest-neighbor interpolation (default true).
|
|
2996
3513
|
* @param asFloat32 - use Float32 datatype rather than Uint8 (default false).
|
|
2997
3514
|
* @param isRobustMinMax - clamp intensity with robust min max (~2%..98%) instead of FreeSurfer (0%..99.99%) (default false).
|
|
2998
|
-
* @see {@link https://niivue.
|
|
3515
|
+
* @see {@link https://niivue.com/demos/features/torso.html | live demo usage}
|
|
2999
3516
|
*/
|
|
3000
3517
|
conform(volume: NVImage, toRAS?: boolean, isLinear?: boolean, asFloat32?: boolean, isRobustMinMax?: boolean): Promise<NVImage>;
|
|
3001
3518
|
/**
|
|
3002
3519
|
* darken crevices and brighten corners when 3D rendering drawings.
|
|
3003
3520
|
* @param ao - amount of ambient occlusion (default 0.4)
|
|
3004
|
-
* @see {@link https://niivue.
|
|
3521
|
+
* @see {@link https://niivue.com/demos/features/torso.html | live demo usage}
|
|
3005
3522
|
*/
|
|
3006
3523
|
setRenderDrawAmbientOcclusion(ao: number): void;
|
|
3524
|
+
/**
|
|
3525
|
+
* @deprecated Use {@link setColormap} instead. This alias is retained for compatibility with NiiVue < 0.35.
|
|
3526
|
+
* @param id - ID of the volume
|
|
3527
|
+
* @param colormap - name of the colormap to apply
|
|
3528
|
+
*/
|
|
3007
3529
|
setColorMap(id: string, colormap: string): void;
|
|
3008
3530
|
/**
|
|
3009
3531
|
* use given color map for negative voxels in image
|
|
@@ -3012,7 +3534,7 @@ declare class Niivue {
|
|
|
3012
3534
|
* @example
|
|
3013
3535
|
* niivue = new Niivue()
|
|
3014
3536
|
* niivue.setColormapNegative(niivue.volumes[1].id,"winter");
|
|
3015
|
-
* @see {@link https://niivue.
|
|
3537
|
+
* @see {@link https://niivue.com/demos/features/mosaics2.html | live demo usage}
|
|
3016
3538
|
*/
|
|
3017
3539
|
setColormapNegative(id: string, colormapNegative: string): void;
|
|
3018
3540
|
/**
|
|
@@ -3021,15 +3543,15 @@ declare class Niivue {
|
|
|
3021
3543
|
* @param idModulation - the ID of the NVImage that controls bias (empty string to disable modulation)
|
|
3022
3544
|
* @param modulateAlpha - does the modulation influence alpha transparency (values greater than 1).
|
|
3023
3545
|
* @example niivue.setModulationImage(niivue.volumes[0].id, niivue.volumes[1].id);
|
|
3024
|
-
* @see {@link https://niivue.
|
|
3025
|
-
* @see {@link https://niivue.
|
|
3546
|
+
* @see {@link https://niivue.com/demos/features/modulate.html | live demo scalar usage}
|
|
3547
|
+
* @see {@link https://niivue.com/demos/features/modulateAfni.html | live demo usage}
|
|
3026
3548
|
*/
|
|
3027
3549
|
setModulationImage(idTarget: string, idModulation: string, modulateAlpha?: number): void;
|
|
3028
3550
|
/**
|
|
3029
3551
|
* adjust screen gamma. Low values emphasize shadows but can appear flat, high gamma hides shadow details.
|
|
3030
3552
|
* @param gamma - selects luminance, default is 1
|
|
3031
3553
|
* @example niivue.setGamma(1.0);
|
|
3032
|
-
* @see {@link https://niivue.
|
|
3554
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
3033
3555
|
*/
|
|
3034
3556
|
setGamma(gamma?: number): void;
|
|
3035
3557
|
/** Load all volumes for image opened with `limitFrames4D`, the user can also click the `...` on a 4D timeline to load deferred volumes
|
|
@@ -3041,7 +3563,7 @@ declare class Niivue {
|
|
|
3041
3563
|
* @param id - the ID of the 4D NVImage
|
|
3042
3564
|
* @param frame4D - frame to display (indexed from zero)
|
|
3043
3565
|
* @example nv1.setFrame4D(nv1.volumes[0].id, 42);
|
|
3044
|
-
* @see {@link https://niivue.
|
|
3566
|
+
* @see {@link https://niivue.com/demos/features/timeseries.html | live demo usage}
|
|
3045
3567
|
*/
|
|
3046
3568
|
setFrame4D(id: string, frame4D: number): void;
|
|
3047
3569
|
/**
|
|
@@ -3049,88 +3571,383 @@ declare class Niivue {
|
|
|
3049
3571
|
* @param id - the ID of the 4D NVImage
|
|
3050
3572
|
* @returns currently selected volume (indexed from 0)
|
|
3051
3573
|
* @example nv1.getFrame4D(nv1.volumes[0].id);
|
|
3052
|
-
* @see {@link https://niivue.
|
|
3574
|
+
* @see {@link https://niivue.com/demos/features/timeseries.html | live demo usage}
|
|
3053
3575
|
*/
|
|
3054
3576
|
getFrame4D(id: string): number;
|
|
3577
|
+
/**
|
|
3578
|
+
* Returns a colormap by its name key.
|
|
3579
|
+
* @internal
|
|
3580
|
+
*/
|
|
3055
3581
|
colormapFromKey(name: string): ColorMap;
|
|
3582
|
+
/**
|
|
3583
|
+
* Retrieve a colormap with optional inversion
|
|
3584
|
+
* @param lutName - name of the lookup table (LUT) colormap
|
|
3585
|
+
* @param isInvert - whether to invert the colormap
|
|
3586
|
+
* @returns the RGBA colormap as a Uint8ClampedArray
|
|
3587
|
+
* @see {@link https://niivue.com/demos/features/colormaps.html | live demo usage}
|
|
3588
|
+
*/
|
|
3056
3589
|
colormap(lutName?: string, isInvert?: boolean): Uint8ClampedArray;
|
|
3590
|
+
/**
|
|
3591
|
+
* Creates or recreates a 2D RGBA colormap texture with specified rows and columns.
|
|
3592
|
+
* @internal
|
|
3593
|
+
*/
|
|
3057
3594
|
createColormapTexture(texture?: WebGLTexture | null, nRow?: number, nCol?: number): WebGLTexture | null;
|
|
3595
|
+
/**
|
|
3596
|
+
* Adds a colormap configuration to the internal list with given parameters.
|
|
3597
|
+
* @internal
|
|
3598
|
+
*/
|
|
3058
3599
|
addColormapList(nm?: string, mn?: number, mx?: number, alpha?: boolean, neg?: boolean, vis?: boolean, inv?: boolean): void;
|
|
3600
|
+
/**
|
|
3601
|
+
* Rebuild and upload all colormap textures for volumes and meshes
|
|
3602
|
+
* @returns the current NiiVue instance, or undefined if no colormaps are used
|
|
3603
|
+
* @see {@link https://niivue.com/demos/features/mesh.stats.html | live demo usage}
|
|
3604
|
+
*/
|
|
3059
3605
|
refreshColormaps(): this | undefined;
|
|
3606
|
+
/**
|
|
3607
|
+
* Calculates volume scaling factors and voxel dimensions for rendering.
|
|
3608
|
+
* @internal
|
|
3609
|
+
*/
|
|
3060
3610
|
sliceScale(forceVox?: boolean): SliceScale;
|
|
3611
|
+
/**
|
|
3612
|
+
* Returns the index of the tile containing the given (x, y) screen coordinates.
|
|
3613
|
+
* Returns -1 if the coordinates are outside all tiles.
|
|
3614
|
+
* @internal
|
|
3615
|
+
*/
|
|
3061
3616
|
tileIndex(x: number, y: number): number;
|
|
3617
|
+
/**
|
|
3618
|
+
* Returns the index of the render tile containing (x, y) screen coordinates, or -1 if none.
|
|
3619
|
+
* @internal
|
|
3620
|
+
*/
|
|
3062
3621
|
inRenderTile(x: number, y: number): number;
|
|
3622
|
+
/**
|
|
3623
|
+
* Adjusts clip plane depth if active, else zooms render size.
|
|
3624
|
+
* @internal
|
|
3625
|
+
*/
|
|
3063
3626
|
sliceScroll3D(posChange?: number): void;
|
|
3627
|
+
/**
|
|
3628
|
+
* Deletes loaded thumbnail texture and frees memory.
|
|
3629
|
+
* @internal
|
|
3630
|
+
*/
|
|
3064
3631
|
deleteThumbnail(): void;
|
|
3632
|
+
/**
|
|
3633
|
+
* Checks if (x,y) is within the visible graph plotting area.
|
|
3634
|
+
* @internal
|
|
3635
|
+
*/
|
|
3065
3636
|
inGraphTile(x: number, y: number): boolean;
|
|
3637
|
+
/**
|
|
3638
|
+
* Updates drawBitmap to match clickToSegmentGrowingBitmap if they differ in content and size.
|
|
3639
|
+
* @internal
|
|
3640
|
+
*/
|
|
3066
3641
|
updateBitmapFromClickToSegment(): void;
|
|
3642
|
+
/**
|
|
3643
|
+
* Calculates the sum of all voxel values in the given bitmap.
|
|
3644
|
+
* @internal
|
|
3645
|
+
*/
|
|
3067
3646
|
sumBitmap(img: Uint8Array): number;
|
|
3647
|
+
/**
|
|
3648
|
+
* Performs click-to-segment operation based on user click within a specified tile.
|
|
3649
|
+
* Validates input, computes voxel coordinates from screen position, and applies flood fill
|
|
3650
|
+
* with intensity-based thresholding and optional growing mask.
|
|
3651
|
+
* Updates drawing bitmaps and triggers redraw and descriptive stats calculation.
|
|
3652
|
+
* @internal
|
|
3653
|
+
*/
|
|
3068
3654
|
doClickToSegment(options: {
|
|
3069
3655
|
x: number;
|
|
3070
3656
|
y: number;
|
|
3071
3657
|
tileIndex: number;
|
|
3072
3658
|
}): void;
|
|
3659
|
+
/**
|
|
3660
|
+
* Handles mouse click on canvas by updating crosshair position, drawing, or segmenting based on current mode and location.
|
|
3661
|
+
* Supports thumbnail loading, graph interaction, 3D slice scrolling, and click-to-segment with flood fill.
|
|
3662
|
+
* @internal
|
|
3663
|
+
*/
|
|
3073
3664
|
mouseClick(x: number, y: number, posChange?: number, isDelta?: boolean): void;
|
|
3665
|
+
/**
|
|
3666
|
+
* Draws a 10cm ruler on a 2D slice tile based on screen FOV and slice dimensions.
|
|
3667
|
+
* @internal
|
|
3668
|
+
*/
|
|
3074
3669
|
drawRuler(): void;
|
|
3670
|
+
/**
|
|
3671
|
+
* Draws a 10cm ruler at specified coordinates with given color and width.
|
|
3672
|
+
* @internal
|
|
3673
|
+
*/
|
|
3075
3674
|
drawRuler10cm(startXYendXY: number[], rulerColor: number[], rulerWidth?: number): void;
|
|
3675
|
+
/**
|
|
3676
|
+
* Returns vec4 with XYZ millimeter coordinates and tile index for given screen XY.
|
|
3677
|
+
* @internal
|
|
3678
|
+
*/
|
|
3076
3679
|
screenXY2mm(x: number, y: number, forceSlice?: number): vec4;
|
|
3680
|
+
/**
|
|
3681
|
+
* Update scene pan position during drag based on start and end screen coordinates.
|
|
3682
|
+
* @internal
|
|
3683
|
+
*/
|
|
3077
3684
|
dragForPanZoom(startXYendXY: number[]): void;
|
|
3685
|
+
/**
|
|
3686
|
+
* Handle center-button drag as pan and zoom.
|
|
3687
|
+
* @internal
|
|
3688
|
+
*/
|
|
3078
3689
|
dragForCenterButton(startXYendXY: number[]): void;
|
|
3690
|
+
/**
|
|
3691
|
+
* Update 3D slicer zoom and pan based on drag movement.
|
|
3692
|
+
* @internal
|
|
3693
|
+
*/
|
|
3079
3694
|
dragForSlicer3D(startXYendXY: number[]): void;
|
|
3695
|
+
/**
|
|
3696
|
+
* Draw a measurement line with end caps and length text on a 2D tile.
|
|
3697
|
+
* @internal
|
|
3698
|
+
*/
|
|
3080
3699
|
drawMeasurementTool(startXYendXY: number[]): void;
|
|
3700
|
+
/**
|
|
3701
|
+
* Draw a rectangle or outline at given position with specified color or default crosshair color.
|
|
3702
|
+
* @internal
|
|
3703
|
+
*/
|
|
3081
3704
|
drawRect(leftTopWidthHeight: number[], lineColor?: number[]): void;
|
|
3705
|
+
/**
|
|
3706
|
+
* Draw a circle or outline at given position with specified color or default crosshair color.
|
|
3707
|
+
* @internal
|
|
3708
|
+
*/
|
|
3082
3709
|
drawCircle(leftTopWidthHeight: number[], circleColor?: Float32List, fillPercent?: number): void;
|
|
3710
|
+
/**
|
|
3711
|
+
* Draw selection box: circle if ROI selection mode, else rectangle.
|
|
3712
|
+
* @internal
|
|
3713
|
+
*/
|
|
3083
3714
|
drawSelectionBox(leftTopWidthHeight: number[]): void;
|
|
3715
|
+
/**
|
|
3716
|
+
* Get canvas height available for tiles (excludes colorbar).
|
|
3717
|
+
* @internal
|
|
3718
|
+
*/
|
|
3084
3719
|
effectiveCanvasHeight(): number;
|
|
3720
|
+
/**
|
|
3721
|
+
* Get canvas width available for tiles (excludes legend panel).
|
|
3722
|
+
* @internal
|
|
3723
|
+
*/
|
|
3085
3724
|
effectiveCanvasWidth(): number;
|
|
3725
|
+
/**
|
|
3726
|
+
* Get all 3D labels from document and connectome meshes.
|
|
3727
|
+
* @internal
|
|
3728
|
+
*/
|
|
3086
3729
|
getAllLabels(): NVLabel3D[];
|
|
3730
|
+
/**
|
|
3731
|
+
* Get all visible connectome and non-anchored mesh labels.
|
|
3732
|
+
* @internal
|
|
3733
|
+
*/
|
|
3087
3734
|
getConnectomeLabels(): NVLabel3D[];
|
|
3735
|
+
/**
|
|
3736
|
+
* Calculate bullet margin width based on widest bullet scale and tallest label height.
|
|
3737
|
+
* @internal
|
|
3738
|
+
*/
|
|
3088
3739
|
getBulletMarginWidth(): number;
|
|
3740
|
+
/**
|
|
3741
|
+
* Calculate width of legend panel based on labels and bullet margin.
|
|
3742
|
+
* Returns 0 if legend is hidden or too wide for canvas.
|
|
3743
|
+
* @internal
|
|
3744
|
+
*/
|
|
3089
3745
|
getLegendPanelWidth(): number;
|
|
3090
|
-
|
|
3746
|
+
/**
|
|
3747
|
+
* Calculate legend panel height based on labels and scale.
|
|
3748
|
+
* @internal
|
|
3749
|
+
*/
|
|
3750
|
+
getLegendPanelHeight(panelScale?: number): number;
|
|
3751
|
+
/**
|
|
3752
|
+
* Calculate and reserve canvas area for colorbar panel.
|
|
3753
|
+
* @internal
|
|
3754
|
+
*/
|
|
3091
3755
|
reserveColorbarPanel(): number[];
|
|
3756
|
+
/**
|
|
3757
|
+
* Render a single colorbar with optional negative coloring and alpha threshold ticks.
|
|
3758
|
+
* @internal
|
|
3759
|
+
*/
|
|
3092
3760
|
drawColorbarCore(layer: number, leftTopWidthHeight: number[], isNegativeColor: boolean, min: number, max: number, isAlphaThreshold: boolean): void;
|
|
3761
|
+
/**
|
|
3762
|
+
* Draw all visible colorbars side by side in the reserved colorbar panel area.
|
|
3763
|
+
* @internal
|
|
3764
|
+
*/
|
|
3093
3765
|
drawColorbar(): void;
|
|
3766
|
+
/**
|
|
3767
|
+
* Calculate pixel width of text string based on glyph advances at given scale.
|
|
3768
|
+
* @internal
|
|
3769
|
+
*/
|
|
3094
3770
|
textWidth(scale: number, str: string): number;
|
|
3771
|
+
/**
|
|
3772
|
+
* Calculate pixel height of text based on tallest glyph at given scale.
|
|
3773
|
+
* @internal
|
|
3774
|
+
*/
|
|
3095
3775
|
textHeight(scale: number, str: string): number;
|
|
3776
|
+
/**
|
|
3777
|
+
* Render a single character glyph at specified position and scale; returns advance width.
|
|
3778
|
+
* @internal
|
|
3779
|
+
*/
|
|
3096
3780
|
drawChar(xy: number[], scale: number, char: number): number;
|
|
3781
|
+
/**
|
|
3782
|
+
* Render loading text centered on the canvas.
|
|
3783
|
+
* @internal
|
|
3784
|
+
*/
|
|
3097
3785
|
drawLoadingText(text: string): void;
|
|
3786
|
+
/**
|
|
3787
|
+
* Render a string of text at specified canvas coordinates with scaling and optional color.
|
|
3788
|
+
* @internal
|
|
3789
|
+
*/
|
|
3098
3790
|
drawText(xy: number[], str: string, scale?: number, color?: Float32List | null): void;
|
|
3791
|
+
/**
|
|
3792
|
+
* Draw text right-aligned to the given coordinates, vertically centered on y.
|
|
3793
|
+
* @internal
|
|
3794
|
+
*/
|
|
3099
3795
|
drawTextRight(xy: number[], str: string, scale?: number, color?: number[] | null): void;
|
|
3796
|
+
/**
|
|
3797
|
+
* Draw text left-aligned to the given coordinates, vertically centered on y.
|
|
3798
|
+
* @internal
|
|
3799
|
+
*/
|
|
3100
3800
|
drawTextLeft(xy: number[], str: string, scale?: number, color?: number[] | null): void;
|
|
3801
|
+
/**
|
|
3802
|
+
* Draw text right-aligned and below the given coordinates.
|
|
3803
|
+
* @internal
|
|
3804
|
+
*/
|
|
3101
3805
|
drawTextRightBelow(xy: number[], str: string, scale?: number, color?: number[] | null): void;
|
|
3806
|
+
/**
|
|
3807
|
+
* Draw text horizontally centered between start and end points with a semi-transparent background.
|
|
3808
|
+
* @internal
|
|
3809
|
+
*/
|
|
3102
3810
|
drawTextBetween(startXYendXY: number[], str: string, scale?: number, color?: number[] | null): void;
|
|
3811
|
+
/**
|
|
3812
|
+
* Draw text horizontally centered below a specified (x,y) position with canvas boundary clamping.
|
|
3813
|
+
* @internal
|
|
3814
|
+
*/
|
|
3103
3815
|
drawTextBelow(xy: number[], str: string, scale?: number, color?: number[] | null): void;
|
|
3816
|
+
/**
|
|
3817
|
+
* Update texture interpolation mode (nearest or linear) for background or overlay layer.
|
|
3818
|
+
* @internal
|
|
3819
|
+
*/
|
|
3104
3820
|
updateInterpolation(layer: number, isForceLinear?: boolean): void;
|
|
3821
|
+
/**
|
|
3822
|
+
* Enable or disable atlas outline overlay
|
|
3823
|
+
* @param isOutline - number 0 to 1 for outline opacity
|
|
3824
|
+
* @see {@link https://niivue.com/demos/features/atlas.sparse.html | live demo usage}
|
|
3825
|
+
*/
|
|
3105
3826
|
setAtlasOutline(isOutline: number): void;
|
|
3106
3827
|
/**
|
|
3107
3828
|
* select between nearest and linear interpolation for voxel based images
|
|
3108
3829
|
* @param isNearest - whether nearest neighbor interpolation is used, else linear interpolation
|
|
3109
3830
|
* @example niivue.setInterpolation(true);
|
|
3110
|
-
* @see {@link https://niivue.
|
|
3831
|
+
* @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
|
|
3111
3832
|
*/
|
|
3112
3833
|
setInterpolation(isNearest: boolean): void;
|
|
3834
|
+
/**
|
|
3835
|
+
* Computes 2D model-view-projection and related matrices for rendering a slice of a 3D volume.
|
|
3836
|
+
* Configures viewport and accounts for radiological orientation, depth clipping, and camera rotation.
|
|
3837
|
+
* @internal
|
|
3838
|
+
*/
|
|
3113
3839
|
calculateMvpMatrix2D(leftTopWidthHeight: number[], mn: vec3, mx: vec3, clipTolerance: number, clipDepth: number, azimuth: number, elevation: number, isRadiolgical: boolean): MvpMatrix2D;
|
|
3840
|
+
/**
|
|
3841
|
+
* Reorders the components of a 3D vector based on the slice orientation (axial, coronal, or sagittal).
|
|
3842
|
+
* @internal
|
|
3843
|
+
*/
|
|
3114
3844
|
swizzleVec3MM(v3: vec3, axCorSag: SLICE_TYPE): vec3;
|
|
3845
|
+
/**
|
|
3846
|
+
* Returns the swizzled field of view for the given slice orientation.
|
|
3847
|
+
* @internal
|
|
3848
|
+
*/
|
|
3115
3849
|
screenFieldOfViewVox(axCorSag?: number): vec3;
|
|
3850
|
+
/**
|
|
3851
|
+
* Returns the field of view in millimeters for the given slice orientation.
|
|
3852
|
+
* @internal
|
|
3853
|
+
*/
|
|
3116
3854
|
screenFieldOfViewMM(axCorSag?: number, forceSliceMM?: boolean): vec3;
|
|
3855
|
+
/**
|
|
3856
|
+
* Returns extended voxel-aligned field of view and bounds for the given slice orientation.
|
|
3857
|
+
* @internal
|
|
3858
|
+
*/
|
|
3117
3859
|
screenFieldOfViewExtendedVox(axCorSag?: number): MM;
|
|
3860
|
+
/**
|
|
3861
|
+
* Returns extended millimeter-aligned field of view and bounds for the given slice orientation.
|
|
3862
|
+
* @internal
|
|
3863
|
+
*/
|
|
3118
3864
|
screenFieldOfViewExtendedMM(axCorSag?: number): MM;
|
|
3865
|
+
/**
|
|
3866
|
+
* Draws anatomical orientation labels (e.g., A/P/L/R) for the given slice view.
|
|
3867
|
+
* @internal
|
|
3868
|
+
*/
|
|
3119
3869
|
drawSliceOrientationText(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, padLeftTop?: number[]): void;
|
|
3870
|
+
/**
|
|
3871
|
+
* Computes a plane in mm space for a given slice orientation and depth.
|
|
3872
|
+
* @internal
|
|
3873
|
+
*/
|
|
3120
3874
|
xyMM2xyzMM(axCorSag: SLICE_TYPE, sliceFrac: number): number[];
|
|
3875
|
+
/**
|
|
3876
|
+
* Draw a 2D slice tile with appropriate orientation, zoom, pan, and optional mesh overlay.
|
|
3877
|
+
* @internal
|
|
3878
|
+
*/
|
|
3121
3879
|
draw2DMain(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number): void;
|
|
3880
|
+
/**
|
|
3881
|
+
* Draw a 2D slice tile with optional custom size and orientation text.
|
|
3882
|
+
* @internal
|
|
3883
|
+
*/
|
|
3122
3884
|
draw2D(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number, imageWidthHeight?: number[]): void;
|
|
3885
|
+
/**
|
|
3886
|
+
* Computes 3D model-view-projection matrices based on view angles and canvas size.
|
|
3887
|
+
* @internal
|
|
3888
|
+
*/
|
|
3123
3889
|
calculateMvpMatrix(_unused: unknown, leftTopWidthHeight: number[], azimuth: number, elevation: number): mat4[];
|
|
3890
|
+
/**
|
|
3891
|
+
* Computes the model transformation matrix for the given azimuth and elevation.
|
|
3892
|
+
* Applies optional oblique RAS rotation if available.
|
|
3893
|
+
* @internal
|
|
3894
|
+
*/
|
|
3124
3895
|
calculateModelMatrix(azimuth: number, elevation: number): mat4;
|
|
3896
|
+
/**
|
|
3897
|
+
* Returns the normalized near-to-far ray direction for the given view angles.
|
|
3898
|
+
* Ensures components are nonzero to avoid divide-by-zero errors.
|
|
3899
|
+
* @internal
|
|
3900
|
+
*/
|
|
3125
3901
|
calculateRayDirection(azimuth: number, elevation: number): vec3;
|
|
3902
|
+
/**
|
|
3903
|
+
* Returns the scene's min, max, and range extents in mm or voxel space.
|
|
3904
|
+
* Includes both volume and mesh geometry.
|
|
3905
|
+
* @internal
|
|
3906
|
+
*/
|
|
3126
3907
|
sceneExtentsMinMax(isSliceMM?: boolean): vec3[];
|
|
3908
|
+
/**
|
|
3909
|
+
* Sets the 3D pivot point and scene scale based on volume and mesh extents.
|
|
3910
|
+
* @internal
|
|
3911
|
+
*/
|
|
3127
3912
|
setPivot3D(): void;
|
|
3913
|
+
/**
|
|
3914
|
+
* Returns the maximum number of 4D volumes across all loaded images.
|
|
3915
|
+
* @internal
|
|
3916
|
+
*/
|
|
3128
3917
|
getMaxVols(): number;
|
|
3918
|
+
/**
|
|
3919
|
+
* Returns true if any loaded 4D volume is missing frames.
|
|
3920
|
+
* @internal
|
|
3921
|
+
*/
|
|
3129
3922
|
detectPartialllyLoaded4D(): boolean;
|
|
3923
|
+
/**
|
|
3924
|
+
* Draws a graph of 4D volume intensity over time at the current crosshair position.
|
|
3925
|
+
* Skips if volume is 3D, region is too small, or graph opacity is zero.
|
|
3926
|
+
* @internal
|
|
3927
|
+
*/
|
|
3130
3928
|
drawGraph(): void;
|
|
3929
|
+
/**
|
|
3930
|
+
* Updates crosshair position using depth-based mouse picking from screen pixel color.
|
|
3931
|
+
* Only active when depth picking is enabled.
|
|
3932
|
+
* @internal
|
|
3933
|
+
*/
|
|
3131
3934
|
depthPicker(leftTopWidthHeight: number[], mvpMatrix: mat4): void;
|
|
3935
|
+
/**
|
|
3936
|
+
* Render a 3D volume visualization of the current NVImage using provided transformation matrices and angles.
|
|
3937
|
+
* @internal
|
|
3938
|
+
*/
|
|
3132
3939
|
drawImage3D(mvpMatrix: mat4, azimuth: number, elevation: number): void;
|
|
3940
|
+
/**
|
|
3941
|
+
* Draw a small orientation cube indicating L/R, A/P, I/S directions in the given tile area with specified azimuth and elevation.
|
|
3942
|
+
* @internal
|
|
3943
|
+
*/
|
|
3133
3944
|
drawOrientationCube(leftTopWidthHeight: number[], azimuth?: number, elevation?: number): void;
|
|
3945
|
+
/**
|
|
3946
|
+
* Internal utility to generate human-readable location strings for the onLocationChange callback
|
|
3947
|
+
* @param axCorSag - optional axis index for coordinate interpretation (NaN by default)
|
|
3948
|
+
* @remarks Computes string representation of current crosshair position in mm (and frame if 4D).
|
|
3949
|
+
* @see {@link https://niivue.com/demos/features/modulateAfni.html | live demo usage}
|
|
3950
|
+
*/
|
|
3134
3951
|
createOnLocationChange(axCorSag?: number): void;
|
|
3135
3952
|
/**
|
|
3136
3953
|
* Add a 3D Label
|
|
@@ -3140,20 +3957,68 @@ declare class Niivue {
|
|
|
3140
3957
|
* @param anchor - optional label anchor position (e.g., top-left, center, etc.)
|
|
3141
3958
|
* @param onClick - optional callback function to invoke when the label is clicked
|
|
3142
3959
|
* @returns the created `NVLabel3D` instance
|
|
3143
|
-
* @see {@link https://niivue.
|
|
3960
|
+
* @see {@link https://niivue.com/demos/features/labels.html | live demo usage}
|
|
3144
3961
|
*/
|
|
3145
3962
|
addLabel(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void): NVLabel3D;
|
|
3963
|
+
/**
|
|
3964
|
+
* Calculate the 2D screen coordinates of a 3D point using the provided MVP matrix and tile position/size.
|
|
3965
|
+
* @internal
|
|
3966
|
+
*/
|
|
3146
3967
|
calculateScreenPoint(point: [number, number, number], mvpMatrix: mat4, leftTopWidthHeight: number[]): vec4;
|
|
3968
|
+
/**
|
|
3969
|
+
* Return the label located at the given screen coordinates, or null if none found.
|
|
3970
|
+
* @internal
|
|
3971
|
+
*/
|
|
3147
3972
|
getLabelAtPoint(screenPoint: [number, number]): NVLabel3D | null;
|
|
3973
|
+
/**
|
|
3974
|
+
* Draw lines from a 2D label position to its associated 3D points; supports solid and dotted lines.
|
|
3975
|
+
* @internal
|
|
3976
|
+
*/
|
|
3148
3977
|
drawLabelLine(label: NVLabel3D, pos: vec2, mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
|
|
3149
|
-
|
|
3978
|
+
/**
|
|
3979
|
+
* Render a 3D label with optional leader lines, bullet markers, and text alignment within a legend.
|
|
3980
|
+
* @internal
|
|
3981
|
+
*/
|
|
3982
|
+
draw3DLabel(label: NVLabel3D, pos: vec2, mvpMatrix?: mat4, leftTopWidthHeight?: number[], bulletMargin?: number, legendWidth?: number, secondPass?: boolean, scaling?: number): void;
|
|
3983
|
+
/**
|
|
3984
|
+
* Render all visible 3D labels in the legend panel, handling font scaling and layering.
|
|
3985
|
+
* @internal
|
|
3986
|
+
*/
|
|
3150
3987
|
draw3DLabels(mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
|
|
3988
|
+
/**
|
|
3989
|
+
* Draw all labels anchored to screen edges or corners with background rectangles.
|
|
3990
|
+
* @internal
|
|
3991
|
+
*/
|
|
3151
3992
|
drawAnchoredLabels(): void;
|
|
3993
|
+
/**
|
|
3994
|
+
* Render the 3D scene including volume, meshes, labels, crosshairs, and orientation cube.
|
|
3995
|
+
* @internal
|
|
3996
|
+
*/
|
|
3152
3997
|
draw3D(leftTopWidthHeight?: number[], mvpMatrix?: mat4 | null, modelMatrix?: mat4 | null, normalMatrix?: mat4 | null, azimuth?: number | null, elevation?: number): string | undefined;
|
|
3998
|
+
/**
|
|
3999
|
+
* Render all visible 3D meshes with proper blending, depth, and shader settings.
|
|
4000
|
+
* @internal
|
|
4001
|
+
*/
|
|
3153
4002
|
drawMesh3D(isDepthTest?: boolean, alpha?: number, m?: mat4, modelMtx?: mat4, normMtx?: mat4): void;
|
|
4003
|
+
/**
|
|
4004
|
+
* Render 3D crosshairs at the current crosshair position with optional depth testing and transparency.
|
|
4005
|
+
* @internal
|
|
4006
|
+
*/
|
|
3154
4007
|
drawCrosshairs3D(isDepthTest?: boolean, alpha?: number, mvpMtx?: mat4 | null, is2DView?: boolean, isSliceMM?: boolean): void;
|
|
4008
|
+
/**
|
|
4009
|
+
* Convert millimeter coordinates to fractional volume coordinates for the specified volume.
|
|
4010
|
+
* @internal
|
|
4011
|
+
*/
|
|
3155
4012
|
mm2frac(mm: vec3 | vec4, volIdx?: number, isForceSliceMM?: boolean): vec3;
|
|
4013
|
+
/**
|
|
4014
|
+
* Convert voxel coordinates to fractional volume coordinates for the specified volume.
|
|
4015
|
+
* @internal
|
|
4016
|
+
*/
|
|
3156
4017
|
vox2frac(vox: vec3, volIdx?: number): vec3;
|
|
4018
|
+
/**
|
|
4019
|
+
* Convert fractional volume coordinates to voxel coordinates for the specified volume.
|
|
4020
|
+
* @internal
|
|
4021
|
+
*/
|
|
3157
4022
|
frac2vox(frac: vec3, volIdx?: number): vec3;
|
|
3158
4023
|
/**
|
|
3159
4024
|
* move crosshair a fixed number of voxels (not mm)
|
|
@@ -3161,31 +4026,99 @@ declare class Niivue {
|
|
|
3161
4026
|
* @param y - translate posterior (-) or +anterior (+)
|
|
3162
4027
|
* @param z - translate inferior (-) or superior (+)
|
|
3163
4028
|
* @example niivue.moveCrosshairInVox(1, 0, 0)
|
|
3164
|
-
* @see {@link https://niivue.
|
|
4029
|
+
* @see {@link https://niivue.com/demos/features/draw2.html | live demo usage}
|
|
3165
4030
|
*/
|
|
3166
4031
|
moveCrosshairInVox(x: number, y: number, z: number): void;
|
|
4032
|
+
/**
|
|
4033
|
+
* Convert fractional volume coordinates to millimeter space for the specified volume.
|
|
4034
|
+
* @internal
|
|
4035
|
+
*/
|
|
3167
4036
|
frac2mm(frac: vec3, volIdx?: number, isForceSliceMM?: boolean): vec4;
|
|
4037
|
+
/**
|
|
4038
|
+
* Convert screen pixel coordinates to texture fractional coordinates for the given slice index.
|
|
4039
|
+
* @internal
|
|
4040
|
+
*/
|
|
3168
4041
|
screenXY2TextureFrac(x: number, y: number, i: number, restrict0to1?: boolean): vec3;
|
|
4042
|
+
/**
|
|
4043
|
+
* Converts a canvas position to fractional texture coordinates.
|
|
4044
|
+
* @internal
|
|
4045
|
+
*/
|
|
3169
4046
|
canvasPos2frac(canvasPos: number[]): vec3;
|
|
4047
|
+
/**
|
|
4048
|
+
* Calculates scaled slice dimensions and position within the canvas.
|
|
4049
|
+
* n.b. beware of similarly named `sliceScale` method.
|
|
4050
|
+
* @internal
|
|
4051
|
+
*/
|
|
3170
4052
|
scaleSlice(w: number, h: number, padPixelsWH?: [number, number], canvasWH?: [number, number]): number[];
|
|
4053
|
+
/**
|
|
4054
|
+
* Renders a centered thumbnail image using the bitmap shader.
|
|
4055
|
+
* @internal
|
|
4056
|
+
*/
|
|
3171
4057
|
drawThumbnail(): void;
|
|
4058
|
+
/**
|
|
4059
|
+
* Draws a 2D line with specified thickness and color on the canvas.
|
|
4060
|
+
* If alpha < 0, uses the default crosshair color.
|
|
4061
|
+
* @internal
|
|
4062
|
+
*/
|
|
3172
4063
|
drawLine(startXYendXY: number[], thickness?: number, lineColor?: number[]): void;
|
|
4064
|
+
/**
|
|
4065
|
+
* Draws a 3D line from screen to world space with specified thickness and color.
|
|
4066
|
+
* If alpha < 0, uses the default crosshair color.
|
|
4067
|
+
* @internal
|
|
4068
|
+
*/
|
|
3173
4069
|
draw3DLine(startXY: vec2, endXYZ: vec3, thickness?: number, lineColor?: number[]): void;
|
|
4070
|
+
/**
|
|
4071
|
+
* Draws a dotted 2D line with specified thickness and color.
|
|
4072
|
+
* If alpha < 0, uses the default crosshair color with reduced opacity.
|
|
4073
|
+
* @internal
|
|
4074
|
+
*/
|
|
3174
4075
|
drawDottedLine(startXYendXY: number[], thickness?: number, lineColor?: number[]): void;
|
|
4076
|
+
/**
|
|
4077
|
+
* Draw a colored line on the graph using given coordinates, color, and thickness.
|
|
4078
|
+
* @internal
|
|
4079
|
+
*/
|
|
3175
4080
|
drawGraphLine(LTRB: number[], color?: number[], thickness?: number): void;
|
|
4081
|
+
/**
|
|
4082
|
+
* Draw crosshair lines in millimeters on a given 2D slice tile.
|
|
4083
|
+
* @internal
|
|
4084
|
+
*/
|
|
3176
4085
|
drawCrossLinesMM(sliceIndex: number, axCorSag: SLICE_TYPE, axiMM: number[], corMM: number[], sagMM: number[]): void;
|
|
4086
|
+
/**
|
|
4087
|
+
* Draw crosshair lines on 2D slice tile, delegating to mm-based drawing if appropriate.
|
|
4088
|
+
* @internal
|
|
4089
|
+
*/
|
|
3177
4090
|
drawCrossLines(sliceIndex: number, axCorSag: SLICE_TYPE, axiMM: number[], corMM: number[], sagMM: number[]): void;
|
|
3178
4091
|
/**
|
|
3179
4092
|
* display a lightbox or montage view
|
|
3180
4093
|
* @param mosaicStr - specifies orientation (A,C,S) and location of slices.
|
|
3181
4094
|
* @example niivue.setSliceMosaicString("A -10 0 20");
|
|
3182
|
-
* @see {@link https://niivue.
|
|
4095
|
+
* @see {@link https://niivue.com/demos/features/mosaics.html | live demo usage}
|
|
3183
4096
|
*/
|
|
3184
4097
|
drawMosaic(mosaicStr: string): void;
|
|
4098
|
+
/**
|
|
4099
|
+
* Calculate width and height to fit a slice within a container, preserving aspect ratio based on slice type and volume scaling.
|
|
4100
|
+
* @internal
|
|
4101
|
+
*/
|
|
3185
4102
|
calculateWidthHeight(sliceType: number, volScale: number[], containerWidth: number, containerHeight: number): [number, number];
|
|
4103
|
+
/**
|
|
4104
|
+
* Core function to draw the entire scene including volumes, meshes, slices, overlays, colorbars, graphs, and handle user interaction like dragging.
|
|
4105
|
+
* @internal
|
|
4106
|
+
*/
|
|
3186
4107
|
drawSceneCore(): string | void;
|
|
4108
|
+
/**
|
|
4109
|
+
* Manage draw calls to prevent concurrency issues, calling drawSceneCore and handling refresh flags.
|
|
4110
|
+
* @internal
|
|
4111
|
+
*/
|
|
3187
4112
|
drawScene(): string | void;
|
|
4113
|
+
/**
|
|
4114
|
+
* Getter for WebGL2 rendering context; throws error if context is unavailable.
|
|
4115
|
+
* @internal
|
|
4116
|
+
*/
|
|
3188
4117
|
get gl(): WebGL2RenderingContext;
|
|
4118
|
+
/**
|
|
4119
|
+
* Setter for WebGL2 rendering context.
|
|
4120
|
+
* @internal
|
|
4121
|
+
*/
|
|
3189
4122
|
set gl(gl: WebGL2RenderingContext | null);
|
|
3190
4123
|
}
|
|
3191
4124
|
|