zincjs 1.19.0 → 1.19.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/build/zinc.js CHANGED
@@ -32,7 +32,7 @@ module.exports = require("url-polyfill");
32
32
  /***/ ((module) => {
33
33
 
34
34
  "use strict";
35
- module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.19.0","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","nifti-reader-js":"^0.8.0","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
35
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.19.1","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","nifti-reader-js":"^0.8.0","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
36
36
 
37
37
  /***/ }),
38
38
  /* 3 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zincjs",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -121,6 +121,89 @@ function readNIFTI(data) {
121
121
  return {niftiHeader: undefined, niftiImage: undefined};
122
122
  }
123
123
 
124
+
125
+ function createSources(niftiHeader, niftiImage, maskHeader, maskImage, options) {
126
+ if (niftiHeader?.dims && niftiHeader.dims[0] === 3) {
127
+ const width = niftiHeader.dims[1];
128
+ const height = niftiHeader.dims[2];
129
+ const depth = niftiHeader.dims[3];
130
+ const { typedData, dataType } = getTypedData(niftiHeader, niftiImage);
131
+ const sliceSize = width * height;
132
+ const length = sliceSize * depth * 4;
133
+ const fullArray = new Uint8Array(length);
134
+ let maskData = undefined;
135
+ if (maskHeader && maskImage) {
136
+ const maskWidth = maskHeader.dims[1];
137
+ const maskHeight = maskHeader.dims[2];
138
+ const maskDepth = maskHeader.dims[3];
139
+ if (maskWidth === width && maskHeight === height && maskDepth === depth) {
140
+ const maskedTypedData = getTypedData(maskHeader, maskImage);
141
+ maskData = maskedTypedData.typedData;
142
+ }
143
+ }
144
+ let slope = niftiHeader.scl_slope || 1;
145
+ let intercept = niftiHeader.scl_inter || 0;
146
+
147
+ let min = Infinity;
148
+ let max = -Infinity;
149
+
150
+ const dataLength = typedData.length;
151
+ for (let i = 0; i < dataLength; i++) {
152
+ let val = (typedData[i] * slope) + intercept;
153
+ if (val < min) min = val;
154
+ if (val > max) max = val;
155
+ }
156
+ let range = max - min;
157
+
158
+ for (let slice = 0; slice < depth; slice++) {
159
+ const sliceOffset = sliceSize * slice;
160
+ for (let row = 0; row < height; row++) {
161
+ const rowOffset = row * width;
162
+ for (let col = 0; col < width; col++) {
163
+ const offset = sliceOffset + rowOffset + col;
164
+ let trueVal = typedData[offset] * slope + intercept;
165
+ let value = 0;
166
+ if (range !== 0) {
167
+ // Map [min, max] to [0, 255]
168
+ value = ((trueVal - min) / range) * 255;
169
+ }
170
+ fullArray[offset * 4] = value;
171
+ fullArray[offset * 4 + 1] = value;
172
+ fullArray[offset * 4 + 2] = value;
173
+ fullArray[offset * 4 + 3] = 255;
174
+ if (maskData) {
175
+ const maskedValue = maskData[offset];
176
+ if (options.hideBlackPixel) {
177
+ //if (maskedValue === 0 && 20 > value) {
178
+ if (maskedValue === 0) {
179
+ fullArray[offset * 4 + 3] = 0;
180
+ }
181
+ }
182
+ } else if (options.filterByValue) {
183
+ if (options.hideWhitePixel && value === 255) {
184
+ fullArray[offset * 4 + 3] = 0;
185
+ }
186
+ if (options.hideBlackPixel && 2 >= value) {
187
+ fullArray[offset * 4] = 240;
188
+ fullArray[offset * 4 + 1] = 240;
189
+ fullArray[offset * 4 + 2] = 240;
190
+ fullArray[offset * 4 + 3] = 1.0;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ return {
198
+ data: fullArray,
199
+ width,
200
+ height,
201
+ depth,
202
+ };
203
+ }
204
+ return undefined;
205
+ }
206
+ /*
124
207
  function createSources(niftiHeader, niftiImage, maskHeader, maskImage, options) {
125
208
  if (niftiHeader?.dims && niftiHeader.dims[0] === 3) {
126
209
  const width = niftiHeader.dims[1];
@@ -206,6 +289,8 @@ function createSources(niftiHeader, niftiImage, maskHeader, maskImage, options)
206
289
  return undefined;
207
290
  }
208
291
 
292
+ */
293
+
209
294
  function getTypedData(niftiHeader, niftiImage) {
210
295
  if (niftiHeader.datatypeCode === nifti.NIFTI1.TYPE_UINT8) {
211
296
  return { typedData: new Uint8Array(niftiImage), dataType: "uint" };