@niivue/niivue 0.56.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # NiiVue
2
2
 
3
- NiiVue is web-based visualization tool for neuroimaging that can run on any operating system and any web device (phone, tablet, computer). This repository contains only the **core NiiVue package** that can be embedded into other projects. We have additional [repositories](https://github.com/niivue) that wrap NiiVue for use in jupyter notebooks, vscode, and electron applications.
4
-
5
- ### [Click here to see NiiVue live demos](https://niivue.github.io/niivue/)
6
-
7
- What makes NiiVue unique is its ability to simultaneously display all the datatypes popular with neuroimaging: voxels, meshes, tractography streamlines, statistical maps and connectomes. Alternative voxel-based web tools include [ami](https://fnndsc.github.io/ami/), [BioImage Suite Web](https://bioimagesuiteweb.github.io/webapp/viewer.html), [BrainBrowser](https://brainbrowser.cbrain.mcgill.ca/volume-viewer), [nifti-drop](http://vsoch.github.io/nifti-drop), [OHIF DICOM Viewer](https://viewer.ohif.org/), [Papaya](https://www.fmrib.ox.ac.uk/ukbiobank/group_means/index.html), and [VTK.js](https://kitware.github.io/paraview-glance/app/).
3
+ NiiVue is web-based visualization tool for neuroimaging that can run on any operating system and any web device (phone, tablet, computer). This repository contains only the **core NiiVue package** that can be embedded into other projects. See [niivue.com](https://niivue.com/) for examples and documentation.
8
4
 
9
5
  ## Local Development
10
6
 
@@ -16,55 +12,3 @@ cd niivue
16
12
  npm install
17
13
  npm run dev
18
14
  ```
19
-
20
- The command `npm run demo` will minify the project and locally host all of the [live demos](https://niivue.github.io/niivue/). The [DEVELOP.md file provides more details for developers](./packages/niivue/DEVELOP.md).
21
-
22
- # Developer Documentation
23
-
24
- [Click here for the docs web page](https://niivue.github.io/niivue/devdocs/)
25
-
26
- # Projects and People using NiiVue
27
-
28
- - Analysis of Functional NeuroImages (AFNI) [Scientific and Statistical Computing Core](https://afni.nimh.nih.gov/) (National Institutes of Health)
29
- - [BOOSTLET.js](https://boostlet.org/) image processing plugins work with NiiVue.
30
- - [brainchop](https://github.com/neuroneural/brainchop) uses NiiVue for their [drag-and-drop segmentation, brain extraction and parcellation tool](https://neuroneural.github.io/brainchop/)
31
- - [BrainLife.io](https://brainlife.io/about/) integrates NiiVue into [ezbids](https://brainlife.io/ezbids/)
32
- - [CACTAS](https://github.com/mpsych/CACTAS) from [Daniel Haehn's team](https://danielhaehn.com/) is extending NiiVue drawing and segmentation capabilities
33
- - [ChRIS Research Integration System (ChRIS) from Boston Children's Hospital](https://chrisproject.org/) uses [NiiVue](https://app.chrisproject.org/niivue)
34
- - [Center for the Study of Aphasia Recovery (C-STAR)](https://cstar.sc.edu/) (University of South Carolina)
35
- - [Digital Brain Bank](https://elifesciences.org/articles/73153) for navigating MRI datasets
36
- - FMRIB's Software Library (FSL) [Wellcome Centre for Integrative Neuroimaging](https://www.win.ox.ac.uk/) (University of Oxford)
37
- - FreeSurfer [Laboratories for Computational Neuroimaging](https://lcn.martinos.org/) (Massachusetts General Hospital) uses NiiVue for [FreeBrowse](https://github.com/freesurfer/freebrowse)
38
- - [OpenNeuro.org](https://openneuro.org) uses NiiVue to visualize datasets
39
- - [neurodesk](https://www.neurodesk.org/) uses NiiVue for their [QSMxT Quantitative Susceptibility Mapping toolbox](https://github.com/QSMxT/QSMxT-UI)
40
- - [Neuroinformatics Research and Development Group](http://neuroinformatics.uw.edu/) embeds NiiVue in [tractoscope](https://github.com/nrdg/tractoscope)
41
- - [nilearn](https://nilearn.github.io/stable/index.html) is extending [ipyniivue](https://github.com/niivue/ipyniivue)
42
- - [niivue-vscode](https://github.com/niivue/niivue-vscode) is a VSCode extension for displaying images
43
- - [QuantCo](https://www.quantco.com/) is using NiiVue in medical imaging workflows
44
- - [FSL Clinical](https://fslclinical.com/) is using NiiVue in brain imaging reports
45
- - [brain2print](https://brain2print.org/) (from the NiiVue team) uses NiiVue for showing both volume data and converted meshes
46
- - [ct2print](https://ct2print.org/) (from the NiiVue team) uses NiiVue for showing volume and mesh data
47
- - [ipyniivue](https://github.com/niivue/ipyniivue) allows NiiVue to be used in Jupyter Notebooks
48
- - [T2Lesion](https://niivue.github.io/T2lesion/) (from the NiiVue team) uses NiiVue to show input data and segmented lesion masks
49
- - [NiiVue Desktop](https://github.com/niivue/desktop) (from the NiiVue team) uses NiiVue in a crossplatform Electron app
50
- - [NiiVue iOS](https://github.com/niivue/ios) (from the NiiVue team) uses NiiVue in a hybrid Swift + webView mobile app
51
- - [NiiVue Neglect](https://niivue.github.io/niivue-neglect/) uses NiiVue to visualise stroke lesion data in the spatial neglect severity prediction tool
52
- - [Plurimedia](https://www.plurimedia.it/) uses NiiVue in client work for medical image visualization
53
- - [Slice:Drop Reloaded](https://gaiborjosue.github.io/slicedrop.github.com/reload/) uses WebGL2-based NiiVue to extend the pioneering WebGL1-based [slicedrop](https://slicedrop.com/) that used the seminal XTK library.
54
- - [VoxLogicA-UI](https://voxlogica-project.github.io/VoxLogicA-UI/) makes advanced medical
55
- imaging analysis intuitive
56
-
57
- # Funding
58
-
59
- - 2021-2022 [P50 DC014664](https://reporter.nih.gov/search/D3sOjJtXwkSRKLpYf1ctBg/project-details/10094384) NIH NIDCD [NOT-OD-21-091](https://grants.nih.gov/grants/guide/notice-files/NOT-OD-21-091.html#:~:text=NOT%2DOD%2D21%2D091,Software%20Tools%20for%20Open%20Science)
60
- - 2023-2026 [RF1 MH133701](https://reporter.nih.gov/search/D3sOjJtXwkSRKLpYf1ctBg/project-details/10724895) NIH NIMH
61
-
62
- # Supported Formats
63
-
64
- NiiVue supports many popular brain imaging formats:
65
-
66
- - Voxel-based formats: [NIfTI](https://brainder.org/2012/09/23/the-nifti-file-format/), [NRRD](http://teem.sourceforge.net/nrrd/format.html), [MRtrix MIF](https://mrtrix.readthedocs.io/en/latest/getting_started/image_data.html#mrtrix-image-formats), [AFNI HEAD/BRIK](https://afni.nimh.nih.gov/pub/dist/doc/program_help/README.attributes.html), [MGH/MGZ](https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat), [ITK MHD](https://itk.org/Wiki/ITK/MetaIO/Documentation#Reading_a_Brick-of-Bytes_.28an_N-Dimensional_volume_in_a_single_file.29), [ECAT7](https://github.com/openneuropet/PET2BIDS/tree/28aae3fab22309047d36d867c624cd629c921ca6/ecat_validation/ecat_info), [DSI-Studio SRC](https://dsi-studio.labsolver.org/doc/cli_data.html).
67
- - Mesh-based formats: [GIfTI](https://www.nitrc.org/projects/gifti/), [ASC](http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm), [BYU/GEO/G](http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm), [BrainSuite DFS](http://brainsuite.org/formats/dfs/), [ICO/TRI](http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm), [PLY](<https://en.wikipedia.org/wiki/PLY_(file_format)>), [BrainNet NV](https://www.nitrc.org/projects/bnv/), [BrainVoyager SRF](https://support.brainvoyager.com/brainvoyager/automation-development/84-file-formats/344-users-guide-2-3-the-format-of-srf-files), [FreeSurfer](http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm), [MZ3](https://github.com/neurolabusc/surf-ice/tree/master/mz3), [OFF](<https://en.wikipedia.org/wiki/OFF_(file_format)>), [Wavefront OBJ](https://brainder.org/tag/obj/), [STL](https://medium.com/3d-printing-stories/why-stl-format-is-bad-fea9ecf5e45), [Legacy VTK](https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf), [WRL](https://en.wikipedia.org/wiki/VRML), [X3D](https://3dprint.nih.gov/).
68
- - Mesh overlay formats: [GIfTI](https://www.nitrc.org/projects/gifti/), [CIfTI-2](https://balsa.wustl.edu/about/fileTypes), [MZ3](https://github.com/neurolabusc/surf-ice/tree/master/mz3), [SMP](https://support.brainvoyager.com/brainvoyager/automation-development/84-file-formats/40-the-format-of-smp-files), STC, FreeSurfer (CURV/ANNOT)
69
- - Tractography formats: [TCK](https://mrtrix.readthedocs.io/en/latest/getting_started/image_data.html#tracks-file-format-tck), [TRK](http://trackvis.org/docs/?subsect=fileformat), [TRX](https://github.com/frheault/tractography_file_format), [TSF](https://mrtrix.readthedocs.io/en/dev/getting_started/image_data.html#track-scalar-file-format-tsf), [TT](https://dsi-studio.labsolver.org/doc/cli_data.html), VTK, AFNI .niml.tract
70
- - DICOM: [DICOM](https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html) and [DICOM Manifests](docs/development-notes/dicom-manifests.md)
package/build/index.d.ts CHANGED
@@ -152,13 +152,13 @@ declare class NVLabel3D {
152
152
  style: NVLabel3DStyle;
153
153
  points?: number[] | number[][];
154
154
  anchor: LabelAnchorPoint;
155
- onClick?: (label: NVLabel3D) => void;
155
+ onClick?: (label: NVLabel3D, e?: MouseEvent) => void;
156
156
  /**
157
157
  * @param text - The text of the label
158
158
  * @param style - The style of the label
159
159
  * @param points - An array of points label for label lines
160
160
  */
161
- constructor(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void);
161
+ constructor(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D, e?: MouseEvent) => void);
162
162
  }
163
163
 
164
164
  /**
@@ -390,7 +390,7 @@ declare class NVImage {
390
390
  */
391
391
  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
392
  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
- 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): Promise<NVImage>;
393
+ 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>;
394
394
  computeObliqueAngle(mtx44: mat4): number;
395
395
  float32V1asRGBA(inImg: Float32Array): Uint8Array;
396
396
  loadImgV1(isFlipX?: boolean, isFlipY?: boolean, isFlipZ?: boolean): boolean;
@@ -403,6 +403,7 @@ declare class NVImage {
403
403
  readNPZ(buffer: ArrayBuffer): Promise<ArrayBuffer>;
404
404
  imageDataFromArrayBuffer(buffer: ArrayBuffer): Promise<ImageData>;
405
405
  readBMP(buffer: ArrayBuffer): Promise<ArrayBuffer>;
406
+ readZARR(buffer: ArrayBuffer, zarrData: unknown): Promise<ArrayBufferLike>;
406
407
  readVMR(buffer: ArrayBuffer): ArrayBuffer;
407
408
  readFIB(buffer: ArrayBuffer): Promise<[ArrayBuffer, Float32Array]>;
408
409
  readSRC(buffer: ArrayBuffer): Promise<ArrayBuffer>;
@@ -428,7 +429,7 @@ declare class NVImage {
428
429
  * set contrast/brightness to robust range (2%..98%)
429
430
  * @param vol - volume for estimate (use -1 to use estimate on all loaded volumes; use INFINITY for current volume)
430
431
  * @param isBorder - if true (default) only center of volume used for estimate
431
- * @sets volume brightness and returns array [pct2, pct98, mnScale, mxScale]
432
+ * @returns volume brightness and returns array [pct2, pct98, mnScale, mxScale]
432
433
  * @see {@link https://niivue.github.io/niivue/features/timeseries2.html | live demo usage}
433
434
  */
434
435
  calMinMax(vol?: number, isBorder?: boolean): number[];
@@ -775,8 +776,10 @@ type NVConfigOptions = {
775
776
  isAlphaClipDark: boolean;
776
777
  gradientOrder: number;
777
778
  gradientOpacity: number;
779
+ renderSilhouette: number;
778
780
  gradientAmount: number;
779
781
  invertScrollDirection: boolean;
782
+ is2DSliceShader: boolean;
780
783
  };
781
784
  declare const DEFAULT_OPTIONS: NVConfigOptions;
782
785
  type SceneData = {
@@ -821,16 +824,16 @@ type Scene = {
821
824
  gamma?: number;
822
825
  };
823
826
  type DocumentData = {
824
- title: string;
825
- imageOptionsArray: ImageFromUrlOptions[];
826
- meshOptionsArray: unknown[];
827
- opts: NVConfigOptions;
828
- previewImageDataURL: string;
829
- labels: NVLabel3D[];
830
- encodedImageBlobs: string[];
831
- encodedDrawingBlob: string;
827
+ title?: string;
828
+ imageOptionsArray?: ImageFromUrlOptions[];
829
+ meshOptionsArray?: unknown[];
830
+ opts?: Partial<NVConfigOptions>;
831
+ previewImageDataURL?: string;
832
+ labels?: NVLabel3D[];
833
+ encodedImageBlobs?: string[];
834
+ encodedDrawingBlob?: string;
832
835
  meshesString?: string;
833
- sceneData?: SceneData;
836
+ sceneData?: Partial<SceneData>;
834
837
  connectomes?: string[];
835
838
  customData?: string;
836
839
  };
@@ -924,17 +927,25 @@ declare class NVDocument {
924
927
  */
925
928
  removeImage(image: NVImage): void;
926
929
  /**
927
- * Returns the options for the image if it was added by url
930
+ * Fetch any image data that is missing from this document.
931
+ * This includes loading image blobs for `ImageFromUrlOptions` with valid `url` fields.
932
+ * After calling this, `volumes` and `imageOptionsMap` will be populated.
928
933
  */
929
- getImageOptions(image: NVImage): ImageFromUrlOptions | null;
934
+ fetchLinkedData(): Promise<void>;
930
935
  /**
931
- * Converts NVDocument to JSON
936
+ * Returns the options for the image if it was added by url
932
937
  */
933
- json(): ExportDocumentData;
938
+ getImageOptions(image: NVImage): ImageFromUrlOptions | null;
934
939
  /**
935
- * Downloads a JSON file with options, scene, images, meshes and drawing of {@link Niivue} instance
940
+ * Serialise the document.
941
+ *
942
+ * @param embedImages If false, encodedImageBlobs is left empty
943
+ * (imageOptionsArray still records the URL / name).
936
944
  */
937
- download(fileName: string, compress: boolean): Promise<void>;
945
+ json(embedImages?: boolean): ExportDocumentData;
946
+ download(fileName: string, compress: boolean, opts?: {
947
+ embedImages: boolean;
948
+ }): Promise<void>;
938
949
  /**
939
950
  * Deserialize mesh data objects
940
951
  */
@@ -948,9 +959,20 @@ declare class NVDocument {
948
959
  */
949
960
  static loadFromFile(file: Blob): Promise<NVDocument>;
950
961
  /**
951
- * Factory method to return an instance of NVDocument from JSON
962
+ * Factory method to return an instance of NVDocument from JSON.
963
+ *
964
+ * This will merge any saved configuration options (`opts`) with the DEFAULT_OPTIONS,
965
+ * ensuring any missing values are filled with defaults. It also restores special-case
966
+ * fields like `meshThicknessOn2D` when serialized as the string "infinity".
967
+ *
968
+ * @param data - A serialized DocumentData object
969
+ * @returns A reconstructed NVDocument instance
952
970
  */
953
971
  static loadFromJSON(data: DocumentData): NVDocument;
972
+ /**
973
+ * Factory method to return an instance of NVDocument from JSON
974
+ */
975
+ static oldloadFromJSON(data: DocumentData): NVDocument;
954
976
  }
955
977
 
956
978
  type NiftiHeader = {
@@ -1036,6 +1058,7 @@ type ConnectomeOptions = {
1036
1058
  edgeMax: number;
1037
1059
  edgeScale: number;
1038
1060
  legendLineThickness?: number;
1061
+ showLegend?: boolean;
1039
1062
  };
1040
1063
  type Connectome = ConnectomeOptions & {
1041
1064
  nodes: NVConnectomeNode[];
@@ -1204,6 +1227,9 @@ type NVMeshLayer = {
1204
1227
  colormapType?: number;
1205
1228
  base64?: string;
1206
1229
  colorbarVisible?: boolean;
1230
+ showLegend?: boolean;
1231
+ labels?: NVLabel3D[];
1232
+ atlasValues?: AnyNumberArray;
1207
1233
  };
1208
1234
  declare const NVMeshLayerDefaults: {
1209
1235
  colormap: string;
@@ -1217,6 +1243,8 @@ declare const NVMeshLayerDefaults: {
1217
1243
  cal_maxNeg: number;
1218
1244
  colormapType: COLORMAP_TYPE;
1219
1245
  values: number[];
1246
+ useNegativeCmap: boolean;
1247
+ showLegend: boolean;
1220
1248
  };
1221
1249
  declare class NVMeshFromUrlOptions {
1222
1250
  url: string;
@@ -1297,6 +1325,7 @@ declare class NVMesh {
1297
1325
  nodeScale: number;
1298
1326
  edgeScale: number;
1299
1327
  legendLineThickness: number;
1328
+ showLegend: boolean;
1300
1329
  nodeColormap: string;
1301
1330
  edgeColormap: string;
1302
1331
  nodeColormapNegative?: string;
@@ -1330,6 +1359,7 @@ declare class NVMesh {
1330
1359
  updateFibers(gl: WebGL2RenderingContext): void;
1331
1360
  indexNearestXYZmm(Xmm: number, Ymm: number, Zmm: number): number[];
1332
1361
  unloadMesh(gl: WebGL2RenderingContext): void;
1362
+ scalars2RGBA(rgba: Uint8ClampedArray, layer: NVMeshLayer, scalars: AnyNumberArray, isNegativeCmap?: boolean): Uint8ClampedArray;
1333
1363
  blendColormap(u8: Uint8Array, additiveRGBA: Uint8Array, layer: NVMeshLayer, mn: number, mx: number, lut: Uint8ClampedArray, invert?: boolean): void;
1334
1364
  updateMesh(gl: WebGL2RenderingContext): void;
1335
1365
  reverseFaces(gl: WebGL2RenderingContext): void;
@@ -1498,6 +1528,7 @@ type Graph = {
1498
1528
  lineColor?: number[];
1499
1529
  textColor?: number[];
1500
1530
  lineThickness?: number;
1531
+ gridLineThickness?: number;
1501
1532
  lineAlpha?: number;
1502
1533
  lines?: number[][];
1503
1534
  selectedColumn?: number;
@@ -1565,6 +1596,8 @@ type UIData = {
1565
1596
  lastTwoTouchDistance: number;
1566
1597
  multiTouchGesture: boolean;
1567
1598
  dpr?: number;
1599
+ max2D?: number;
1600
+ max3D?: number;
1568
1601
  windowX: number;
1569
1602
  windowY: number;
1570
1603
  };
@@ -1617,6 +1650,7 @@ declare class Niivue {
1617
1650
  overlayTexture: WebGLTexture | null;
1618
1651
  overlayTextureID: WebGLTexture | null;
1619
1652
  sliceMMShader?: Shader;
1653
+ slice2DShader?: Shader;
1620
1654
  sliceV1Shader?: Shader;
1621
1655
  orientCubeShader?: Shader;
1622
1656
  orientCubeShaderVAO: WebGLVertexArrayObject | null;
@@ -2270,7 +2304,7 @@ declare class Niivue {
2270
2304
  binarize(volume: NVImage): void;
2271
2305
  /**
2272
2306
  * Open drawing
2273
- * @param filename - of NIfTI format drawing
2307
+ * @param fnm - filename of NIfTI format drawing
2274
2308
  * @param isBinarize - if true will force drawing voxels to be either 0 or 1.
2275
2309
  * @example niivue.loadDrawingFromUrl("../images/lesion.nii.gz");
2276
2310
  * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
@@ -2293,12 +2327,17 @@ declare class Niivue {
2293
2327
  */
2294
2328
  removeHaze(level?: number, volIndex?: number): void;
2295
2329
  /**
2296
- * save voxel-based image to disk
2297
- * @param fnm - filename of NIfTI image to create
2298
- * @param isSaveDrawing - determines whether drawing or background image is saved
2299
- * @param volumeByIndex - determines layer to save (0 for background)
2300
- * @param volumeByIndex - determines layer to save (0 for background)
2301
- * @example niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
2330
+ * Save voxel-based image to disk.
2331
+ *
2332
+ * @param options - configuration object with the following fields:
2333
+ * - `filename`: name of the NIfTI image to create
2334
+ * - `isSaveDrawing`: whether to save the drawing layer or the background image
2335
+ * - `volumeByIndex`: which image layer to save (0 for background)
2336
+ * @returns `true` if successful when writing to disk, or a `Uint8Array` if exported as binary data
2337
+ *
2338
+ * @example
2339
+ * niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
2340
+ * niivue.saveImage({ filename: "myimage.nii.gz", isSaveDrawing: true });
2302
2341
  * @see {@link https://niivue.github.io/niivue/features/draw.ui.html | live demo usage}
2303
2342
  */
2304
2343
  saveImage(options?: SaveImageOptions): Promise<boolean | Uint8Array>;
@@ -2307,14 +2346,14 @@ declare class Niivue {
2307
2346
  * change property of mesh, tractogram or connectome
2308
2347
  * @param id - identity of mesh to change
2309
2348
  * @param key - attribute to change
2310
- * @param value - for attribute
2349
+ * @param val - for attribute
2311
2350
  * @example niivue.setMeshProperty(niivue.meshes[0].id, 'fiberLength', 42)
2312
2351
  * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
2313
2352
  */
2314
2353
  setMeshProperty(id: number, key: keyof NVMesh, val: number | string | boolean | Uint8Array | number[] | ColorMap | LegacyConnectome | Float32Array): void;
2315
2354
  /**
2316
2355
  * returns the index of the mesh vertex that is closest to the provided coordinates
2317
- * @param id - identity of mesh to change
2356
+ * @param mesh - identity of mesh to change
2318
2357
  * @param Xmm - location in left/right dimension
2319
2358
  * @param Ymm - location in posterior/anterior dimension
2320
2359
  * @param Zmm - location in foot/head dimension
@@ -2334,7 +2373,7 @@ declare class Niivue {
2334
2373
  decimateHierarchicalMesh(mesh: number, order?: number): boolean;
2335
2374
  /**
2336
2375
  * reverse triangle winding of mesh (swap front and back faces)
2337
- * @param id - identity of mesh to change
2376
+ * @param mesh - identity of mesh to change
2338
2377
  * @example niivue.reverseFaces(niivue.meshes[0].id)
2339
2378
  * @see {@link https://niivue.github.io/niivue/features/meshes.html | live demo usage}
2340
2379
  */
@@ -2344,7 +2383,7 @@ declare class Niivue {
2344
2383
  * @param mesh - identity of mesh to change
2345
2384
  * @param layer - selects the mesh overlay (e.g. GIfTI or STC file)
2346
2385
  * @param key - attribute to change
2347
- * @param value - for attribute
2386
+ * @param val - value for attribute
2348
2387
  * @example niivue.setMeshLayerProperty(niivue.meshes[0].id, 0, 'frame4D', 22)
2349
2388
  * @see {@link https://niivue.github.io/niivue/features/mesh.4D.html | live demo usage}
2350
2389
  */
@@ -2455,8 +2494,11 @@ declare class Niivue {
2455
2494
  */
2456
2495
  sph2cartDeg(azimuth: number, elevation: number): number[];
2457
2496
  /**
2458
- * update the clip plane orientation in 3D view mode
2459
- * @param azimuthElevationDepth - a two component vector. azimuth: camera position in degrees around object, typically 0..360 (or -180..+180). elevation: camera height in degrees, range -90..90
2497
+ * Update the clip plane orientation in 3D view mode.
2498
+ * @param depthAzimuthElevation - a 3-component array:
2499
+ * - `depth`: distance of clip plane from center of volume (0 to ~1.73, or >2.0 to disable clipping)
2500
+ * - `azimuth`: camera angle around the object in degrees (0–360 or -180–180)
2501
+ * - `elevation`: camera height in degrees (-90 to 90)
2460
2502
  * @example
2461
2503
  * niivue = new Niivue()
2462
2504
  * niivue.setClipPlane([42, 42])
@@ -2513,7 +2555,7 @@ declare class Niivue {
2513
2555
  sliceScroll2D(posChange: number, x: number, y: number, isDelta?: boolean): void;
2514
2556
  /**
2515
2557
  * set the slice type. This changes the view mode
2516
- * @param sliceType - an enum of slice types to use
2558
+ * @param st - sliceType is an enum of slice types to use
2517
2559
  * @example
2518
2560
  * niivue = new Niivue()
2519
2561
  * niivue.setSliceType(Niivue.sliceTypeMultiplanar)
@@ -2556,7 +2598,8 @@ declare class Niivue {
2556
2598
  setClipPlaneThick(thick: number): void;
2557
2599
  /**
2558
2600
  * set the clipping region for volume rendering
2559
- * @param color - the new color. expects an array of RGBA values. values can range from 0 to 1
2601
+ * @param low - 3-component array specifying the lower bound of the clipping region along the X, Y, and Z axes. Values range from 0 (start) to 1 (end of volume).
2602
+ * @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.
2560
2603
  * @example
2561
2604
  * niivue.setClipPlaneColor([0.0, 0.0, 0.2], [1.0, 1.0, 0.7]) // remove inferior 20% and superior 30%
2562
2605
  * @see {@link https://niivue.github.io/niivue/features/clipplanes.html | live demo usage}
@@ -2574,11 +2617,12 @@ declare class Niivue {
2574
2617
  /**
2575
2618
  * set volume rendering opacity influence of the gradient magnitude
2576
2619
  * @param gradientOpacity - amount of gradient magnitude influence on opacity (0..1), default 0 (no-influence)
2620
+ * @param renderSilhouette - make core transparent to enhance rims (0..1), default 0 (no-influence)
2577
2621
  * @example
2578
2622
  * niivue.setGradientOpacity(0.6);
2579
2623
  * @see {@link https://niivue.github.io/niivue/features/gradient.opacity.html | live demo usage}
2580
2624
  */
2581
- setGradientOpacity(gradientOpacity?: number): Promise<void>;
2625
+ setGradientOpacity(gradientOpacity?: number, renderSilhouette?: number): Promise<void>;
2582
2626
  overlayRGBA(volume: NVImage): Uint8ClampedArray;
2583
2627
  vox2mm(XYZ: number[], mtx: mat4): vec3;
2584
2628
  /**
@@ -2634,14 +2678,22 @@ declare class Niivue {
2634
2678
  */
2635
2679
  json(): ExportDocumentData;
2636
2680
  /**
2637
- * save the entire scene (objects and settings) as a document
2638
- * @param fileName - the name of the document storing the scene
2639
- * @param compress - whether the file should be compressed
2681
+ * Save the current scene as an .nvd document.
2682
+ *
2683
+ * @param fileName Name of the file to create (default "untitled.nvd")
2684
+ * @param compress If true, gzip-compress the JSON (default true)
2685
+ * @param options Fine-grained switches:
2686
+ * • embedImages – store encodedImageBlobs (default true)
2687
+ * • embedPreview – store previewImageDataURL (default true)
2688
+ *
2640
2689
  * @example
2641
- * niivue.saveDocument("niivue.basic.nvd")
2642
- * @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
2690
+ * // smallest possible file – no preview, just metadata
2691
+ * await nv.saveDocument('scene.nvd', true, { embedImages:false, embedPreview:false });
2643
2692
  */
2644
- saveDocument(fileName?: string, compress?: boolean): Promise<void>;
2693
+ saveDocument(fileName?: string, compress?: boolean, options?: {
2694
+ embedImages?: boolean;
2695
+ embedPreview?: boolean;
2696
+ }): Promise<void>;
2645
2697
  loadImages(images: Array<ImageFromUrlOptions | LoadFromUrlParams>): Promise<this>;
2646
2698
  loadDicoms(dicomList: ImageFromUrlOptions[]): Promise<this>;
2647
2699
  /**
@@ -2673,20 +2725,25 @@ declare class Niivue {
2673
2725
  */
2674
2726
  loadMeshes(meshList: LoadFromUrlParams[]): Promise<this>;
2675
2727
  /**
2676
- * load a connectome specified by url
2677
- * @returns Niivue instance
2728
+ * Load a connectome from a given URL and initialize it.
2729
+ *
2730
+ * @param url - the URL to a JSON-formatted connectome definition
2731
+ * @param headers - optional HTTP headers to include with the request (e.g. for authorization)
2732
+ * @returns the `Niivue` instance (for method chaining)
2678
2733
  * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2679
2734
  */
2680
2735
  loadConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
2681
2736
  /**
2682
- * load a connectome specified by url
2683
- * @returns Niivue instance
2737
+ * Load a FreeSurfer-style connectome from a given URL and initialize it.
2738
+ * @param url - the URL of the JSON-formatted connectome file
2739
+ * @param headers - optional HTTP headers to include in the fetch request (e.g. for authorization)
2740
+ * @returns the `Niivue` instance (for method chaining)
2684
2741
  * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2685
2742
  */
2686
2743
  loadFreeSurferConnectomeFromUrl(url: string, headers?: {}): Promise<this>;
2687
2744
  /**
2688
2745
  * load a connectome specified by json
2689
- * @param connectome - freesurfer model
2746
+ * @param json - freesurfer model
2690
2747
  * @returns Niivue instance
2691
2748
  * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2692
2749
  */
@@ -2699,7 +2756,7 @@ declare class Niivue {
2699
2756
  loadConnectomeAsMesh(json: Connectome | LegacyConnectome | FreeSurferConnectome): NVMesh;
2700
2757
  /**
2701
2758
  * load a connectome specified by json
2702
- * @param connectome - model
2759
+ * @param json - connectome model
2703
2760
  * @returns Niivue instance
2704
2761
  * @see {@link https://niivue.github.io/niivue/features/connectome.html | live demo usage}
2705
2762
  */
@@ -2744,7 +2801,9 @@ declare class Niivue {
2744
2801
  * @see {@link https://niivue.github.io/niivue/features/cactus.html | live demo usage}
2745
2802
  */
2746
2803
  refreshDrawing(isForceRedraw?: boolean, useClickToSegmentBitmap?: boolean): void;
2804
+ r8Tex2D(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
2747
2805
  r8Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
2806
+ rgbaTex2D(texID: WebGLTexture | null, activeID: number, dims: number[], data?: Uint8Array | null, isFlipVertical?: boolean): WebGLTexture | null;
2748
2807
  rgbaTex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
2749
2808
  rgba16Tex(texID: WebGLTexture | null, activeID: number, dims: number[], isInit?: boolean): WebGLTexture | null;
2750
2809
  requestCORSIfNotSameOrigin(img: HTMLImageElement, url: string): void;
@@ -2753,7 +2812,7 @@ declare class Niivue {
2753
2812
  loadBmpTexture(bmpUrl: string): Promise<WebGLTexture | null>;
2754
2813
  /**
2755
2814
  * Load matcap for illumination model.
2756
- * @param name - name of matcap to load ("Shiny", "Cortex", "Cream")
2815
+ * @param bmpUrl - name of matcap to load ("Shiny", "Cortex", "Cream")
2757
2816
  * @example
2758
2817
  * niivue.loadMatCapTexture("Cortex");
2759
2818
  * @see {@link https://niivue.github.io/niivue/features/shiny.volumes.html | live demo usage}
@@ -2762,7 +2821,9 @@ declare class Niivue {
2762
2821
  initFontMets(): void;
2763
2822
  /**
2764
2823
  * Load typeface for colorbars, measurements and orientation text.
2765
- * @param name - name of matcap to load ("Roboto", "Garamond", "Ubuntu")
2824
+ * @param fontSheetUrl - URL to a bitmap font sheet image (e.g., a PNG atlas of glyphs)
2825
+ * @param metricsUrl - URL to the corresponding font metrics JSON (defines character bounds and spacing)
2826
+ * @returns a Promise that resolves when the font is loaded
2766
2827
  * @example
2767
2828
  * niivue.loadMatCapTexture("Cortex");
2768
2829
  * @see {@link https://niivue.github.io/niivue/features/selectfont.html | live demo usage}
@@ -2832,9 +2893,9 @@ declare class Niivue {
2832
2893
  };
2833
2894
  /**
2834
2895
  * Define a new GLSL shader program to influence mesh coloration
2835
- * @param fragmentShaderText - custom fragment shader.
2836
- * @param ame - title for new shader.
2837
- * @returns index of the new shader (for setMeshShader)
2896
+ * @param fragmentShaderText - the GLSL source code for the custom fragment shader
2897
+ * @param name - a descriptive label for the shader (used in menus or debugging)
2898
+ * @returns the index of the new shader (use with {@link setMeshShader})
2838
2899
  * @see {@link https://niivue.github.io/niivue/features/mesh.atlas.html | live demo usage}
2839
2900
  */
2840
2901
  setCustomMeshShader(fragmentShaderText?: string, name?: string): number;
@@ -2889,7 +2950,6 @@ declare class Niivue {
2889
2950
  refreshLayers(overlayItem: NVImage, layer: number): void;
2890
2951
  /**
2891
2952
  * query all available color maps that can be applied to volumes
2892
- * @param sort - whether or not to sort the returned array
2893
2953
  * @returns an array of colormap strings
2894
2954
  * @example
2895
2955
  * niivue = new Niivue()
@@ -2900,7 +2960,7 @@ declare class Niivue {
2900
2960
  /**
2901
2961
  * create a new colormap
2902
2962
  * @param key - name of new colormap
2903
- * @param colormap - properties (Red, Green, Blue, Alpha and Indices)
2963
+ * @param cmap - colormap properties (Red, Green, Blue, Alpha and Indices)
2904
2964
  * @see {@link https://niivue.github.io/niivue/features/colormaps.html | live demo usage}
2905
2965
  */
2906
2966
  addColormap(key: string, cmap: ColorMap): void;
@@ -2940,7 +3000,7 @@ declare class Niivue {
2940
3000
  conform(volume: NVImage, toRAS?: boolean, isLinear?: boolean, asFloat32?: boolean, isRobustMinMax?: boolean): Promise<NVImage>;
2941
3001
  /**
2942
3002
  * darken crevices and brighten corners when 3D rendering drawings.
2943
- * @param amount - amount of ambient occlusion (default 0.4)
3003
+ * @param ao - amount of ambient occlusion (default 0.4)
2944
3004
  * @see {@link https://niivue.github.io/niivue/features/torso.html | live demo usage}
2945
3005
  */
2946
3006
  setRenderDrawAmbientOcclusion(ao: number): void;
@@ -3074,9 +3134,13 @@ declare class Niivue {
3074
3134
  createOnLocationChange(axCorSag?: number): void;
3075
3135
  /**
3076
3136
  * Add a 3D Label
3077
- * @param text - text of the label
3078
- * @param style - label style
3079
- * @param point - 3D point on the model
3137
+ * @param text - the text content of the label
3138
+ * @param style - visual styling options for the label (e.g., color, scale, line width)
3139
+ * @param points - a 3D point `[x, y, z]` or array of points to anchor the label in space
3140
+ * @param anchor - optional label anchor position (e.g., top-left, center, etc.)
3141
+ * @param onClick - optional callback function to invoke when the label is clicked
3142
+ * @returns the created `NVLabel3D` instance
3143
+ * @see {@link https://niivue.github.io/niivue/features/labels.html | live demo usage}
3080
3144
  */
3081
3145
  addLabel(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void): NVLabel3D;
3082
3146
  calculateScreenPoint(point: [number, number, number], mvpMatrix: mat4, leftTopWidthHeight: number[]): vec4;