@vitessce/zarr 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-aef6c8fd.js";
2
+ import { B as BaseDecoder } from "./index-58807fea.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  class DeflateDecoder extends BaseDecoder {
@@ -28390,6 +28390,363 @@ var unit = /* @__PURE__ */ createUnitFunction({
28390
28390
  Unit,
28391
28391
  typed
28392
28392
  });
28393
+ function commonjsRequire(path) {
28394
+ 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.');
28395
+ }
28396
+ var pluralize = { exports: {} };
28397
+ (function(module2, exports2) {
28398
+ (function(root2, pluralize2) {
28399
+ if (typeof commonjsRequire === "function" && true && true) {
28400
+ module2.exports = pluralize2();
28401
+ } else {
28402
+ root2.pluralize = pluralize2();
28403
+ }
28404
+ })(commonjsGlobal, function() {
28405
+ var pluralRules = [];
28406
+ var singularRules = [];
28407
+ var uncountables = {};
28408
+ var irregularPlurals = {};
28409
+ var irregularSingles = {};
28410
+ function sanitizeRule(rule) {
28411
+ if (typeof rule === "string") {
28412
+ return new RegExp("^" + rule + "$", "i");
28413
+ }
28414
+ return rule;
28415
+ }
28416
+ function restoreCase(word, token) {
28417
+ if (word === token)
28418
+ return token;
28419
+ if (word === word.toLowerCase())
28420
+ return token.toLowerCase();
28421
+ if (word === word.toUpperCase())
28422
+ return token.toUpperCase();
28423
+ if (word[0] === word[0].toUpperCase()) {
28424
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
28425
+ }
28426
+ return token.toLowerCase();
28427
+ }
28428
+ function interpolate2(str, args) {
28429
+ return str.replace(/\$(\d{1,2})/g, function(match, index2) {
28430
+ return args[index2] || "";
28431
+ });
28432
+ }
28433
+ function replace(word, rule) {
28434
+ return word.replace(rule[0], function(match, index2) {
28435
+ var result = interpolate2(rule[1], arguments);
28436
+ if (match === "") {
28437
+ return restoreCase(word[index2 - 1], result);
28438
+ }
28439
+ return restoreCase(match, result);
28440
+ });
28441
+ }
28442
+ function sanitizeWord(token, word, rules) {
28443
+ if (!token.length || uncountables.hasOwnProperty(token)) {
28444
+ return word;
28445
+ }
28446
+ var len2 = rules.length;
28447
+ while (len2--) {
28448
+ var rule = rules[len2];
28449
+ if (rule[0].test(word))
28450
+ return replace(word, rule);
28451
+ }
28452
+ return word;
28453
+ }
28454
+ function replaceWord(replaceMap, keepMap, rules) {
28455
+ return function(word) {
28456
+ var token = word.toLowerCase();
28457
+ if (keepMap.hasOwnProperty(token)) {
28458
+ return restoreCase(word, token);
28459
+ }
28460
+ if (replaceMap.hasOwnProperty(token)) {
28461
+ return restoreCase(word, replaceMap[token]);
28462
+ }
28463
+ return sanitizeWord(token, word, rules);
28464
+ };
28465
+ }
28466
+ function checkWord(replaceMap, keepMap, rules, bool) {
28467
+ return function(word) {
28468
+ var token = word.toLowerCase();
28469
+ if (keepMap.hasOwnProperty(token))
28470
+ return true;
28471
+ if (replaceMap.hasOwnProperty(token))
28472
+ return false;
28473
+ return sanitizeWord(token, token, rules) === token;
28474
+ };
28475
+ }
28476
+ function pluralize2(word, count2, inclusive) {
28477
+ var pluralized = count2 === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
28478
+ return (inclusive ? count2 + " " : "") + pluralized;
28479
+ }
28480
+ pluralize2.plural = replaceWord(
28481
+ irregularSingles,
28482
+ irregularPlurals,
28483
+ pluralRules
28484
+ );
28485
+ pluralize2.isPlural = checkWord(
28486
+ irregularSingles,
28487
+ irregularPlurals,
28488
+ pluralRules
28489
+ );
28490
+ pluralize2.singular = replaceWord(
28491
+ irregularPlurals,
28492
+ irregularSingles,
28493
+ singularRules
28494
+ );
28495
+ pluralize2.isSingular = checkWord(
28496
+ irregularPlurals,
28497
+ irregularSingles,
28498
+ singularRules
28499
+ );
28500
+ pluralize2.addPluralRule = function(rule, replacement) {
28501
+ pluralRules.push([sanitizeRule(rule), replacement]);
28502
+ };
28503
+ pluralize2.addSingularRule = function(rule, replacement) {
28504
+ singularRules.push([sanitizeRule(rule), replacement]);
28505
+ };
28506
+ pluralize2.addUncountableRule = function(word) {
28507
+ if (typeof word === "string") {
28508
+ uncountables[word.toLowerCase()] = true;
28509
+ return;
28510
+ }
28511
+ pluralize2.addPluralRule(word, "$0");
28512
+ pluralize2.addSingularRule(word, "$0");
28513
+ };
28514
+ pluralize2.addIrregularRule = function(single, plural) {
28515
+ plural = plural.toLowerCase();
28516
+ single = single.toLowerCase();
28517
+ irregularSingles[single] = plural;
28518
+ irregularPlurals[plural] = single;
28519
+ };
28520
+ [
28521
+ // Pronouns.
28522
+ ["I", "we"],
28523
+ ["me", "us"],
28524
+ ["he", "they"],
28525
+ ["she", "they"],
28526
+ ["them", "them"],
28527
+ ["myself", "ourselves"],
28528
+ ["yourself", "yourselves"],
28529
+ ["itself", "themselves"],
28530
+ ["herself", "themselves"],
28531
+ ["himself", "themselves"],
28532
+ ["themself", "themselves"],
28533
+ ["is", "are"],
28534
+ ["was", "were"],
28535
+ ["has", "have"],
28536
+ ["this", "these"],
28537
+ ["that", "those"],
28538
+ // Words ending in with a consonant and `o`.
28539
+ ["echo", "echoes"],
28540
+ ["dingo", "dingoes"],
28541
+ ["volcano", "volcanoes"],
28542
+ ["tornado", "tornadoes"],
28543
+ ["torpedo", "torpedoes"],
28544
+ // Ends with `us`.
28545
+ ["genus", "genera"],
28546
+ ["viscus", "viscera"],
28547
+ // Ends with `ma`.
28548
+ ["stigma", "stigmata"],
28549
+ ["stoma", "stomata"],
28550
+ ["dogma", "dogmata"],
28551
+ ["lemma", "lemmata"],
28552
+ ["schema", "schemata"],
28553
+ ["anathema", "anathemata"],
28554
+ // Other irregular rules.
28555
+ ["ox", "oxen"],
28556
+ ["axe", "axes"],
28557
+ ["die", "dice"],
28558
+ ["yes", "yeses"],
28559
+ ["foot", "feet"],
28560
+ ["eave", "eaves"],
28561
+ ["goose", "geese"],
28562
+ ["tooth", "teeth"],
28563
+ ["quiz", "quizzes"],
28564
+ ["human", "humans"],
28565
+ ["proof", "proofs"],
28566
+ ["carve", "carves"],
28567
+ ["valve", "valves"],
28568
+ ["looey", "looies"],
28569
+ ["thief", "thieves"],
28570
+ ["groove", "grooves"],
28571
+ ["pickaxe", "pickaxes"],
28572
+ ["passerby", "passersby"]
28573
+ ].forEach(function(rule) {
28574
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
28575
+ });
28576
+ [
28577
+ [/s?$/i, "s"],
28578
+ [/[^\u0000-\u007F]$/i, "$0"],
28579
+ [/([^aeiou]ese)$/i, "$1"],
28580
+ [/(ax|test)is$/i, "$1es"],
28581
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
28582
+ [/(e[mn]u)s?$/i, "$1s"],
28583
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
28584
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
28585
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
28586
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
28587
+ [/(her|at|gr)o$/i, "$1oes"],
28588
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
28589
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
28590
+ [/sis$/i, "ses"],
28591
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
28592
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
28593
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
28594
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
28595
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
28596
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
28597
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
28598
+ [/(child)(?:ren)?$/i, "$1ren"],
28599
+ [/eaux$/i, "$0"],
28600
+ [/m[ae]n$/i, "men"],
28601
+ ["thou", "you"]
28602
+ ].forEach(function(rule) {
28603
+ return pluralize2.addPluralRule(rule[0], rule[1]);
28604
+ });
28605
+ [
28606
+ [/s$/i, ""],
28607
+ [/(ss)$/i, "$1"],
28608
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
28609
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
28610
+ [/ies$/i, "y"],
28611
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
28612
+ [/\b(mon|smil)ies$/i, "$1ey"],
28613
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
28614
+ [/(seraph|cherub)im$/i, "$1"],
28615
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
28616
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
28617
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
28618
+ [/(test)(?:is|es)$/i, "$1is"],
28619
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
28620
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
28621
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
28622
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
28623
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
28624
+ [/(matr|append)ices$/i, "$1ix"],
28625
+ [/(pe)(rson|ople)$/i, "$1rson"],
28626
+ [/(child)ren$/i, "$1"],
28627
+ [/(eau)x?$/i, "$1"],
28628
+ [/men$/i, "man"]
28629
+ ].forEach(function(rule) {
28630
+ return pluralize2.addSingularRule(rule[0], rule[1]);
28631
+ });
28632
+ [
28633
+ // Singular words with no plurals.
28634
+ "adulthood",
28635
+ "advice",
28636
+ "agenda",
28637
+ "aid",
28638
+ "aircraft",
28639
+ "alcohol",
28640
+ "ammo",
28641
+ "analytics",
28642
+ "anime",
28643
+ "athletics",
28644
+ "audio",
28645
+ "bison",
28646
+ "blood",
28647
+ "bream",
28648
+ "buffalo",
28649
+ "butter",
28650
+ "carp",
28651
+ "cash",
28652
+ "chassis",
28653
+ "chess",
28654
+ "clothing",
28655
+ "cod",
28656
+ "commerce",
28657
+ "cooperation",
28658
+ "corps",
28659
+ "debris",
28660
+ "diabetes",
28661
+ "digestion",
28662
+ "elk",
28663
+ "energy",
28664
+ "equipment",
28665
+ "excretion",
28666
+ "expertise",
28667
+ "firmware",
28668
+ "flounder",
28669
+ "fun",
28670
+ "gallows",
28671
+ "garbage",
28672
+ "graffiti",
28673
+ "hardware",
28674
+ "headquarters",
28675
+ "health",
28676
+ "herpes",
28677
+ "highjinks",
28678
+ "homework",
28679
+ "housework",
28680
+ "information",
28681
+ "jeans",
28682
+ "justice",
28683
+ "kudos",
28684
+ "labour",
28685
+ "literature",
28686
+ "machinery",
28687
+ "mackerel",
28688
+ "mail",
28689
+ "media",
28690
+ "mews",
28691
+ "moose",
28692
+ "music",
28693
+ "mud",
28694
+ "manga",
28695
+ "news",
28696
+ "only",
28697
+ "personnel",
28698
+ "pike",
28699
+ "plankton",
28700
+ "pliers",
28701
+ "police",
28702
+ "pollution",
28703
+ "premises",
28704
+ "rain",
28705
+ "research",
28706
+ "rice",
28707
+ "salmon",
28708
+ "scissors",
28709
+ "series",
28710
+ "sewage",
28711
+ "shambles",
28712
+ "shrimp",
28713
+ "software",
28714
+ "species",
28715
+ "staff",
28716
+ "swine",
28717
+ "tennis",
28718
+ "traffic",
28719
+ "transportation",
28720
+ "trout",
28721
+ "tuna",
28722
+ "wealth",
28723
+ "welfare",
28724
+ "whiting",
28725
+ "wildebeest",
28726
+ "wildlife",
28727
+ "you",
28728
+ /pok[eé]mon$/i,
28729
+ // Regexes.
28730
+ /[^aeiou]ese$/i,
28731
+ // "chinese", "japanese"
28732
+ /deer$/i,
28733
+ // "deer", "reindeer"
28734
+ /fish$/i,
28735
+ // "fish", "blowfish", "angelfish"
28736
+ /measles$/i,
28737
+ /o[iu]s$/i,
28738
+ // "carnivorous"
28739
+ /pox$/i,
28740
+ // "chickpox", "smallpox"
28741
+ /sheep$/i
28742
+ ].forEach(pluralize2.addUncountableRule);
28743
+ return pluralize2;
28744
+ });
28745
+ })(pluralize);
28746
+ var pluralizeExports = pluralize.exports;
28747
+ const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
28748
+ plur.addPluralRule("glomerulus", "glomeruli");
28749
+ plur.addPluralRule("interstitium", "interstitia");
28393
28750
  function fromEntries(iterable) {
28394
28751
  return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
28395
28752
  }
@@ -78314,9 +78671,6 @@ class GeoCellLayer extends CompositeLayer {
78314
78671
  }
78315
78672
  _defineProperty$e(GeoCellLayer, "layerName", "GeoCellLayer");
78316
78673
  _defineProperty$e(GeoCellLayer, "defaultProps", defaultProps$t);
78317
- function commonjsRequire(path) {
78318
- 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.');
78319
- }
78320
78674
  var long = { exports: {} };
78321
78675
  (function(module2) {
78322
78676
  /**
@@ -141799,16 +142153,16 @@ function addDecoder(cases, importFn) {
141799
142153
  }
141800
142154
  cases.forEach((c) => registry.set(c, importFn));
141801
142155
  }
141802
- addDecoder([void 0, 1], () => import("./raw-431129e7.js").then((m) => m.default));
141803
- addDecoder(5, () => import("./lzw-8a6eb694.js").then((m) => m.default));
142156
+ addDecoder([void 0, 1], () => import("./raw-bf0fb054.js").then((m) => m.default));
142157
+ addDecoder(5, () => import("./lzw-5712b930.js").then((m) => m.default));
141804
142158
  addDecoder(6, () => {
141805
142159
  throw new Error("old style JPEG compression is not supported.");
141806
142160
  });
141807
- addDecoder(7, () => import("./jpeg-608a0f2a.js").then((m) => m.default));
141808
- addDecoder([8, 32946], () => import("./deflate-e4df5be8.js").then((m) => m.default));
141809
- addDecoder(32773, () => import("./packbits-e34e4553.js").then((m) => m.default));
141810
- addDecoder(34887, () => import("./lerc-9d769a30.js").then((m) => m.default));
141811
- addDecoder(50001, () => import("./webimage-c5617d00.js").then((m) => m.default));
142161
+ addDecoder(7, () => import("./jpeg-d96062a4.js").then((m) => m.default));
142162
+ addDecoder([8, 32946], () => import("./deflate-7cf024eb.js").then((m) => m.default));
142163
+ addDecoder(32773, () => import("./packbits-ed7b9205.js").then((m) => m.default));
142164
+ addDecoder(34887, () => import("./lerc-6865e403.js").then((m) => m.default));
142165
+ addDecoder(50001, () => import("./webimage-a8d94527.js").then((m) => m.default));
141812
142166
  function decodeRowAcc(row, stride) {
141813
142167
  let length2 = row.length - stride;
141814
142168
  let offset = 0;
@@ -147751,6 +148105,41 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
147751
148105
  }
147752
148106
  return mat;
147753
148107
  }
148108
+ function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
148109
+ var _a2;
148110
+ let result = [];
148111
+ if (Array.isArray(coordinateTransformations)) {
148112
+ result = coordinateTransformations.map((transform2) => {
148113
+ if (transform2.input && transform2.output) {
148114
+ const { type } = transform2;
148115
+ if (type === "translation") {
148116
+ return {
148117
+ type,
148118
+ translation: transform2.translation
148119
+ };
148120
+ }
148121
+ if (type === "scale") {
148122
+ return {
148123
+ type,
148124
+ scale: transform2.scale
148125
+ };
148126
+ }
148127
+ if (type === "identity") {
148128
+ return { type };
148129
+ }
148130
+ console.warn(`Coordinate transformation type "${type}" is not supported.`);
148131
+ }
148132
+ return transform2;
148133
+ });
148134
+ }
148135
+ if (Array.isArray((_a2 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a2.coordinateTransformations)) {
148136
+ result = [
148137
+ ...datasets[0].coordinateTransformations,
148138
+ ...result
148139
+ ];
148140
+ }
148141
+ return result;
148142
+ }
147754
148143
  class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader {
147755
148144
  /**
147756
148145
  * Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
@@ -147939,28 +148328,34 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
147939
148328
  const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options || {};
147940
148329
  const loader = await loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: "multiscales" });
147941
148330
  const { metadata, data } = loader;
147942
- const { omero, multiscales } = metadata;
147943
- if (!omero) {
147944
- console.error("Path for image not valid");
148331
+ const { omero, multiscales, channels_metadata: spatialDataChannels } = metadata;
148332
+ const isSpatialData = !!spatialDataChannels;
148333
+ if (!isSpatialData && !omero) {
148334
+ console.error("image.ome-zarr must have omero metadata in attributes.");
147945
148335
  return Promise.reject(payload);
147946
148336
  }
147947
148337
  if (!Array.isArray(multiscales) || multiscales.length === 0) {
147948
148338
  console.error("Multiscales array must exist and have at least one element");
147949
148339
  }
147950
- const { coordinateTransformations } = multiscales[0];
148340
+ const {
148341
+ datasets,
148342
+ coordinateTransformations: coordinateTransformationsFromFile,
148343
+ name: imageName
148344
+ } = multiscales[0];
147951
148345
  const axes = getNgffAxes(multiscales[0].axes);
148346
+ const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
148347
+ coordinateTransformationsFromFile,
148348
+ datasets
148349
+ );
147952
148350
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(
147953
148351
  coordinateTransformationsFromOptions,
147954
148352
  axes
147955
148353
  );
147956
148354
  const transformMatrixFromFile = coordinateTransformationsToMatrix(
147957
- coordinateTransformations,
148355
+ normCoordinateTransformationsFromFile,
147958
148356
  axes
147959
148357
  );
147960
148358
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
147961
- const { rdefs, channels: channels2, name: omeroName } = omero;
147962
- const t2 = rdefs.defaultT ?? 0;
147963
- const z2 = rdefs.defaultZ ?? 0;
147964
148359
  const filterSelection = (sel) => {
147965
148360
  if (data.length > 0) {
147966
148361
  const nextSel = {};
@@ -147974,14 +148369,37 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
147974
148369
  }
147975
148370
  return sel;
147976
148371
  };
148372
+ let channelObjects;
148373
+ let channelLabels = [];
148374
+ let initialTargetT = 0;
148375
+ let initialTargetZ = 0;
148376
+ if (isSpatialData) {
148377
+ const { channels: channels2 } = spatialDataChannels;
148378
+ channelObjects = channels2.map((channel, i2) => ({
148379
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i2 }),
148380
+ slider: [0, 255],
148381
+ color: [255, 255, 255]
148382
+ }));
148383
+ channelLabels = channels2.map((c) => c.label);
148384
+ } else {
148385
+ const { rdefs, channels: channels2 } = omero;
148386
+ if (typeof rdefs.defaultT === "number") {
148387
+ initialTargetT = rdefs.defaultT;
148388
+ }
148389
+ if (typeof rdefs.defaultZ === "number") {
148390
+ initialTargetZ = rdefs.defaultZ;
148391
+ }
148392
+ channelObjects = channels2.map((channel, i2) => ({
148393
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i2 }),
148394
+ slider: [channel.window.start, channel.window.end],
148395
+ color: hexToRgb(channel.color)
148396
+ }));
148397
+ channelLabels = channels2.map((c) => c.label);
148398
+ }
147977
148399
  const imagesWithLoaderCreators = [
147978
148400
  {
147979
- name: omeroName || "Image",
147980
- channels: channels2.map((channel, i2) => ({
147981
- selection: filterSelection({ z: z2, t: t2, c: i2 }),
147982
- slider: [channel.window.start, channel.window.end],
147983
- color: hexToRgb(channel.color)
147984
- })),
148401
+ name: imageName || "Image",
148402
+ channels: channelObjects,
147985
148403
  ...transformMatrix ? {
147986
148404
  metadata: {
147987
148405
  transform: {
@@ -147989,7 +148407,7 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
147989
148407
  }
147990
148408
  }
147991
148409
  } : {},
147992
- loaderCreator: async () => ({ ...loader, channels: channels2.map((c) => c.label) })
148410
+ loaderCreator: async () => ({ ...loader, channels: channelLabels })
147993
148411
  }
147994
148412
  ];
147995
148413
  const [
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, F, G, a, M, b, O, f, c, d, e, h, Z } from "./index-aef6c8fd.js";
1
+ import { A, F, G, a, M, b, O, f, c, d, e, h, Z } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-aef6c8fd.js";
1
+ import { B as BaseDecoder } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const dctZigZag = new Int32Array([
@@ -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-aef6c8fd.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-58807fea.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  const LercParameters = {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-aef6c8fd.js";
1
+ import { B as BaseDecoder } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const MIN_BITS = 9;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-aef6c8fd.js";
1
+ import { B as BaseDecoder } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class PackbitsDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-aef6c8fd.js";
1
+ import { B as BaseDecoder } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class RawDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-aef6c8fd.js";
1
+ import { B as BaseDecoder } from "./index-58807fea.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class WebImageDecoder extends BaseDecoder {
@@ -1 +1 @@
1
- {"version":3,"file":"OmeZarrLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrLoader.js"],"names":[],"mappings":"AAqBA;IACE,qBA2FC;CACF"}
1
+ {"version":3,"file":"OmeZarrLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrLoader.js"],"names":[],"mappings":"AAsBA;IACE,qBAsIC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { viv } from '@vitessce/gl';
2
- import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, } from '@vitessce/spatial-utils';
2
+ import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, normalizeCoordinateTransformations, } from '@vitessce/spatial-utils';
3
3
  import { AbstractLoaderError, LoaderResult, AbstractTwoStepLoader, } from '@vitessce/vit-s';
4
4
  function hexToRgb(hex) {
5
5
  const result = /^#?([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})$/i.exec(hex);
@@ -18,23 +18,26 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
18
18
  const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options || {};
19
19
  const loader = await viv.loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: 'multiscales' });
20
20
  const { metadata, data } = loader;
21
- const { omero, multiscales } = metadata;
22
- if (!omero) {
23
- console.error('Path for image not valid');
21
+ const { omero, multiscales, channels_metadata: spatialDataChannels } = metadata;
22
+ // Crude way to check if this is a SpatialData OME-NGFF.
23
+ const isSpatialData = !!spatialDataChannels;
24
+ if (!isSpatialData && !omero) {
25
+ console.error('image.ome-zarr must have omero metadata in attributes.');
24
26
  return Promise.reject(payload);
25
27
  }
26
28
  if (!Array.isArray(multiscales) || multiscales.length === 0) {
27
29
  console.error('Multiscales array must exist and have at least one element');
28
30
  }
29
- const { coordinateTransformations } = multiscales[0];
31
+ const { datasets, coordinateTransformations: coordinateTransformationsFromFile, name: imageName, } = multiscales[0];
30
32
  // Axes in v0.4 format.
31
33
  const axes = getNgffAxes(multiscales[0].axes);
34
+ // SpatialData uses the new coordinateTransformations spec.
35
+ // Reference: https://github.com/ome/ngff/pull/138
36
+ // This new spec is very flexible, so here we will attepmpt to convert it back to the old spec.
37
+ const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
32
38
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, axes);
33
- const transformMatrixFromFile = coordinateTransformationsToMatrix(coordinateTransformations, axes);
39
+ const transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, axes);
34
40
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
35
- const { rdefs, channels, name: omeroName } = omero;
36
- const t = rdefs.defaultT ?? 0;
37
- const z = rdefs.defaultZ ?? 0;
38
41
  const filterSelection = (sel) => {
39
42
  // Remove selection keys for which there is no dimension.
40
43
  if (data.length > 0) {
@@ -50,14 +53,45 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
50
53
  }
51
54
  return sel;
52
55
  };
56
+ let channelObjects;
57
+ let channelLabels = [];
58
+ let initialTargetT = 0;
59
+ let initialTargetZ = 0;
60
+ if (isSpatialData) {
61
+ // TODO: Consider removing support for `channels_metadata` once OME-NGFF loosens
62
+ // requirements for channel metadata fields such as `window` and `color`.
63
+ // (Unclear if we will need to keep this around for backwards compatibility with
64
+ // those SpatialData objects generated in the meantime though.)
65
+ // References:
66
+ // - https://github.com/ome/ngff/issues/192
67
+ // - https://github.com/ome/ome-zarr-py/pull/261
68
+ const { channels } = spatialDataChannels;
69
+ channelObjects = channels.map((channel, i) => ({
70
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i }),
71
+ slider: [0, 255],
72
+ color: [255, 255, 255],
73
+ }));
74
+ channelLabels = channels.map(c => c.label);
75
+ }
76
+ else {
77
+ const { rdefs, channels } = omero;
78
+ if (typeof rdefs.defaultT === 'number') {
79
+ initialTargetT = rdefs.defaultT;
80
+ }
81
+ if (typeof rdefs.defaultZ === 'number') {
82
+ initialTargetZ = rdefs.defaultZ;
83
+ }
84
+ channelObjects = channels.map((channel, i) => ({
85
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i }),
86
+ slider: [channel.window.start, channel.window.end],
87
+ color: hexToRgb(channel.color),
88
+ }));
89
+ channelLabels = channels.map(c => c.label);
90
+ }
53
91
  const imagesWithLoaderCreators = [
54
92
  {
55
- name: omeroName || 'Image',
56
- channels: channels.map((channel, i) => ({
57
- selection: filterSelection({ z, t, c: i }),
58
- slider: [channel.window.start, channel.window.end],
59
- color: hexToRgb(channel.color),
60
- })),
93
+ name: imageName || 'Image',
94
+ channels: channelObjects,
61
95
  ...(transformMatrix ? {
62
96
  metadata: {
63
97
  transform: {
@@ -65,7 +99,7 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
65
99
  },
66
100
  },
67
101
  } : {}),
68
- loaderCreator: async () => ({ ...loader, channels: channels.map(c => c.label) }),
102
+ loaderCreator: async () => ({ ...loader, channels: channelLabels }),
69
103
  },
70
104
  ];
71
105
  // TODO: use options for initial selection of channels
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/zarr",
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,12 +19,12 @@
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarr": "0.5.1",
22
- "@vitessce/constants-internal": "3.1.1",
23
- "@vitessce/gl": "3.1.1",
24
- "@vitessce/sets-utils": "3.1.1",
25
- "@vitessce/spatial-utils": "3.1.1",
26
- "@vitessce/utils": "3.1.1",
27
- "@vitessce/vit-s": "3.1.1"
22
+ "@vitessce/constants-internal": "3.1.3",
23
+ "@vitessce/gl": "3.1.3",
24
+ "@vitessce/sets-utils": "3.1.3",
25
+ "@vitessce/spatial-utils": "3.1.3",
26
+ "@vitessce/utils": "3.1.3",
27
+ "@vitessce/vit-s": "3.1.3"
28
28
  },
29
29
  "scripts": {
30
30
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
@@ -3,6 +3,7 @@ import {
3
3
  initializeRasterLayersAndChannels,
4
4
  coordinateTransformationsToMatrix,
5
5
  getNgffAxes,
6
+ normalizeCoordinateTransformations,
6
7
  } from '@vitessce/spatial-utils';
7
8
  import {
8
9
  AbstractLoaderError,
@@ -31,34 +32,46 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
31
32
  const loader = await viv.loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: 'multiscales' });
32
33
  const { metadata, data } = loader;
33
34
 
34
- const { omero, multiscales } = metadata;
35
+ const { omero, multiscales, channels_metadata: spatialDataChannels } = metadata;
35
36
 
36
- if (!omero) {
37
- console.error('Path for image not valid');
37
+ // Crude way to check if this is a SpatialData OME-NGFF.
38
+ const isSpatialData = !!spatialDataChannels;
39
+
40
+ if (!isSpatialData && !omero) {
41
+ console.error('image.ome-zarr must have omero metadata in attributes.');
38
42
  return Promise.reject(payload);
39
43
  }
40
44
 
41
45
  if (!Array.isArray(multiscales) || multiscales.length === 0) {
42
46
  console.error('Multiscales array must exist and have at least one element');
43
47
  }
44
- const { coordinateTransformations } = multiscales[0];
48
+
49
+ const {
50
+ datasets,
51
+ coordinateTransformations: coordinateTransformationsFromFile,
52
+ name: imageName,
53
+ } = multiscales[0];
45
54
 
46
55
  // Axes in v0.4 format.
47
56
  const axes = getNgffAxes(multiscales[0].axes);
48
57
 
58
+ // SpatialData uses the new coordinateTransformations spec.
59
+ // Reference: https://github.com/ome/ngff/pull/138
60
+
61
+ // This new spec is very flexible, so here we will attepmpt to convert it back to the old spec.
62
+ const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
63
+ coordinateTransformationsFromFile, datasets,
64
+ );
65
+
49
66
  const transformMatrixFromOptions = coordinateTransformationsToMatrix(
50
67
  coordinateTransformationsFromOptions, axes,
51
68
  );
52
69
  const transformMatrixFromFile = coordinateTransformationsToMatrix(
53
- coordinateTransformations, axes,
70
+ normCoordinateTransformationsFromFile, axes,
54
71
  );
55
72
 
56
73
  const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
57
74
 
58
- const { rdefs, channels, name: omeroName } = omero;
59
-
60
- const t = rdefs.defaultT ?? 0;
61
- const z = rdefs.defaultZ ?? 0;
62
75
 
63
76
  const filterSelection = (sel) => {
64
77
  // Remove selection keys for which there is no dimension.
@@ -76,14 +89,45 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
76
89
  return sel;
77
90
  };
78
91
 
92
+ let channelObjects;
93
+ let channelLabels = [];
94
+ let initialTargetT = 0;
95
+ let initialTargetZ = 0;
96
+ if (isSpatialData) {
97
+ // TODO: Consider removing support for `channels_metadata` once OME-NGFF loosens
98
+ // requirements for channel metadata fields such as `window` and `color`.
99
+ // (Unclear if we will need to keep this around for backwards compatibility with
100
+ // those SpatialData objects generated in the meantime though.)
101
+ // References:
102
+ // - https://github.com/ome/ngff/issues/192
103
+ // - https://github.com/ome/ome-zarr-py/pull/261
104
+ const { channels } = spatialDataChannels;
105
+ channelObjects = channels.map((channel, i) => ({
106
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i }),
107
+ slider: [0, 255],
108
+ color: [255, 255, 255],
109
+ }));
110
+ channelLabels = channels.map(c => c.label);
111
+ } else {
112
+ const { rdefs, channels } = omero;
113
+ if (typeof rdefs.defaultT === 'number') {
114
+ initialTargetT = rdefs.defaultT;
115
+ }
116
+ if (typeof rdefs.defaultZ === 'number') {
117
+ initialTargetZ = rdefs.defaultZ;
118
+ }
119
+ channelObjects = channels.map((channel, i) => ({
120
+ selection: filterSelection({ z: initialTargetZ, t: initialTargetT, c: i }),
121
+ slider: [channel.window.start, channel.window.end],
122
+ color: hexToRgb(channel.color),
123
+ }));
124
+ channelLabels = channels.map(c => c.label);
125
+ }
126
+
79
127
  const imagesWithLoaderCreators = [
80
128
  {
81
- name: omeroName || 'Image',
82
- channels: channels.map((channel, i) => ({
83
- selection: filterSelection({ z, t, c: i }),
84
- slider: [channel.window.start, channel.window.end],
85
- color: hexToRgb(channel.color),
86
- })),
129
+ name: imageName || 'Image',
130
+ channels: channelObjects,
87
131
  ...(transformMatrix ? {
88
132
  metadata: {
89
133
  transform: {
@@ -91,7 +135,7 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
91
135
  },
92
136
  },
93
137
  } : {}),
94
- loaderCreator: async () => ({ ...loader, channels: channels.map(c => c.label) }),
138
+ loaderCreator: async () => ({ ...loader, channels: channelLabels }),
95
139
  },
96
140
  ];
97
141