@vitessce/ome-tiff 3.6.10 → 3.6.12

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,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
2
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -103001,7 +103001,8 @@ const PIXELATED_TEXTURE_PARAMETERS = {
103001
103001
  const GLSL_COLORMAPS = [
103002
103002
  "plasma",
103003
103003
  "viridis",
103004
- "jet"
103004
+ "jet",
103005
+ "greys"
103005
103006
  ];
103006
103007
  const GLSL_COLORMAP_DEFAULT = "plasma";
103007
103008
  const COLORMAP_SHADER_PLACEHOLDER = "COLORMAP_FUNC";
@@ -104771,22 +104772,22 @@ async function getDecoder(fileDirectory) {
104771
104772
  const Decoder = await importFn();
104772
104773
  return new Decoder(fileDirectory);
104773
104774
  }
104774
- addDecoder([void 0, 1], () => import("./raw-C3hLu5jb.js").then((m) => m.default));
104775
- addDecoder(5, () => import("./lzw-Ce2kmxIQ.js").then((m) => m.default));
104775
+ addDecoder([void 0, 1], () => import("./raw-DBApv_dB.js").then((m) => m.default));
104776
+ addDecoder(5, () => import("./lzw-C6XzILiL.js").then((m) => m.default));
104776
104777
  addDecoder(6, () => {
104777
104778
  throw new Error("old style JPEG compression is not supported.");
104778
104779
  });
104779
- addDecoder(7, () => import("./jpeg-CCpTe65J.js").then((m) => m.default));
104780
- addDecoder([8, 32946], () => import("./deflate-BmN326NK.js").then((m) => m.default));
104781
- addDecoder(32773, () => import("./packbits-DmSd6DAT.js").then((m) => m.default));
104780
+ addDecoder(7, () => import("./jpeg-BOmRcIup.js").then((m) => m.default));
104781
+ addDecoder([8, 32946], () => import("./deflate-CsVUJRQh.js").then((m) => m.default));
104782
+ addDecoder(32773, () => import("./packbits-DPaUyK48.js").then((m) => m.default));
104782
104783
  addDecoder(
104783
104784
  34887,
104784
- () => import("./lerc-CS9H9Ndh.js").then(async (m) => {
104785
+ () => import("./lerc-D8moRaV1.js").then(async (m) => {
104785
104786
  await m.zstd.init();
104786
104787
  return m;
104787
104788
  }).then((m) => m.default)
104788
104789
  );
104789
- addDecoder(50001, () => import("./webimage-DItILlGR.js").then((m) => m.default));
104790
+ addDecoder(50001, () => import("./webimage-DIeQ7UJG.js").then((m) => m.default));
104790
104791
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
104791
104792
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
104792
104793
  }
@@ -141285,6 +141286,101 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
141285
141286
  const sliders = stats.map((stat) => stat.slider);
141286
141287
  return { domains, sliders };
141287
141288
  };
141289
+ class InternMap extends Map {
141290
+ constructor(entries, key = keyof) {
141291
+ super();
141292
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
141293
+ if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
141294
+ }
141295
+ get(key) {
141296
+ return super.get(intern_get(this, key));
141297
+ }
141298
+ has(key) {
141299
+ return super.has(intern_get(this, key));
141300
+ }
141301
+ set(key, value) {
141302
+ return super.set(intern_set(this, key), value);
141303
+ }
141304
+ delete(key) {
141305
+ return super.delete(intern_delete(this, key));
141306
+ }
141307
+ }
141308
+ function intern_get({ _intern, _key }, value) {
141309
+ const key = _key(value);
141310
+ return _intern.has(key) ? _intern.get(key) : value;
141311
+ }
141312
+ function intern_set({ _intern, _key }, value) {
141313
+ const key = _key(value);
141314
+ if (_intern.has(key)) return _intern.get(key);
141315
+ _intern.set(key, value);
141316
+ return value;
141317
+ }
141318
+ function intern_delete({ _intern, _key }, value) {
141319
+ const key = _key(value);
141320
+ if (_intern.has(key)) {
141321
+ value = _intern.get(key);
141322
+ _intern.delete(key);
141323
+ }
141324
+ return value;
141325
+ }
141326
+ function keyof(value) {
141327
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
141328
+ }
141329
+ class DAG {
141330
+ /**
141331
+ * DAG constructor.
141332
+ * @param {{ from: string, to: string, attributes: any}[]} edges
141333
+ */
141334
+ constructor(edges) {
141335
+ this.graph = /* @__PURE__ */ new Map();
141336
+ this.edgeData = new InternMap([], JSON.stringify);
141337
+ edges.forEach((edge) => {
141338
+ const { from, to } = edge;
141339
+ if (!this.graph.has(from)) {
141340
+ this.graph.set(from, []);
141341
+ }
141342
+ this.graph.get(from).push(to);
141343
+ this.edgeData.set([from, to], edge.attributes);
141344
+ });
141345
+ }
141346
+ /**
141347
+ * Find a path from start to end using DFS.
141348
+ * @param {string} start
141349
+ * @param {string} end
141350
+ * @returns {{ from: string, to: string, attributes: any }[] | null} Returns
141351
+ * the path as an array of edges or null if no path exists.
141352
+ */
141353
+ findPath(start, end) {
141354
+ const path = [];
141355
+ const visited = /* @__PURE__ */ new Set();
141356
+ const dfs = (node) => {
141357
+ if (node === end) {
141358
+ return true;
141359
+ }
141360
+ visited.add(node);
141361
+ const neighbors = this.graph.get(node) || [];
141362
+ for (const neighbor of neighbors) {
141363
+ if (!visited.has(neighbor)) {
141364
+ path.push([node, neighbor]);
141365
+ if (dfs(neighbor)) {
141366
+ return true;
141367
+ }
141368
+ path.pop();
141369
+ }
141370
+ }
141371
+ return false;
141372
+ };
141373
+ const found = dfs(start);
141374
+ if (found) {
141375
+ return path.map(([from, to]) => ({
141376
+ from,
141377
+ to,
141378
+ attributes: this.edgeData.get([from, to])
141379
+ }));
141380
+ }
141381
+ return null;
141382
+ }
141383
+ }
141288
141384
  function getSourceFromLoader(loader, level) {
141289
141385
  const { data } = loader;
141290
141386
  const source = Array.isArray(data) ? data[data.length - 1] : data;
@@ -141574,8 +141670,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141574
141670
  }
141575
141671
  } else if (spatialOutputAxes.length === 2) {
141576
141672
  const nextMat = new Matrix4().fromArray([
141577
- ...filteredAffine[0],
141578
- ...filteredAffine[1],
141673
+ filteredAffine[0][0],
141674
+ filteredAffine[0][1],
141675
+ 0,
141676
+ filteredAffine[0][2],
141677
+ filteredAffine[1][0],
141678
+ filteredAffine[1][1],
141679
+ 0,
141680
+ filteredAffine[1][2],
141579
141681
  0,
141580
141682
  0,
141581
141683
  1,
@@ -141591,6 +141693,7 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141591
141693
  const swapMat = new Matrix4().fromArray(swapMatNested.flat());
141592
141694
  mat = mat.multiplyLeft(swapMat);
141593
141695
  }
141696
+ mat = mat.transpose();
141594
141697
  } else {
141595
141698
  throw new Error("Affine transformation must have 2 or 3 rows.");
141596
141699
  }
@@ -141617,6 +141720,9 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141617
141720
  }
141618
141721
  });
141619
141722
  }
141723
+ if (mat.some((value) => Number.isNaN(value))) {
141724
+ throw new Error("Matrix contains NaN values");
141725
+ }
141620
141726
  return mat;
141621
141727
  }
141622
141728
  function hexToRgb(hex) {
@@ -141627,6 +141733,17 @@ function hexToRgb(hex) {
141627
141733
  parseInt(result[3].toLowerCase(), 16)
141628
141734
  ];
141629
141735
  }
141736
+ function normalizeAxes(axes) {
141737
+ return axes.map((axisInfo) => {
141738
+ if (typeof axisInfo === "string") {
141739
+ return { name: axisInfo, type: "space" };
141740
+ }
141741
+ return axisInfo;
141742
+ });
141743
+ }
141744
+ function getIntrinsicCoordinateSystem(normAxes) {
141745
+ return normAxes.map((axis) => axis.name).join("");
141746
+ }
141630
141747
  function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
141631
141748
  var _a3;
141632
141749
  let result = [];
@@ -141634,35 +141751,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
141634
141751
  result = coordinateTransformations.flatMap((transform2) => {
141635
141752
  if (transform2.input && transform2.output) {
141636
141753
  const { type } = transform2;
141637
- if (type === "translation") {
141638
- return {
141639
- type,
141640
- translation: transform2.translation
141641
- };
141642
- }
141643
- if (type === "scale") {
141644
- return {
141645
- type,
141646
- scale: transform2.scale
141647
- };
141648
- }
141649
- if (type === "affine") {
141650
- return {
141651
- type,
141652
- affine: transform2.affine,
141653
- // Affine transformations can potentially swap axes,
141654
- // so we need to include the input and output axes.
141655
- input: transform2.input,
141656
- output: transform2.output
141657
- };
141658
- }
141659
- if (type === "identity") {
141660
- return { type };
141661
- }
141662
141754
  if (type === "sequence") {
141663
- return normalizeCoordinateTransformations(transform2.transformations, datasets);
141755
+ return normalizeCoordinateTransformations(transform2.transformations, null);
141664
141756
  }
141665
- log$1.warn(`Coordinate transformation type "${type}" is not supported.`);
141757
+ if (type === "affine" || type === "translation" || type === "scale" || type === "identity") {
141758
+ return transform2;
141759
+ }
141760
+ log$1.error(`Coordinate transformation type "${type}" is not supported.`);
141666
141761
  }
141667
141762
  return transform2;
141668
141763
  });
@@ -141675,6 +141770,27 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
141675
141770
  }
141676
141771
  return result;
141677
141772
  }
141773
+ function coordinateTransformationsToMatrixForSpatialData(ngffMetadata, targetCoordinateSystem) {
141774
+ const { datasets, coordinateTransformations, axes } = ngffMetadata;
141775
+ const normAxes = normalizeAxes(axes);
141776
+ const intrinsicCoordinateSystem = getIntrinsicCoordinateSystem(normAxes);
141777
+ const edges = coordinateTransformations.map((ct) => ({
141778
+ from: ct.input.name,
141779
+ to: ct.output.name,
141780
+ attributes: ct
141781
+ }));
141782
+ const dag = new DAG(edges);
141783
+ const ctPath = dag.findPath(intrinsicCoordinateSystem, targetCoordinateSystem);
141784
+ if (!ctPath) {
141785
+ if (!coordinateTransformations.find((ct) => ct.output.name === targetCoordinateSystem)) {
141786
+ throw new Error(`No coordinate transformation found with output.name "${targetCoordinateSystem}".`);
141787
+ }
141788
+ throw new Error(`No path found from "${intrinsicCoordinateSystem}" to "${targetCoordinateSystem}".`);
141789
+ }
141790
+ const filteredTransformations = ctPath.map((ctEdge) => ctEdge.attributes);
141791
+ const normalizedTransformations = normalizeCoordinateTransformations(filteredTransformations, datasets);
141792
+ return coordinateTransformationsToMatrix(normalizedTransformations, normAxes);
141793
+ }
141678
141794
  function getDomains() {
141679
141795
  const domains = {};
141680
141796
  const needMin = ["Int8", "Int16", "Int32"];
@@ -141720,13 +141836,22 @@ class ImageWrapper {
141720
141836
  return this.modelMatrix;
141721
141837
  }
141722
141838
  _getModelMatrix() {
141723
- const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
141839
+ const { coordinateSystem = "global", coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
141724
141840
  if ("multiscales" in this.vivLoader.metadata) {
141725
141841
  const { multiscales: [{ datasets, coordinateTransformations: coordinateTransformationsFromFile, axes }] } = this.vivLoader.metadata;
141726
141842
  const ngffAxes = getNgffAxes(axes);
141727
141843
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
141728
- const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
141729
- const transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, ngffAxes);
141844
+ let transformMatrixFromFile;
141845
+ if ("spatialdata_attrs" in this.vivLoader.metadata) {
141846
+ transformMatrixFromFile = coordinateTransformationsToMatrixForSpatialData(
141847
+ // Pass the first multiscales element.
141848
+ this.vivLoader.metadata.multiscales[0],
141849
+ coordinateSystem
141850
+ );
141851
+ } else {
141852
+ const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
141853
+ transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, ngffAxes);
141854
+ }
141730
141855
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
141731
141856
  return transformMatrix;
141732
141857
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c, b, O } from "./index-DVU_YY8y.js";
1
+ import { c, b, O } from "./index-CvbBsZl9.js";
2
2
  export {
3
3
  c as OmeTiffAsObsSegmentationsLoader,
4
4
  b as OmeTiffLoader,
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
1
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-DVU_YY8y.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-CvbBsZl9.js";
3
3
  var LercDecode = { exports: {} };
4
4
  var hasRequiredLercDecode;
5
5
  function requireLercDecode() {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
1
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
1
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
1
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DVU_YY8y.js";
1
+ import { B as BaseDecoder } from "./index-CvbBsZl9.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/ome-tiff",
3
- "version": "3.6.10",
3
+ "version": "3.6.12",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -18,15 +18,15 @@
18
18
  "dependencies": {
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
- "@vitessce/abstract": "3.6.10",
22
- "@vitessce/error": "3.6.10",
23
- "@vitessce/constants-internal": "3.6.10",
24
- "@vitessce/config": "3.6.10",
25
- "@vitessce/gl": "3.6.10",
26
- "@vitessce/sets-utils": "3.6.10",
27
- "@vitessce/spatial-utils": "3.6.10",
28
- "@vitessce/image-utils": "3.6.10",
29
- "@vitessce/utils": "3.6.10"
21
+ "@vitessce/abstract": "3.6.12",
22
+ "@vitessce/error": "3.6.12",
23
+ "@vitessce/constants-internal": "3.6.12",
24
+ "@vitessce/config": "3.6.12",
25
+ "@vitessce/gl": "3.6.12",
26
+ "@vitessce/sets-utils": "3.6.12",
27
+ "@vitessce/spatial-utils": "3.6.12",
28
+ "@vitessce/image-utils": "3.6.12",
29
+ "@vitessce/utils": "3.6.12"
30
30
  },
31
31
  "scripts": {
32
32
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",