@niivue/niivue 0.43.2 → 0.43.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niivue/niivue",
3
- "version": "0.43.2",
3
+ "version": "0.43.3",
4
4
  "description": "minimal webgl2 nifti image viewer",
5
5
  "types": "./build/index.d.ts",
6
6
  "main": "./build/index.js",
@@ -3377,6 +3377,18 @@ export class Niivue {
3377
3377
  }
3378
3378
  const image = NVImage.loadFromBase64({ base64, ...imageOptions })
3379
3379
  if (image) {
3380
+ if (image.colormapLabel) {
3381
+ const length = Object.keys(image.colormapLabel.lut).length
3382
+
3383
+ // Create a new Uint8ClampedArray with the length of the object.
3384
+ const uint8ClampedArray = new Uint8ClampedArray(length)
3385
+
3386
+ // Iterate over the object and set the values of the Uint8ClampedArray.
3387
+ for (const key in image.colormapLabel.lut) {
3388
+ uint8ClampedArray[key] = image.colormapLabel.lut[key]
3389
+ }
3390
+ image.colormapLabel.lut = uint8ClampedArray
3391
+ }
3380
3392
  this.addVolume(image)
3381
3393
  }
3382
3394
  }
package/src/nvdocument.ts CHANGED
@@ -234,6 +234,7 @@ export type DocumentData = {
234
234
  sceneData?: SceneData
235
235
  // TODO referenced in niivue/loadDocument
236
236
  connectomes?: string[]
237
+ customData?: string
237
238
  }
238
239
 
239
240
  export type ExportDocumentData = {
@@ -256,6 +257,7 @@ export type ExportDocumentData = {
256
257
  // TODO the following fields were missing in the typedef
257
258
  labels: NVLabel3D[]
258
259
  connectomes: string[]
260
+ customData: string
259
261
  }
260
262
 
261
263
  /**
@@ -428,6 +430,14 @@ export class NVDocument {
428
430
  this.data.labels = labels
429
431
  }
430
432
 
433
+ get customData(): string | undefined {
434
+ return this.data.customData
435
+ }
436
+
437
+ set customData(data: string) {
438
+ this.data.customData = data
439
+ }
440
+
431
441
  /**
432
442
  * Checks if document has an image by id
433
443
  */
@@ -515,6 +525,7 @@ export class NVDocument {
515
525
  }
516
526
 
517
527
  data.labels = [...this.data.labels]
528
+ data.customData = this.customData
518
529
 
519
530
  // volumes
520
531
  // TODO move this to a per-volume export function in NVImage?
@@ -3560,7 +3560,7 @@ export class NVImage {
3560
3560
  */
3561
3561
  toUint8Array(drawingBytes: Uint8Array | null = null): Uint8Array {
3562
3562
  const isDrawing = drawingBytes !== null
3563
- const hdrBytes = hdrToArrayBuffer(this.hdr!, isDrawing)
3563
+ const hdrBytes = hdrToArrayBuffer({ ...this.hdr!, vox_offset: 352 }, isDrawing)
3564
3564
 
3565
3565
  let drawingBytesToBeConverted = drawingBytes
3566
3566
  if (isDrawing) {