@niivue/niivue 0.50.0 → 0.51.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 ADDED
@@ -0,0 +1,70 @@
1
+ # NiiVue
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/).
8
+
9
+ ## Local Development
10
+
11
+ To run a hot-loading development that is updated whenever you save changes to any source files, you can run:
12
+
13
+ ```
14
+ git clone git@github.com:niivue/niivue.git
15
+ cd niivue
16
+ npm install
17
+ npm run dev
18
+ ```
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
@@ -1,6 +1,5 @@
1
1
  import { mat4, vec3, vec4, vec2 } from 'gl-matrix';
2
2
  import { NIFTI1, NIFTI2 } from 'nifti-reader-js';
3
- import { WebSocketSubject } from 'rxjs/webSocket';
4
3
 
5
4
  type ColorMap = {
6
5
  R: number[];
@@ -408,7 +407,7 @@ declare class NVImage {
408
407
  readMIF(buffer: ArrayBuffer, pairedImgData: ArrayBuffer | null): Promise<ArrayBuffer>;
409
408
  readNRRD(dataBuffer: ArrayBuffer, pairedImgData: ArrayBuffer | null): Promise<ArrayBuffer>;
410
409
  calculateRAS(): void;
411
- hdr2RAS(nVolumes?: number): NIFTI1 | NIFTI2;
410
+ hdr2RAS(nVolumes?: number): Promise<NIFTI1 | NIFTI2>;
412
411
  img2RAS(nVolume?: number): TypedVoxelArray;
413
412
  vox2mm(XYZ: number[], mtx: mat4): vec3;
414
413
  mm2vox(mm: number[], frac?: boolean): Float32Array | vec3;
@@ -1093,11 +1092,16 @@ type ANNOT = Uint32Array | {
1093
1092
  scalars: Float32Array;
1094
1093
  colormapLabel: LUT;
1095
1094
  };
1096
- type MZ3 = Float32Array | {
1095
+ type MZ3 = {
1097
1096
  positions: Float32Array | null;
1098
1097
  indices: Uint32Array | null;
1099
1098
  scalars: Float32Array;
1100
1099
  colors: Float32Array | null;
1100
+ } | {
1101
+ scalars: Float32Array;
1102
+ colormapLabel: LUT;
1103
+ } | {
1104
+ scalars: Float32Array;
1101
1105
  };
1102
1106
  type GII = {
1103
1107
  scalars: Float32Array;
@@ -1303,213 +1307,6 @@ declare class NVMesh {
1303
1307
  loadFromBase64({ base64, gl, name, opacity, rgba255, visible, layers }?: Partial<LoadFromBase64Params>): Promise<NVMesh>;
1304
1308
  }
1305
1309
 
1306
- /**
1307
- * Enum for sync operations
1308
- */
1309
- declare enum NVMESSAGE {
1310
- ZOOM = 1,// "zoom",
1311
- CLIP_PLANE = 2,// "clipPlane",
1312
- AZIMUTH_ELEVATION = 3,// "ae",
1313
- FRAME_CHANGED = 4,// "frame changed",
1314
- VOLUME_ADDED_FROM_URL = 5,// "volume added from url",
1315
- VOLUME_WITH_URL_REMOVED = 6,// "volume with url removed",
1316
- COLORMAP_CHANGED = 7,// "color map has changed",
1317
- OPACITY_CHANGED = 8,// "opacity has changed",
1318
- MESH_FROM_URL_ADDED = 9,// "mesh added from url",
1319
- MESH_WITH_URL_REMOVED = 10,// "mesh with url removed",
1320
- CUSTOM_SHADER_ADDED = 11,// "custom shader added",
1321
- SHADER_CHANGED = 12,// "mesh shader changed",
1322
- MESH_PROPERTY_CHANGED = 13,// "mesh property changed",
1323
- USER_JOINED = "user joined",// TODO this breaks the scheme a bit -- see session-bus::localStorageEventListener
1324
- CREATE = "create",// TODO same as above
1325
- VOLUME_LOADED_FROM_URL = "volume with url added"
1326
- }
1327
- type Message = {
1328
- userKey?: string;
1329
- from?: string;
1330
- } & ({
1331
- op: NVMESSAGE.ZOOM;
1332
- zoom: number;
1333
- } | {
1334
- op: NVMESSAGE.CLIP_PLANE;
1335
- clipPlane: number[];
1336
- } | {
1337
- op: NVMESSAGE.AZIMUTH_ELEVATION;
1338
- elevation: number;
1339
- azimuth: number;
1340
- } | {
1341
- op: NVMESSAGE.FRAME_CHANGED;
1342
- url: string;
1343
- index: number;
1344
- } | {
1345
- op: NVMESSAGE.VOLUME_ADDED_FROM_URL;
1346
- imageOptions: any;
1347
- } | {
1348
- op: NVMESSAGE.VOLUME_LOADED_FROM_URL;
1349
- url: string;
1350
- } | {
1351
- op: NVMESSAGE.VOLUME_WITH_URL_REMOVED;
1352
- url: string;
1353
- } | {
1354
- op: NVMESSAGE.COLORMAP_CHANGED;
1355
- url: string;
1356
- colormap: string;
1357
- } | {
1358
- op: NVMESSAGE.OPACITY_CHANGED;
1359
- url: string;
1360
- opacity: number;
1361
- } | {
1362
- op: NVMESSAGE.MESH_FROM_URL_ADDED;
1363
- meshOptions: LoadFromUrlParams;
1364
- } | {
1365
- op: NVMESSAGE.MESH_WITH_URL_REMOVED;
1366
- url: string;
1367
- } | {
1368
- op: NVMESSAGE.CUSTOM_SHADER_ADDED;
1369
- fragmentShaderText: string;
1370
- name: string;
1371
- } | {
1372
- op: NVMESSAGE.SHADER_CHANGED;
1373
- meshIndex: number;
1374
- shaderIndex: number;
1375
- } | {
1376
- op: NVMESSAGE.MESH_PROPERTY_CHANGED;
1377
- meshIndex: number;
1378
- key: string;
1379
- val: unknown;
1380
- } | {
1381
- op: NVMESSAGE.USER_JOINED;
1382
- user: SessionUser;
1383
- } | {
1384
- op: NVMESSAGE.CREATE;
1385
- key: string;
1386
- });
1387
-
1388
- /**
1389
- * SessionUser specifies display name, user id and user key
1390
- * @param userKey - Used to protect user properties
1391
- */
1392
- declare class SessionUser {
1393
- id: string;
1394
- displayName: string;
1395
- key: string;
1396
- properties: Map<string, string>;
1397
- constructor(displayName?: string, userId?: string, userKey?: string, userProperties?: Map<string, string>);
1398
- }
1399
- /**
1400
- * SessionBus is for synchronizing both remote and local instances
1401
- */
1402
- declare class SessionBus {
1403
- userList: SessionUser[];
1404
- user: SessionUser;
1405
- userQueueName?: string;
1406
- userListName?: string;
1407
- onMessageCallback: (newMessage: Message) => void;
1408
- isConnectedToServer: boolean;
1409
- isController: boolean;
1410
- sessionScene: {};
1411
- sessionKey: string;
1412
- sessionName: string;
1413
- sessionSceneName: string;
1414
- serverConnection$: WebSocketSubject<Message> | null;
1415
- constructor(name: string, user: SessionUser, onMessageCallback: (newMessage: Message) => void, serverURL?: string, sessionKey?: string);
1416
- sendSessionMessage(message: Message): void;
1417
- connectToServer(serverURL: string, sessionName: string): void;
1418
- subscribeToServer(): void;
1419
- sendLocalMessage(message: Message): void;
1420
- localStorageEventListener(e: StorageEvent): void;
1421
- }
1422
-
1423
- /**
1424
- * NVController is for synchronizing both remote and local instances of Niivue
1425
- * @ignore
1426
- */
1427
- declare class NVController {
1428
- niivue: Niivue;
1429
- mediaUrlMap: Map<string, unknown>;
1430
- isInSession: boolean;
1431
- user?: SessionUser;
1432
- sessionBus?: SessionBus;
1433
- onFrameChange: (_volume: NVImage, _index: number) => void;
1434
- /**
1435
- * @param niivue - niivue object to control
1436
- */
1437
- constructor(niivue: Niivue);
1438
- onLocationChangeHandler(location: unknown): void;
1439
- addVolume(volume: NVImage, url: string): void;
1440
- addMesh(mesh: NVMesh, url: string): void;
1441
- onNewMessage(msg: Message): void;
1442
- /**
1443
- * Connects to existing session or creates new session
1444
- */
1445
- connectToSession(sessionName: string, user?: SessionUser, serverBaseUrl?: string, sessionKey?: string): void;
1446
- /**
1447
- * Zoom level has changed
1448
- */
1449
- onZoom3DChangeHandler(zoom: number): void;
1450
- /**
1451
- * Azimuth and/or elevation has changed
1452
- */
1453
- onAzimuthElevationChangeHandler(azimuth: number, elevation: number): void;
1454
- /**
1455
- * Clip plane has changed
1456
- */
1457
- onClipPlaneChangeHandler(clipPlane: number[]): void;
1458
- /**
1459
- * Add an image and notify subscribers
1460
- */
1461
- onVolumeAddedFromUrlHandler(imageOptions: ImageFromUrlOptions, volume: NVImage): void;
1462
- /**
1463
- * A volume has been added
1464
- */
1465
- onImageLoadedHandler(volume: NVImage): void;
1466
- /**
1467
- * Notifies other users that a volume has been removed
1468
- */
1469
- onVolumeWithUrlRemovedHandler(url: string): void;
1470
- /**
1471
- * Notifies that a mesh has been loaded by URL
1472
- */
1473
- onMeshAddedFromUrlHandler(meshOptions: LoadFromUrlParams): void;
1474
- /**
1475
- * Notifies that a mesh has been added
1476
- */
1477
- onMeshLoadedHandler(mesh: NVMesh): void;
1478
- onMeshWithUrlRemovedHandler(url: string): void;
1479
- /**
1480
- *
1481
- * @param volume - volume that has changed color maps
1482
- */
1483
- onColormapChangeHandler(volume: NVImage): void;
1484
- /**
1485
- * @param volume - volume that has changed opacity
1486
- */
1487
- onOpacityChangeHandler(volume: NVImage): void;
1488
- /**
1489
- * Frame for 4D image has changed
1490
- */
1491
- onFrameChangeHandler(volume: NVImage, index: number): void;
1492
- /**
1493
- * Custom mesh shader has been added
1494
- * @param fragmentShaderText - shader code to be compiled
1495
- * @param name - name of shader, can be used as index
1496
- */
1497
- onCustomMeshShaderAddedHandler(fragmentShaderText: string, name: string): void;
1498
- /**
1499
- * Mesh shader has changed
1500
- * @param meshIndex - index of mesh
1501
- * @param shaderIndex - index of shader
1502
- */
1503
- onMeshShaderChanged(meshIndex: number, shaderIndex: number): void;
1504
- /**
1505
- * Mesh property has been changed
1506
- * @param meshIndex - index of mesh
1507
- * @param key - property index
1508
- * @param val - property value
1509
- */
1510
- onMeshPropertyChanged(meshIndex: number, key: string, val: unknown): void;
1511
- }
1512
-
1513
1310
  type TypedNumberArray = Float64Array | Float32Array | Uint32Array | Uint16Array | Uint8Array | Int32Array | Int16Array | Int8Array;
1514
1311
  declare class NVUtilities {
1515
1312
  static arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
@@ -2048,7 +1845,6 @@ declare class Niivue {
2048
1845
  mediaUrlMap: Map<NVImage | NVMesh, string>;
2049
1846
  initialized: boolean;
2050
1847
  currentDrawUndoBitmap: number;
2051
- loadingText: string;
2052
1848
  /**
2053
1849
  * @param options - options object to set modifiable Niivue properties
2054
1850
  */
@@ -3196,4 +2992,4 @@ declare class Niivue {
3196
2992
  set gl(gl: WebGL2RenderingContext | null);
3197
2993
  }
3198
2994
 
3199
- export { COLORMAP_TYPE, type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, DRAG_MODE_PRIMARY, DRAG_MODE_SECONDARY, type DicomLoader, type DicomLoaderInput, 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 };
2995
+ export { COLORMAP_TYPE, type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, DRAG_MODE_PRIMARY, DRAG_MODE_SECONDARY, type DicomLoader, type DicomLoaderInput, type DocumentData, type DragReleaseParams, type ExportDocumentData, INITIAL_SCENE_DATA, LabelAnchorPoint, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConfigOptions, type NVConnectomeEdge, type NVConnectomeNode, 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 };