@vitessce/ome-tiff 3.6.6 → 3.6.8

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-DhCSKj-N.js";
2
+ import { B as BaseDecoder } from "./index-DVU_YY8y.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -104771,22 +104771,22 @@ async function getDecoder(fileDirectory) {
104771
104771
  const Decoder = await importFn();
104772
104772
  return new Decoder(fileDirectory);
104773
104773
  }
104774
- addDecoder([void 0, 1], () => import("./raw-Bs6xZKCz.js").then((m) => m.default));
104775
- addDecoder(5, () => import("./lzw-DE-YIxT2.js").then((m) => m.default));
104774
+ addDecoder([void 0, 1], () => import("./raw-C3hLu5jb.js").then((m) => m.default));
104775
+ addDecoder(5, () => import("./lzw-Ce2kmxIQ.js").then((m) => m.default));
104776
104776
  addDecoder(6, () => {
104777
104777
  throw new Error("old style JPEG compression is not supported.");
104778
104778
  });
104779
- addDecoder(7, () => import("./jpeg-CMQmXH4z.js").then((m) => m.default));
104780
- addDecoder([8, 32946], () => import("./deflate-DKBrgfhi.js").then((m) => m.default));
104781
- addDecoder(32773, () => import("./packbits-BT-Ed6dQ.js").then((m) => m.default));
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));
104782
104782
  addDecoder(
104783
104783
  34887,
104784
- () => import("./lerc-CPWteBlj.js").then(async (m) => {
104784
+ () => import("./lerc-CS9H9Ndh.js").then(async (m) => {
104785
104785
  await m.zstd.init();
104786
104786
  return m;
104787
104787
  }).then((m) => m.default)
104788
104788
  );
104789
- addDecoder(50001, () => import("./webimage-DvRQ4HVR.js").then((m) => m.default));
104789
+ addDecoder(50001, () => import("./webimage-DItILlGR.js").then((m) => m.default));
104790
104790
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
104791
104791
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
104792
104792
  }
@@ -141521,11 +141521,80 @@ function getNgffAxesForTiff(dimOrder) {
141521
141521
  type: getDefaultAxisType(name2)
141522
141522
  }));
141523
141523
  }
141524
+ function getSwapAxesMatrix(inputAxes, outputAxes) {
141525
+ const size2 = inputAxes.length;
141526
+ if (!(size2 === 2 || size2 === 3)) {
141527
+ throw new Error(`Expected input and output axes to have 2 or 3 elements, got ${size2}.`);
141528
+ }
141529
+ const matrix2 = [
141530
+ [0, 0, 0, 0],
141531
+ [0, 0, 0, 0],
141532
+ [0, 0, size2 === 2 ? 1 : 0, 0],
141533
+ // In 2D, leave Z unchanged.
141534
+ [0, 0, 0, 1]
141535
+ ];
141536
+ for (let outRow = 0; outRow < size2; outRow++) {
141537
+ const axis = outputAxes[outRow];
141538
+ const inCol = inputAxes.indexOf(axis);
141539
+ if (inCol === -1) {
141540
+ throw new Error(`Axis "${axis}" not found in inputAxes`);
141541
+ }
141542
+ matrix2[outRow][inCol] = 1;
141543
+ }
141544
+ return matrix2;
141545
+ }
141524
141546
  function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
141525
141547
  let mat = new Matrix4().identity();
141526
141548
  if (coordinateTransformations && axes) {
141527
141549
  const xyzIndices = ["x", "y", "z"].map((name2) => axes.findIndex((axisObj) => axisObj.type === "space" && axisObj.name === name2));
141528
141550
  coordinateTransformations.forEach((transform2) => {
141551
+ if (transform2.type === "affine") {
141552
+ const { affine, input, output } = transform2;
141553
+ const excludeEntries = input.axes.map((axis, i2) => [axis, i2]).filter(([axis, i2]) => axis.type !== "space").map(([axis, i2]) => i2);
141554
+ const filteredAffine = affine.filter((_, i2) => !excludeEntries.includes(i2)).map((row) => row.filter((_, i2) => !excludeEntries.includes(i2)));
141555
+ const spatialInputAxes = input.axes.filter((axis) => axis.type === "space");
141556
+ const spatialOutputAxes = output.axes.filter((axis) => axis.type === "space");
141557
+ const inputAxisNames = spatialInputAxes.map((axis) => axis.name);
141558
+ const outputAxisNames = spatialOutputAxes.map((axis) => axis.name);
141559
+ if (spatialInputAxes.length === 3) {
141560
+ const nextMat = new Matrix4().fromArray([
141561
+ ...filteredAffine[0],
141562
+ ...filteredAffine[1],
141563
+ ...filteredAffine[2],
141564
+ 0,
141565
+ 0,
141566
+ 0,
141567
+ 1
141568
+ ]);
141569
+ mat = mat.multiplyLeft(nextMat);
141570
+ if (!isEqual(inputAxisNames, outputAxisNames)) {
141571
+ const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
141572
+ const swapMat = new Matrix4().fromArray(swapMatNested.flat());
141573
+ mat = mat.multiplyLeft(swapMat);
141574
+ }
141575
+ } else if (spatialOutputAxes.length === 2) {
141576
+ const nextMat = new Matrix4().fromArray([
141577
+ ...filteredAffine[0],
141578
+ ...filteredAffine[1],
141579
+ 0,
141580
+ 0,
141581
+ 1,
141582
+ 0,
141583
+ 0,
141584
+ 0,
141585
+ 0,
141586
+ 1
141587
+ ]);
141588
+ mat = mat.multiplyLeft(nextMat);
141589
+ if (!isEqual(inputAxisNames, outputAxisNames)) {
141590
+ const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
141591
+ const swapMat = new Matrix4().fromArray(swapMatNested.flat());
141592
+ mat = mat.multiplyLeft(swapMat);
141593
+ }
141594
+ } else {
141595
+ throw new Error("Affine transformation must have 2 or 3 rows.");
141596
+ }
141597
+ }
141529
141598
  if (transform2.type === "translation") {
141530
141599
  const { translation: axisOrderedTranslation } = transform2;
141531
141600
  if (axisOrderedTranslation.length !== axes.length) {
@@ -141558,6 +141627,54 @@ function hexToRgb(hex) {
141558
141627
  parseInt(result[3].toLowerCase(), 16)
141559
141628
  ];
141560
141629
  }
141630
+ function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
141631
+ var _a3;
141632
+ let result = [];
141633
+ if (Array.isArray(coordinateTransformations)) {
141634
+ result = coordinateTransformations.flatMap((transform2) => {
141635
+ if (transform2.input && transform2.output) {
141636
+ 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
+ if (type === "sequence") {
141663
+ return normalizeCoordinateTransformations(transform2.transformations, datasets);
141664
+ }
141665
+ log$1.warn(`Coordinate transformation type "${type}" is not supported.`);
141666
+ }
141667
+ return transform2;
141668
+ });
141669
+ }
141670
+ if (Array.isArray((_a3 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a3.coordinateTransformations)) {
141671
+ result = [
141672
+ ...datasets[0].coordinateTransformations,
141673
+ ...result
141674
+ ];
141675
+ }
141676
+ return result;
141677
+ }
141561
141678
  function getDomains() {
141562
141679
  const domains = {};
141563
141680
  const needMin = ["Int8", "Int16", "Int32"];
@@ -141573,6 +141690,7 @@ class ImageWrapper {
141573
141690
  constructor(vivLoader, options) {
141574
141691
  __publicField(this, "vivLoader");
141575
141692
  __publicField(this, "options");
141693
+ __publicField(this, "modelMatrix", null);
141576
141694
  this.options = options || {};
141577
141695
  this.vivLoader = vivLoader;
141578
141696
  }
@@ -141596,12 +141714,19 @@ class ImageWrapper {
141596
141714
  return this.vivLoader.data;
141597
141715
  }
141598
141716
  getModelMatrix() {
141717
+ if (!this.modelMatrix) {
141718
+ this.modelMatrix = this._getModelMatrix();
141719
+ }
141720
+ return this.modelMatrix;
141721
+ }
141722
+ _getModelMatrix() {
141599
141723
  const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
141600
141724
  if ("multiscales" in this.vivLoader.metadata) {
141601
- const { multiscales: [{ coordinateTransformations, axes }] } = this.vivLoader.metadata;
141725
+ const { multiscales: [{ datasets, coordinateTransformations: coordinateTransformationsFromFile, axes }] } = this.vivLoader.metadata;
141602
141726
  const ngffAxes = getNgffAxes(axes);
141603
141727
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
141604
- const transformMatrixFromFile = coordinateTransformationsToMatrix(coordinateTransformations, ngffAxes);
141728
+ const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
141729
+ const transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, ngffAxes);
141605
141730
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
141606
141731
  return transformMatrix;
141607
141732
  }
@@ -141746,15 +141871,45 @@ class ImageWrapper {
141746
141871
  hasZStack() {
141747
141872
  const loader = this.vivLoader;
141748
141873
  const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141874
+ if (!labels.includes("z")) {
141875
+ return false;
141876
+ }
141749
141877
  const hasZStack = shape[labels.indexOf("z")] > 1;
141750
141878
  return hasZStack;
141751
141879
  }
141752
141880
  hasTStack() {
141753
141881
  const loader = this.vivLoader;
141754
141882
  const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141883
+ if (!labels.includes("t")) {
141884
+ return false;
141885
+ }
141755
141886
  const hasTStack = shape[labels.indexOf("t")] > 1;
141756
141887
  return hasTStack;
141757
141888
  }
141889
+ hasCStack() {
141890
+ const loader = this.vivLoader;
141891
+ const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141892
+ if (!labels.includes("c")) {
141893
+ return false;
141894
+ }
141895
+ const hasCStack = shape[labels.indexOf("c")] > 1;
141896
+ return hasCStack;
141897
+ }
141898
+ hasDimZ() {
141899
+ const loader = this.vivLoader;
141900
+ const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141901
+ return labels.includes("z");
141902
+ }
141903
+ hasDimT() {
141904
+ const loader = this.vivLoader;
141905
+ const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141906
+ return labels.includes("t");
141907
+ }
141908
+ hasDimC() {
141909
+ const loader = this.vivLoader;
141910
+ const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141911
+ return labels.includes("c");
141912
+ }
141758
141913
  getNumZ() {
141759
141914
  const loader = this.vivLoader;
141760
141915
  const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
@@ -141765,6 +141920,11 @@ class ImageWrapper {
141765
141920
  const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141766
141921
  return shape[labels.indexOf("t")];
141767
141922
  }
141923
+ getNumC() {
141924
+ const loader = this.vivLoader;
141925
+ const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
141926
+ return shape[labels.indexOf("c")];
141927
+ }
141768
141928
  isMultiResolution() {
141769
141929
  const loader = this.vivLoader;
141770
141930
  const hasViewableResolutions = Boolean(Array.from({
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c, b, O } from "./index-DhCSKj-N.js";
1
+ import { c, b, O } from "./index-DVU_YY8y.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-DhCSKj-N.js";
1
+ import { B as BaseDecoder } from "./index-DVU_YY8y.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-DhCSKj-N.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-DVU_YY8y.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-DhCSKj-N.js";
1
+ import { B as BaseDecoder } from "./index-DVU_YY8y.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-DhCSKj-N.js";
1
+ import { B as BaseDecoder } from "./index-DVU_YY8y.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-DhCSKj-N.js";
1
+ import { B as BaseDecoder } from "./index-DVU_YY8y.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-DhCSKj-N.js";
1
+ import { B as BaseDecoder } from "./index-DVU_YY8y.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.6",
3
+ "version": "3.6.8",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -18,14 +18,15 @@
18
18
  "dependencies": {
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
- "@vitessce/abstract": "3.6.6",
22
- "@vitessce/constants-internal": "3.6.6",
23
- "@vitessce/config": "3.6.6",
24
- "@vitessce/gl": "3.6.6",
25
- "@vitessce/sets-utils": "3.6.6",
26
- "@vitessce/spatial-utils": "3.6.6",
27
- "@vitessce/image-utils": "3.6.6",
28
- "@vitessce/utils": "3.6.6"
21
+ "@vitessce/abstract": "3.6.8",
22
+ "@vitessce/error": "3.6.8",
23
+ "@vitessce/constants-internal": "3.6.8",
24
+ "@vitessce/config": "3.6.8",
25
+ "@vitessce/gl": "3.6.8",
26
+ "@vitessce/sets-utils": "3.6.8",
27
+ "@vitessce/spatial-utils": "3.6.8",
28
+ "@vitessce/image-utils": "3.6.8",
29
+ "@vitessce/utils": "3.6.8"
29
30
  },
30
31
  "scripts": {
31
32
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",