@vitessce/ome-tiff 3.6.11 → 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-CovJQ-Ac.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;
@@ -104772,22 +104772,22 @@ async function getDecoder(fileDirectory) {
104772
104772
  const Decoder = await importFn();
104773
104773
  return new Decoder(fileDirectory);
104774
104774
  }
104775
- addDecoder([void 0, 1], () => import("./raw-DDSNvMvp.js").then((m) => m.default));
104776
- addDecoder(5, () => import("./lzw-Dqvz6OCO.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));
104777
104777
  addDecoder(6, () => {
104778
104778
  throw new Error("old style JPEG compression is not supported.");
104779
104779
  });
104780
- addDecoder(7, () => import("./jpeg-DetTipZt.js").then((m) => m.default));
104781
- addDecoder([8, 32946], () => import("./deflate-BiUHdZkx.js").then((m) => m.default));
104782
- addDecoder(32773, () => import("./packbits-DnigFejA.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));
104783
104783
  addDecoder(
104784
104784
  34887,
104785
- () => import("./lerc-BOE0M084.js").then(async (m) => {
104785
+ () => import("./lerc-D8moRaV1.js").then(async (m) => {
104786
104786
  await m.zstd.init();
104787
104787
  return m;
104788
104788
  }).then((m) => m.default)
104789
104789
  );
104790
- addDecoder(50001, () => import("./webimage-BBiKOH38.js").then((m) => m.default));
104790
+ addDecoder(50001, () => import("./webimage-DIeQ7UJG.js").then((m) => m.default));
104791
104791
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
104792
104792
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
104793
104793
  }
@@ -141286,6 +141286,101 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
141286
141286
  const sliders = stats.map((stat) => stat.slider);
141287
141287
  return { domains, sliders };
141288
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
+ }
141289
141384
  function getSourceFromLoader(loader, level) {
141290
141385
  const { data } = loader;
141291
141386
  const source = Array.isArray(data) ? data[data.length - 1] : data;
@@ -141575,8 +141670,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141575
141670
  }
141576
141671
  } else if (spatialOutputAxes.length === 2) {
141577
141672
  const nextMat = new Matrix4().fromArray([
141578
- ...filteredAffine[0],
141579
- ...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],
141580
141681
  0,
141581
141682
  0,
141582
141683
  1,
@@ -141592,6 +141693,7 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141592
141693
  const swapMat = new Matrix4().fromArray(swapMatNested.flat());
141593
141694
  mat = mat.multiplyLeft(swapMat);
141594
141695
  }
141696
+ mat = mat.transpose();
141595
141697
  } else {
141596
141698
  throw new Error("Affine transformation must have 2 or 3 rows.");
141597
141699
  }
@@ -141618,6 +141720,9 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141618
141720
  }
141619
141721
  });
141620
141722
  }
141723
+ if (mat.some((value) => Number.isNaN(value))) {
141724
+ throw new Error("Matrix contains NaN values");
141725
+ }
141621
141726
  return mat;
141622
141727
  }
141623
141728
  function hexToRgb(hex) {
@@ -141628,6 +141733,17 @@ function hexToRgb(hex) {
141628
141733
  parseInt(result[3].toLowerCase(), 16)
141629
141734
  ];
141630
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
+ }
141631
141747
  function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
141632
141748
  var _a3;
141633
141749
  let result = [];
@@ -141635,35 +141751,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
141635
141751
  result = coordinateTransformations.flatMap((transform2) => {
141636
141752
  if (transform2.input && transform2.output) {
141637
141753
  const { type } = transform2;
141638
- if (type === "translation") {
141639
- return {
141640
- type,
141641
- translation: transform2.translation
141642
- };
141643
- }
141644
- if (type === "scale") {
141645
- return {
141646
- type,
141647
- scale: transform2.scale
141648
- };
141649
- }
141650
- if (type === "affine") {
141651
- return {
141652
- type,
141653
- affine: transform2.affine,
141654
- // Affine transformations can potentially swap axes,
141655
- // so we need to include the input and output axes.
141656
- input: transform2.input,
141657
- output: transform2.output
141658
- };
141659
- }
141660
- if (type === "identity") {
141661
- return { type };
141662
- }
141663
141754
  if (type === "sequence") {
141664
- return normalizeCoordinateTransformations(transform2.transformations, datasets);
141755
+ return normalizeCoordinateTransformations(transform2.transformations, null);
141665
141756
  }
141666
- 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.`);
141667
141761
  }
141668
141762
  return transform2;
141669
141763
  });
@@ -141676,6 +141770,27 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
141676
141770
  }
141677
141771
  return result;
141678
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
+ }
141679
141794
  function getDomains() {
141680
141795
  const domains = {};
141681
141796
  const needMin = ["Int8", "Int16", "Int32"];
@@ -141721,13 +141836,22 @@ class ImageWrapper {
141721
141836
  return this.modelMatrix;
141722
141837
  }
141723
141838
  _getModelMatrix() {
141724
- const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
141839
+ const { coordinateSystem = "global", coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
141725
141840
  if ("multiscales" in this.vivLoader.metadata) {
141726
141841
  const { multiscales: [{ datasets, coordinateTransformations: coordinateTransformationsFromFile, axes }] } = this.vivLoader.metadata;
141727
141842
  const ngffAxes = getNgffAxes(axes);
141728
141843
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
141729
- const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
141730
- 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
+ }
141731
141855
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
141732
141856
  return transformMatrix;
141733
141857
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c, b, O } from "./index-CovJQ-Ac.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-CovJQ-Ac.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-CovJQ-Ac.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-CovJQ-Ac.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-CovJQ-Ac.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-CovJQ-Ac.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-CovJQ-Ac.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.11",
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.11",
22
- "@vitessce/error": "3.6.11",
23
- "@vitessce/constants-internal": "3.6.11",
24
- "@vitessce/config": "3.6.11",
25
- "@vitessce/gl": "3.6.11",
26
- "@vitessce/sets-utils": "3.6.11",
27
- "@vitessce/spatial-utils": "3.6.11",
28
- "@vitessce/image-utils": "3.6.11",
29
- "@vitessce/utils": "3.6.11"
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",