@vitessce/image-utils 3.2.2 → 3.3.1

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-4ea1f112.js";
2
+ import { B as BaseDecoder } from "./index-0d0c0adf.js";
3
3
  import "react";
4
4
  class DeflateDecoder extends BaseDecoder {
5
5
  decodeBlock(buffer) {
@@ -28436,6 +28436,7 @@ const DataType$2 = {
28436
28436
  const FileType$1 = {
28437
28437
  // Joint file types
28438
28438
  ANNDATA_ZARR: "anndata.zarr",
28439
+ SPATIALDATA_ZARR: "spatialdata.zarr",
28439
28440
  // Atomic file types
28440
28441
  OBS_EMBEDDING_CSV: "obsEmbedding.csv",
28441
28442
  OBS_SPOTS_CSV: "obsSpots.csv",
@@ -28458,6 +28459,16 @@ const FileType$1 = {
28458
28459
  OBS_SEGMENTATIONS_ANNDATA_ZARR: "obsSegmentations.anndata.zarr",
28459
28460
  OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
28460
28461
  FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
28462
+ // SpatialData
28463
+ IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
28464
+ LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
28465
+ SHAPES_SPATIALDATA_ZARR: "shapes.spatialdata.zarr",
28466
+ OBS_FEATURE_MATRIX_SPATIALDATA_ZARR: "obsFeatureMatrix.spatialdata.zarr",
28467
+ OBS_SETS_SPATIALDATA_ZARR: "obsSets.spatialdata.zarr",
28468
+ OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
28469
+ // TODO:
28470
+ // OBS_POINTS_SPATIALDATA_ZARR: 'obsPoints.spatialdata.zarr',
28471
+ // OBS_LOCATIONS_SPATIALDATA_ZARR: 'obsLocations.spatialdata.zarr',
28461
28472
  // MuData
28462
28473
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
28463
28474
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -28894,9 +28905,30 @@ z.object({
28894
28905
  offsetsUrl: z.string().optional(),
28895
28906
  coordinateTransformations: omeCoordinateTransformations.optional()
28896
28907
  });
28897
- z.object({
28908
+ const imageOmeZarrSchema = z.object({
28898
28909
  coordinateTransformations: omeCoordinateTransformations.optional()
28899
28910
  });
28911
+ imageOmeZarrSchema.extend({
28912
+ path: z.string()
28913
+ });
28914
+ z.object({
28915
+ path: z.string()
28916
+ });
28917
+ z.object({
28918
+ path: z.string()
28919
+ });
28920
+ z.object({
28921
+ path: z.string(),
28922
+ tablePath: z.string().optional().describe("The path to a table which annotates the spots. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected.")
28923
+ });
28924
+ annDataObsFeatureMatrix.extend({
28925
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional()
28926
+ });
28927
+ z.object({
28928
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional(),
28929
+ tablePath: z.string().optional().describe("The path to a table which contains the index for the set values."),
28930
+ obsSets: annDataObsSets
28931
+ });
28900
28932
  z.object({
28901
28933
  obsIndex: z.string(),
28902
28934
  obsEmbedding: z.array(z.string()).length(2)
@@ -35454,9 +35486,9 @@ const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [2
35454
35486
  function rgbSpline(spline) {
35455
35487
  return (colors) => {
35456
35488
  const n3 = colors.length;
35457
- let r2 = new Array(n3);
35458
- let g2 = new Array(n3);
35459
- let b = new Array(n3);
35489
+ const r2 = new Array(n3);
35490
+ const g2 = new Array(n3);
35491
+ const b = new Array(n3);
35460
35492
  let i2;
35461
35493
  let color;
35462
35494
  for (i2 = 0; i2 < n3; ++i2) {
@@ -35465,10 +35497,10 @@ function rgbSpline(spline) {
35465
35497
  g2[i2] = color[1] || 0;
35466
35498
  b[i2] = color[2] || 0;
35467
35499
  }
35468
- r2 = spline(r2);
35469
- g2 = spline(g2);
35470
- b = spline(b);
35471
- return (t2) => [r2(t2), g2(t2), b(t2)];
35500
+ const rFunc = spline(r2);
35501
+ const gFunc = spline(g2);
35502
+ const bFunc = spline(b);
35503
+ return (t2) => [rFunc(t2), gFunc(t2), bFunc(t2)];
35472
35504
  };
35473
35505
  }
35474
35506
  function basis(values) {
@@ -38427,7 +38459,7 @@ const jsonLoader = {
38427
38459
  testText: isJSON,
38428
38460
  parseTextSync: JSON.parse
38429
38461
  };
38430
- const version = "8.8.20";
38462
+ const version = "8.8.27";
38431
38463
  const existingVersion = globalThis.deck && globalThis.deck.VERSION;
38432
38464
  if (existingVersion && existingVersion !== version) {
38433
38465
  throw new Error("deck.gl - multiple versions detected: ".concat(existingVersion, " vs ").concat(version));
@@ -39626,9 +39658,8 @@ function cssToDeviceRatio(gl) {
39626
39658
  luma
39627
39659
  } = gl;
39628
39660
  if (gl.canvas && luma) {
39629
- const {
39630
- clientWidth
39631
- } = luma.canvasSizeInfo;
39661
+ const cachedSize = luma.canvasSizeInfo;
39662
+ const clientWidth = "clientWidth" in cachedSize ? cachedSize.clientWidth : gl.canvas.clientWidth;
39632
39663
  return clientWidth ? gl.drawingBufferWidth / clientWidth : 1;
39633
39664
  }
39634
39665
  return 1;
@@ -39884,7 +39915,7 @@ function setDevicePixelRatio(gl, devicePixelRatio, options) {
39884
39915
  });
39885
39916
  }
39886
39917
  }
39887
- const VERSION$7 = "8.5.16";
39918
+ const VERSION$7 = "8.5.21";
39888
39919
  const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
39889
39920
  class StatsManager {
39890
39921
  constructor() {
@@ -40005,7 +40036,6 @@ let Resource$1 = class Resource {
40005
40036
  this._handle = this._createHandle();
40006
40037
  }
40007
40038
  this.byteLength = 0;
40008
- this._initStats();
40009
40039
  this._addStats();
40010
40040
  }
40011
40041
  toString() {
@@ -40141,9 +40171,6 @@ let Resource$1 = class Resource {
40141
40171
  this.gl.luma = this.gl.luma || {};
40142
40172
  return this.gl.luma;
40143
40173
  }
40144
- _initStats() {
40145
- this.gl.stats = this.gl.stats || new StatsManager();
40146
- }
40147
40174
  _addStats() {
40148
40175
  const name2 = this[Symbol.toStringTag];
40149
40176
  const stats = lumaStats.get("Resource Counts");
@@ -40158,27 +40185,29 @@ let Resource$1 = class Resource {
40158
40185
  }
40159
40186
  _trackAllocatedMemory(bytes) {
40160
40187
  let name2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this[Symbol.toStringTag];
40161
- this._doTrackAllocatedMemory(bytes, name2);
40162
- this._doTrackAllocatedMemory(bytes, name2, this.gl.stats.get("Memory Usage"));
40188
+ this._trackAllocatedMemoryForContext(bytes, name2);
40189
+ this._trackAllocatedMemoryForContext(bytes, name2, this.gl.canvas && this.gl.canvas.id);
40190
+ this.byteLength = bytes;
40163
40191
  }
40164
- _doTrackAllocatedMemory(bytes) {
40192
+ _trackAllocatedMemoryForContext(bytes) {
40165
40193
  let name2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this[Symbol.toStringTag];
40166
- let stats = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : lumaStats.get("Memory Usage");
40194
+ let id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
40195
+ const stats = lumaStats.get("Memory Usage".concat(id));
40167
40196
  stats.get("GPU Memory").addCount(bytes);
40168
40197
  stats.get("".concat(name2, " Memory")).addCount(bytes);
40169
- this.byteLength = bytes;
40170
40198
  }
40171
40199
  _trackDeallocatedMemory() {
40172
40200
  let name2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this[Symbol.toStringTag];
40173
- this._doTrackDeallocatedMemory(name2);
40174
- this._doTrackDeallocatedMemory(name2, this.gl.stats.get("Memory Usage"));
40201
+ this._trackDeallocatedMemoryForContext(name2);
40202
+ this._trackDeallocatedMemoryForContext(name2, this.gl.canvas && this.gl.canvas.id);
40203
+ this.byteLength = 0;
40175
40204
  }
40176
- _doTrackDeallocatedMemory() {
40205
+ _trackDeallocatedMemoryForContext() {
40177
40206
  let name2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this[Symbol.toStringTag];
40178
- let stats = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : lumaStats.get("Memory Usage");
40207
+ let id = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
40208
+ const stats = lumaStats.get("Memory Usage".concat(id));
40179
40209
  stats.get("GPU Memory").subtractCount(this.byteLength);
40180
40210
  stats.get("".concat(name2, " Memory")).subtractCount(this.byteLength);
40181
- this.byteLength = 0;
40182
40211
  }
40183
40212
  };
40184
40213
  const ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
@@ -49793,6 +49822,7 @@ const picking = {
49793
49822
  inject: {
49794
49823
  "vs:DECKGL_FILTER_GL_POSITION": "\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ",
49795
49824
  "vs:DECKGL_FILTER_COLOR": "\n picking_setPickingColor(geometry.pickingColor);\n ",
49825
+ "fs:#decl": "\nuniform bool picking_uAttribute;\n ",
49796
49826
  "fs:DECKGL_FILTER_COLOR": {
49797
49827
  order: 99,
49798
49828
  injection: "\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "
@@ -50603,6 +50633,9 @@ class Viewport {
50603
50633
  this.projectFlat = this.projectFlat.bind(this);
50604
50634
  this.unprojectFlat = this.unprojectFlat.bind(this);
50605
50635
  }
50636
+ get subViewports() {
50637
+ return null;
50638
+ }
50606
50639
  get metersPerPixel() {
50607
50640
  return this.distanceScales.metersPerUnit[2] / this.scale;
50608
50641
  }
@@ -59494,7 +59527,7 @@ class Attribute extends DataColumn {
59494
59527
  const {
59495
59528
  startIndices
59496
59529
  } = this;
59497
- const vertexIndex = startIndices ? startIndices[row] : row;
59530
+ const vertexIndex = startIndices ? row < startIndices.length ? startIndices[row] : this.numInstances : row;
59498
59531
  return vertexIndex * this.size;
59499
59532
  }
59500
59533
  getShaderAttributes() {
@@ -62138,7 +62171,7 @@ class Layer extends Component {
62138
62171
  if (Array.isArray(highlightColor)) {
62139
62172
  parameters.pickingHighlightColor = highlightColor;
62140
62173
  }
62141
- if (Number.isInteger(highlightedObjectIndex)) {
62174
+ if (forceUpdate || highlightedObjectIndex !== oldProps.highlightedObjectIndex) {
62142
62175
  parameters.pickingSelectedColor = Number.isFinite(highlightedObjectIndex) && highlightedObjectIndex >= 0 ? this.encodePickingColor(highlightedObjectIndex) : null;
62143
62176
  }
62144
62177
  this.setModuleParameters(parameters);
@@ -63501,7 +63534,7 @@ function interpolateQuad(quad, ut, vt) {
63501
63534
  }
63502
63535
  const vs$g = "\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nattribute vec2 texCoords;\nattribute vec3 positions;\nattribute vec3 positions64Low;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float coordinateConversion;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project_uCommonOrigin.xy;\n } else if (coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n";
63503
63536
  const packUVsIntoRGB = "\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n";
63504
- const fs$i = "\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float desaturate;\nuniform vec4 transparentColor;\nuniform vec3 tintColor;\nuniform float opacity;\n\nuniform float coordinateConversion;\nuniform vec4 bounds;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n return mix(transparentColor, vec4(color, 1.0), alpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bounds[0]) / (bounds[2] - bounds[0]),\n (pos.y - bounds[3]) / (bounds[1] - bounds[3])\n );\n}\n\n".concat(packUVsIntoRGB, "\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture2D(bitmapTexture, uv);\n\n gl_FragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n\n if (picking_uActive) {\n // Since instance information is not used, we can use picking color for pixel index\n gl_FragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n");
63537
+ const fs$i = "\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float desaturate;\nuniform vec4 transparentColor;\nuniform vec3 tintColor;\nuniform float opacity;\n\nuniform float coordinateConversion;\nuniform vec4 bounds;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n return mix(transparentColor, vec4(color, 1.0), alpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bounds[0]) / (bounds[2] - bounds[0]),\n (pos.y - bounds[3]) / (bounds[1] - bounds[3])\n );\n}\n\n".concat(packUVsIntoRGB, "\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture2D(bitmapTexture, uv);\n\n gl_FragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n\n if (picking_uActive && !picking_uAttribute) {\n // Since instance information is not used, we can use picking color for pixel index\n gl_FragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n");
63505
63538
  const defaultProps$I = {
63506
63539
  image: {
63507
63540
  type: "image",
@@ -71641,18 +71674,22 @@ function getBoundingBox(viewport, zRange, extent2) {
71641
71674
  }
71642
71675
  function getCullBounds({
71643
71676
  viewport,
71644
- z: z2,
71677
+ z: z2 = 0,
71645
71678
  cullRect
71646
71679
  }) {
71647
- const x2 = cullRect.x - viewport.x;
71648
- const y2 = cullRect.y - viewport.y;
71649
- const {
71650
- width,
71651
- height
71652
- } = cullRect;
71680
+ const subViewports = viewport.subViewports || [viewport];
71681
+ return subViewports.map((v) => getCullBoundsInViewport(v, z2, cullRect));
71682
+ }
71683
+ function getCullBoundsInViewport(viewport, z2, cullRect) {
71653
71684
  if (!Array.isArray(z2)) {
71685
+ const x2 = cullRect.x - viewport.x;
71686
+ const y2 = cullRect.y - viewport.y;
71687
+ const {
71688
+ width,
71689
+ height
71690
+ } = cullRect;
71654
71691
  const unprojectOption = {
71655
- targetZ: z2 || 0
71692
+ targetZ: z2
71656
71693
  };
71657
71694
  const topLeft = viewport.unproject([x2, y2], unprojectOption);
71658
71695
  const topRight = viewport.unproject([x2 + width, y2], unprojectOption);
@@ -71660,16 +71697,8 @@ function getCullBounds({
71660
71697
  const bottomRight = viewport.unproject([x2 + width, y2 + height], unprojectOption);
71661
71698
  return [Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]), Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]), Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]), Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1])];
71662
71699
  }
71663
- const bounds0 = getCullBounds({
71664
- viewport,
71665
- z: z2[0],
71666
- cullRect
71667
- });
71668
- const bounds1 = getCullBounds({
71669
- viewport,
71670
- z: z2[1],
71671
- cullRect
71672
- });
71700
+ const bounds0 = getCullBoundsInViewport(viewport, z2[0], cullRect);
71701
+ const bounds1 = getCullBoundsInViewport(viewport, z2[1], cullRect);
71673
71702
  return [Math.min(bounds0[0], bounds1[0]), Math.min(bounds0[1], bounds1[1]), Math.max(bounds0[2], bounds1[2]), Math.max(bounds0[3], bounds1[3])];
71674
71703
  }
71675
71704
  function getIndexingCoords(bbox2, scale2, modelMatrixInverse) {
@@ -71899,7 +71928,7 @@ class Tileset2D {
71899
71928
  return false;
71900
71929
  }
71901
71930
  if (cullRect && this._viewport) {
71902
- const [minX, minY, maxX, maxY] = getCullBounds({
71931
+ const boundsArr = this._getCullBounds({
71903
71932
  viewport: this._viewport,
71904
71933
  z: this._zRange,
71905
71934
  cullRect
@@ -71907,12 +71936,20 @@ class Tileset2D {
71907
71936
  const {
71908
71937
  bbox: bbox2
71909
71938
  } = tile;
71910
- if ("west" in bbox2) {
71911
- return bbox2.west < maxX && bbox2.east > minX && bbox2.south < maxY && bbox2.north > minY;
71939
+ for (const [minX, minY, maxX, maxY] of boundsArr) {
71940
+ let overlaps;
71941
+ if ("west" in bbox2) {
71942
+ overlaps = bbox2.west < maxX && bbox2.east > minX && bbox2.south < maxY && bbox2.north > minY;
71943
+ } else {
71944
+ const y02 = Math.min(bbox2.top, bbox2.bottom);
71945
+ const y12 = Math.max(bbox2.top, bbox2.bottom);
71946
+ overlaps = bbox2.left < maxX && bbox2.right > minX && y02 < maxY && y12 > minY;
71947
+ }
71948
+ if (overlaps) {
71949
+ return true;
71950
+ }
71912
71951
  }
71913
- const y02 = Math.min(bbox2.top, bbox2.bottom);
71914
- const y12 = Math.max(bbox2.top, bbox2.bottom);
71915
- return bbox2.left < maxX && bbox2.right > minX && y02 < maxY && y12 > minY;
71952
+ return false;
71916
71953
  }
71917
71954
  return true;
71918
71955
  }
@@ -72361,14 +72398,19 @@ class TileLayer extends CompositeLayer {
72361
72398
  info,
72362
72399
  sourceLayer
72363
72400
  }) {
72401
+ const sourceTile = sourceLayer.props.tile;
72364
72402
  if (info.picked) {
72365
- info.tile = sourceLayer.props.tile;
72403
+ info.tile = sourceTile;
72366
72404
  }
72405
+ info.sourceTile = sourceTile;
72367
72406
  return info;
72368
72407
  }
72369
72408
  _updateAutoHighlight(info) {
72370
- if (info.sourceLayer) {
72371
- info.sourceLayer.updateAutoHighlight(info);
72409
+ const sourceTile = info.sourceTile;
72410
+ if (sourceTile && sourceTile.layers) {
72411
+ for (const layer of sourceTile.layers) {
72412
+ layer.updateAutoHighlight(info);
72413
+ }
72372
72414
  }
72373
72415
  }
72374
72416
  renderLayers() {
@@ -84686,6 +84728,9 @@ class ScenegraphNode {
84686
84728
  toString() {
84687
84729
  return "{type: ScenegraphNode, id: ".concat(this.id, ")}");
84688
84730
  }
84731
+ getBounds() {
84732
+ return null;
84733
+ }
84689
84734
  setPosition(position) {
84690
84735
  assert$7(position.length === 3, "setPosition requires vector argument");
84691
84736
  this.position = position;
@@ -84836,6 +84881,34 @@ class GroupNode extends ScenegraphNode {
84836
84881
  this.removeAll();
84837
84882
  super.delete();
84838
84883
  }
84884
+ getBounds() {
84885
+ const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
84886
+ this.traverse((node2, _ref) => {
84887
+ let {
84888
+ worldMatrix
84889
+ } = _ref;
84890
+ const bounds2 = node2.getBounds();
84891
+ if (!bounds2) {
84892
+ return;
84893
+ }
84894
+ const [min2, max2] = bounds2;
84895
+ const center2 = new Vector3(min2).add(max2).divide([2, 2, 2]);
84896
+ worldMatrix.transformAsPoint(center2, center2);
84897
+ const halfSize = new Vector3(max2).subtract(min2).divide([2, 2, 2]);
84898
+ worldMatrix.transformAsVector(halfSize, halfSize);
84899
+ for (let v = 0; v < 8; v++) {
84900
+ const position = new Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center2);
84901
+ for (let i2 = 0; i2 < 3; i2++) {
84902
+ result[0][i2] = Math.min(result[0][i2], position[i2]);
84903
+ result[1][i2] = Math.max(result[1][i2], position[i2]);
84904
+ }
84905
+ }
84906
+ });
84907
+ if (!Number.isFinite(result[0][0])) {
84908
+ return null;
84909
+ }
84910
+ return result;
84911
+ }
84839
84912
  traverse(visitor) {
84840
84913
  let {
84841
84914
  worldMatrix = new Matrix4()
@@ -85085,6 +85158,7 @@ class ModelNode extends ScenegraphNode {
85085
85158
  } else {
85086
85159
  this.model = new Model(gl, props2);
85087
85160
  }
85161
+ this.bounds = null;
85088
85162
  this.managedResources = props2.managedResources || [];
85089
85163
  }
85090
85164
  setProps(props2) {
@@ -85092,6 +85166,9 @@ class ModelNode extends ScenegraphNode {
85092
85166
  this._setModelNodeProps(props2);
85093
85167
  return this;
85094
85168
  }
85169
+ getBounds() {
85170
+ return this.bounds;
85171
+ }
85095
85172
  delete() {
85096
85173
  if (this.model) {
85097
85174
  this.model.delete();
@@ -85276,17 +85353,21 @@ function createGLTFModel(gl, options) {
85276
85353
  const managedResources = [];
85277
85354
  managedResources.push(...materialParser.generatedTextures);
85278
85355
  managedResources.push(...Object.values(attributes).map((attribute) => attribute.buffer));
85279
- const model = new ModelNode(gl, Object.assign({
85356
+ const model = new ModelNode(gl, {
85280
85357
  id,
85281
85358
  drawMode,
85282
85359
  vertexCount,
85283
85360
  modules: [pbr],
85284
- defines: materialParser.defines,
85285
85361
  parameters: materialParser.parameters,
85286
85362
  vs: addVersionToShader(gl, vs$7),
85287
85363
  fs: addVersionToShader(gl, fs$7),
85288
- managedResources
85289
- }, modelOptions));
85364
+ managedResources,
85365
+ ...modelOptions,
85366
+ defines: {
85367
+ ...materialParser.defines,
85368
+ ...modelOptions.defines
85369
+ }
85370
+ });
85290
85371
  model.setProps({
85291
85372
  attributes
85292
85373
  });
@@ -85381,13 +85462,15 @@ class GLTFInstantiator {
85381
85462
  log$2.warn("getVertexCount() not found")();
85382
85463
  }
85383
85464
  createPrimitive(gltfPrimitive, i2, gltfMesh) {
85384
- return createGLTFModel(this.gl, Object.assign({
85465
+ const model = createGLTFModel(this.gl, Object.assign({
85385
85466
  id: gltfPrimitive.name || "".concat(gltfMesh.name || gltfMesh.id, "-primitive-").concat(i2),
85386
85467
  drawMode: gltfPrimitive.mode || 4,
85387
85468
  vertexCount: gltfPrimitive.indices ? gltfPrimitive.indices.count : this.getVertexCount(gltfPrimitive.attributes),
85388
85469
  attributes: this.createAttributes(gltfPrimitive.attributes, gltfPrimitive.indices),
85389
85470
  material: gltfPrimitive.material
85390
85471
  }, this.options));
85472
+ model.bounds = [gltfPrimitive.attributes.POSITION.min, gltfPrimitive.attributes.POSITION.max];
85473
+ return model;
85391
85474
  }
85392
85475
  createAttributes(attributes, indices) {
85393
85476
  const loadedAttributes = {};
@@ -93315,15 +93398,11 @@ class Tile3DLayer extends CompositeLayer {
93315
93398
  info,
93316
93399
  sourceLayer
93317
93400
  }) {
93318
- const {
93319
- layerMap
93320
- } = this.state;
93321
- const layerId = sourceLayer && sourceLayer.id;
93322
- if (layerId) {
93323
- const substr = layerId.substring(this.id.length + 1);
93324
- const tileId = substr.substring(substr.indexOf("-") + 1);
93325
- info.object = layerMap[tileId] && layerMap[tileId].tile;
93401
+ const sourceTile = sourceLayer && sourceLayer.props.tile;
93402
+ if (info.picked) {
93403
+ info.object = sourceTile;
93326
93404
  }
93405
+ info.sourceTile = sourceTile;
93327
93406
  return info;
93328
93407
  }
93329
93408
  filterSubLayer({
@@ -93339,8 +93418,10 @@ class Tile3DLayer extends CompositeLayer {
93339
93418
  return tile.selected && tile.viewportIds.includes(viewportId);
93340
93419
  }
93341
93420
  _updateAutoHighlight(info) {
93342
- if (info.sourceLayer) {
93343
- info.sourceLayer.updateAutoHighlight(info);
93421
+ const sourceTile = info.sourceTile;
93422
+ const layerCache = this.state.layerMap[sourceTile === null || sourceTile === void 0 ? void 0 : sourceTile.id];
93423
+ if (layerCache && layerCache.layer) {
93424
+ layerCache.layer.updateAutoHighlight(info);
93344
93425
  }
93345
93426
  }
93346
93427
  async _loadTileset(tilesetUrl) {
@@ -133362,16 +133443,16 @@ function addDecoder(cases, importFn) {
133362
133443
  }
133363
133444
  cases.forEach((c) => registry$1.set(c, importFn));
133364
133445
  }
133365
- addDecoder([void 0, 1], () => import("./raw-313ce7d6.js").then((m) => m.default));
133366
- addDecoder(5, () => import("./lzw-1a9b457b.js").then((m) => m.default));
133446
+ addDecoder([void 0, 1], () => import("./raw-0bd252aa.js").then((m) => m.default));
133447
+ addDecoder(5, () => import("./lzw-ff35f80d.js").then((m) => m.default));
133367
133448
  addDecoder(6, () => {
133368
133449
  throw new Error("old style JPEG compression is not supported.");
133369
133450
  });
133370
- addDecoder(7, () => import("./jpeg-f9fe8321.js").then((m) => m.default));
133371
- addDecoder([8, 32946], () => import("./deflate-7e090157.js").then((m) => m.default));
133372
- addDecoder(32773, () => import("./packbits-2f01a6d2.js").then((m) => m.default));
133373
- addDecoder(34887, () => import("./lerc-666d031c.js").then((m) => m.default));
133374
- addDecoder(50001, () => import("./webimage-830864f6.js").then((m) => m.default));
133451
+ addDecoder(7, () => import("./jpeg-740477bd.js").then((m) => m.default));
133452
+ addDecoder([8, 32946], () => import("./deflate-e92fb9a9.js").then((m) => m.default));
133453
+ addDecoder(32773, () => import("./packbits-2148c0a8.js").then((m) => m.default));
133454
+ addDecoder(34887, () => import("./lerc-bed4a26d.js").then((m) => m.default));
133455
+ addDecoder(50001, () => import("./webimage-78bc948c.js").then((m) => m.default));
133375
133456
  function decodeRowAcc(row, stride) {
133376
133457
  let length2 = row.length - stride;
133377
133458
  let offset = 0;
@@ -145075,6 +145156,15 @@ class ImageWrapper {
145075
145156
  } = this.vivLoader.metadata;
145076
145157
  return channels2.length;
145077
145158
  }
145159
+ if ("channels_metadata" in this.vivLoader.metadata) {
145160
+ const {
145161
+ channels_metadata: channelsMetadata
145162
+ } = this.vivLoader.metadata;
145163
+ return (channelsMetadata == null ? void 0 : channelsMetadata.channels.length) || 0;
145164
+ }
145165
+ if ("image-label" in this.vivLoader.metadata) {
145166
+ return 1;
145167
+ }
145078
145168
  return 0;
145079
145169
  }
145080
145170
  getChannelNames() {
@@ -145094,6 +145184,14 @@ class ImageWrapper {
145094
145184
  } = this.vivLoader.metadata;
145095
145185
  return channels2.map((channel, i2) => channel.label || `Channel ${i2}`);
145096
145186
  }
145187
+ if ("channels_metadata" in this.vivLoader.metadata) {
145188
+ const {
145189
+ channels_metadata: channelsMetadata
145190
+ } = this.vivLoader.metadata;
145191
+ if (channelsMetadata && Array.isArray(channelsMetadata == null ? void 0 : channelsMetadata.channels)) {
145192
+ return channelsMetadata.channels.map((channel) => `Channel ${channel.label}`);
145193
+ }
145194
+ }
145097
145195
  return [];
145098
145196
  }
145099
145197
  getChannelObjects() {
@@ -145124,6 +145222,19 @@ class ImageWrapper {
145124
145222
  autoDefaultColor: VIEWER_PALETTE[i2 % VIEWER_PALETTE.length]
145125
145223
  }));
145126
145224
  }
145225
+ if ("channels_metadata" in this.vivLoader.metadata) {
145226
+ const {
145227
+ channels_metadata: channelsMetadata
145228
+ } = this.vivLoader.metadata;
145229
+ if (channelsMetadata && Array.isArray(channelsMetadata == null ? void 0 : channelsMetadata.channels)) {
145230
+ return channelsMetadata.channels.map((channel, i2) => ({
145231
+ name: `Channel ${channel.label}`,
145232
+ defaultColor: void 0,
145233
+ defaultWindow: void 0,
145234
+ autoDefaultColor: VIEWER_PALETTE[i2 % VIEWER_PALETTE.length]
145235
+ }));
145236
+ }
145237
+ }
145127
145238
  return [];
145128
145239
  }
145129
145240
  getDtype() {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { I } from "./index-4ea1f112.js";
1
+ import { I } from "./index-0d0c0adf.js";
2
2
  import "react";
3
3
  export {
4
4
  I as ImageWrapper
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-4ea1f112.js";
1
+ import { B as BaseDecoder } from "./index-0d0c0adf.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-4ea1f112.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-0d0c0adf.js";
3
3
  import "react";
4
4
  const LercParameters = {
5
5
  Version: 0,
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-4ea1f112.js";
1
+ import { B as BaseDecoder } from "./index-0d0c0adf.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-4ea1f112.js";
1
+ import { B as BaseDecoder } from "./index-0d0c0adf.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-4ea1f112.js";
1
+ import { B as BaseDecoder } from "./index-0d0c0adf.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-4ea1f112.js";
1
+ import { B as BaseDecoder } from "./index-0d0c0adf.js";
2
2
  import "react";
3
3
  class WebImageDecoder extends BaseDecoder {
4
4
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../src/ImageWrapper.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,aAAK,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,sBAAsB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAC/F,aAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,aAAK,YAAY,GAAG;IAClB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IAGb,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAKjC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB;QAAC,MAAM;QAAE,MAAM;KAAC;IAChB;QAAC,MAAM;QAAE,MAAM;KAAC;IAChB;QAAC,MAAM;QAAE,MAAM;KAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,C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,GAAG,SAAS;IAS9B,SAAS,IAAI,OAAO;IAOpB,SAAS,IAAI,OAAO;IAOpB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,iBAAiB,IAAI,OAAO;IAU5B,uBAAuB,IAAI,gBAAgB,EAAE;IAsB7C;;;;;OAKG;IACH,uBAAuB,IAAI,MAAM,GAAC,IAAI;IAetC,eAAe,IAAI,YAAY;IAc/B,aAAa,IAAI,OAAO;CAKzB"}
@@ -108,6 +108,19 @@ export default class ImageWrapper {
108
108
  const { omero: { channels, }, } = this.vivLoader.metadata;
109
109
  return channels.length;
110
110
  }
111
+ // SpatialData case: should be temporary code path,
112
+ // References:
113
+ // - https://github.com/ome/ngff/issues/192
114
+ // - https://github.com/ome/ome-zarr-py/pull/261
115
+ if ('channels_metadata' in this.vivLoader.metadata) {
116
+ const { channels_metadata: channelsMetadata, } = this.vivLoader.metadata;
117
+ return channelsMetadata?.channels.length || 0;
118
+ }
119
+ if ('image-label' in this.vivLoader.metadata) {
120
+ // As far as I can tell, SpatialData labels
121
+ // are always single-channel bitmasks (as of 2023-09-20).
122
+ return 1;
123
+ }
111
124
  return 0;
112
125
  }
113
126
  getChannelNames() {
@@ -119,6 +132,12 @@ export default class ImageWrapper {
119
132
  const { omero: { channels, }, } = this.vivLoader.metadata;
120
133
  return channels.map((channel, i) => channel.label || `Channel ${i}`);
121
134
  }
135
+ if ('channels_metadata' in this.vivLoader.metadata) {
136
+ const { channels_metadata: channelsMetadata, } = this.vivLoader.metadata;
137
+ if (channelsMetadata && Array.isArray(channelsMetadata?.channels)) {
138
+ return channelsMetadata.channels.map(channel => `Channel ${channel.label}`);
139
+ }
140
+ }
122
141
  return [];
123
142
  }
124
143
  getChannelObjects() {
@@ -147,6 +166,17 @@ export default class ImageWrapper {
147
166
  autoDefaultColor: VIEWER_PALETTE[i % VIEWER_PALETTE.length],
148
167
  }));
149
168
  }
169
+ if ('channels_metadata' in this.vivLoader.metadata) {
170
+ const { channels_metadata: channelsMetadata, } = this.vivLoader.metadata;
171
+ if (channelsMetadata && Array.isArray(channelsMetadata?.channels)) {
172
+ return channelsMetadata.channels.map((channel, i) => ({
173
+ name: `Channel ${channel.label}`,
174
+ defaultColor: undefined,
175
+ defaultWindow: undefined,
176
+ autoDefaultColor: VIEWER_PALETTE[i % VIEWER_PALETTE.length],
177
+ }));
178
+ }
179
+ }
150
180
  return [];
151
181
  }
152
182
  getDtype() {
@@ -32,10 +32,20 @@ declare type Multiscale = {
32
32
  version?: string;
33
33
  coordinateTransformations?: object[];
34
34
  };
35
+ declare type SpatialDataTempAttrs = {
36
+ channels_metadata?: {
37
+ channels: {
38
+ label: number;
39
+ }[];
40
+ };
41
+ 'image-label'?: {
42
+ version: string;
43
+ };
44
+ };
35
45
  declare type RootAttrs = {
36
46
  omero: Omero;
37
47
  multiscales: Multiscale[];
38
- };
48
+ } | SpatialDataTempAttrs;
39
49
  export declare type LoadOmeZarrReturnValue<S extends string[]> = {
40
50
  data: ZarrPixelSource<S>[];
41
51
  metadata: RootAttrs;
@@ -1 +1 @@
1
- {"version":3,"file":"ome-zarr-types.d.ts","sourceRoot":"","sources":["../src/ome-zarr-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,aAAK,OAAO,GAAG;IACb,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAA;AAED,aAAK,KAAK,GAAG;IACX,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB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MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAGD,aAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,aAAK,UAAU,GAAG;IAChB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC,CAAA;AAED,aAAK,oBAAoB,GAAG;IAC1B,iBAAiB,CAAC,EAAE;QAClB,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC/B,CAAA;IACD,aAAa,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,CAAA;AAED,aAAK,SAAS,GAAG;IACf,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,GAAG,oBAAoB,CAAC;AAEzB,oBAAY,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI;IACvD,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/image-utils",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -17,8 +17,8 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "@hms-dbmi/viv": "~0.13.8",
20
- "@vitessce/spatial-utils": "3.2.2",
21
- "@vitessce/utils": "3.2.2"
20
+ "@vitessce/spatial-utils": "3.3.1",
21
+ "@vitessce/utils": "3.3.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "vite": "^4.3.0",
@@ -229,6 +229,21 @@ export default class ImageWrapper<S extends string[]> {
229
229
  } = this.vivLoader.metadata;
230
230
  return channels.length;
231
231
  }
232
+ // SpatialData case: should be temporary code path,
233
+ // References:
234
+ // - https://github.com/ome/ngff/issues/192
235
+ // - https://github.com/ome/ome-zarr-py/pull/261
236
+ if ('channels_metadata' in this.vivLoader.metadata) {
237
+ const {
238
+ channels_metadata: channelsMetadata,
239
+ } = this.vivLoader.metadata;
240
+ return channelsMetadata?.channels.length || 0;
241
+ }
242
+ if ('image-label' in this.vivLoader.metadata) {
243
+ // As far as I can tell, SpatialData labels
244
+ // are always single-channel bitmasks (as of 2023-09-20).
245
+ return 1;
246
+ }
232
247
  return 0;
233
248
  }
234
249
 
@@ -249,6 +264,14 @@ export default class ImageWrapper<S extends string[]> {
249
264
  } = this.vivLoader.metadata;
250
265
  return channels.map((channel, i) => channel.label || `Channel ${i}`);
251
266
  }
267
+ if ('channels_metadata' in this.vivLoader.metadata) {
268
+ const {
269
+ channels_metadata: channelsMetadata,
270
+ } = this.vivLoader.metadata;
271
+ if (channelsMetadata && Array.isArray(channelsMetadata?.channels)) {
272
+ return channelsMetadata.channels.map(channel => `Channel ${channel.label}`);
273
+ }
274
+ }
252
275
  return [];
253
276
  }
254
277
 
@@ -286,6 +309,19 @@ export default class ImageWrapper<S extends string[]> {
286
309
  autoDefaultColor: VIEWER_PALETTE[i % VIEWER_PALETTE.length],
287
310
  }));
288
311
  }
312
+ if ('channels_metadata' in this.vivLoader.metadata) {
313
+ const {
314
+ channels_metadata: channelsMetadata,
315
+ } = this.vivLoader.metadata;
316
+ if (channelsMetadata && Array.isArray(channelsMetadata?.channels)) {
317
+ return channelsMetadata.channels.map((channel, i) => ({
318
+ name: `Channel ${channel.label}`,
319
+ defaultColor: undefined,
320
+ defaultWindow: undefined,
321
+ autoDefaultColor: VIEWER_PALETTE[i % VIEWER_PALETTE.length],
322
+ }));
323
+ }
324
+ }
289
325
  return [];
290
326
  }
291
327
 
@@ -36,10 +36,17 @@ type Multiscale = {
36
36
  coordinateTransformations?: object[]; // TODO: stricter type
37
37
  }
38
38
 
39
+ type SpatialDataTempAttrs = {
40
+ channels_metadata?: {
41
+ channels: { label: number }[];
42
+ }
43
+ 'image-label'?: { version: string };
44
+ }
45
+
39
46
  type RootAttrs = {
40
47
  omero: Omero;
41
48
  multiscales: Multiscale[];
42
- }
49
+ } | SpatialDataTempAttrs;
43
50
 
44
51
  export type LoadOmeZarrReturnValue<S extends string[]> = {
45
52
  data: ZarrPixelSource<S>[];