@vitessce/spatial-utils 3.6.11 → 3.6.13

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-SrBFQLfa.js";
2
+ import { B as BaseDecoder } from "./index-B7UQn9SL.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -120366,22 +120366,22 @@ function addDecoder(cases, importFn) {
120366
120366
  }
120367
120367
  cases.forEach((c) => registry$2.set(c, importFn));
120368
120368
  }
120369
- addDecoder([void 0, 1], () => import("./raw-C8msAWCy.js").then((m) => m.default));
120370
- addDecoder(5, () => import("./lzw-m-7_MlEr.js").then((m) => m.default));
120369
+ addDecoder([void 0, 1], () => import("./raw-NP8gx4mT.js").then((m) => m.default));
120370
+ addDecoder(5, () => import("./lzw-CEZtZPvs.js").then((m) => m.default));
120371
120371
  addDecoder(6, () => {
120372
120372
  throw new Error("old style JPEG compression is not supported.");
120373
120373
  });
120374
- addDecoder(7, () => import("./jpeg-CPDP-GQ7.js").then((m) => m.default));
120375
- addDecoder([8, 32946], () => import("./deflate-CBbIkiez.js").then((m) => m.default));
120376
- addDecoder(32773, () => import("./packbits-D2Yz8IY3.js").then((m) => m.default));
120374
+ addDecoder(7, () => import("./jpeg-C55SiNtf.js").then((m) => m.default));
120375
+ addDecoder([8, 32946], () => import("./deflate-TxuAgoYJ.js").then((m) => m.default));
120376
+ addDecoder(32773, () => import("./packbits-BDxIgeb9.js").then((m) => m.default));
120377
120377
  addDecoder(
120378
120378
  34887,
120379
- () => import("./lerc-DqLmboAn.js").then(async (m) => {
120379
+ () => import("./lerc-cC8m0WBJ.js").then(async (m) => {
120380
120380
  await m.zstd.init();
120381
120381
  return m;
120382
120382
  }).then((m) => m.default)
120383
120383
  );
120384
- addDecoder(50001, () => import("./webimage-CBuzuQEe.js").then((m) => m.default));
120384
+ addDecoder(50001, () => import("./webimage-BMtq3qgy.js").then((m) => m.default));
120385
120385
  function decodeRowAcc(row, stride) {
120386
120386
  let length2 = row.length - stride;
120387
120387
  let offset = 0;
@@ -137721,6 +137721,101 @@ function abbreviateNumber(value) {
137721
137721
  if (naive.length <= maxLength) return naive;
137722
137722
  return value.toExponential(0);
137723
137723
  }
137724
+ class InternMap extends Map {
137725
+ constructor(entries, key = keyof) {
137726
+ super();
137727
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
137728
+ if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
137729
+ }
137730
+ get(key) {
137731
+ return super.get(intern_get(this, key));
137732
+ }
137733
+ has(key) {
137734
+ return super.has(intern_get(this, key));
137735
+ }
137736
+ set(key, value) {
137737
+ return super.set(intern_set(this, key), value);
137738
+ }
137739
+ delete(key) {
137740
+ return super.delete(intern_delete(this, key));
137741
+ }
137742
+ }
137743
+ function intern_get({ _intern, _key }, value) {
137744
+ const key = _key(value);
137745
+ return _intern.has(key) ? _intern.get(key) : value;
137746
+ }
137747
+ function intern_set({ _intern, _key }, value) {
137748
+ const key = _key(value);
137749
+ if (_intern.has(key)) return _intern.get(key);
137750
+ _intern.set(key, value);
137751
+ return value;
137752
+ }
137753
+ function intern_delete({ _intern, _key }, value) {
137754
+ const key = _key(value);
137755
+ if (_intern.has(key)) {
137756
+ value = _intern.get(key);
137757
+ _intern.delete(key);
137758
+ }
137759
+ return value;
137760
+ }
137761
+ function keyof(value) {
137762
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
137763
+ }
137764
+ class DAG {
137765
+ /**
137766
+ * DAG constructor.
137767
+ * @param {{ from: string, to: string, attributes: any}[]} edges
137768
+ */
137769
+ constructor(edges) {
137770
+ this.graph = /* @__PURE__ */ new Map();
137771
+ this.edgeData = new InternMap([], JSON.stringify);
137772
+ edges.forEach((edge) => {
137773
+ const { from, to } = edge;
137774
+ if (!this.graph.has(from)) {
137775
+ this.graph.set(from, []);
137776
+ }
137777
+ this.graph.get(from).push(to);
137778
+ this.edgeData.set([from, to], edge.attributes);
137779
+ });
137780
+ }
137781
+ /**
137782
+ * Find a path from start to end using DFS.
137783
+ * @param {string} start
137784
+ * @param {string} end
137785
+ * @returns {{ from: string, to: string, attributes: any }[] | null} Returns
137786
+ * the path as an array of edges or null if no path exists.
137787
+ */
137788
+ findPath(start, end) {
137789
+ const path = [];
137790
+ const visited = /* @__PURE__ */ new Set();
137791
+ const dfs = (node2) => {
137792
+ if (node2 === end) {
137793
+ return true;
137794
+ }
137795
+ visited.add(node2);
137796
+ const neighbors = this.graph.get(node2) || [];
137797
+ for (const neighbor of neighbors) {
137798
+ if (!visited.has(neighbor)) {
137799
+ path.push([node2, neighbor]);
137800
+ if (dfs(neighbor)) {
137801
+ return true;
137802
+ }
137803
+ path.pop();
137804
+ }
137805
+ }
137806
+ return false;
137807
+ };
137808
+ const found = dfs(start);
137809
+ if (found) {
137810
+ return path.map(([from, to]) => ({
137811
+ from,
137812
+ to,
137813
+ attributes: this.edgeData.get([from, to])
137814
+ }));
137815
+ }
137816
+ return null;
137817
+ }
137818
+ }
137724
137819
  function getSourceFromLoader(loader, level) {
137725
137820
  const { data } = loader;
137726
137821
  const source = Array.isArray(data) ? data[level || data.length - 1] : data;
@@ -138049,8 +138144,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
138049
138144
  }
138050
138145
  } else if (spatialOutputAxes.length === 2) {
138051
138146
  const nextMat = new Matrix4().fromArray([
138052
- ...filteredAffine[0],
138053
- ...filteredAffine[1],
138147
+ filteredAffine[0][0],
138148
+ filteredAffine[0][1],
138149
+ 0,
138150
+ filteredAffine[0][2],
138151
+ filteredAffine[1][0],
138152
+ filteredAffine[1][1],
138153
+ 0,
138154
+ filteredAffine[1][2],
138054
138155
  0,
138055
138156
  0,
138056
138157
  1,
@@ -138066,6 +138167,7 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
138066
138167
  const swapMat = new Matrix4().fromArray(swapMatNested.flat());
138067
138168
  mat = mat.multiplyLeft(swapMat);
138068
138169
  }
138170
+ mat = mat.transpose();
138069
138171
  } else {
138070
138172
  throw new Error("Affine transformation must have 2 or 3 rows.");
138071
138173
  }
@@ -138092,6 +138194,9 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
138092
138194
  }
138093
138195
  });
138094
138196
  }
138197
+ if (mat.some((value) => Number.isNaN(value))) {
138198
+ throw new Error("Matrix contains NaN values");
138199
+ }
138095
138200
  return mat;
138096
138201
  }
138097
138202
  function hexToRgb(hex) {
@@ -138110,6 +138215,9 @@ function normalizeAxes(axes) {
138110
138215
  return axisInfo;
138111
138216
  });
138112
138217
  }
138218
+ function getIntrinsicCoordinateSystem(normAxes) {
138219
+ return normAxes.map((axis) => axis.name).join("");
138220
+ }
138113
138221
  function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
138114
138222
  var _a3;
138115
138223
  let result = [];
@@ -138117,35 +138225,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
138117
138225
  result = coordinateTransformations.flatMap((transform2) => {
138118
138226
  if (transform2.input && transform2.output) {
138119
138227
  const { type } = transform2;
138120
- if (type === "translation") {
138121
- return {
138122
- type,
138123
- translation: transform2.translation
138124
- };
138125
- }
138126
- if (type === "scale") {
138127
- return {
138128
- type,
138129
- scale: transform2.scale
138130
- };
138131
- }
138132
- if (type === "affine") {
138133
- return {
138134
- type,
138135
- affine: transform2.affine,
138136
- // Affine transformations can potentially swap axes,
138137
- // so we need to include the input and output axes.
138138
- input: transform2.input,
138139
- output: transform2.output
138140
- };
138141
- }
138142
- if (type === "identity") {
138143
- return { type };
138144
- }
138145
138228
  if (type === "sequence") {
138146
- return normalizeCoordinateTransformations(transform2.transformations, datasets);
138229
+ return normalizeCoordinateTransformations(transform2.transformations, null);
138147
138230
  }
138148
- log$5.warn(`Coordinate transformation type "${type}" is not supported.`);
138231
+ if (type === "affine" || type === "translation" || type === "scale" || type === "identity") {
138232
+ return transform2;
138233
+ }
138234
+ log$5.error(`Coordinate transformation type "${type}" is not supported.`);
138149
138235
  }
138150
138236
  return transform2;
138151
138237
  });
@@ -138158,6 +138244,36 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
138158
138244
  }
138159
138245
  return result;
138160
138246
  }
138247
+ function coordinateTransformationsToMatrixForSpatialData(ngffMetadata, targetCoordinateSystem) {
138248
+ const {
138249
+ datasets,
138250
+ coordinateTransformations,
138251
+ axes
138252
+ } = ngffMetadata;
138253
+ const normAxes = normalizeAxes(axes);
138254
+ const intrinsicCoordinateSystem = getIntrinsicCoordinateSystem(normAxes);
138255
+ const edges = coordinateTransformations.map((ct) => ({
138256
+ from: ct.input.name,
138257
+ to: ct.output.name,
138258
+ attributes: ct
138259
+ }));
138260
+ const dag = new DAG(edges);
138261
+ const ctPath = dag.findPath(intrinsicCoordinateSystem, targetCoordinateSystem);
138262
+ if (!ctPath) {
138263
+ if (!coordinateTransformations.find(
138264
+ (ct) => ct.output.name === targetCoordinateSystem
138265
+ )) {
138266
+ throw new Error(`No coordinate transformation found with output.name "${targetCoordinateSystem}".`);
138267
+ }
138268
+ throw new Error(`No path found from "${intrinsicCoordinateSystem}" to "${targetCoordinateSystem}".`);
138269
+ }
138270
+ const filteredTransformations = ctPath.map((ctEdge) => ctEdge.attributes);
138271
+ const normalizedTransformations = normalizeCoordinateTransformations(
138272
+ filteredTransformations,
138273
+ datasets
138274
+ );
138275
+ return coordinateTransformationsToMatrix(normalizedTransformations, normAxes);
138276
+ }
138161
138277
  class NodeNotFoundError extends Error {
138162
138278
  constructor(context, options = {}) {
138163
138279
  super(`Node not found: ${context}`, options);
@@ -139741,13 +139857,14 @@ function getDomains() {
139741
139857
  }
139742
139858
  const DOMAINS = getDomains();
139743
139859
  export {
139744
- getBoundingCube as A,
139860
+ getPhysicalSizeScalingMatrix as A,
139745
139861
  BaseDecoder as B,
139746
- abbreviateNumber as C,
139862
+ getBoundingCube as C,
139747
139863
  DEFAULT_CELLS_LAYER as D,
139748
- filterSelection as E,
139749
- DOMAINS as F,
139864
+ abbreviateNumber as E,
139865
+ filterSelection as F,
139750
139866
  GLOBAL_LABELS as G,
139867
+ DOMAINS as H,
139751
139868
  ZarritaPixelSource as Z,
139752
139869
  DEFAULT_MOLECULES_LAYER as a,
139753
139870
  DEFAULT_NEIGHBORHOODS_LAYER as b,
@@ -139763,16 +139880,16 @@ export {
139763
139880
  getNgffAxes as l,
139764
139881
  getNgffAxesForTiff as m,
139765
139882
  coordinateTransformationsToMatrix as n,
139766
- hexToRgb as o,
139883
+ coordinateTransformationsToMatrixForSpatialData as o,
139767
139884
  physicalSizeToMatrix as p,
139768
- getStatsForResolution as q,
139769
- canLoadResolution as r,
139770
- normalizeCoordinateTransformations as s,
139771
- normalizeAxes as t,
139772
- loadOmeZarr as u,
139773
- guessTileSize as v,
139774
- toRgbUIString as w,
139775
- getSingleSelectionStats as x,
139776
- getMultiSelectionStats as y,
139777
- getPhysicalSizeScalingMatrix as z
139885
+ hexToRgb as q,
139886
+ getStatsForResolution as r,
139887
+ canLoadResolution as s,
139888
+ normalizeCoordinateTransformations as t,
139889
+ normalizeAxes as u,
139890
+ loadOmeZarr as v,
139891
+ guessTileSize as w,
139892
+ toRgbUIString as x,
139893
+ getSingleSelectionStats as y,
139894
+ getMultiSelectionStats as z
139778
139895
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, e, a, b, c, d, F, G, Z, C, r, n, E, A, y, l, m, z, x, h, q, v, o, i, f, j, k, u, t, s, p, w } from "./index-SrBFQLfa.js";
1
+ import { D, e, a, b, c, d, H, G, Z, E, s, n, o, F, C, z, l, m, A, y, h, r, w, q, i, f, j, k, v, u, t, p, x } from "./index-B7UQn9SL.js";
2
2
  export {
3
3
  D as DEFAULT_CELLS_LAYER,
4
4
  e as DEFAULT_LAYER_TYPE_ORDERING,
@@ -6,30 +6,31 @@ export {
6
6
  b as DEFAULT_NEIGHBORHOODS_LAYER,
7
7
  c as DEFAULT_RASTER_DOMAIN_TYPE,
8
8
  d as DEFAULT_RASTER_LAYER_PROPS,
9
- F as DOMAINS,
9
+ H as DOMAINS,
10
10
  G as GLOBAL_LABELS,
11
11
  Z as ZarritaPixelSource,
12
- C as abbreviateNumber,
13
- r as canLoadResolution,
12
+ E as abbreviateNumber,
13
+ s as canLoadResolution,
14
14
  n as coordinateTransformationsToMatrix,
15
- E as filterSelection,
16
- A as getBoundingCube,
17
- y as getMultiSelectionStats,
15
+ o as coordinateTransformationsToMatrixForSpatialData,
16
+ F as filterSelection,
17
+ C as getBoundingCube,
18
+ z as getMultiSelectionStats,
18
19
  l as getNgffAxes,
19
20
  m as getNgffAxesForTiff,
20
- z as getPhysicalSizeScalingMatrix,
21
- x as getSingleSelectionStats,
21
+ A as getPhysicalSizeScalingMatrix,
22
+ y as getSingleSelectionStats,
22
23
  h as getSourceFromLoader,
23
- q as getStatsForResolution,
24
- v as guessTileSize,
25
- o as hexToRgb,
24
+ r as getStatsForResolution,
25
+ w as guessTileSize,
26
+ q as hexToRgb,
26
27
  i as initializeLayerChannels,
27
28
  f as initializeRasterLayersAndChannels,
28
29
  j as isInterleaved,
29
30
  k as isRgb,
30
- u as loadOmeZarr,
31
- t as normalizeAxes,
32
- s as normalizeCoordinateTransformations,
31
+ v as loadOmeZarr,
32
+ u as normalizeAxes,
33
+ t as normalizeCoordinateTransformations,
33
34
  p as physicalSizeToMatrix,
34
- w as toRgbUIString
35
+ x as toRgbUIString
35
36
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-SrBFQLfa.js";
1
+ import { B as BaseDecoder } from "./index-B7UQn9SL.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 } from "./index-SrBFQLfa.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-B7UQn9SL.js";
3
3
  const LercParameters = {
4
4
  AddCompression: 1
5
5
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-SrBFQLfa.js";
1
+ import { B as BaseDecoder } from "./index-B7UQn9SL.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-SrBFQLfa.js";
1
+ import { B as BaseDecoder } from "./index-B7UQn9SL.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-SrBFQLfa.js";
1
+ import { B as BaseDecoder } from "./index-B7UQn9SL.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-SrBFQLfa.js";
1
+ import { B as BaseDecoder } from "./index-B7UQn9SL.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
@@ -0,0 +1,35 @@
1
+ export class DAG {
2
+ /**
3
+ * DAG constructor.
4
+ * @param {{ from: string, to: string, attributes: any}[]} edges
5
+ */
6
+ constructor(edges: {
7
+ from: string;
8
+ to: string;
9
+ attributes: any;
10
+ }[]);
11
+ /**
12
+ * Adjacency list representation of the DAG.
13
+ * Maps each input to an array of outputs.
14
+ * @type {Map<string, string[]>}
15
+ */
16
+ graph: Map<string, string[]>;
17
+ /**
18
+ * Mapping from [from, to] pairs to edge data.
19
+ * @type {InternMap<[string, string], any>}
20
+ */
21
+ edgeData: InternMap<[string, string], any>;
22
+ /**
23
+ * Find a path from start to end using DFS.
24
+ * @param {string} start
25
+ * @param {string} end
26
+ * @returns {{ from: string, to: string, attributes: any }[] | null} Returns
27
+ * the path as an array of edges or null if no path exists.
28
+ */
29
+ findPath(start: string, end: string): {
30
+ from: string;
31
+ to: string;
32
+ attributes: any;
33
+ }[] | null;
34
+ }
35
+ //# sourceMappingURL=dag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dag.d.ts","sourceRoot":"","sources":["../src/dag.js"],"names":[],"mappings":"AAMA;IACE;;;SAGK;IACL,mBAFa;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAC,EAAE,EAwB1D;IArBC;;;;OAIG;IACH,OAFU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAET;IACtB;;;OAGG;IACH,UAFU,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAEO;IAanD;;;;;;OAMG;IACH,gBALW,MAAM,OACN,MAAM,GACJ;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,EAAE,GAAG,IAAI,CA0ClE;CACF"}
@@ -0,0 +1,75 @@
1
+ import { InternMap } from 'internmap';
2
+ // Simple DAG class, with minimum functionality:
3
+ // to find a path from targetInput-to-targetOutput.
4
+ // Edges can have arbitrary attributes.
5
+ export class DAG {
6
+ /**
7
+ * DAG constructor.
8
+ * @param {{ from: string, to: string, attributes: any}[]} edges
9
+ */
10
+ constructor(edges) {
11
+ /**
12
+ * Adjacency list representation of the DAG.
13
+ * Maps each input to an array of outputs.
14
+ * @type {Map<string, string[]>}
15
+ */
16
+ this.graph = new Map();
17
+ /**
18
+ * Mapping from [from, to] pairs to edge data.
19
+ * @type {InternMap<[string, string], any>}
20
+ */
21
+ this.edgeData = new InternMap([], JSON.stringify);
22
+ // Build adjacency list
23
+ edges.forEach((edge) => {
24
+ const { from, to } = edge;
25
+ if (!this.graph.has(from)) {
26
+ this.graph.set(from, []);
27
+ }
28
+ this.graph.get(from).push(to);
29
+ this.edgeData.set([from, to], edge.attributes);
30
+ });
31
+ }
32
+ /**
33
+ * Find a path from start to end using DFS.
34
+ * @param {string} start
35
+ * @param {string} end
36
+ * @returns {{ from: string, to: string, attributes: any }[] | null} Returns
37
+ * the path as an array of edges or null if no path exists.
38
+ */
39
+ findPath(start, end) {
40
+ const path = [];
41
+ const visited = new Set();
42
+ // Depth-first search (DFS) to find a path from start to end.
43
+ const dfs = (node) => {
44
+ if (node === end) {
45
+ return true;
46
+ }
47
+ visited.add(node);
48
+ const neighbors = this.graph.get(node) || [];
49
+ // Do not use forEach to allow early exit (returning).
50
+ // eslint-disable-next-line no-restricted-syntax
51
+ for (const neighbor of neighbors) {
52
+ if (!visited.has(neighbor)) {
53
+ path.push([node, neighbor]);
54
+ if (dfs(neighbor)) {
55
+ return true;
56
+ }
57
+ path.pop(); // backtrack
58
+ }
59
+ }
60
+ return false;
61
+ };
62
+ // Start DFS from the start node.
63
+ const found = dfs(start);
64
+ if (found) {
65
+ // Convert path to a list of edge objects with info
66
+ return path.map(([from, to]) => ({
67
+ from,
68
+ to,
69
+ attributes: this.edgeData.get([from, to]),
70
+ }));
71
+ }
72
+ // If no path is found, return null.
73
+ return null;
74
+ }
75
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dag.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dag.test.d.ts","sourceRoot":"","sources":["../src/dag.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { DAG } from './dag.js';
3
+ describe('DAG', () => {
4
+ describe('findPath', () => {
5
+ it('Can find a path from start to end.', () => {
6
+ // Example usage:
7
+ const edges = [
8
+ { from: 'A', to: 'B', attributes: { some_key: 'a_to_b' } },
9
+ { from: 'B', to: 'C', attributes: { some_key: 'b_to_c', hello: 'world' } },
10
+ { from: 'A', to: 'D', attributes: { some_key: 'a_to_d' } },
11
+ { from: 'D', to: 'E', attributes: { some_key: 'd_to_e' } },
12
+ { from: 'E', to: 'C', attributes: { some_key: 'e_to_c' } },
13
+ ];
14
+ const dag = new DAG(edges);
15
+ const path = dag.findPath('A', 'C');
16
+ expect(path).toEqual([
17
+ { from: 'A', to: 'B', attributes: { some_key: 'a_to_b' } },
18
+ { from: 'B', to: 'C', attributes: { some_key: 'b_to_c', hello: 'world' } },
19
+ ]);
20
+ const path2 = dag.findPath('D', 'C');
21
+ expect(path2).toEqual([
22
+ { from: 'D', to: 'E', attributes: { some_key: 'd_to_e' } },
23
+ { from: 'E', to: 'C', attributes: { some_key: 'e_to_c' } },
24
+ ]);
25
+ const path3 = dag.findPath('D', 'B');
26
+ expect(path3).toEqual(null);
27
+ });
28
+ });
29
+ });
@@ -1,6 +1,6 @@
1
1
  export { DOMAINS } from "./constants.js";
2
2
  export { GLOBAL_LABELS, DEFAULT_CELLS_LAYER, DEFAULT_MOLECULES_LAYER, DEFAULT_NEIGHBORHOODS_LAYER, DEFAULT_RASTER_DOMAIN_TYPE, DEFAULT_RASTER_LAYER_PROPS, DEFAULT_LAYER_TYPE_ORDERING } from "@vitessce/constants-internal";
3
- export { initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, physicalSizeToMatrix, hexToRgb, getStatsForResolution, canLoadResolution, normalizeCoordinateTransformations, normalizeAxes } from "./spatial.js";
3
+ export { initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, coordinateTransformationsToMatrixForSpatialData, physicalSizeToMatrix, hexToRgb, getStatsForResolution, canLoadResolution, normalizeCoordinateTransformations, normalizeAxes } from "./spatial.js";
4
4
  export { loadOmeZarr, guessTileSize, ZarritaPixelSource } from "./load-ome-zarr.js";
5
5
  export { toRgbUIString, getSingleSelectionStats, getMultiSelectionStats, getPhysicalSizeScalingMatrix, getBoundingCube, abbreviateNumber, filterSelection } from "./layer-controller.js";
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist-tsc/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { GLOBAL_LABELS, DEFAULT_CELLS_LAYER, DEFAULT_MOLECULES_LAYER, DEFAULT_NEIGHBORHOODS_LAYER, DEFAULT_RASTER_DOMAIN_TYPE, DEFAULT_RASTER_LAYER_PROPS, DEFAULT_LAYER_TYPE_ORDERING, } from '@vitessce/constants-internal';
2
- export { initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, physicalSizeToMatrix, hexToRgb, getStatsForResolution, canLoadResolution, normalizeCoordinateTransformations, normalizeAxes, } from './spatial.js';
2
+ export { initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, coordinateTransformationsToMatrixForSpatialData, physicalSizeToMatrix, hexToRgb, getStatsForResolution, canLoadResolution, normalizeCoordinateTransformations, normalizeAxes, } from './spatial.js';
3
3
  export { loadOmeZarr, guessTileSize, ZarritaPixelSource, } from './load-ome-zarr.js';
4
4
  export { toRgbUIString, getSingleSelectionStats, getMultiSelectionStats, getPhysicalSizeScalingMatrix, getBoundingCube, abbreviateNumber, filterSelection, } from './layer-controller.js';
5
5
  export { DOMAINS, } from './constants.js';
@@ -61,6 +61,7 @@ export function getSwapAxesMatrix(inputAxes: ("x" | "y" | "z")[], outputAxes: ("
61
61
  export function coordinateTransformationsToMatrix(coordinateTransformations: object[] | undefined, axes: object[] | undefined): Matrix4;
62
62
  export function hexToRgb(hex: any): number[];
63
63
  export function normalizeAxes(axes: any): any;
64
+ export function getIntrinsicCoordinateSystem(normAxes: any): any;
64
65
  /**
65
66
  * Normalize coordinate transformations to the OME-NGFF v0.4 format,
66
67
  * despite potentially being in the new format proposed in
@@ -72,6 +73,30 @@ export function normalizeAxes(axes: any): any;
72
73
  * @returns {object[]} Array of coordinateTransformations in OME-NGFF v0.4 format.
73
74
  */
74
75
  export function normalizeCoordinateTransformations(coordinateTransformations: object[] | undefined, datasets: object[]): object[];
76
+ /**
77
+ * Convert coordinate transformations to a 4x4 matrix for SpatialData
78
+ * spatial elements. This function is intended to be used with SpatialData
79
+ * objects which have named coordinate systems. This function should
80
+ * be compatible with any SpatialElement (shapes, points, labels, images).
81
+ * @param {{
82
+ * axe?: (string[]|{ name: string, type?: string, unit?: string }[]),
83
+ * coordinateTransformations?: object[],
84
+ * datasets?: object[]
85
+ * }} ngffMetadata For images/labels, this is multiscales[0] from .zattrs.
86
+ * For shapes/points, this is { axes, coordinateTransformations } from .zattrs.
87
+ * @param {string} targetCoordinateSystem A target coordinate system name.
88
+ * @returns {Matrix4} A 4x4 transformation matrix.
89
+ * This can later be multiplied with other matrices if needed.
90
+ */
91
+ export function coordinateTransformationsToMatrixForSpatialData(ngffMetadata: {
92
+ axe?: (string[] | {
93
+ name: string;
94
+ type?: string;
95
+ unit?: string;
96
+ }[]);
97
+ coordinateTransformations?: object[];
98
+ datasets?: object[];
99
+ }, targetCoordinateSystem: string): Matrix4;
75
100
  export function getStatsForResolution(loader: any, resolution: any): {
76
101
  height: any;
77
102
  width: any;
@@ -1 +1 @@
1
- {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../src/spatial.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,4CAJW,MAAM,SACN,MAAM,GAAG,SAAS,GAChB,MAAM,CAMlB;AAoCD;;;;GAIG;AACH,8BAHW,MAAM,YACN,KAAK,GAAC,IAAI,WAiBpB;AAID,sHAmCC;AAiHD;;GAEG;AACH,qCAFW,KAAK,CAAE,MAAM,CAAC,WAKxB;AAED;;;;;;GAMG;AACH,gDALW,MAAM,eAEJ,MAAM,EAAE,CAuCpB;AAED;;;;;;;;;GASG;AACH,gEAJW,MAAM,EAAE,sBAER,CAAC,MAAM,EAAE,GAAC,IAAI,CAAC,+CAuEzB;AASD;;;IAuBC;AAED,uDAQC;AAED;;;;;;GAMG;AACH,6CAJW,CAAC,GAAG,GAAC,GAAG,GAAC,GAAG,CAAC,EAAE,cACf,CAAC,GAAG,GAAC,GAAG,GAAC,GAAG,CAAC,EAAE,GACd,MAAM,EAAE,EAAE,CA6BrB;AAED;;;;;;;;GAQG;AACH,6EANW,MAAM,EAAE,GAAC,SAAS,QAElB,MAAM,EAAE,GAAC,SAAS,GAEhB,OAAO,CA0GnB;AAED,6CAOC;AAMD,8CASC;AAED;;;;;;;;;GASG;AACH,8EANW,MAAM,EAAE,GAAC,SAAS,YAGlB,MAAM,EAAE,GACN,MAAM,EAAE,CA+DpB;AApnBM;;;;;EAYN;AAEM,yEAkBN;wBAnDuB,SAAS"}
1
+ {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../src/spatial.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,4CAJW,MAAM,SACN,MAAM,GAAG,SAAS,GAChB,MAAM,CAMlB;AAoCD;;;;GAIG;AACH,8BAHW,MAAM,YACN,KAAK,GAAC,IAAI,WAiBpB;AAID,sHAmCC;AAiHD;;GAEG;AACH,qCAFW,KAAK,CAAE,MAAM,CAAC,WAKxB;AAED;;;;;;GAMG;AACH,gDALW,MAAM,eAEJ,MAAM,EAAE,CAuCpB;AAED;;;;;;;;;GASG;AACH,gEAJW,MAAM,EAAE,sBAER,CAAC,MAAM,EAAE,GAAC,IAAI,CAAC,+CAuEzB;AASD;;;IAuBC;AAED,uDAQC;AAED;;;;;;GAMG;AACH,6CAJW,CAAC,GAAG,GAAC,GAAG,GAAC,GAAG,CAAC,EAAE,cACf,CAAC,GAAG,GAAC,GAAG,GAAC,GAAG,CAAC,EAAE,GACd,MAAM,EAAE,EAAE,CA6BrB;AAED;;;;;;;;GAQG;AACH,6EANW,MAAM,EAAE,GAAC,SAAS,QAElB,MAAM,EAAE,GAAC,SAAS,GAEhB,OAAO,CAiHnB;AAED,6CAOC;AAMD,8CASC;AAED,iEAKC;AAGD;;;;;;;;;GASG;AACH,8EANW,MAAM,EAAE,GAAC,SAAS,YAGlB,MAAM,EAAE,GACN,MAAM,EAAE,CA4CpB;AAED;;;;;;;;;;;;;;GAcG;AACH,8EAVW;IACV,GAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IACrE,yBAA4B,CAAC,EAAE,MAAM,EAAE,CAAC;IACxC,QAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,0BAEO,MAAM,GACJ,OAAO,CA2CnB;AAzqBM;;;;;EAYN;AAEM,yEAkBN;wBArDuB,SAAS"}