@niivue/niivue 0.44.1 → 0.44.2-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,15 @@ The command `npm run demo` will minify the project and locally host all of the [
46
46
  - [Neuroinformatics Research and Development Group](http://neuroinformatics.uw.edu/) embeds NiiVue in [tractoscope](https://github.com/nrdg/tractoscope)
47
47
  - [nilearn](https://nilearn.github.io/stable/index.html) is extending [ipyniivue](https://github.com/niivue/ipyniivue)
48
48
  - [niivue-vscode](https://github.com/niivue/niivue-vscode) is a VSCode extension for displaying images
49
+ - [QuantCo](https://www.quantco.com/) is using NiiVue in medical imaging workflows
50
+ - [FSL Clinical](https://fslclinical.com/) is using NiiVue in brain imaging reports
51
+ - [brain2print](https://brain2print.org/) (from the NiiVue team) uses NiiVue for showing both volume data and converted meshes
52
+ - [ct2print](https://ct2print.org/) (from the NiiVue team) uses NiiVue for showing volume and mesh data
53
+ - [ipyniivue](https://github.com/niivue/ipyniivue) allows NiiVue to be used in Jupyter Notebooks
54
+ - [T2Lesion](https://niivue.github.io/T2lesion/) (from the NiiVue team) uses NiiVue to show input data and segmented lesion masks
55
+ - [NiiVue Desktop](https://github.com/niivue/desktop) (from the NiiVue team) uses NiiVue in a crossplatform Electron app
56
+ - [NiiVue iOS](https://github.com/niivue/ios) (from the NiiVue team) uses NiiVue in a hybrid Swift + webView mobile app
57
+ - [NiiVue Neglect](https://niivue.github.io/niivue-neglect/) uses NiiVue to visualise stroke lesion data in the spatial neglect severity prediction tool
49
58
 
50
59
  # Funding
51
60
 
package/build/index.d.ts CHANGED
@@ -107,6 +107,18 @@ declare enum LabelLineTerminator {
107
107
  CIRCLE = "circle",
108
108
  RING = "ring"
109
109
  }
110
+ declare enum LabelAnchorPoint {
111
+ NONE = 0,
112
+ TOPLEFT = 9,
113
+ TOPCENTER = 10,
114
+ TOPRIGHT = 12,
115
+ MIDDLELEFT = 17,
116
+ MIDDLECENTER = 18,
117
+ MIDDLERIGHT = 20,
118
+ BOTTOMLEFT = 33,
119
+ BOTTOMCENTER = 34,
120
+ BOTTOMRIGHT = 36
121
+ }
110
122
  /**
111
123
  * Class representing label style.
112
124
  * @ignore
@@ -140,12 +152,14 @@ declare class NVLabel3D {
140
152
  text: string;
141
153
  style: NVLabel3DStyle;
142
154
  points?: number[] | number[][];
155
+ anchor: LabelAnchorPoint;
156
+ onClick?: (label: NVLabel3D) => void;
143
157
  /**
144
158
  * @param text - The text of the label
145
159
  * @param style - The style of the label
146
160
  * @param points - An array of points label for label lines
147
161
  */
148
- constructor(text: string, style: NVLabel3DStyle, points?: number[] | number[][]);
162
+ constructor(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void);
149
163
  }
150
164
 
151
165
  /**
@@ -584,7 +598,8 @@ declare enum DRAG_MODE {
584
598
  measurement = 2,
585
599
  pan = 3,
586
600
  slicer3D = 4,
587
- callbackOnly = 5
601
+ callbackOnly = 5,
602
+ roiSelection = 6
588
603
  }
589
604
  /**
590
605
  * NVConfigOptions
@@ -619,6 +634,7 @@ type NVConfigOptions = {
619
634
  isOrientCube: boolean;
620
635
  multiplanarPadPixels: number;
621
636
  multiplanarForceRender: boolean;
637
+ multiplanarEqualSize: boolean;
622
638
  multiplanarShowRender: SHOW_RENDER;
623
639
  isRadiologicalConvention: boolean;
624
640
  meshThicknessOn2D: number | string;
@@ -653,13 +669,21 @@ type NVConfigOptions = {
653
669
  renderOverlayBlend: number;
654
670
  sliceMosaicString: string;
655
671
  centerMosaic: boolean;
672
+ penSize: number;
656
673
  clickToSegment: boolean;
657
674
  clickToSegmentRadius: number;
658
- clickToSegmentSteps: number;
659
675
  clickToSegmentBright: boolean;
676
+ clickToSegmentAutoIntensity: boolean;
677
+ clickToSegmentIntensityMax: number;
678
+ clickToSegmentIntensityMin: number;
679
+ clickToSegmentPercent: number;
680
+ clickToSegmentMaxDistanceMM: number;
681
+ selectionBoxLineThickness: number;
682
+ selectionBoxIsOutline: boolean;
660
683
  };
661
684
  declare const DEFAULT_OPTIONS: NVConfigOptions;
662
685
  type SceneData = {
686
+ gamma: number;
663
687
  azimuth: number;
664
688
  elevation: number;
665
689
  crosshairPos: vec3;
@@ -672,6 +696,7 @@ type SceneData = {
672
696
  clipVolumeHigh: number[];
673
697
  };
674
698
  declare const INITIAL_SCENE_DATA: {
699
+ gamma: number;
675
700
  azimuth: number;
676
701
  elevation: number;
677
702
  crosshairPos: vec3;
@@ -696,6 +721,7 @@ type Scene = {
696
721
  pan2Dxyzmm: vec4;
697
722
  _elevation?: number;
698
723
  _azimuth?: number;
724
+ gamma?: number;
699
725
  };
700
726
  type DocumentData = {
701
727
  title: string;
@@ -958,6 +984,18 @@ type NiiVueLocation = {
958
984
  vox: vec3;
959
985
  xy: [number, number];
960
986
  };
987
+ type SyncOpts = {
988
+ '3d'?: boolean;
989
+ '2d'?: boolean;
990
+ zoomPan?: boolean;
991
+ cal_min?: boolean;
992
+ cal_max?: boolean;
993
+ gamma?: boolean;
994
+ useSliceOffset?: boolean;
995
+ sliceType?: boolean;
996
+ crosshair?: boolean;
997
+ clipPlane?: boolean;
998
+ };
961
999
 
962
1000
  type ValuesArray = Array<{
963
1001
  id: string;
@@ -1506,6 +1544,7 @@ declare class NVMeshLoaders {
1506
1544
  static readLayer(name: string, buffer: ArrayBuffer, nvmesh: NVMesh, opacity?: number, colormap?: string, colormapNegative?: string, useNegativeCmap?: boolean, cal_min?: number | null, cal_max?: number | null, outlineBorder?: number): NVMeshLayer | undefined;
1507
1545
  static readSMP(buffer: ArrayBuffer, n_vert: number): Float32Array;
1508
1546
  static readSTC(buffer: ArrayBuffer, n_vert: number): Float32Array;
1547
+ static isCurv(buffer: ArrayBuffer): boolean;
1509
1548
  static readCURV(buffer: ArrayBuffer, n_vert: number): Float32Array;
1510
1549
  static readANNOT(buffer: ArrayBuffer, n_vert: number, isReadColortables?: boolean): ANNOT;
1511
1550
  static readNV(buffer: ArrayBuffer): DefaultMeshType;
@@ -1593,6 +1632,7 @@ type Descriptive = {
1593
1632
  cal_max: number;
1594
1633
  robust_min: number;
1595
1634
  robust_max: number;
1635
+ area: number | null;
1596
1636
  };
1597
1637
  type SliceScale = {
1598
1638
  volScale: number[];
@@ -1677,6 +1717,7 @@ declare class Niivue {
1677
1717
  orientCubeShader?: Shader;
1678
1718
  orientCubeShaderVAO: WebGLVertexArrayObject | null;
1679
1719
  rectShader?: Shader;
1720
+ rectOutlineShader?: Shader;
1680
1721
  renderShader?: Shader;
1681
1722
  lineShader?: Shader;
1682
1723
  line3DShader?: Shader;
@@ -1721,7 +1762,7 @@ declare class Niivue {
1721
1762
  extentsMin?: vec3;
1722
1763
  extentsMax?: vec3;
1723
1764
  private resizeObserver;
1724
- syncOpts: Record<string, unknown>;
1765
+ syncOpts: SyncOpts;
1725
1766
  readyForSync: boolean;
1726
1767
  uiData: UIData;
1727
1768
  back: NVImage | null;
@@ -1742,7 +1783,7 @@ declare class Niivue {
1742
1783
  screen2frac?: number[];
1743
1784
  }>;
1744
1785
  cuboidVertexBuffer?: WebGLBuffer;
1745
- otherNV: Niivue | Niivue[] | null;
1786
+ otherNV: Niivue[] | null;
1746
1787
  volumeObject3D: NiivueObject3D | null;
1747
1788
  pivot3D: number[];
1748
1789
  furthestFromPivot: number;
@@ -1997,7 +2038,7 @@ declare class Niivue {
1997
2038
  * @deprecated use broadcastTo instead
1998
2039
  * @see {@link https://niivue.github.io/niivue/features/sync.mesh.html | live demo usage}
1999
2040
  */
2000
- syncWith(otherNV: Niivue, syncOpts?: {
2041
+ syncWith(otherNV: Niivue | Niivue[], syncOpts?: {
2001
2042
  '2d': boolean;
2002
2043
  '3d': boolean;
2003
2044
  }): void;
@@ -2016,6 +2057,15 @@ declare class Niivue {
2016
2057
  '2d': boolean;
2017
2058
  '3d': boolean;
2018
2059
  }): void;
2060
+ doSync3d(otherNV: Niivue): void;
2061
+ doSync2d(otherNV: Niivue): void;
2062
+ doSyncGamma(otherNV: Niivue): void;
2063
+ doSyncZoomPan(otherNV: Niivue): void;
2064
+ doSyncCrosshair(otherNV: Niivue): void;
2065
+ doSyncCalMin(otherNV: Niivue): void;
2066
+ doSyncCalMax(otherNV: Niivue): void;
2067
+ doSyncSliceType(otherNV: Niivue): void;
2068
+ doSyncClipPlane(otherNV: Niivue): void;
2019
2069
  /**
2020
2070
  * Sync the scene controls (orientation, crosshair location, etc.) from one Niivue instance to another. useful for using one canvas to drive another.
2021
2071
  * @internal
@@ -2676,9 +2726,17 @@ declare class Niivue {
2676
2726
  drawGrowCut(): void;
2677
2727
  drawPt(x: number, y: number, z: number, penValue: number): void;
2678
2728
  drawPenLine(ptA: number[], ptB: number[], penValue: number): void;
2729
+ /**
2730
+ * Performs a 1-voxel binary dilation on a connected cluster within the drawing mask using the drawFloodFillCore function.
2731
+ *
2732
+ * @param seedXYZ - voxel index of the seed voxel in the mask array.
2733
+ * @param neighbors - Number of neighbors to consider for connectivity and dilation (6, 18, or 26).
2734
+ */
2735
+ drawingBinaryDilationWithSeed(seedXYZ: number[], // seed voxel x,y,z
2736
+ neighbors?: 6 | 18 | 26): void;
2679
2737
  drawFloodFillCore(img: Uint8Array, seedVx: number, neighbors?: number): void;
2680
2738
  drawFloodFill(seedXYZ: number[], newColor?: number, growSelectedCluster?: number, // if non-zero, growth based on background intensity POSITIVE_INFINITY for selected or bright, NEGATIVE_INFINITY for selected or darker
2681
- forceMin?: number, forceMax?: number, neighbors?: number): void;
2739
+ forceMin?: number, forceMax?: number, neighbors?: number, maxDistanceMM?: number): void;
2682
2740
  drawPenFilled(): void;
2683
2741
  /**
2684
2742
  * close drawing: make sure you have saved any changes before calling this!
@@ -2807,13 +2865,33 @@ declare class Niivue {
2807
2865
  updateGLVolume(): void;
2808
2866
  /**
2809
2867
  * basic statistics for selected voxel-based image
2810
- * @param layer - selects image to describe
2811
- * @param masks - are optional binary images to filter voxles
2812
- * @returns numeric values to describe image
2813
- * @example niivue.getDescriptives(0);
2868
+ * @param options - an object containing the following properties:
2869
+ * - layer: selects image to describe
2870
+ * - masks: optional binary images to filter voxels
2871
+ * - drawingIsMask: a boolean indicating if the drawing is used as a mask
2872
+ * - roiIsMask: a boolean indicating if the ROI is used as a mask
2873
+ * - startVox: the starting voxel coordinates
2874
+ * - endVox: the ending voxel coordinates
2875
+ * @returns numeric values to describe image or regions of images
2876
+ * @example
2877
+ * niivue.getDescriptives({
2878
+ * layer: 0,
2879
+ * masks: [],
2880
+ * drawingIsMask: true, // drawingIsMask and roiIsMask are mutually exclusive
2881
+ * roiIsMask: false,
2882
+ * startVox: [10, 20, 30], // ignored if roiIsMask is false
2883
+ * endVox: [40, 50, 60] // ignored if roiIsMask is false
2884
+ * });
2814
2885
  * @see {@link https://niivue.github.io/niivue/features/draw2.html | live demo usage}
2815
2886
  */
2816
- getDescriptives(layer?: number, masks?: any[], drawingIsMask?: boolean): Descriptive;
2887
+ getDescriptives(options: {
2888
+ layer?: number;
2889
+ masks?: number[];
2890
+ drawingIsMask?: boolean;
2891
+ roiIsMask?: boolean;
2892
+ startVox?: number[];
2893
+ endVox?: number[];
2894
+ }): Descriptive;
2817
2895
  refreshLayers(overlayItem: NVImage, layer: number): void;
2818
2896
  /**
2819
2897
  * query all available color maps that can be applied to volumes
@@ -2945,6 +3023,7 @@ declare class Niivue {
2945
3023
  effectiveCanvasHeight(): number;
2946
3024
  effectiveCanvasWidth(): number;
2947
3025
  getAllLabels(): NVLabel3D[];
3026
+ getConnectomeLabels(): NVLabel3D[];
2948
3027
  getBulletMarginWidth(): number;
2949
3028
  getLegendPanelWidth(): number;
2950
3029
  getLegendPanelHeight(): number;
@@ -2976,9 +3055,10 @@ declare class Niivue {
2976
3055
  screenFieldOfViewMM(axCorSag?: number, forceSliceMM?: boolean): vec3;
2977
3056
  screenFieldOfViewExtendedVox(axCorSag?: number): MM;
2978
3057
  screenFieldOfViewExtendedMM(axCorSag?: number): MM;
2979
- drawSliceOrientationText(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE): void;
3058
+ drawSliceOrientationText(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, padLeftTop?: number[]): void;
2980
3059
  xyMM2xyzMM(axCorSag: SLICE_TYPE, sliceFrac: number): number[];
2981
- draw2D(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number): void;
3060
+ draw2DMain(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number): void;
3061
+ draw2D(leftTopWidthHeight: number[], axCorSag: SLICE_TYPE, customMM?: number, imageWidthHeight?: number[]): void;
2982
3062
  calculateMvpMatrix(_unused: unknown, leftTopWidthHeight: number[], azimuth: number, elevation: number): mat4[];
2983
3063
  calculateModelMatrix(azimuth: number, elevation: number): mat4;
2984
3064
  calculateRayDirection(azimuth: number, elevation: number): vec3;
@@ -2997,12 +3077,13 @@ declare class Niivue {
2997
3077
  * @param style - label style
2998
3078
  * @param point - 3D point on the model
2999
3079
  */
3000
- addLabel(text: string, style: NVLabel3DStyle, points?: number[] | number[][]): NVLabel3D;
3080
+ addLabel(text: string, style: NVLabel3DStyle, points?: number[] | number[][], anchor?: LabelAnchorPoint, onClick?: (label: NVLabel3D) => void): NVLabel3D;
3001
3081
  calculateScreenPoint(point: [number, number, number], mvpMatrix: mat4, leftTopWidthHeight: number[]): vec4;
3002
3082
  getLabelAtPoint(screenPoint: [number, number]): NVLabel3D | null;
3003
3083
  drawLabelLine(label: NVLabel3D, pos: vec2, mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
3004
- draw3DLabel(label: NVLabel3D, pos: vec2, mvpMatrix: mat4, leftTopWidthHeight: number[], bulletMargin: number, legendWidth: number, secondPass?: boolean): void;
3084
+ draw3DLabel(label: NVLabel3D, pos: vec2, mvpMatrix?: mat4, leftTopWidthHeight?: number[], bulletMargin?: number, legendWidth?: number, secondPass?: boolean): void;
3005
3085
  draw3DLabels(mvpMatrix: mat4, leftTopWidthHeight: number[], secondPass?: boolean): void;
3086
+ drawAnchoredLabels(): void;
3006
3087
  draw3D(leftTopWidthHeight?: number[], mvpMatrix?: mat4 | null, modelMatrix?: mat4 | null, normalMatrix?: mat4 | null, azimuth?: number | null, elevation?: number): string | undefined;
3007
3088
  drawMesh3D(isDepthTest?: boolean, alpha?: number, m?: mat4, modelMtx?: mat4, normMtx?: mat4): void;
3008
3089
  drawCrosshairs3D(isDepthTest?: boolean, alpha?: number, mvpMtx?: mat4 | null, is2DView?: boolean, isSliceMM?: boolean): void;
@@ -3042,4 +3123,4 @@ declare class Niivue {
3042
3123
  set gl(gl: WebGL2RenderingContext | null);
3043
3124
  }
3044
3125
 
3045
- export { type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type DragReleaseParams, type ExportDocumentData, INITIAL_SCENE_DATA, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConfigOptions, type NVConnectomeEdge, type NVConnectomeNode, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLayerDefaults, NVMeshLoaders, NVMeshUtilities, NVUtilities, type NiftiHeader, type NiiVueLocation, type NiiVueLocationValue, Niivue, type Point, SHOW_RENDER, SLICE_TYPE, type Scene, type Volume, cmapper, ColorTables as colortables };
3126
+ export { type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type DragReleaseParams, type ExportDocumentData, INITIAL_SCENE_DATA, LabelAnchorPoint, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConfigOptions, type NVConnectomeEdge, type NVConnectomeNode, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLayerDefaults, NVMeshLoaders, NVMeshUtilities, NVUtilities, type NiftiHeader, type NiiVueLocation, type NiiVueLocationValue, Niivue, type Point, SHOW_RENDER, SLICE_TYPE, type Scene, type SyncOpts, type Volume, cmapper, ColorTables as colortables };