@vitessce/spatial-utils 3.1.1 → 3.1.3

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-68f84e2a.js";
2
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
2
+ import { B as BaseDecoder } from "./index-e86d2626.js";
3
3
  import "react";
4
4
  class DeflateDecoder extends BaseDecoder {
5
5
  decodeBlock(buffer) {
@@ -19770,6 +19770,363 @@ var unit = /* @__PURE__ */ createUnitFunction({
19770
19770
  Unit,
19771
19771
  typed
19772
19772
  });
19773
+ function commonjsRequire(path) {
19774
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
19775
+ }
19776
+ var pluralize = { exports: {} };
19777
+ (function(module2, exports2) {
19778
+ (function(root2, pluralize2) {
19779
+ if (typeof commonjsRequire === "function" && true && true) {
19780
+ module2.exports = pluralize2();
19781
+ } else {
19782
+ root2.pluralize = pluralize2();
19783
+ }
19784
+ })(commonjsGlobal, function() {
19785
+ var pluralRules = [];
19786
+ var singularRules = [];
19787
+ var uncountables = {};
19788
+ var irregularPlurals = {};
19789
+ var irregularSingles = {};
19790
+ function sanitizeRule(rule) {
19791
+ if (typeof rule === "string") {
19792
+ return new RegExp("^" + rule + "$", "i");
19793
+ }
19794
+ return rule;
19795
+ }
19796
+ function restoreCase(word, token) {
19797
+ if (word === token)
19798
+ return token;
19799
+ if (word === word.toLowerCase())
19800
+ return token.toLowerCase();
19801
+ if (word === word.toUpperCase())
19802
+ return token.toUpperCase();
19803
+ if (word[0] === word[0].toUpperCase()) {
19804
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
19805
+ }
19806
+ return token.toLowerCase();
19807
+ }
19808
+ function interpolate2(str, args) {
19809
+ return str.replace(/\$(\d{1,2})/g, function(match, index2) {
19810
+ return args[index2] || "";
19811
+ });
19812
+ }
19813
+ function replace(word, rule) {
19814
+ return word.replace(rule[0], function(match, index2) {
19815
+ var result = interpolate2(rule[1], arguments);
19816
+ if (match === "") {
19817
+ return restoreCase(word[index2 - 1], result);
19818
+ }
19819
+ return restoreCase(match, result);
19820
+ });
19821
+ }
19822
+ function sanitizeWord(token, word, rules) {
19823
+ if (!token.length || uncountables.hasOwnProperty(token)) {
19824
+ return word;
19825
+ }
19826
+ var len2 = rules.length;
19827
+ while (len2--) {
19828
+ var rule = rules[len2];
19829
+ if (rule[0].test(word))
19830
+ return replace(word, rule);
19831
+ }
19832
+ return word;
19833
+ }
19834
+ function replaceWord(replaceMap, keepMap, rules) {
19835
+ return function(word) {
19836
+ var token = word.toLowerCase();
19837
+ if (keepMap.hasOwnProperty(token)) {
19838
+ return restoreCase(word, token);
19839
+ }
19840
+ if (replaceMap.hasOwnProperty(token)) {
19841
+ return restoreCase(word, replaceMap[token]);
19842
+ }
19843
+ return sanitizeWord(token, word, rules);
19844
+ };
19845
+ }
19846
+ function checkWord(replaceMap, keepMap, rules, bool) {
19847
+ return function(word) {
19848
+ var token = word.toLowerCase();
19849
+ if (keepMap.hasOwnProperty(token))
19850
+ return true;
19851
+ if (replaceMap.hasOwnProperty(token))
19852
+ return false;
19853
+ return sanitizeWord(token, token, rules) === token;
19854
+ };
19855
+ }
19856
+ function pluralize2(word, count2, inclusive) {
19857
+ var pluralized = count2 === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
19858
+ return (inclusive ? count2 + " " : "") + pluralized;
19859
+ }
19860
+ pluralize2.plural = replaceWord(
19861
+ irregularSingles,
19862
+ irregularPlurals,
19863
+ pluralRules
19864
+ );
19865
+ pluralize2.isPlural = checkWord(
19866
+ irregularSingles,
19867
+ irregularPlurals,
19868
+ pluralRules
19869
+ );
19870
+ pluralize2.singular = replaceWord(
19871
+ irregularPlurals,
19872
+ irregularSingles,
19873
+ singularRules
19874
+ );
19875
+ pluralize2.isSingular = checkWord(
19876
+ irregularPlurals,
19877
+ irregularSingles,
19878
+ singularRules
19879
+ );
19880
+ pluralize2.addPluralRule = function(rule, replacement) {
19881
+ pluralRules.push([sanitizeRule(rule), replacement]);
19882
+ };
19883
+ pluralize2.addSingularRule = function(rule, replacement) {
19884
+ singularRules.push([sanitizeRule(rule), replacement]);
19885
+ };
19886
+ pluralize2.addUncountableRule = function(word) {
19887
+ if (typeof word === "string") {
19888
+ uncountables[word.toLowerCase()] = true;
19889
+ return;
19890
+ }
19891
+ pluralize2.addPluralRule(word, "$0");
19892
+ pluralize2.addSingularRule(word, "$0");
19893
+ };
19894
+ pluralize2.addIrregularRule = function(single, plural) {
19895
+ plural = plural.toLowerCase();
19896
+ single = single.toLowerCase();
19897
+ irregularSingles[single] = plural;
19898
+ irregularPlurals[plural] = single;
19899
+ };
19900
+ [
19901
+ // Pronouns.
19902
+ ["I", "we"],
19903
+ ["me", "us"],
19904
+ ["he", "they"],
19905
+ ["she", "they"],
19906
+ ["them", "them"],
19907
+ ["myself", "ourselves"],
19908
+ ["yourself", "yourselves"],
19909
+ ["itself", "themselves"],
19910
+ ["herself", "themselves"],
19911
+ ["himself", "themselves"],
19912
+ ["themself", "themselves"],
19913
+ ["is", "are"],
19914
+ ["was", "were"],
19915
+ ["has", "have"],
19916
+ ["this", "these"],
19917
+ ["that", "those"],
19918
+ // Words ending in with a consonant and `o`.
19919
+ ["echo", "echoes"],
19920
+ ["dingo", "dingoes"],
19921
+ ["volcano", "volcanoes"],
19922
+ ["tornado", "tornadoes"],
19923
+ ["torpedo", "torpedoes"],
19924
+ // Ends with `us`.
19925
+ ["genus", "genera"],
19926
+ ["viscus", "viscera"],
19927
+ // Ends with `ma`.
19928
+ ["stigma", "stigmata"],
19929
+ ["stoma", "stomata"],
19930
+ ["dogma", "dogmata"],
19931
+ ["lemma", "lemmata"],
19932
+ ["schema", "schemata"],
19933
+ ["anathema", "anathemata"],
19934
+ // Other irregular rules.
19935
+ ["ox", "oxen"],
19936
+ ["axe", "axes"],
19937
+ ["die", "dice"],
19938
+ ["yes", "yeses"],
19939
+ ["foot", "feet"],
19940
+ ["eave", "eaves"],
19941
+ ["goose", "geese"],
19942
+ ["tooth", "teeth"],
19943
+ ["quiz", "quizzes"],
19944
+ ["human", "humans"],
19945
+ ["proof", "proofs"],
19946
+ ["carve", "carves"],
19947
+ ["valve", "valves"],
19948
+ ["looey", "looies"],
19949
+ ["thief", "thieves"],
19950
+ ["groove", "grooves"],
19951
+ ["pickaxe", "pickaxes"],
19952
+ ["passerby", "passersby"]
19953
+ ].forEach(function(rule) {
19954
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
19955
+ });
19956
+ [
19957
+ [/s?$/i, "s"],
19958
+ [/[^\u0000-\u007F]$/i, "$0"],
19959
+ [/([^aeiou]ese)$/i, "$1"],
19960
+ [/(ax|test)is$/i, "$1es"],
19961
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
19962
+ [/(e[mn]u)s?$/i, "$1s"],
19963
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
19964
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
19965
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
19966
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
19967
+ [/(her|at|gr)o$/i, "$1oes"],
19968
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
19969
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
19970
+ [/sis$/i, "ses"],
19971
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
19972
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
19973
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
19974
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
19975
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
19976
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
19977
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
19978
+ [/(child)(?:ren)?$/i, "$1ren"],
19979
+ [/eaux$/i, "$0"],
19980
+ [/m[ae]n$/i, "men"],
19981
+ ["thou", "you"]
19982
+ ].forEach(function(rule) {
19983
+ return pluralize2.addPluralRule(rule[0], rule[1]);
19984
+ });
19985
+ [
19986
+ [/s$/i, ""],
19987
+ [/(ss)$/i, "$1"],
19988
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
19989
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
19990
+ [/ies$/i, "y"],
19991
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
19992
+ [/\b(mon|smil)ies$/i, "$1ey"],
19993
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
19994
+ [/(seraph|cherub)im$/i, "$1"],
19995
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
19996
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
19997
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
19998
+ [/(test)(?:is|es)$/i, "$1is"],
19999
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
20000
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
20001
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
20002
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
20003
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
20004
+ [/(matr|append)ices$/i, "$1ix"],
20005
+ [/(pe)(rson|ople)$/i, "$1rson"],
20006
+ [/(child)ren$/i, "$1"],
20007
+ [/(eau)x?$/i, "$1"],
20008
+ [/men$/i, "man"]
20009
+ ].forEach(function(rule) {
20010
+ return pluralize2.addSingularRule(rule[0], rule[1]);
20011
+ });
20012
+ [
20013
+ // Singular words with no plurals.
20014
+ "adulthood",
20015
+ "advice",
20016
+ "agenda",
20017
+ "aid",
20018
+ "aircraft",
20019
+ "alcohol",
20020
+ "ammo",
20021
+ "analytics",
20022
+ "anime",
20023
+ "athletics",
20024
+ "audio",
20025
+ "bison",
20026
+ "blood",
20027
+ "bream",
20028
+ "buffalo",
20029
+ "butter",
20030
+ "carp",
20031
+ "cash",
20032
+ "chassis",
20033
+ "chess",
20034
+ "clothing",
20035
+ "cod",
20036
+ "commerce",
20037
+ "cooperation",
20038
+ "corps",
20039
+ "debris",
20040
+ "diabetes",
20041
+ "digestion",
20042
+ "elk",
20043
+ "energy",
20044
+ "equipment",
20045
+ "excretion",
20046
+ "expertise",
20047
+ "firmware",
20048
+ "flounder",
20049
+ "fun",
20050
+ "gallows",
20051
+ "garbage",
20052
+ "graffiti",
20053
+ "hardware",
20054
+ "headquarters",
20055
+ "health",
20056
+ "herpes",
20057
+ "highjinks",
20058
+ "homework",
20059
+ "housework",
20060
+ "information",
20061
+ "jeans",
20062
+ "justice",
20063
+ "kudos",
20064
+ "labour",
20065
+ "literature",
20066
+ "machinery",
20067
+ "mackerel",
20068
+ "mail",
20069
+ "media",
20070
+ "mews",
20071
+ "moose",
20072
+ "music",
20073
+ "mud",
20074
+ "manga",
20075
+ "news",
20076
+ "only",
20077
+ "personnel",
20078
+ "pike",
20079
+ "plankton",
20080
+ "pliers",
20081
+ "police",
20082
+ "pollution",
20083
+ "premises",
20084
+ "rain",
20085
+ "research",
20086
+ "rice",
20087
+ "salmon",
20088
+ "scissors",
20089
+ "series",
20090
+ "sewage",
20091
+ "shambles",
20092
+ "shrimp",
20093
+ "software",
20094
+ "species",
20095
+ "staff",
20096
+ "swine",
20097
+ "tennis",
20098
+ "traffic",
20099
+ "transportation",
20100
+ "trout",
20101
+ "tuna",
20102
+ "wealth",
20103
+ "welfare",
20104
+ "whiting",
20105
+ "wildebeest",
20106
+ "wildlife",
20107
+ "you",
20108
+ /pok[eé]mon$/i,
20109
+ // Regexes.
20110
+ /[^aeiou]ese$/i,
20111
+ // "chinese", "japanese"
20112
+ /deer$/i,
20113
+ // "deer", "reindeer"
20114
+ /fish$/i,
20115
+ // "fish", "blowfish", "angelfish"
20116
+ /measles$/i,
20117
+ /o[iu]s$/i,
20118
+ // "carnivorous"
20119
+ /pox$/i,
20120
+ // "chickpox", "smallpox"
20121
+ /sheep$/i
20122
+ ].forEach(pluralize2.addUncountableRule);
20123
+ return pluralize2;
20124
+ });
20125
+ })(pluralize);
20126
+ var pluralizeExports = pluralize.exports;
20127
+ const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
20128
+ plur.addPluralRule("glomerulus", "glomeruli");
20129
+ plur.addPluralRule("interstitium", "interstitia");
19773
20130
  function fromEntries(iterable) {
19774
20131
  return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
19775
20132
  }
@@ -69458,9 +69815,6 @@ class GeoCellLayer extends CompositeLayer {
69458
69815
  }
69459
69816
  _defineProperty$e(GeoCellLayer, "layerName", "GeoCellLayer");
69460
69817
  _defineProperty$e(GeoCellLayer, "defaultProps", defaultProps$t);
69461
- function commonjsRequire(path) {
69462
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
69463
- }
69464
69818
  var long = { exports: {} };
69465
69819
  (function(module2) {
69466
69820
  /**
@@ -132943,16 +133297,16 @@ function addDecoder(cases, importFn) {
132943
133297
  }
132944
133298
  cases.forEach((c) => registry$1.set(c, importFn));
132945
133299
  }
132946
- addDecoder([void 0, 1], () => import("./raw-51c1d779.js").then((m) => m.default));
132947
- addDecoder(5, () => import("./lzw-183b6431.js").then((m) => m.default));
133300
+ addDecoder([void 0, 1], () => import("./raw-01deac62.js").then((m) => m.default));
133301
+ addDecoder(5, () => import("./lzw-61ae68b2.js").then((m) => m.default));
132948
133302
  addDecoder(6, () => {
132949
133303
  throw new Error("old style JPEG compression is not supported.");
132950
133304
  });
132951
- addDecoder(7, () => import("./jpeg-c95516fd.js").then((m) => m.default));
132952
- addDecoder([8, 32946], () => import("./deflate-e1882774.js").then((m) => m.default));
132953
- addDecoder(32773, () => import("./packbits-b1c7f20d.js").then((m) => m.default));
132954
- addDecoder(34887, () => import("./lerc-c8eb24c6.js").then((m) => m.default));
132955
- addDecoder(50001, () => import("./webimage-54b36ce2.js").then((m) => m.default));
133305
+ addDecoder(7, () => import("./jpeg-03b93228.js").then((m) => m.default));
133306
+ addDecoder([8, 32946], () => import("./deflate-e2811f40.js").then((m) => m.default));
133307
+ addDecoder(32773, () => import("./packbits-b1d8eca2.js").then((m) => m.default));
133308
+ addDecoder(34887, () => import("./lerc-d5a641c1.js").then((m) => m.default));
133309
+ addDecoder(50001, () => import("./webimage-f6e6dcb0.js").then((m) => m.default));
132956
133310
  function decodeRowAcc(row, stride) {
132957
133311
  let length2 = row.length - stride;
132958
133312
  let offset = 0;
@@ -144121,6 +144475,41 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
144121
144475
  }
144122
144476
  return mat;
144123
144477
  }
144478
+ function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
144479
+ var _a2;
144480
+ let result = [];
144481
+ if (Array.isArray(coordinateTransformations)) {
144482
+ result = coordinateTransformations.map((transform2) => {
144483
+ if (transform2.input && transform2.output) {
144484
+ const { type } = transform2;
144485
+ if (type === "translation") {
144486
+ return {
144487
+ type,
144488
+ translation: transform2.translation
144489
+ };
144490
+ }
144491
+ if (type === "scale") {
144492
+ return {
144493
+ type,
144494
+ scale: transform2.scale
144495
+ };
144496
+ }
144497
+ if (type === "identity") {
144498
+ return { type };
144499
+ }
144500
+ console.warn(`Coordinate transformation type "${type}" is not supported.`);
144501
+ }
144502
+ return transform2;
144503
+ });
144504
+ }
144505
+ if (Array.isArray((_a2 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a2.coordinateTransformations)) {
144506
+ result = [
144507
+ ...datasets[0].coordinateTransformations,
144508
+ ...result
144509
+ ];
144510
+ }
144511
+ return result;
144512
+ }
144124
144513
  export {
144125
144514
  BaseDecoder as B,
144126
144515
  DEFAULT_CELLS_LAYER as D,
@@ -144139,5 +144528,6 @@ export {
144139
144528
  getNgffAxes as l,
144140
144529
  getNgffAxesForTiff as m,
144141
144530
  coordinateTransformationsToMatrix as n,
144531
+ normalizeCoordinateTransformations as o,
144142
144532
  square as s
144143
144533
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, e, a, b, c, d, G, n, l, m, h, i, f, j, k, s } from "./index-50f2f2d8.js";
1
+ import { D, e, a, b, c, d, G, n, l, m, h, i, f, j, k, o, s } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  export {
4
4
  D as DEFAULT_CELLS_LAYER,
@@ -16,5 +16,6 @@ export {
16
16
  f as initializeRasterLayersAndChannels,
17
17
  j as isInterleaved,
18
18
  k as isRgb,
19
+ o as normalizeCoordinateTransformations,
19
20
  s as square
20
21
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
1
+ import { B as BaseDecoder } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  const dctZigZag = new Int32Array([
4
4
  0,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-50f2f2d8.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-e86d2626.js";
3
3
  import "react";
4
4
  const LercParameters = {
5
5
  Version: 0,
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
1
+ import { B as BaseDecoder } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  const MIN_BITS = 9;
4
4
  const CLEAR_CODE = 256;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
1
+ import { B as BaseDecoder } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  class PackbitsDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
1
+ import { B as BaseDecoder } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  class RawDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-50f2f2d8.js";
1
+ import { B as BaseDecoder } from "./index-e86d2626.js";
2
2
  import "react";
3
3
  class WebImageDecoder extends BaseDecoder {
4
4
  constructor() {
@@ -1,2 +1,2 @@
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, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix } from "./spatial.js";
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, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, normalizeCoordinateTransformations } from "./spatial.js";
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist-tsc/index.js CHANGED
@@ -1 +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, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, } from './spatial.js';
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, square, initializeLayerChannels, initializeRasterLayersAndChannels, getSourceFromLoader, isInterleaved, isRgb, getNgffAxes, getNgffAxesForTiff, coordinateTransformationsToMatrix, normalizeCoordinateTransformations, } from './spatial.js';
@@ -51,6 +51,17 @@ export function getNgffAxesForTiff(dimOrder: any): any;
51
51
  * @returns {Array<number>} Array of 16 numbers representing the Matrix4.
52
52
  */
53
53
  export function coordinateTransformationsToMatrix(coordinateTransformations: object[], axes: object[]): Array<number>;
54
+ /**
55
+ * Normalize coordinate transformations to the OME-NGFF v0.4 format,
56
+ * despite potentially being in the new format proposed in
57
+ * https://github.com/ome/ngff/pull/138 (As of 2023-09-02).
58
+ * @param {object[]|undefined} coordinateTransformations Value of
59
+ * multiscales[0].coordinateTransformations in either OME-NGFF v0.4 format
60
+ * or that proposed in https://github.com/ome/ngff/pull/138.
61
+ * @param {object[]} datasets Value of multiscales[0].datasets in OME-NGFF v0.4 format.
62
+ * @returns {object[]} Array of coordinateTransformations in OME-NGFF v0.4 format.
63
+ */
64
+ export function normalizeCoordinateTransformations(coordinateTransformations: object[] | undefined, datasets: object[]): object[];
54
65
  export const GLOBAL_LABELS: string[];
55
66
  export const DEFAULT_RASTER_DOMAIN_TYPE: "Min/Max";
56
67
  export namespace DEFAULT_RASTER_LAYER_PROPS {
@@ -1 +1 @@
1
- {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../src/spatial.js"],"names":[],"mappings":"AAOA,wDAEC;AAiCD;;;;;;GAMG;AACH,4CAJW,MAAM,UACN,MAAM,eACJ,MAAM,CAMlB;AAED;;;;GAIG;AACH,8BAHW,MAAM,YACN,QAAM,IAAI,WAiBpB;AAmHD;;GAEG;AACH,qCAFW,MAAO,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;;;;;;;;GAQG;AACH,6EANW,MAAM,EAAE,QAER,MAAM,EAAE,GAEN,MAAM,MAAM,CAAC,CA4CzB;AAtZD,qCAAwC;AAExC,mDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBpD,mDAKE"}
1
+ {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../src/spatial.js"],"names":[],"mappings":"AAOA,wDAEC;AAiCD;;;;;;GAMG;AACH,4CAJW,MAAM,UACN,MAAM,eACJ,MAAM,CAMlB;AAED;;;;GAIG;AACH,8BAHW,MAAM,YACN,QAAM,IAAI,WAiBpB;AAmHD;;GAEG;AACH,qCAFW,MAAO,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;;;;;;;;GAQG;AACH,6EANW,MAAM,EAAE,QAER,MAAM,EAAE,GAEN,MAAM,MAAM,CAAC,CA4CzB;AAED;;;;;;;;;GASG;AACH,8EANW,MAAM,EAAE,GAAC,SAAS,YAGlB,MAAM,EAAE,GACN,MAAM,EAAE,CAiDpB;AAjdD,qCAAwC;AAExC,mDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBpD,mDAKE"}
@@ -373,3 +373,58 @@ export function coordinateTransformationsToMatrix(coordinateTransformations, axe
373
373
  }
374
374
  return mat;
375
375
  }
376
+ /**
377
+ * Normalize coordinate transformations to the OME-NGFF v0.4 format,
378
+ * despite potentially being in the new format proposed in
379
+ * https://github.com/ome/ngff/pull/138 (As of 2023-09-02).
380
+ * @param {object[]|undefined} coordinateTransformations Value of
381
+ * multiscales[0].coordinateTransformations in either OME-NGFF v0.4 format
382
+ * or that proposed in https://github.com/ome/ngff/pull/138.
383
+ * @param {object[]} datasets Value of multiscales[0].datasets in OME-NGFF v0.4 format.
384
+ * @returns {object[]} Array of coordinateTransformations in OME-NGFF v0.4 format.
385
+ */
386
+ export function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
387
+ // "The transformations in the list are applied sequentially and in order."
388
+ // Reference: https://ngff.openmicroscopy.org/0.4/index.html#trafo-md
389
+ let result = [];
390
+ if (Array.isArray(coordinateTransformations)) {
391
+ result = coordinateTransformations.map((transform) => {
392
+ if (transform.input && transform.output) {
393
+ // This is a new-style coordinate transformation.
394
+ // (As proposed in https://github.com/ome/ngff/pull/138)
395
+ const { type } = transform;
396
+ if (type === 'translation') {
397
+ return {
398
+ type,
399
+ translation: transform.translation,
400
+ };
401
+ }
402
+ if (type === 'scale') {
403
+ return {
404
+ type,
405
+ scale: transform.scale,
406
+ };
407
+ }
408
+ if (type === 'identity') {
409
+ return { type };
410
+ }
411
+ console.warn(`Coordinate transformation type "${type}" is not supported.`);
412
+ }
413
+ // Assume it was already an old-style (NGFF v0.4) coordinate transformation.
414
+ return transform;
415
+ });
416
+ }
417
+ if (Array.isArray(datasets?.[0]?.coordinateTransformations)) {
418
+ // "Datasets SHOULD define a transformation from array space
419
+ // to their "native physical space."
420
+ // This transformation SHOULD describe physical pixel spacing
421
+ // and origin only, and therefore SHOULD consist of
422
+ // `scale` and/or `translation` types only.""
423
+ // Reference: https://github.com/ome/ngff/blob/b92f540dc95440f2d6b7012185b09c2b862aa744/latest/transform-details.bs#L99
424
+ result = [
425
+ ...datasets[0].coordinateTransformations,
426
+ ...result,
427
+ ];
428
+ }
429
+ return result;
430
+ }
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { square, coordinateTransformationsToMatrix } from './spatial.js';
2
+ import { square, coordinateTransformationsToMatrix, normalizeCoordinateTransformations, } from './spatial.js';
3
3
  const defaultAxes = [
4
4
  { type: 'time', name: 't' },
5
5
  { type: 'channel', name: 'c' },
@@ -41,4 +41,159 @@ describe('Spatial.js', () => {
41
41
  ]);
42
42
  });
43
43
  });
44
+ describe('normalizeCoordinateTransformations', () => {
45
+ it('does nothing for OME-NGFF v0.4 input', () => {
46
+ const datasets = [
47
+ {
48
+ coordinateTransformations: [
49
+ {
50
+ scale: [
51
+ 1,
52
+ 0.5002025531914894,
53
+ 0.3603981534640209,
54
+ 0.3603981534640209,
55
+ ],
56
+ type: 'scale',
57
+ },
58
+ ],
59
+ path: '0',
60
+ },
61
+ {
62
+ coordinateTransformations: [
63
+ {
64
+ scale: [
65
+ 1,
66
+ 0.5002025531914894,
67
+ 0.7207963069280418,
68
+ 0.7207963069280418,
69
+ ],
70
+ type: 'scale',
71
+ },
72
+ ],
73
+ path: '1',
74
+ },
75
+ {
76
+ coordinateTransformations: [
77
+ {
78
+ scale: [
79
+ 1,
80
+ 0.5002025531914894,
81
+ 1.4415926138560835,
82
+ 1.4415926138560835,
83
+ ],
84
+ type: 'scale',
85
+ },
86
+ ],
87
+ path: '2',
88
+ },
89
+ ];
90
+ expect(normalizeCoordinateTransformations(undefined, datasets)).toEqual([
91
+ // Here, we expect only the first dataset to be used.
92
+ // However, we should eventually support transforms
93
+ // specified for each dataset individually,
94
+ // since there could in theory be irregular ways of downsampling.
95
+ {
96
+ scale: [
97
+ 1,
98
+ 0.5002025531914894,
99
+ 0.3603981534640209,
100
+ 0.3603981534640209,
101
+ ],
102
+ type: 'scale',
103
+ },
104
+ ]);
105
+ });
106
+ it('transforms SpatialData input', () => {
107
+ const newCoordinateTransformations = [
108
+ {
109
+ input: {
110
+ axes: [
111
+ {
112
+ name: 'c',
113
+ type: 'channel',
114
+ },
115
+ {
116
+ name: 'y',
117
+ type: 'space',
118
+ unit: 'unit',
119
+ },
120
+ {
121
+ name: 'x',
122
+ type: 'space',
123
+ unit: 'unit',
124
+ },
125
+ ],
126
+ name: 'cyx',
127
+ },
128
+ output: {
129
+ axes: [
130
+ {
131
+ name: 'c',
132
+ type: 'channel',
133
+ },
134
+ {
135
+ name: 'y',
136
+ type: 'space',
137
+ unit: 'unit',
138
+ },
139
+ {
140
+ name: 'x',
141
+ type: 'space',
142
+ unit: 'unit',
143
+ },
144
+ ],
145
+ name: 'ST8059048',
146
+ },
147
+ scale: [
148
+ 1.0,
149
+ 8.670500183814605,
150
+ 8.670500183814605,
151
+ ],
152
+ type: 'scale',
153
+ },
154
+ ];
155
+ const datasets = [
156
+ {
157
+ coordinateTransformations: [
158
+ {
159
+ scale: [
160
+ 1.0,
161
+ 1.0,
162
+ 1.0,
163
+ ],
164
+ type: 'scale',
165
+ },
166
+ ],
167
+ path: '0',
168
+ },
169
+ ];
170
+ expect(normalizeCoordinateTransformations(newCoordinateTransformations, datasets)).toEqual([
171
+ // Here, we expect only the first dataset to be used.
172
+ // However, we should eventually support transforms
173
+ // specified for each dataset individually,
174
+ // since there could in theory be irregular ways of downsampling.
175
+ {
176
+ scale: [
177
+ 1.0,
178
+ 1.0,
179
+ 1.0,
180
+ ],
181
+ type: 'scale',
182
+ },
183
+ // We expect the dataset transform to be prepended
184
+ // to the newCoordinateTransformations items.
185
+ // We do not check the input/output coordinate systems, but we should eventually allow
186
+ // the user to specify this somehow and use that information to filter which transforms
187
+ // are included here.
188
+ {
189
+ scale: [
190
+ 1.0,
191
+ 8.670500183814605,
192
+ 8.670500183814605,
193
+ ],
194
+ type: 'scale',
195
+ },
196
+ ]);
197
+ });
198
+ });
44
199
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/spatial-utils",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,8 +19,8 @@
19
19
  "lodash-es": "^4.17.21",
20
20
  "math.gl": "^3.5.6",
21
21
  "mathjs": "^9.2.0",
22
- "@vitessce/gl": "3.1.1",
23
- "@vitessce/utils": "3.1.1"
22
+ "@vitessce/gl": "3.1.3",
23
+ "@vitessce/utils": "3.1.3"
24
24
  },
25
25
  "scripts": {
26
26
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
package/src/index.js CHANGED
@@ -15,4 +15,5 @@ export {
15
15
  getNgffAxes,
16
16
  getNgffAxesForTiff,
17
17
  coordinateTransformationsToMatrix,
18
+ normalizeCoordinateTransformations,
18
19
  } from './spatial.js';
package/src/spatial.js CHANGED
@@ -416,3 +416,62 @@ export function coordinateTransformationsToMatrix(coordinateTransformations, axe
416
416
  }
417
417
  return mat;
418
418
  }
419
+
420
+ /**
421
+ * Normalize coordinate transformations to the OME-NGFF v0.4 format,
422
+ * despite potentially being in the new format proposed in
423
+ * https://github.com/ome/ngff/pull/138 (As of 2023-09-02).
424
+ * @param {object[]|undefined} coordinateTransformations Value of
425
+ * multiscales[0].coordinateTransformations in either OME-NGFF v0.4 format
426
+ * or that proposed in https://github.com/ome/ngff/pull/138.
427
+ * @param {object[]} datasets Value of multiscales[0].datasets in OME-NGFF v0.4 format.
428
+ * @returns {object[]} Array of coordinateTransformations in OME-NGFF v0.4 format.
429
+ */
430
+ export function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
431
+ // "The transformations in the list are applied sequentially and in order."
432
+ // Reference: https://ngff.openmicroscopy.org/0.4/index.html#trafo-md
433
+ let result = [];
434
+
435
+ if (Array.isArray(coordinateTransformations)) {
436
+ result = coordinateTransformations.map((transform) => {
437
+ if (transform.input && transform.output) {
438
+ // This is a new-style coordinate transformation.
439
+ // (As proposed in https://github.com/ome/ngff/pull/138)
440
+ const { type } = transform;
441
+ if (type === 'translation') {
442
+ return {
443
+ type,
444
+ translation: transform.translation,
445
+ };
446
+ }
447
+ if (type === 'scale') {
448
+ return {
449
+ type,
450
+ scale: transform.scale,
451
+ };
452
+ }
453
+ if (type === 'identity') {
454
+ return { type };
455
+ }
456
+ console.warn(`Coordinate transformation type "${type}" is not supported.`);
457
+ }
458
+ // Assume it was already an old-style (NGFF v0.4) coordinate transformation.
459
+ return transform;
460
+ });
461
+ }
462
+
463
+ if (Array.isArray(datasets?.[0]?.coordinateTransformations)) {
464
+ // "Datasets SHOULD define a transformation from array space
465
+ // to their "native physical space."
466
+ // This transformation SHOULD describe physical pixel spacing
467
+ // and origin only, and therefore SHOULD consist of
468
+ // `scale` and/or `translation` types only.""
469
+ // Reference: https://github.com/ome/ngff/blob/b92f540dc95440f2d6b7012185b09c2b862aa744/latest/transform-details.bs#L99
470
+
471
+ result = [
472
+ ...datasets[0].coordinateTransformations,
473
+ ...result,
474
+ ];
475
+ }
476
+ return result;
477
+ }
@@ -1,5 +1,9 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { square, coordinateTransformationsToMatrix } from './spatial.js';
2
+ import {
3
+ square,
4
+ coordinateTransformationsToMatrix,
5
+ normalizeCoordinateTransformations,
6
+ } from './spatial.js';
3
7
 
4
8
  const defaultAxes = [
5
9
  { type: 'time', name: 't' },
@@ -43,4 +47,159 @@ describe('Spatial.js', () => {
43
47
  ]);
44
48
  });
45
49
  });
50
+ describe('normalizeCoordinateTransformations', () => {
51
+ it('does nothing for OME-NGFF v0.4 input', () => {
52
+ const datasets = [
53
+ {
54
+ coordinateTransformations: [
55
+ {
56
+ scale: [
57
+ 1,
58
+ 0.5002025531914894,
59
+ 0.3603981534640209,
60
+ 0.3603981534640209,
61
+ ],
62
+ type: 'scale',
63
+ },
64
+ ],
65
+ path: '0',
66
+ },
67
+ {
68
+ coordinateTransformations: [
69
+ {
70
+ scale: [
71
+ 1,
72
+ 0.5002025531914894,
73
+ 0.7207963069280418,
74
+ 0.7207963069280418,
75
+ ],
76
+ type: 'scale',
77
+ },
78
+ ],
79
+ path: '1',
80
+ },
81
+ {
82
+ coordinateTransformations: [
83
+ {
84
+ scale: [
85
+ 1,
86
+ 0.5002025531914894,
87
+ 1.4415926138560835,
88
+ 1.4415926138560835,
89
+ ],
90
+ type: 'scale',
91
+ },
92
+ ],
93
+ path: '2',
94
+ },
95
+ ];
96
+ expect(normalizeCoordinateTransformations(undefined, datasets)).toEqual([
97
+ // Here, we expect only the first dataset to be used.
98
+ // However, we should eventually support transforms
99
+ // specified for each dataset individually,
100
+ // since there could in theory be irregular ways of downsampling.
101
+ {
102
+ scale: [
103
+ 1,
104
+ 0.5002025531914894,
105
+ 0.3603981534640209,
106
+ 0.3603981534640209,
107
+ ],
108
+ type: 'scale',
109
+ },
110
+ ]);
111
+ });
112
+ it('transforms SpatialData input', () => {
113
+ const newCoordinateTransformations = [
114
+ {
115
+ input: {
116
+ axes: [
117
+ {
118
+ name: 'c',
119
+ type: 'channel',
120
+ },
121
+ {
122
+ name: 'y',
123
+ type: 'space',
124
+ unit: 'unit',
125
+ },
126
+ {
127
+ name: 'x',
128
+ type: 'space',
129
+ unit: 'unit',
130
+ },
131
+ ],
132
+ name: 'cyx',
133
+ },
134
+ output: {
135
+ axes: [
136
+ {
137
+ name: 'c',
138
+ type: 'channel',
139
+ },
140
+ {
141
+ name: 'y',
142
+ type: 'space',
143
+ unit: 'unit',
144
+ },
145
+ {
146
+ name: 'x',
147
+ type: 'space',
148
+ unit: 'unit',
149
+ },
150
+ ],
151
+ name: 'ST8059048',
152
+ },
153
+ scale: [
154
+ 1.0,
155
+ 8.670500183814605,
156
+ 8.670500183814605,
157
+ ],
158
+ type: 'scale',
159
+ },
160
+ ];
161
+ const datasets = [
162
+ {
163
+ coordinateTransformations: [
164
+ {
165
+ scale: [
166
+ 1.0,
167
+ 1.0,
168
+ 1.0,
169
+ ],
170
+ type: 'scale',
171
+ },
172
+ ],
173
+ path: '0',
174
+ },
175
+ ];
176
+ expect(normalizeCoordinateTransformations(newCoordinateTransformations, datasets)).toEqual([
177
+ // Here, we expect only the first dataset to be used.
178
+ // However, we should eventually support transforms
179
+ // specified for each dataset individually,
180
+ // since there could in theory be irregular ways of downsampling.
181
+ {
182
+ scale: [
183
+ 1.0,
184
+ 1.0,
185
+ 1.0,
186
+ ],
187
+ type: 'scale',
188
+ },
189
+ // We expect the dataset transform to be prepended
190
+ // to the newCoordinateTransformations items.
191
+ // We do not check the input/output coordinate systems, but we should eventually allow
192
+ // the user to specify this somehow and use that information to filter which transforms
193
+ // are included here.
194
+ {
195
+ scale: [
196
+ 1.0,
197
+ 8.670500183814605,
198
+ 8.670500183814605,
199
+ ],
200
+ type: 'scale',
201
+ },
202
+ ]);
203
+ });
204
+ });
46
205
  });