@niivue/niivue 0.63.0 → 0.65.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.
@@ -1,4 +1,4 @@
1
- import { S as SLICE_TYPE, T as TypedVoxelArray } from '../nvdocument-5GNlbB1d.js';
1
+ import { S as SLICE_TYPE, T as TypedVoxelArray } from '../nvdocument-Bma8slLJ.js';
2
2
  import 'gl-matrix';
3
3
  import 'nifti-reader-js';
4
4
 
@@ -8089,12 +8089,22 @@ var ColorTables = class {
8089
8089
  const cmap = this.colormapFromKey(key);
8090
8090
  return this.makeLut(cmap.R, cmap.G, cmap.B, cmap.A, cmap.I, isInvert);
8091
8091
  }
8092
- makeLabelLut(cm, alphaFill = 255) {
8092
+ makeLabelLut(cm, alphaFill = 255, maxIdx = Infinity) {
8093
8093
  if (cm.R === void 0 || cm.G === void 0 || cm.B === void 0) {
8094
8094
  throw new Error(`Invalid colormap table: ${cm}`);
8095
8095
  }
8096
8096
  const nLabels = cm.R.length;
8097
8097
  const idxs = cm.I ?? [...Array(nLabels).keys()];
8098
+ let hasInvalid = false;
8099
+ for (let i = 0; i < idxs.length; i++) {
8100
+ if (idxs[i] > maxIdx) {
8101
+ hasInvalid = true;
8102
+ idxs[i] = maxIdx;
8103
+ }
8104
+ }
8105
+ if (hasInvalid) {
8106
+ log.warn(`Some colormap indices clamped to match label range.`);
8107
+ }
8098
8108
  if (nLabels !== cm.G.length || nLabels !== cm.B.length || nLabels !== idxs.length) {
8099
8109
  throw new Error(
8100
8110
  `colormap does not make sense: ${cm} Rs ${cm.R.length} Gs ${cm.G.length} Bs ${cm.B.length} Is ${idxs.length}`
@@ -8135,10 +8145,10 @@ var ColorTables = class {
8135
8145
  }
8136
8146
  return cmap;
8137
8147
  }
8138
- async makeLabelLutFromUrl(name) {
8148
+ async makeLabelLutFromUrl(name, alphaFill = 255, maxIdx = Infinity) {
8139
8149
  const response = await fetch(name);
8140
8150
  const cm = await response.json();
8141
- return this.makeLabelLut(cm);
8151
+ return this.makeLabelLut(cm, alphaFill, maxIdx);
8142
8152
  }
8143
8153
  // not included in public docs
8144
8154
  // The drawing colormap is a variant of the label colormap with precisely 256 colors
@@ -8276,6 +8286,7 @@ var ImageType = /* @__PURE__ */ ((ImageType3) => {
8276
8286
  ImageType3[ImageType3["ZARR"] = 20] = "ZARR";
8277
8287
  ImageType3[ImageType3["NPY"] = 21] = "NPY";
8278
8288
  ImageType3[ImageType3["NPZ"] = 22] = "NPZ";
8289
+ ImageType3[ImageType3["HDR"] = 23] = "HDR";
8279
8290
  return ImageType3;
8280
8291
  })(ImageType || {});
8281
8292
  var NVIMAGE_TYPE = Object.freeze({
@@ -8296,6 +8307,7 @@ var NVIMAGE_TYPE = Object.freeze({
8296
8307
  case "FIB":
8297
8308
  imageType = 18 /* FIB */;
8298
8309
  break;
8310
+ case "HDR":
8299
8311
  case "NII":
8300
8312
  imageType = 1 /* NII */;
8301
8313
  break;
@@ -8426,15 +8438,14 @@ var DEFAULT_OPTIONS = {
8426
8438
  fontColor: [0.5, 0.5, 0.5, 1],
8427
8439
  selectionBoxColor: [1, 1, 1, 0.5],
8428
8440
  clipPlaneColor: [0.7, 0, 0.7, 0.5],
8441
+ isClipPlanesCutaway: false,
8429
8442
  paqdUniforms: [0.3, 0.5, 0.5, 1],
8430
8443
  // paqdUniforms: [0.3, 0.9, 1.0, 0.5],
8431
- clipThick: 2,
8432
- clipVolumeLow: [0, 0, 0],
8433
- clipVolumeHigh: [1, 1, 1],
8434
8444
  rulerColor: [1, 0, 0, 0.8],
8435
8445
  colorbarMargin: 0.05,
8436
8446
  trustCalMinMax: true,
8437
8447
  clipPlaneHotKey: "KeyC",
8448
+ cycleClipPlaneHotKey: "KeyP",
8438
8449
  viewModeHotKey: "KeyV",
8439
8450
  doubleTouchTimeout: 500,
8440
8451
  longTouchTimeout: 1e3,
@@ -8544,13 +8555,12 @@ var INITIAL_SCENE_DATA = {
8544
8555
  azimuth: 110,
8545
8556
  elevation: 10,
8546
8557
  crosshairPos: vec39.fromValues(0.5, 0.5, 0.5),
8547
- clipPlane: [0, 0, 0, 0],
8548
- clipPlaneDepthAziElev: [2, 0, 0],
8558
+ clipPlanes: [[0, 0, 0, 0]],
8559
+ // start with no planes
8560
+ clipPlaneDepthAziElevs: [[2, 0, 0]],
8561
+ // empty by default
8549
8562
  volScaleMultiplier: 1,
8550
- pan2Dxyzmm: vec47.fromValues(0, 0, 0, 1),
8551
- clipThick: 2,
8552
- clipVolumeLow: [0, 0, 0],
8553
- clipVolumeHigh: [1, 1, 1]
8563
+ pan2Dxyzmm: vec47.fromValues(0, 0, 0, 1)
8554
8564
  };
8555
8565
 
8556
8566
  // src/drawing/masks.ts