@niivue/niivue 0.31.0 → 0.33.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  NiiVue is a WebGL 2.0 medical image viewer. This repository contains the **core NiiVue package**. We have additional projects under development that will demonstrate a [web-based user interface implementation](https://github.com/niivue/niivue-ui), and a [desktop application](https://github.com/niivue/niivue-desktop) built using web technologies.
4
4
 
5
- NiiVue allows developers to create interactive web pages for visualizing [nifti](https://nifti.nimh.nih.gov) and other formats popular in neuroimaging. NiiVue includes many mouse and keyboard interactions that enable browsing and manipulating images displayed in the canvas. This core package does not include a comprehensive user interface outside of the canvas (e.g. buttons, and other widgets). However, developers who wish to build custom user interfaces around the NiiVue canvas can manipulate the rendered images and change settings via the API. Our [UI wrapper](https://github.com/niivue/niivue-ui) demonstrates how the modular core NiiVue can be embedded into a rich user interface.
5
+ NiiVue allows developers to create interactive web pages for visualizing [nifti](https://nifti.nimh.nih.gov) and other formats popular in neuroimaging. NiiVue includes many mouse and keyboard interactions that enable browsing and manipulating images displayed in the canvas. This core package does not include a comprehensive user interface outside of the canvas (e.g. buttons, and other widgets). However, developers who wish to build custom user interfaces around the NiiVue canvas can manipulate the rendered images and change settings via the API. Our [UI wrapper](https://github.com/niivue/niivue-ui) demonstrates how the modular core NiiVue can be embedded into a rich user interface.
6
6
 
7
7
  # Getting started Docs and References
8
8
 
@@ -18,7 +18,7 @@ npm install --only=prod @niivue/niivue
18
18
 
19
19
  # Overview/Mission
20
20
 
21
- NiiVue brings the features of the widely used native desktop applications ([AFNI](https://afni.nimh.nih.gov/about_afni), [FSLeyes](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLeyes), [MRIcroGL](https://github.com/rordenlab/MRIcroGL), [Surfice](https://github.com/neurolabusc/surf-ice), [SUMA](https://afni.nimh.nih.gov/Suma)) to the web. The developers of these tools developed NiiVue in collaboration, allowing us to benefit from collective wisdom. This will enable other researchers and developers to build cloud-based medical imaging tools with a powerful viewer that can operate on any device (desktop, tablet, mobile).
21
+ NiiVue brings the features of the widely used native desktop applications ([AFNI](https://afni.nimh.nih.gov/about_afni), [FSLeyes](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLeyes), [MRIcroGL](https://github.com/rordenlab/MRIcroGL), [Surfice](https://github.com/neurolabusc/surf-ice), [SUMA](https://afni.nimh.nih.gov/Suma)) to the web. The developers of these tools developed NiiVue in collaboration, allowing us to benefit from collective wisdom. This will enable other researchers and developers to build cloud-based medical imaging tools with a powerful viewer that can operate on any device (desktop, tablet, mobile).
22
22
 
23
23
  # Projects and People using NiiVue
24
24
 
@@ -34,7 +34,7 @@ We host many NiiVue examples via github pages. These are updated and deployed au
34
34
 
35
35
  [See the examples here](https://niivue.github.io/niivue/)
36
36
 
37
- # Requirements for NiiVue to work
37
+ # Requirements for NiiVue to work
38
38
 
39
39
  - [WebGL 2.0 capable](https://caniuse.com/webgl2) web browser (Chrome, FireFox, Safari).
40
40
 
@@ -48,22 +48,30 @@ While NiiVue can be wrapped with frameworks (VueJS, React, Angular), you can als
48
48
  <!DOCTYPE html>
49
49
  <html lang="en">
50
50
  <head>
51
- <meta charset="utf-8">
51
+ <meta charset="utf-8" />
52
52
  <title>NiiVue</title>
53
53
  </head>
54
54
  <body>
55
- <canvas id="gl"></canvas>
55
+ <canvas id="gl" width="640" height="640"></canvas>
56
56
  </body>
57
- <script src="https://unpkg.com/@niivue/niivue@0.29.0/dist/niivue.umd.js"></script>
58
- <script>
59
- var volumeList = [{url: "https://niivue.github.io/niivue-demo-images/mni152.nii.gz"}]
60
- var nv = new niivue.Niivue()
61
- nv.attachTo('gl')
62
- nv.loadVolumes(volumeList)
63
- </script>
57
+ <script src="https://niivue.github.io/niivue/features/niivue.umd.js"></script>
58
+ <script>
59
+ var volumeList = [
60
+ { url: "https://niivue.github.io/niivue-demo-images/mni152.nii.gz" },
61
+ ];
62
+ var nv = new niivue.Niivue({ isResizeCanvas: false });
63
+ nv.attachTo("gl");
64
+ nv.loadVolumes(volumeList);
65
+ </script>
64
66
  </html>
65
67
  ```
66
68
 
69
+ Note that the code above will load the latest current stable release. Alternatively, you can specify a specific NiiVue version. For example, to ensure compatibility with release 0.32.0, you could specify:
70
+
71
+ ```html
72
+ <script src="https://unpkg.com/@niivue/niivue@0.32.0/dist/niivue.umd.js"></script>
73
+ ```
74
+
67
75
  ## VueJS example
68
76
 
69
77
  install: `npm i @niivue/niivue`
@@ -93,7 +101,7 @@ export default {
93
101
  mounted() {
94
102
 
95
103
  nv.attachTo('gl')
96
- nv.loadVolumes(this.volumeList)
104
+ nv.loadVolumes(this.volumeList)
97
105
  }
98
106
  }
99
107
 
@@ -111,61 +119,60 @@ export default {
111
119
  install: `npm i @niivue/niivue`
112
120
 
113
121
  ```js
114
- import { useRef, useEffect } from 'react'
115
- import { Niivue } from '@niivue/niivue'
122
+ import { useRef, useEffect } from "react";
123
+ import { Niivue } from "@niivue/niivue";
116
124
 
117
125
  const NiiVue = ({ imageUrl }) => {
118
- const canvas = useRef()
126
+ const canvas = useRef();
119
127
  useEffect(() => {
120
128
  const volumeList = [
121
129
  {
122
130
  url: imageUrl,
123
131
  },
124
- ]
125
- const nv = new Niivue()
126
- nv.attachToCanvas(canvas.current)
127
- nv.loadVolumes(volumeList)
128
- }, [imageUrl])
129
-
130
- return (
131
- <canvas ref={canvas} height={480} width={640} />
132
- )
133
- }
132
+ ];
133
+ const nv = new Niivue();
134
+ nv.attachToCanvas(canvas.current);
135
+ nv.loadVolumes(volumeList);
136
+ }, [imageUrl]);
137
+
138
+ return <canvas ref={canvas} height={480} width={640} />;
139
+ };
134
140
 
135
141
  // use as: <NiiVue imageUrl={someUrl}> </NiiVue>
136
142
  ```
143
+
137
144
  ## Angular example
145
+
138
146
  Check our [Angular TypeScript development notes](docs/development-notes/angular-typescript.md) for instructions on building an Angular App with Niivue.
139
147
 
140
148
  install: `npm i @niivue/niivue`
141
149
 
142
150
  ```ts
143
- import { Component, OnInit, ViewChild} from '@angular/core';
151
+ import { Component, OnInit, ViewChild } from "@angular/core";
144
152
 
145
- import {Niivue} from '@niivue/niivue';
153
+ import { Niivue } from "@niivue/niivue";
146
154
 
147
155
  @Component({
148
- selector: 'app-niivue-view',
149
- templateUrl: './niivue-view.component.html',
150
- styleUrls: ['./niivue-view.component.sass']
156
+ selector: "app-niivue-view",
157
+ templateUrl: "./niivue-view.component.html",
158
+ styleUrls: ["./niivue-view.component.sass"],
151
159
  })
152
160
  export class NiivueViewComponent implements OnInit {
153
- @ViewChild('gl') canvas:HTMLCanvasElement|undefined;
161
+ @ViewChild("gl") canvas: HTMLCanvasElement | undefined;
154
162
 
155
- constructor() { }
163
+ constructor() {}
156
164
 
157
165
  ngOnInit(): void {
158
- const url = '/assets/mni152.nii.gz';
166
+ const url = "/assets/mni152.nii.gz";
159
167
  const volumeList = [
160
- {
161
- url,
162
- },
163
- ]
168
+ {
169
+ url,
170
+ },
171
+ ];
164
172
  const niivue = new Niivue();
165
- niivue.attachTo('gl');
173
+ niivue.attachTo("gl");
166
174
  niivue.loadVolumes(volumeList);
167
175
  }
168
-
169
176
  }
170
177
  ```
171
178
 
@@ -186,11 +193,11 @@ export class NiivueViewComponent implements OnInit {
186
193
 
187
194
  NiiVue can open several formats popular with brain imaging:
188
195
 
189
- - 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).
190
- - Mesh-based formats: [GIfTI](https://www.nitrc.org/projects/gifti/), [ASC](http://www.grahamwideman.com/gw/brain/fs/surfacefileformats.htm), [BrainSuite DFS](http://brainsuite.org/formats/dfs/), [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/).
191
- - 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)
192
- - 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
193
- - DICOM: [DICOM](https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html) and [DICOM Manifests](docs/development-notes/dicom-manifests.md)
196
+ - 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).
197
+ - 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/).
198
+ - 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)
199
+ - 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
200
+ - DICOM: [DICOM](https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html) and [DICOM Manifests](docs/development-notes/dicom-manifests.md)
194
201
 
195
202
  # Alternatives
196
203
 
@@ -229,7 +236,7 @@ npm install --save-dev @niivue/niivue
229
236
 
230
237
  ## Local Development
231
238
 
232
- Make sure you have nodejs and npm installed.
239
+ Make sure you have nodejs and npm installed.
233
240
 
234
241
  ```
235
242
  git clone git@github.com:niivue/niivue.git
@@ -240,7 +247,7 @@ npm run dev
240
247
 
241
248
  ## Launch included demos
242
249
 
243
- Launching the demos will format, build, and serve niivue demo pages. Open the demo URL in your browser to view the demo web pages. You can find the demo URL in your terminal after running `npm run demo`. The demos are intentionally simple, and each canvas showcases different NiiVue features.
250
+ Launching the demos will format, build, and serve niivue demo pages. Open the demo URL in your browser to view the demo web pages. You can find the demo URL in your terminal after running `npm run demo`. The demos are intentionally simple, and each canvas showcases different NiiVue features.
244
251
 
245
252
  **When viewing the demos during development, be sure to shift + click the refresh button in your browser in order to avoid using cached versions of files.**
246
253
 
@@ -274,7 +281,7 @@ npm run build-win
274
281
 
275
282
  ## Versioning
276
283
 
277
- NiiVue uses [semantic versioning](https://semver.org/).
284
+ NiiVue uses [semantic versioning](https://semver.org/).
278
285
 
279
286
  To update the version run:
280
287
 
@@ -314,6 +321,7 @@ npm run test -- -t 'test string'
314
321
  ```
315
322
 
316
323
  ## Creating fonts
324
+
317
325
  ```
318
326
  { echo "data:image/png;base64,"; openssl enc -base64 -in fnt.png; } > fnt.txt
319
327
 
@@ -322,17 +330,17 @@ npm run test -- -t 'test string'
322
330
 
323
331
  # Contributing
324
332
 
325
- Contributions to NiiVue are encouraged and welcomed. Feel free to update documentation, add features, fix bugs, or just ask questions on the [issue board](https://github.com/niivue/niivue/issues).
333
+ Contributions to NiiVue are encouraged and welcomed. Feel free to update documentation, add features, fix bugs, or just ask questions on the [issue board](https://github.com/niivue/niivue/issues).
326
334
 
327
335
  ## Using Issues
328
336
 
329
- **All** contributions should start as a new issue on the [NiiVue issue board](https://github.com/niivue/niivue/issues).
337
+ **All** contributions should start as a new issue on the [NiiVue issue board](https://github.com/niivue/niivue/issues).
330
338
 
331
- By starting a new issue for everything we ping everyone watching the project at the same time, and therefore alerting them to the feature, bug, or question. It also gives everyone a change to comment on new posts.
339
+ By starting a new issue for everything we ping everyone watching the project at the same time, and therefore alerting them to the feature, bug, or question. It also gives everyone a change to comment on new posts.
332
340
 
333
341
  ## Things to consider
334
342
 
335
- When adding features please keep in mind that we want NiiVue to work on all devices that support WebGL 2.0 (laptops, desktops, tablets, and phones). Therefore, please do your best to test features on as many devices as you have access to.
343
+ When adding features please keep in mind that we want NiiVue to work on all devices that support WebGL 2.0 (laptops, desktops, tablets, and phones). Therefore, please do your best to test features on as many devices as you have access to.
336
344
 
337
345
  When testing locally from other devices you can navigate to your development computer's local IP address (assuming your phone and computer are on the same local network) at the port specified in the URL you see when running `npm run demo`.
338
346
 
@@ -342,23 +350,23 @@ NiiVue relies on [Jest](https://jestjs.io/)
342
350
 
343
351
  If you add a feature, or fix a bug please try to add a test for it. You can find tests in the `tests` folder within the niivue project. There are numerous existing tests, so you can probably use one of those as a template. Generally, a test is contained with an `it('test name')` block in the `tests/test.niivue.js` file.
344
352
 
345
- Some tests generate screenshots of the WebGL canvas in order to compare renderings to previous snapshots. Please have a look at the current tests in order to see how you can add this to your new tests if needed.
353
+ Some tests generate screenshots of the WebGL canvas in order to compare renderings to previous snapshots. Please have a look at the current tests in order to see how you can add this to your new tests if needed.
346
354
 
347
355
  ## Automated CI/CD
348
356
 
349
357
  We rely heavily on GitHub's actions to automate testing and checks.
350
358
 
351
- These automated tests only test in a Linux desktop environment. So do please try to visually check that things work on other devices like tablets and phones when needed.
359
+ These automated tests only test in a Linux desktop environment. So do please try to visually check that things work on other devices like tablets and phones when needed.
352
360
 
353
- Each PR to the main branch must pass the automated checks, and must be reviewed and signed off by at least one other person.
361
+ Each PR to the main branch must pass the automated checks, and must be reviewed and signed off by at least one other person.
354
362
 
355
- If all checks and tests pass then PRs will be merged into main.
363
+ If all checks and tests pass then PRs will be merged into main.
356
364
 
357
- You can edit a feature branch as many times as needed to fix broken tests in order to get them passing and merged into main.
365
+ You can edit a feature branch as many times as needed to fix broken tests in order to get them passing and merged into main.
358
366
 
359
367
  ## Protected branches
360
368
 
361
- The `main` branch is protected. This means that no one can commit to main directly. All edits must be merged in from forks or feature branches.
369
+ The `main` branch is protected. This means that no one can commit to main directly. All edits must be merged in from forks or feature branches.
362
370
 
363
371
  ## Making colormap loader
364
372
 
@@ -377,5 +385,3 @@ sudo lsof -iTCP -sTCP:LISTEN -n -P | grep 8888 # 8888 is the test server used by
377
385
 
378
386
  kill <pid> # kill the node process running the server if needed (when tests fail locally)
379
387
  ```
380
-
381
-