@niivue/niivue 0.35.1 → 0.37.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 +23 -362
- package/dist/niivue.es.js +14643 -13901
- package/dist/niivue.umd.js +369 -126
- package/package.json +3 -2
- package/src/cmaps/index.js +1 -1
- package/src/cmaps/redyell.json +1 -1
- package/src/colortables.js +123 -25
- package/src/index.html +1 -0
- package/src/niivue.js +776 -129
- package/src/nvdocument.js +5 -0
- package/src/nvimage.js +44 -5
- package/src/nvmesh.js +487 -63
- package/src/shader-srcs.js +322 -54
- /package/src/cmaps/{ROI_i256.json → roi_i256.json} +0 -0
package/README.md
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
# NiiVue
|
|
2
2
|
|
|
3
|
-
NiiVue is
|
|
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
4
|
|
|
5
|
-
|
|
5
|
+
[Click here to see NiiVue live demos](https://niivue.github.io/niivue/)
|
|
6
6
|
|
|
7
|
-
|
|
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), [VTK.js](https://kitware.github.io/paraview-glance/app/), and [slicedrop](https://slicedrop.com/).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Supported Nodejs versions for building/developing with NiiVue
|
|
12
|
-
|
|
13
|
-
NiiVue is built and tested using [Nodejs](https://nodejs.dev/en/) `14`, `16`, and `18` and their accompanying npm versions. We recommend using the latest LTS version of Nodejs when building and developing with NiiVue.
|
|
14
|
-
|
|
15
|
-
### Install NiiVue using npm
|
|
9
|
+
## Local Development
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
To run a hot-loading development that is updated whenever you save changes to any source files, you can run:
|
|
18
12
|
|
|
19
13
|
```
|
|
20
|
-
|
|
14
|
+
git clone git@github.com:niivue/niivue.git
|
|
15
|
+
cd niivue
|
|
16
|
+
npm install
|
|
17
|
+
npm run dev
|
|
21
18
|
```
|
|
22
19
|
|
|
23
|
-
|
|
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](./DEVELOP.md).
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
# Developer Documentation
|
|
23
|
+
|
|
24
|
+
[Click here for the docs web page](https://niivue.github.io/niivue/devdocs/)
|
|
26
25
|
|
|
27
26
|
# Projects and People using NiiVue
|
|
28
27
|
|
|
@@ -30,364 +29,26 @@ NiiVue brings the features of the widely used native desktop applications ([AFNI
|
|
|
30
29
|
- [Center for the Study of Aphasia Recovery](https://cstar.sc.edu/) (University of South Carolina)
|
|
31
30
|
- FMRIB's Software Library (FSL) [Wellcome Centre for Integrative Neuroimaging](https://www.win.ox.ac.uk/) (University of Oxford)
|
|
32
31
|
- FreeSurfer [Laboratories for Computational Neuroimaging](https://lcn.martinos.org/) (Massachusetts General Hospital)
|
|
33
|
-
- [OpenNeuro.org](https://openneuro.org)
|
|
34
|
-
- [BrainLife.io](https://brainlife.io/about/)
|
|
32
|
+
- [OpenNeuro.org](https://openneuro.org) uses NiiVue to visualize datasets
|
|
33
|
+
- [BrainLife.io](https://brainlife.io/about/) integrates NiiVue into [ezbids](https://brainlife.io/ezbids/)
|
|
35
34
|
- [nilearn](https://nilearn.github.io/stable/index.html) is extending [ipyniivue](https://github.com/niivue/ipyniivue)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[See the examples here](https://niivue.github.io/niivue/)
|
|
42
|
-
|
|
43
|
-
# Requirements for NiiVue to work
|
|
44
|
-
|
|
45
|
-
- [WebGL 2.0 capable](https://caniuse.com/webgl2) web browser (Chrome, FireFox, Safari).
|
|
46
|
-
|
|
47
|
-
# Usage
|
|
48
|
-
|
|
49
|
-
## Pure HTML
|
|
50
|
-
|
|
51
|
-
While NiiVue can be wrapped with frameworks (VueJS, React, Angular), you can also embed it directly into HTML web pages. Here is a minimal example:
|
|
52
|
-
|
|
53
|
-
```html
|
|
54
|
-
<!DOCTYPE html>
|
|
55
|
-
<html lang="en">
|
|
56
|
-
<head>
|
|
57
|
-
<meta charset="utf-8" />
|
|
58
|
-
<title>NiiVue</title>
|
|
59
|
-
</head>
|
|
60
|
-
<body>
|
|
61
|
-
<canvas id="gl" width="640" height="640"></canvas>
|
|
62
|
-
</body>
|
|
63
|
-
<script src="https://niivue.github.io/niivue/features/niivue.umd.js"></script>
|
|
64
|
-
<script>
|
|
65
|
-
var volumeList = [
|
|
66
|
-
{ url: "https://niivue.github.io/niivue-demo-images/mni152.nii.gz" },
|
|
67
|
-
];
|
|
68
|
-
var nv = new niivue.Niivue({ isResizeCanvas: false });
|
|
69
|
-
nv.attachTo("gl");
|
|
70
|
-
nv.loadVolumes(volumeList);
|
|
71
|
-
</script>
|
|
72
|
-
</html>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
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:
|
|
76
|
-
|
|
77
|
-
```html
|
|
78
|
-
<script src="https://unpkg.com/@niivue/niivue@0.32.0/dist/niivue.umd.js"></script>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## VueJS example
|
|
82
|
-
|
|
83
|
-
install: `npm i @niivue/niivue`
|
|
84
|
-
|
|
85
|
-
```js
|
|
86
|
-
<script>
|
|
87
|
-
import {Niivue} from '@niivue/niivue'
|
|
88
|
-
const nv = new Niivue()
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export default {
|
|
92
|
-
name: 'App',
|
|
93
|
-
props: {
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
data(){
|
|
97
|
-
return {
|
|
98
|
-
volumeList: [
|
|
99
|
-
{
|
|
100
|
-
url: "./mni152.nii.gz",
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
mounted() {
|
|
108
|
-
|
|
109
|
-
nv.attachTo('gl')
|
|
110
|
-
nv.loadVolumes(this.volumeList)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
</script>
|
|
115
|
-
|
|
116
|
-
<template>
|
|
117
|
-
<canvas id="gl" height="480" width="640">
|
|
118
|
-
|
|
119
|
-
</canvas>
|
|
120
|
-
</template>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## React example
|
|
124
|
-
|
|
125
|
-
install: `npm i @niivue/niivue`
|
|
126
|
-
|
|
127
|
-
```js
|
|
128
|
-
import { useRef, useEffect } from "react";
|
|
129
|
-
import { Niivue } from "@niivue/niivue";
|
|
130
|
-
|
|
131
|
-
const NiiVue = ({ imageUrl }) => {
|
|
132
|
-
const canvas = useRef();
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
const volumeList = [
|
|
135
|
-
{
|
|
136
|
-
url: imageUrl,
|
|
137
|
-
},
|
|
138
|
-
];
|
|
139
|
-
const nv = new Niivue();
|
|
140
|
-
nv.attachToCanvas(canvas.current);
|
|
141
|
-
nv.loadVolumes(volumeList);
|
|
142
|
-
}, [imageUrl]);
|
|
143
|
-
|
|
144
|
-
return <canvas ref={canvas} height={480} width={640} />;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// use as: <NiiVue imageUrl={someUrl}> </NiiVue>
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Angular example
|
|
151
|
-
|
|
152
|
-
Check our [Angular TypeScript development notes](docs/development-notes/angular-typescript.md) for instructions on building an Angular App with Niivue.
|
|
153
|
-
|
|
154
|
-
install: `npm i @niivue/niivue`
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
import { Component, OnInit, ViewChild } from "@angular/core";
|
|
158
|
-
|
|
159
|
-
import { Niivue } from "@niivue/niivue";
|
|
160
|
-
|
|
161
|
-
@Component({
|
|
162
|
-
selector: "app-niivue-view",
|
|
163
|
-
templateUrl: "./niivue-view.component.html",
|
|
164
|
-
styleUrls: ["./niivue-view.component.sass"],
|
|
165
|
-
})
|
|
166
|
-
export class NiivueViewComponent implements OnInit {
|
|
167
|
-
@ViewChild("gl") canvas: HTMLCanvasElement | undefined;
|
|
168
|
-
|
|
169
|
-
constructor() {}
|
|
170
|
-
|
|
171
|
-
ngOnInit(): void {
|
|
172
|
-
const url = "/assets/mni152.nii.gz";
|
|
173
|
-
const volumeList = [
|
|
174
|
-
{
|
|
175
|
-
url,
|
|
176
|
-
},
|
|
177
|
-
];
|
|
178
|
-
const niivue = new Niivue();
|
|
179
|
-
niivue.attachTo("gl");
|
|
180
|
-
niivue.loadVolumes(volumeList);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
# Core Libraries
|
|
186
|
-
|
|
187
|
-
- [shader.js source](https://github.com/Twinklebear/webgl-util)
|
|
188
|
-
- [Daikon](https://github.com/rii-mango/Daikon)
|
|
189
|
-
- [NIFTI-Reader-JS source](https://github.com/rii-mango/NIFTI-Reader-JS)
|
|
190
|
-
- [glMatrix](https://glmatrix.net/)
|
|
191
|
-
- [fflate](https://github.com/101arrowz/fflate)
|
|
35
|
+
- [neurodesk](https://www.neurodesk.org/) uses NiiVue for their [QSMxT Quantitative Susceptibility Mapping toolbox](https://github.com/QSMxT/QSMxT-UI)
|
|
36
|
+
- [niivue-vscode](https://github.com/niivue/niivue-vscode) is a VSCode extension for displaying images
|
|
37
|
+
- [Neuroinformatics Research and Development Group](http://neuroinformatics.uw.edu/) embeds NiiVue in [tractoscope](https://github.com/nrdg/tractoscope)
|
|
38
|
+
- [CACTAS](https://github.com/mpsych/CACTAS) from [Daniel Haehn's team](https://danielhaehn.com/) is extending NiiVue drawing and segmentation capabilities
|
|
39
|
+
- [Digital Brain Bank](https://elifesciences.org/articles/73153) for navigating MRI datasets
|
|
192
40
|
|
|
193
41
|
# Funding
|
|
194
42
|
|
|
195
|
-
- 2021-2022
|
|
196
|
-
|
|
43
|
+
- 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)
|
|
44
|
+
- 2023-2026 [RF1 MH133701](https://reporter.nih.gov/search/D3sOjJtXwkSRKLpYf1ctBg/project-details/10724895) NIH NIMH
|
|
197
45
|
|
|
198
46
|
# Supported Formats
|
|
199
47
|
|
|
200
|
-
NiiVue
|
|
48
|
+
NiiVue supports many popular brain imaging formats:
|
|
201
49
|
|
|
202
50
|
- 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).
|
|
203
51
|
- 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/).
|
|
204
52
|
- 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)
|
|
205
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
|
|
206
54
|
- DICOM: [DICOM](https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html) and [DICOM Manifests](docs/development-notes/dicom-manifests.md)
|
|
207
|
-
|
|
208
|
-
# Alternatives
|
|
209
|
-
|
|
210
|
-
There are several open source JavaScript NIfTI viewers. What makes NiiVue unique is how it leverages the shaders functions and 3D textures introduced with WebGL 2.0. The minimal design makes it easy to integrate with existing web pages quickly in order to build powerful web-based viewers and support cloud-based analysis pipelines. Unlike many alternatives, NiiVue does **not** use [three.js](https://threejs.org). This means the screen is only refreshed when needed (preserving battery life and helping your computer do other tasks). On the other hand, NiiVue does not have access to the three.js user interface widgets, requiring developers to create their own custom widgets (e.g. using VueJS, React, Angular or pure HTML). Since there are numerous free alternatives, you can choose the optimal tool for your task.
|
|
211
|
-
[Francesco Giorlando](https://f.giorlando.org/2018/07/web-viewers-for-fmri/) describes some of the differences between different tools.
|
|
212
|
-
|
|
213
|
-
| Tool | Live Demos |
|
|
214
|
-
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
|
215
|
-
| [AMI](https://github.com/FNNDSC/ami) | [live demo](https://fnndsc.github.io/ami/) |
|
|
216
|
-
| [BioImage Suite Web Project](https://github.com/bioimagesuiteweb/bisweb) | [live demo](https://bioimagesuiteweb.github.io/webapp/viewer.html) |
|
|
217
|
-
| [BrainBrowser](https://brainbrowser.cbrain.mcgill.ca/) | [live demo](https://brainbrowser.cbrain.mcgill.ca/volume-viewer) |
|
|
218
|
-
| [nifti-drop](https://github.com/vsoch/nifti-drop) | [live demo](http://vsoch.github.io/nifti-drop) |
|
|
219
|
-
| [Papaya](https://github.com/rii-mango/Papaya) | [live demo](https://www.fmrib.ox.ac.uk/ukbiobank/group_means/index.html) |
|
|
220
|
-
| [VTK.js](https://github.com/Kitware/vtk-js) | [live demo](https://kitware.github.io/paraview-glance/app/) |
|
|
221
|
-
| [slicedrop](https://github.com/slicedrop/slicedrop.github.com) | [live demo](https://slicedrop.com/) |
|
|
222
|
-
|
|
223
|
-
# Development
|
|
224
|
-
|
|
225
|
-
All NiiVue development is public on GitHub. The `main` branch represents the most current state of NiiVue.
|
|
226
|
-
|
|
227
|
-
NiiVue is currently in a state of rapid development until we get to version `1.0.0`. Therefore, it may be a good idea to check back frequently if you are developing software that relies on NiiVue. NiiVue releases starting with `0` should be considered beta software.
|
|
228
|
-
|
|
229
|
-
**Note**: All PRs from a fork or feature branch to `main` will require the automated github actions test suite to pass.
|
|
230
|
-
|
|
231
|
-
## Install NiiVue into your project via NPM
|
|
232
|
-
|
|
233
|
-
Each version of NiiVue is published to NPM
|
|
234
|
-
|
|
235
|
-
https://www.npmjs.com/package/@niivue/niivue
|
|
236
|
-
|
|
237
|
-
Do the following to install NiiVue as a dependency in your project
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
npm install --save-dev @niivue/niivue
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
## Local Development
|
|
244
|
-
|
|
245
|
-
Make sure you have nodejs and npm installed.
|
|
246
|
-
|
|
247
|
-
```
|
|
248
|
-
git clone git@github.com:niivue/niivue.git
|
|
249
|
-
cd niivue
|
|
250
|
-
npm install
|
|
251
|
-
npm run dev
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## Launch included demos
|
|
255
|
-
|
|
256
|
-
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.
|
|
257
|
-
|
|
258
|
-
**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.**
|
|
259
|
-
|
|
260
|
-
### On macOS and Linux
|
|
261
|
-
|
|
262
|
-
```
|
|
263
|
-
npm run demo
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### On Windows
|
|
267
|
-
|
|
268
|
-
```
|
|
269
|
-
npm run demo-win
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## Build NiiVue
|
|
273
|
-
|
|
274
|
-
Building NiiVue will format, build, and copy the bundled `niivue.js` to the `tests` and `demos` folders.
|
|
275
|
-
|
|
276
|
-
### on macOS and Linux
|
|
277
|
-
|
|
278
|
-
```
|
|
279
|
-
npm run build
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### on Windows
|
|
283
|
-
|
|
284
|
-
```
|
|
285
|
-
npm run build-win
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Versioning
|
|
289
|
-
|
|
290
|
-
NiiVue uses [semantic versioning](https://semver.org/).
|
|
291
|
-
|
|
292
|
-
To update the version run:
|
|
293
|
-
|
|
294
|
-
```
|
|
295
|
-
npm version patch # options are: major | minor | patch
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## Run unit tests
|
|
299
|
-
|
|
300
|
-
Running the tests will format, build, and copy the bundled `niivue.js` to the `tests` and `demos` folders, then automatically begin the test suite.
|
|
301
|
-
|
|
302
|
-
### on macOS and Linux
|
|
303
|
-
|
|
304
|
-
**If using macOS with Apple Silicon add this to your .zshrc (if zsh). Also ensure Chrome is installed at that location:**
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
308
|
-
export PUPPETEER_EXECUTABLE_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
```
|
|
312
|
-
npm install
|
|
313
|
-
npm run test
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
### on Windows
|
|
317
|
-
|
|
318
|
-
```
|
|
319
|
-
npm run test-win
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### Running a specific test
|
|
323
|
-
|
|
324
|
-
```
|
|
325
|
-
npm run test -- -t 'test string'
|
|
326
|
-
# on windows use npm run test-win
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
## Creating fonts
|
|
330
|
-
|
|
331
|
-
```
|
|
332
|
-
{ echo "data:image/png;base64,"; openssl enc -base64 -in fnt.png; } > fnt.txt
|
|
333
|
-
|
|
334
|
-
# then copy the contents of fnt.txt to the font string in src/fnt.js
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
# Contributing
|
|
338
|
-
|
|
339
|
-
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).
|
|
340
|
-
|
|
341
|
-
## Using Issues
|
|
342
|
-
|
|
343
|
-
**All** contributions should start as a new issue on the [NiiVue issue board](https://github.com/niivue/niivue/issues).
|
|
344
|
-
|
|
345
|
-
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.
|
|
346
|
-
|
|
347
|
-
## Things to consider
|
|
348
|
-
|
|
349
|
-
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.
|
|
350
|
-
|
|
351
|
-
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`.
|
|
352
|
-
|
|
353
|
-
## Adding tests
|
|
354
|
-
|
|
355
|
-
NiiVue relies on [Jest](https://jestjs.io/)
|
|
356
|
-
|
|
357
|
-
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.
|
|
358
|
-
|
|
359
|
-
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.
|
|
360
|
-
|
|
361
|
-
## Automated CI/CD
|
|
362
|
-
|
|
363
|
-
We rely heavily on GitHub's actions to automate testing and checks.
|
|
364
|
-
|
|
365
|
-
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.
|
|
366
|
-
|
|
367
|
-
Each PR to the main branch must pass the automated checks, and must be reviewed and signed off by at least one other person.
|
|
368
|
-
|
|
369
|
-
If all checks and tests pass then PRs will be merged into main.
|
|
370
|
-
|
|
371
|
-
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.
|
|
372
|
-
|
|
373
|
-
## Protected branches
|
|
374
|
-
|
|
375
|
-
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.
|
|
376
|
-
|
|
377
|
-
## Making colormap loader
|
|
378
|
-
|
|
379
|
-
```
|
|
380
|
-
cd src/cmaps
|
|
381
|
-
|
|
382
|
-
for f in ls *.json; do echo "export { default as `basename $f .json` } from './$f';" >> index.js; done;
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
## macOS kill test server if kept alive because of failing tests
|
|
386
|
-
|
|
387
|
-
```
|
|
388
|
-
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep 8888 # 8888 is the test server used by jest
|
|
389
|
-
|
|
390
|
-
# the process id is the second column in the result
|
|
391
|
-
|
|
392
|
-
kill <pid> # kill the node process running the server if needed (when tests fail locally)
|
|
393
|
-
```
|