@niivue/niivue 0.9.3 → 0.12.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.
Files changed (76) hide show
  1. package/README.md +77 -13
  2. package/dist/niivue.es.js +13936 -0
  3. package/dist/niivue.umd.js +541 -0
  4. package/package.json +26 -19
  5. package/src/cmaps/actc.json +9 -0
  6. package/src/cmaps/blue.json +9 -0
  7. package/src/cmaps/blue2red.json +9 -0
  8. package/src/cmaps/bluegrn.json +9 -0
  9. package/src/cmaps/bone.json +9 -0
  10. package/src/cmaps/bronze.json +9 -0
  11. package/src/cmaps/cividis.json +9 -0
  12. package/src/cmaps/cool.json +9 -0
  13. package/src/cmaps/copper.json +9 -0
  14. package/src/cmaps/copper2.json +9 -0
  15. package/src/cmaps/ct_airways.json +9 -0
  16. package/src/cmaps/ct_bones.json +9 -0
  17. package/src/cmaps/ct_brain.json +9 -0
  18. package/src/cmaps/ct_brain_gray.json +9 -0
  19. package/src/cmaps/ct_cardiac.json +9 -0
  20. package/src/cmaps/ct_head.json +9 -0
  21. package/src/cmaps/ct_kidneys.json +9 -0
  22. package/src/cmaps/ct_liver.json +9 -0
  23. package/src/cmaps/ct_muscles.json +9 -0
  24. package/src/cmaps/ct_scalp.json +9 -0
  25. package/src/cmaps/ct_skull.json +9 -0
  26. package/src/cmaps/ct_soft.json +9 -0
  27. package/src/cmaps/ct_soft_tissue.json +9 -0
  28. package/src/cmaps/ct_surface.json +9 -0
  29. package/src/cmaps/ct_vessels.json +9 -0
  30. package/src/cmaps/ct_w_contrast.json +9 -0
  31. package/src/cmaps/cubehelix.json +24 -0
  32. package/src/cmaps/electric_blue.json +9 -0
  33. package/src/cmaps/ge_color.json +9 -0
  34. package/src/cmaps/gold.json +9 -0
  35. package/src/cmaps/gray.json +9 -0
  36. package/src/cmaps/green.json +9 -0
  37. package/src/cmaps/hot.json +9 -0
  38. package/src/cmaps/hotiron.json +9 -0
  39. package/src/cmaps/hsv.json +9 -0
  40. package/src/cmaps/index.js +52 -0
  41. package/src/cmaps/inferno.json +9 -0
  42. package/src/cmaps/jet.json +9 -0
  43. package/src/cmaps/linspecer.json +9 -0
  44. package/src/cmaps/magma.json +9 -0
  45. package/src/cmaps/mako.json +9 -0
  46. package/src/cmaps/nih.json +9 -0
  47. package/src/cmaps/plasma.json +9 -0
  48. package/src/cmaps/random.json +92 -0
  49. package/src/cmaps/red.json +9 -0
  50. package/src/cmaps/redyell.json +9 -0
  51. package/src/cmaps/rocket.json +9 -0
  52. package/src/cmaps/surface.json +9 -0
  53. package/src/cmaps/violet.json +9 -0
  54. package/src/cmaps/viridis.json +9 -0
  55. package/src/cmaps/warm.json +9 -0
  56. package/src/cmaps/winter.json +9 -0
  57. package/src/cmaps/x_rain.json +9 -0
  58. package/src/fonts/Garamond.json +1491 -0
  59. package/src/fonts/Garamond.png +0 -0
  60. package/src/fonts/GaramondBold.json +1506 -0
  61. package/src/fonts/GaramondBold.png +0 -0
  62. package/src/fonts/Roboto-Regular.json +1496 -0
  63. package/src/fonts/Roboto-Regular.png +0 -0
  64. package/src/fonts/Ubuntu.json +1506 -0
  65. package/src/fonts/Ubuntu.png +0 -0
  66. package/src/fonts/UbuntuBold.json +1506 -0
  67. package/src/fonts/UbuntuBold.png +0 -0
  68. package/src/index.html +80 -0
  69. package/src/mni152.nii.gz +0 -0
  70. package/src/niivue-object3D.js +31 -0
  71. package/src/niivue-shader3D.js +11 -0
  72. package/src/niivue.js +2872 -0
  73. package/src/nvimage.js +566 -0
  74. package/src/shader-srcs.js +519 -0
  75. package/src/shader.js +76 -0
  76. package/dist/niivue.js +0 -2
package/README.md CHANGED
@@ -4,6 +4,10 @@ NiiVue is a WebGL 2.0 medical image viewer. This repository contains the **core
4
4
 
5
5
  The NiiVue package is intented to be used by individuals developing interactive web pages related to showing [nifti](https://nifti.nimh.nih.gov) images. 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 [web-based user interface implementation](https://github.com/niivue/niivue-ui) (under development) will demonstrate how to integrate NiiVue into a more comprehensive [VueJS](https://vuejs.org/) UI.
6
6
 
7
+ # Getting started Docs and References
8
+
9
+ [click here to go to the docs web page](https://niivue.github.io/niivue/devdocs/)
10
+
7
11
  # Active Projects
8
12
 
9
13
  [See our active projects here](https://github.com/orgs/niivue/projects)
@@ -33,8 +37,8 @@ We host many NiiVue examples via github pages. These are updated and deployed au
33
37
  # Usage
34
38
 
35
39
  ## existing html page
36
- ```
37
- <script src="https://unpkg.com/@niivue/niivue@0.9.3/dist/niivue.js"></script>
40
+ ```html
41
+ <script src="https://unpkg.com/@niivue/niivue@0.12.1/dist/niivue.js"></script>
38
42
 
39
43
  <canvas id="gl" height=480 width=640></canvas>
40
44
 
@@ -45,11 +49,8 @@ We host many NiiVue examples via github pages. These are updated and deployed au
45
49
  url: "./some_image.nii.gz",
46
50
  volume: {hdr: null, img: null},
47
51
  name: "some_image",
48
- intensityMin: 0, // not used yet
49
- intensityMax: 100, // not used yet
50
- intensityRange:[0, 100], // not used yet
51
52
  colorMap: "gray",
52
- opacity: 100,
53
+ opacity: 1,
53
54
  visible: true,
54
55
  }
55
56
  ]
@@ -59,16 +60,17 @@ We host many NiiVue examples via github pages. These are updated and deployed au
59
60
  var nv = new niivue.Niivue()
60
61
  nv.attachTo('gl') // the canvas element id
61
62
  nv.loadVolumes(volumeList)
62
- nv.setSliceType(nv.sliceTypeMultiPlanar)
63
+ nv.setSliceType(nv.sliceTypeMultiPlanar) // press the "v" key to cycle through views
63
64
  </script>
64
65
  ```
65
66
 
66
67
  ## VueJS example
67
68
 
68
- ```
69
+ install: `npm i @niivue/niivue`
70
+
71
+ ```js
69
72
  <script>
70
73
  import {Niivue} from '@niivue/niivue'
71
- console.log(Niivue)
72
74
  const nv = new Niivue()
73
75
 
74
76
 
@@ -84,7 +86,7 @@ export default {
84
86
  url: "./mni152.nii.gz",
85
87
  volume: {hdr: null, img: null},
86
88
  colorMap: "gray",
87
- opacity: 100,
89
+ opacity: 1,
88
90
  visible: true,
89
91
  }
90
92
  ]
@@ -95,7 +97,7 @@ export default {
95
97
  mounted() {
96
98
 
97
99
  nv.attachTo('gl')
98
- nv.loadVolumes(this.volumeList)
100
+ nv.loadVolumes(this.volumeList) // press the "v" key to cycle through views
99
101
 
100
102
  }
101
103
  }
@@ -116,13 +118,41 @@ export default {
116
118
 
117
119
  ## React example
118
120
 
119
- to come...
120
-
121
+ install: `npm i @niivue/niivue`
122
+
123
+ ```js
124
+ import { useRef, useState } from 'react'
125
+ import { Niivue } from '@niivue/niivue'
126
+
127
+ const NiiVue = ({ imageUrl }) => {
128
+ const canvas = useRef()
129
+ useEffect(() => {
130
+ const volumeList = [
131
+ {
132
+ url: imageUrl,
133
+ volume: { hdr: null, img: null },
134
+ colorMap: 'gray',
135
+ opacity: 1,
136
+ visible: true,
137
+ },
138
+ ]
139
+ const nv = new Niivue()
140
+ nv.attachToCanvas(canvas)
141
+ nv.loadVolumes(volumeList) // press the "v" key to cycle through volumes
142
+ }, [imageUrl])
143
+
144
+ return (
145
+ <canvas ref={canvas} height={480} width={640} />
146
+ )
147
+ }
148
+ ```
149
+
121
150
  # Contributors
122
151
 
123
152
  - [Taylor Hanayik](https://github.com/hanayik)
124
153
  - [Chris Rorden](https://github.com/neurolabusc)
125
154
  - [Christopher Drake](https://github.com/cdrake)
155
+ - [Nell Hardcastle](https://github.com/nellh)
126
156
 
127
157
  *To add yourself please create a PR
128
158
 
@@ -183,6 +213,14 @@ Source code can be found in `src/`.
183
213
 
184
214
  You can edit the sources and then launch demos to see the effect of your changes. See the "Launch inlcluded demos" section.
185
215
 
216
+ ## Run hot module reload development mode
217
+
218
+ This will run the vite HMR dev server. Open a browser to the URL output in your terminal. changes made to the source code will be immediately reflected in the browser.
219
+
220
+ ```
221
+ npm run dev
222
+ ```
223
+
186
224
  ## Launch included demos
187
225
 
188
226
  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.
@@ -233,7 +271,15 @@ Running the tests will format, build, and copy the bundled `niivue.js` to the `t
233
271
 
234
272
  ### on macOS and Linux
235
273
 
274
+ **If using macOS with Apple Silicon add this to your .zshrc (if zsh). Also ensure Chrome is installed at that location:**
275
+
276
+ ```
277
+ export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
278
+ export PUPPETEER_EXECUTABLE_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
279
+ ```
280
+
236
281
  ```
282
+ npm install
237
283
  npm run test
238
284
  ```
239
285
 
@@ -297,4 +343,22 @@ You can edit a feature branch as many times as needed to fix broken tests in ord
297
343
 
298
344
  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.
299
345
 
346
+ ## Making colormap loader
347
+
348
+ ```
349
+ cd src/cmaps
350
+
351
+ for f in ls *.json; do echo "export { default as `basename $f .json` } from './$f';" >> index.js; done;
352
+ ```
353
+
354
+ ## macOS kill test server if kept alive because of failing tests
355
+
356
+ ```
357
+ sudo lsof -iTCP -sTCP:LISTEN -n -P | grep 8888 # 8888 is the test server used by jest
358
+
359
+ # the process id is the second column in the result
360
+
361
+ kill <pid> # kill the node process running the server if needed (when tests fail locally)
362
+ ```
363
+
300
364