@niivue/niivue 0.39.0 → 0.40.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
@@ -26,9 +26,10 @@ The command `npm run demo` will minify the project and locally host all of the [
26
26
  # Projects and People using NiiVue
27
27
 
28
28
  - Analysis of Functional NeuroImages (AFNI) [Scientific and Statistical Computing Core](https://afni.nimh.nih.gov/) (National Institutes of Health)
29
+ - [ChRIS Research Integration System (ChRIS) from Boston Children's Hospital](https://chrisproject.org/) uses [NiiVue](https://app.chrisproject.org/niivue).
29
30
  - [Center for the Study of Aphasia Recovery](https://cstar.sc.edu/) (University of South Carolina)
30
31
  - FMRIB's Software Library (FSL) [Wellcome Centre for Integrative Neuroimaging](https://www.win.ox.ac.uk/) (University of Oxford)
31
- - FreeSurfer [Laboratories for Computational Neuroimaging](https://lcn.martinos.org/) (Massachusetts General Hospital)
32
+ - FreeSurfer [Laboratories for Computational Neuroimaging](https://lcn.martinos.org/) (Massachusetts General Hospital) uses NiiVue for [FreeBrowse](https://github.com/freesurfer/freebrowse)
32
33
  - [OpenNeuro.org](https://openneuro.org) uses NiiVue to visualize datasets
33
34
  - [BrainLife.io](https://brainlife.io/about/) integrates NiiVue into [ezbids](https://brainlife.io/ezbids/)
34
35
  - [nilearn](https://nilearn.github.io/stable/index.html) is extending [ipyniivue](https://github.com/niivue/ipyniivue)
@@ -50,5 +51,5 @@ NiiVue supports many popular brain imaging formats:
50
51
  - 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).
51
52
  - 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), [X3D](https://3dprint.nih.gov/).
52
53
  - 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)
53
- - 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), VTK, AFNI .niml.tract
54
+ - 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
54
55
  - DICOM: [DICOM](https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html) and [DICOM Manifests](docs/development-notes/dicom-manifests.md)
@@ -248,6 +248,10 @@ type LegacyConnectome = Partial<ConnectomeOptions> & {
248
248
  type ValuesArray = Array<{
249
249
  id: string;
250
250
  vals: number[];
251
+ global_min?: number;
252
+ global_max?: number;
253
+ cal_min?: number;
254
+ cal_max?: number;
251
255
  }>;
252
256
  type TypedNumberArray = Float64Array | Float32Array | Uint32Array | Uint16Array | Uint8Array | Int32Array | Int16Array | Int8Array;
253
257
  type AnyNumberArray = number[] | TypedNumberArray;
@@ -397,6 +401,7 @@ declare class NVMesh {
397
401
  indexBuffer: WebGLBuffer;
398
402
  vertexBuffer: WebGLBuffer;
399
403
  vao: WebGLVertexArrayObject;
404
+ vaoFiber: WebGLVertexArrayObject;
400
405
  pts: number[] | Float32Array;
401
406
  tris?: number[] | Uint32Array;
402
407
  layers: NVMeshLayer[];
@@ -408,6 +413,9 @@ declare class NVMesh {
408
413
  fiberDither: number;
409
414
  fiberColor: string;
410
415
  fiberDecimationStride: number;
416
+ fiberSides: number;
417
+ fiberRadius: number;
418
+ f32PerVertex: number;
411
419
  fiberMask?: unknown[];
412
420
  colormap?: ColorMap | LegacyConnectome | string | null;
413
421
  dpg?: ValuesArray | null;
@@ -446,8 +454,10 @@ declare class NVMesh {
446
454
  * @param anatomicalStructurePrimary - region for mesh. Default is an empty string
447
455
  */
448
456
  constructor(pts: number[] | Float32Array, tris: number[] | Uint32Array, name: string | undefined, rgba255: number[] | undefined, opacity: number | undefined, visible: boolean | undefined, gl: WebGL2RenderingContext, connectome?: LegacyConnectome | string | null, dpg?: ValuesArray | null, dps?: ValuesArray | null, dpv?: ValuesArray | null, colorbarVisible?: boolean, anatomicalStructurePrimary?: string);
457
+ linesToCylinders(gl: WebGL2RenderingContext, posClrF32: Float32Array, indices: number[]): void;
449
458
  updateFibers(gl: WebGL2RenderingContext): void;
450
459
  updateConnectome(gl: WebGL2RenderingContext): void;
460
+ indexNearestXYZmm(Xmm: number, Ymm: number, Zmm: number): number[];
451
461
  updateMesh(gl: WebGL2RenderingContext): void;
452
462
  reverseFaces(gl: WebGL2RenderingContext): void;
453
463
  setLayerProperty(id: number, key: keyof NVMeshLayer, val: number | string | boolean, gl: WebGL2RenderingContext): void;
@@ -500,6 +510,7 @@ declare class NVMesh {
500
510
  static readTxtVTK(buffer: ArrayBuffer): VTK;
501
511
  static readTRK(buffer: ArrayBuffer): TRK;
502
512
  static readTCK(buffer: ArrayBuffer): TCK;
513
+ static readTSF(buffer: ArrayBuffer): Float32Array;
503
514
  static readTT(buffer: ArrayBuffer): TT;
504
515
  static readTRX(buffer: ArrayBuffer): TRX;
505
516
  static readTRACT(buffer: ArrayBuffer): TRACT;
@@ -752,7 +763,7 @@ declare class NVImage {
752
763
  * factory function to load and return a new NVImage instance from a given URL
753
764
  * @returns NVImage instance
754
765
  */
755
- static loadFromUrl({ url, urlImgData, headers, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, visible, useQFormNotSForm, colormapNegative, frame4D, isManifest, limitFrames4D, imageType }?: Partial<Omit<ImageFromUrlOptions, 'url'>> & {
766
+ static loadFromUrl({ url, urlImgData, headers, name, colormap, opacity, cal_min, cal_max, trustCalMinMax, percentileFrac, ignoreZeroVoxels, visible, useQFormNotSForm, colormapNegative, frame4D, isManifest, limitFrames4D, imageType, colorbarVisible }?: Partial<Omit<ImageFromUrlOptions, 'url'>> & {
756
767
  url?: string | Uint8Array | ArrayBuffer;
757
768
  }): Promise<NVImage>;
758
769
  static readFileAsync(file: File, bytesToLoad?: number): Promise<ArrayBuffer>;
@@ -814,6 +825,10 @@ declare class NVImage {
814
825
  * Converts NVImage to NIfTI compliant byte array
815
826
  */
816
827
  toUint8Array(drawingBytes?: Uint8Array | null): Uint8Array;
828
+ convertVox2Frac(vox: vec3): vec3;
829
+ convertFrac2Vox(frac: vec3): vec3;
830
+ convertFrac2MM(frac: vec3, isForceSliceMM?: boolean): vec4;
831
+ convertMM2Frac(mm: vec3 | vec4, isForceSliceMM?: boolean): vec3;
817
832
  }
818
833
 
819
834
  type FreeSurferConnectome = {
@@ -912,13 +927,16 @@ type NVConfigOptions = {
912
927
  isRadiologicalConvention: boolean;
913
928
  meshThicknessOn2D: number | string;
914
929
  dragMode: DRAG_MODE;
930
+ yoke3Dto2DZoom: boolean;
915
931
  isDepthPickMesh: boolean;
916
932
  isCornerOrientationText: boolean;
917
933
  sagittalNoseLeft: boolean;
918
934
  isSliceMM: boolean;
935
+ isV1SliceShader: boolean;
919
936
  isHighResolutionCapable: boolean;
920
937
  logLevel: 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent';
921
938
  loadingText: string;
939
+ isForceMouseClickToVoxelCenters: boolean;
922
940
  dragAndDropEnabled: boolean;
923
941
  drawingEnabled: boolean;
924
942
  penValue: number;
@@ -1317,6 +1335,16 @@ declare class NVUtilities {
1317
1335
  * @returns filled number array
1318
1336
  */
1319
1337
  static range(start: number, stop: number, step: number): number[];
1338
+ /**
1339
+ * convert spherical AZIMUTH, ELEVATION to Cartesian
1340
+ * @param azimuth - azimuth number
1341
+ * @param elevation - elevation number
1342
+ * @returns the converted [x, y, z] coordinates
1343
+ * @example
1344
+ * xyz = NVUtilities.sph2cartDeg(42, 42)
1345
+ */
1346
+ static sph2cartDeg(azimuth: number, elevation: number): number[];
1347
+ static vox2mm(XYZ: number[], mtx: mat4): vec3;
1320
1348
  }
1321
1349
 
1322
1350
  /**
@@ -1326,10 +1354,11 @@ declare class NVMeshLoaders {
1326
1354
  static readTRACT(buffer: ArrayBuffer): TRACT;
1327
1355
  static readTT(buffer: ArrayBuffer): TT;
1328
1356
  static readTRX(buffer: ArrayBuffer): TRX;
1357
+ static readTSF(buffer: ArrayBuffer, n_vert?: number): Float32Array;
1329
1358
  static readTCK(buffer: ArrayBuffer): TCK;
1330
1359
  static readTRK(buffer: ArrayBuffer): TRK;
1331
1360
  static readTxtVTK(buffer: ArrayBuffer): VTK;
1332
- static readLayer(name: string, buffer: ArrayBuffer, nvmesh: NVMesh, opacity?: number, colormap?: string, colormapNegative?: string, useNegativeCmap?: boolean, cal_min?: number | null, cal_max?: number | null, isOutlineBorder?: boolean): void;
1361
+ static readLayer(name: string | undefined, buffer: ArrayBuffer, nvmesh: NVMesh, opacity?: number, colormap?: string, colormapNegative?: string, useNegativeCmap?: boolean, cal_min?: number | null, cal_max?: number | null, isOutlineBorder?: boolean): void;
1333
1362
  static readSMP(buffer: ArrayBuffer, n_vert: number): Float32Array;
1334
1363
  static readSTC(buffer: ArrayBuffer, n_vert: number): Float32Array;
1335
1364
  static readCURV(buffer: ArrayBuffer, n_vert: number): Float32Array;
@@ -1467,12 +1496,15 @@ type NiiVueOptions = {
1467
1496
  isCornerOrientationText?: boolean;
1468
1497
  sagittalNoseLeft?: boolean;
1469
1498
  isSliceMM?: boolean;
1499
+ isV1SliceShader?: boolean;
1470
1500
  isHighResolutionCapable?: boolean;
1501
+ isForceMouseClickToVoxelCenters?: boolean;
1471
1502
  drawingEnabled?: boolean;
1472
1503
  penValue?: number;
1473
1504
  floodFillNeighbors?: number;
1474
1505
  maxDrawUndoBitmaps?: number;
1475
1506
  thumbnail?: string;
1507
+ meshXRay?: number;
1476
1508
  };
1477
1509
  type UIData = {
1478
1510
  mousedown: boolean;
@@ -1535,6 +1567,7 @@ declare class Niivue {
1535
1567
  overlayTexture: WebGLTexture | null;
1536
1568
  overlayTextureID: WebGLTexture | null;
1537
1569
  sliceMMShader?: Shader;
1570
+ sliceV1Shader?: Shader;
1538
1571
  orientCubeShader?: Shader;
1539
1572
  orientCubeShaderVAO: WebGLVertexArrayObject | null;
1540
1573
  rectShader?: Shader;
@@ -1821,13 +1854,16 @@ declare class Niivue {
1821
1854
  isRadiologicalConvention: boolean;
1822
1855
  meshThicknessOn2D: string | number;
1823
1856
  dragMode: DRAG_MODE;
1857
+ yoke3Dto2DZoom: boolean;
1824
1858
  isDepthPickMesh: boolean;
1825
1859
  isCornerOrientationText: boolean;
1826
1860
  sagittalNoseLeft: boolean;
1827
1861
  isSliceMM: boolean;
1862
+ isV1SliceShader: boolean;
1828
1863
  isHighResolutionCapable: boolean;
1829
1864
  logLevel: "debug" | "info" | "warn" | "error" | "fatal" | "silent";
1830
1865
  loadingText: string;
1866
+ isForceMouseClickToVoxelCenters: boolean;
1831
1867
  dragAndDropEnabled: boolean;
1832
1868
  drawingEnabled: boolean;
1833
1869
  penValue: number;
@@ -2348,7 +2384,7 @@ declare class Niivue {
2348
2384
  * niivue.setCrosshairColor([0, 1, 0, 0.5]) // set crosshair to transparent green
2349
2385
  * @see {@link https://niivue.github.io/niivue/features/colormaps.html|live demo usage}
2350
2386
  */
2351
- setCrosshairColor(color: number[]): Promise<void>;
2387
+ setCrosshairColor(color: number[]): void;
2352
2388
  /**
2353
2389
  * set thickness of crosshair
2354
2390
  * @example niivue.crosshairWidth(2)