@vitessce/zarr 3.3.2 → 3.3.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.
Files changed (45) hide show
  1. package/dist/{deflate-9cfe31b4.js → deflate-1db2c1f1.js} +1 -1
  2. package/dist/{index-2d09430a.js → index-3b4ae0c4.js} +32873 -32548
  3. package/dist/index.js +6 -5
  4. package/dist/{jpeg-e623e3f3.js → jpeg-dc023be1.js} +1 -1
  5. package/dist/{lerc-3b89a300.js → lerc-425a18cf.js} +1 -1
  6. package/dist/{lzw-834edf30.js → lzw-0fce08a3.js} +1 -1
  7. package/dist/{packbits-37beb194.js → packbits-4ac4feea.js} +1 -1
  8. package/dist/{raw-f349901d.js → raw-98377c0e.js} +1 -1
  9. package/dist/{webimage-89dafa8c.js → webimage-9de78ad4.js} +1 -1
  10. package/dist-tsc/ZarrDataSource.d.ts +2 -1
  11. package/dist-tsc/ZarrDataSource.d.ts.map +1 -1
  12. package/dist-tsc/ZarrDataSource.js +6 -2
  13. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts.map +1 -1
  14. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.js +18 -1
  15. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts.map +1 -1
  16. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.js +27 -1
  17. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts.map +1 -1
  18. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.js +19 -1
  19. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts +4 -0
  20. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts.map +1 -0
  21. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.js +41 -0
  22. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts +2 -0
  23. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts.map +1 -1
  24. package/dist-tsc/ome-loaders/OmeZarrLoader.js +34 -3
  25. package/dist-tsc/ome-loaders/index.d.ts +1 -0
  26. package/dist-tsc/ome-loaders/index.js +1 -0
  27. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts +0 -2
  28. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts.map +1 -1
  29. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.js +3 -7
  30. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.d.ts.map +1 -1
  31. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.js +30 -0
  32. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts +2 -0
  33. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts.map +1 -1
  34. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.js +38 -1
  35. package/package.json +10 -9
  36. package/src/ZarrDataSource.js +8 -2
  37. package/src/anndata-loaders/ObsPointsAnndataLoader.js +20 -0
  38. package/src/anndata-loaders/ObsSegmentationsAnndataLoader.js +30 -0
  39. package/src/anndata-loaders/ObsSpotsAnndataLoader.js +21 -0
  40. package/src/ome-loaders/OmeZarrAsObsSegmentationsLoader.js +49 -0
  41. package/src/ome-loaders/OmeZarrLoader.js +37 -3
  42. package/src/ome-loaders/index.js +1 -0
  43. package/src/spatialdata-loaders/SpatialDataImageLoader.js +4 -7
  44. package/src/spatialdata-loaders/SpatialDataLabelsLoader.js +34 -0
  45. package/src/spatialdata-loaders/SpatialDataObsSpotsLoader.js +47 -4
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, F, G, b, M, c, O, j, f, e, h, i, d, k, l, m, o, n, a, S, Z } from "./index-2d09430a.js";
1
+ import { A, F, G, b, M, c, O, j, f, e, h, i, d, l, k, m, n, p, o, a, S, Z } from "./index-3b4ae0c4.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  export {
@@ -15,11 +15,12 @@ export {
15
15
  h as ObsSegmentationsAnndataLoader,
16
16
  i as ObsSetsAnndataLoader,
17
17
  d as ObsSpotsAnndataLoader,
18
+ l as OmeZarrAsObsSegmentationsLoader,
18
19
  k as OmeZarrLoader,
19
- l as SpatialDataImageLoader,
20
- m as SpatialDataLabelsLoader,
21
- o as SpatialDataObsSetsLoader,
22
- n as SpatialDataObsSpotsLoader,
20
+ m as SpatialDataImageLoader,
21
+ n as SpatialDataLabelsLoader,
22
+ p as SpatialDataObsSetsLoader,
23
+ o as SpatialDataObsSpotsLoader,
23
24
  a as SpatialDataShapesSource,
24
25
  S as SpatialDataTableSource,
25
26
  Z as ZarrDataSource
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-2d09430a.js";
1
+ import { B as BaseDecoder } from "./index-3b4ae0c4.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-2d09430a.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-3b4ae0c4.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-2d09430a.js";
1
+ import { B as BaseDecoder } from "./index-3b4ae0c4.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-2d09430a.js";
1
+ import { B as BaseDecoder } from "./index-3b4ae0c4.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-2d09430a.js";
1
+ import { B as BaseDecoder } from "./index-3b4ae0c4.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-2d09430a.js";
1
+ import { B as BaseDecoder } from "./index-3b4ae0c4.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class WebImageDecoder extends BaseDecoder {
@@ -9,6 +9,7 @@ export default class ZarrDataSource {
9
9
  store: any;
10
10
  });
11
11
  storeRoot: any;
12
+ getStoreRoot(path: any): any;
12
13
  /**
13
14
  * Class method for decoding json from the store.
14
15
  * @param {string} key A path to the item.
@@ -16,6 +17,6 @@ export default class ZarrDataSource {
16
17
  * that resolves to the parsed JSON if successful.
17
18
  * @throws This may throw an error.
18
19
  */
19
- getJson(key: string): Promise<any>;
20
+ getJson(key: string, storeRootParam?: null): Promise<any>;
20
21
  }
21
22
  //# sourceMappingURL=ZarrDataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZarrDataSource.d.ts","sourceRoot":"","sources":["../src/ZarrDataSource.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;OAOC;IAJG,eAAgC;IAMpC;;;;;;OAMG;IACH,aALW,MAAM,gBAchB;CACF"}
1
+ {"version":3,"file":"ZarrDataSource.d.ts","sourceRoot":"","sources":["../src/ZarrDataSource.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;OAOC;IAJG,eAAgC;IAMpC,6BAEC;IAED;;;;;;OAMG;IACH,aALW,MAAM,uCAgBhB;CACF"}
@@ -14,6 +14,9 @@ export default class ZarrDataSource {
14
14
  this.storeRoot = zarrOpenRoot(url, requestInit);
15
15
  }
16
16
  }
17
+ getStoreRoot(path) {
18
+ return this.storeRoot.resolve(path);
19
+ }
17
20
  /**
18
21
  * Class method for decoding json from the store.
19
22
  * @param {string} key A path to the item.
@@ -21,13 +24,14 @@ export default class ZarrDataSource {
21
24
  * that resolves to the parsed JSON if successful.
22
25
  * @throws This may throw an error.
23
26
  */
24
- async getJson(key) {
27
+ async getJson(key, storeRootParam = null) {
25
28
  const { storeRoot } = this;
29
+ const storeRootToUse = storeRootParam || storeRoot;
26
30
  let dirKey = key;
27
31
  // TODO: update calls to not include these file names in the first place.
28
32
  if (key.endsWith('.zattrs') || key.endsWith('.zarray') || key.endsWith('.zgroup')) {
29
33
  dirKey = key.substring(0, key.length - 8);
30
34
  }
31
- return (await zarrOpen(storeRoot.resolve(dirKey))).attrs;
35
+ return (await zarrOpen(storeRootToUse.resolve(dirKey))).attrs;
32
36
  }
33
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObsPointsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsPointsAnndataLoader.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACE;;;OAGG;IACH,2BAWC;IALG,eAA+D;IAOnE,qBAaC;CACF"}
1
+ {"version":3,"file":"ObsPointsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsPointsAnndataLoader.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACE;;;OAGG;IACH,2BAWC;IALG,eAA+D;IAOnE,qBAgCC;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/vit-s';
2
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
3
  /**
3
4
  * Loader for embedding arrays located in anndata.zarr stores.
4
5
  */
@@ -25,9 +26,25 @@ export default class ObsPointsAnndataLoader extends AbstractTwoStepLoader {
25
26
  if (superResult instanceof AbstractLoaderError) {
26
27
  return Promise.reject(superResult);
27
28
  }
29
+ const coordinationValues = {
30
+ pointLayer: CL({
31
+ obsType: 'point',
32
+ // obsColorEncoding: 'spatialLayerColor',
33
+ // spatialLayerColor: [255, 255, 255],
34
+ spatialLayerVisible: true,
35
+ spatialLayerOpacity: 1.0,
36
+ // TODO: support a point radius?
37
+ // featureValueColormapRange: [0, 1],
38
+ // obsHighlight: null,
39
+ // obsSetColor: null,
40
+ // obsSetSelection: null,
41
+ // additionalObsSets: null,
42
+ // obsLabelsType: null,
43
+ }),
44
+ };
28
45
  return Promise.all([
29
46
  this.dataSource.loadObsIndex(path),
30
47
  this.loadPoints(),
31
- ]).then(([obsIndex, obsPoints]) => Promise.resolve(new LoaderResult({ obsIndex, obsPoints }, null)));
48
+ ]).then(([obsIndex, obsPoints]) => Promise.resolve(new LoaderResult({ obsIndex, obsPoints }, null, coordinationValues)));
32
49
  }
33
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObsSegmentationsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSegmentationsAnndataLoader.js"],"names":[],"mappings":"AAMA;;GAEG;AACH;IACE;;;OAGG;IACH,kCAiCC;IAXG,mBAMC;IAOL,qBAoBC;CACF"}
1
+ {"version":3,"file":"ObsSegmentationsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSegmentationsAnndataLoader.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IACE;;;OAGG;IACH,kCAiCC;IAXG,mBAMC;IAOL,qBAiDC;CACF"}
@@ -1,5 +1,6 @@
1
1
  import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/vit-s';
2
2
  import { DEFAULT_CELLS_LAYER } from '@vitessce/spatial-utils';
3
+ import { CoordinationLevel as CL } from '@vitessce/config';
3
4
  /**
4
5
  * Loader for embedding arrays located in anndata.zarr stores.
5
6
  */
@@ -48,8 +49,33 @@ export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader
48
49
  if (superResult instanceof AbstractLoaderError) {
49
50
  return Promise.reject(superResult);
50
51
  }
52
+ const channelCoordination = [{
53
+ // obsType: null,
54
+ spatialChannelColor: [255, 255, 255],
55
+ spatialChannelVisible: true,
56
+ spatialChannelOpacity: 1.0,
57
+ spatialChannelWindow: null,
58
+ // featureType: 'feature',
59
+ // featureValueType: 'value',
60
+ obsColorEncoding: 'spatialChannelColor',
61
+ spatialSegmentationFilled: true,
62
+ spatialSegmentationStrokeWidth: 1.0,
63
+ obsHighlight: null,
64
+ }];
51
65
  const coordinationValues = {
66
+ // Old
52
67
  spatialSegmentationLayer: DEFAULT_CELLS_LAYER,
68
+ // New
69
+ // spatialTargetZ: imageWrapper.getDefaultTargetZ(),
70
+ // spatialTargetT: imageWrapper.getDefaultTargetT(),
71
+ segmentationLayer: CL([
72
+ {
73
+ fileUid: this.coordinationValues?.fileUid || null,
74
+ spatialLayerOpacity: 1.0,
75
+ spatialLayerVisible: true,
76
+ segmentationChannel: CL(channelCoordination),
77
+ },
78
+ ]),
53
79
  };
54
80
  return Promise.all([
55
81
  this.dataSource.loadObsIndex(path),
@@ -58,6 +84,6 @@ export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader
58
84
  obsIndex,
59
85
  obsSegmentations,
60
86
  obsSegmentationsType: 'polygon',
61
- }, coordinationValues)));
87
+ }, null, coordinationValues)));
62
88
  }
63
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObsSpotsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSpotsAnndataLoader.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACE;;;OAGG;IACH,0BAWC;IALG,eAA+D;IAOnE,qBAaC;CACF"}
1
+ {"version":3,"file":"ObsSpotsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSpotsAnndataLoader.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACE;;;OAGG;IACH,0BAWC;IALG,eAA+D;IAOnE,qBAiCC;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/vit-s';
2
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
3
  /**
3
4
  * Loader for embedding arrays located in anndata.zarr stores.
4
5
  */
@@ -25,9 +26,26 @@ export default class ObsSpotsAnndataLoader extends AbstractTwoStepLoader {
25
26
  if (superResult instanceof AbstractLoaderError) {
26
27
  return Promise.reject(superResult);
27
28
  }
29
+ const coordinationValues = {
30
+ spotLayer: CL({
31
+ obsType: 'spot',
32
+ // obsColorEncoding: 'spatialLayerColor',
33
+ // spatialLayerColor: [255, 255, 255],
34
+ spatialLayerVisible: true,
35
+ spatialLayerOpacity: 1.0,
36
+ spatialSpotRadius: 10.0, // TODO: get this from adata.uns if possible.
37
+ // TODO: spatialSpotRadiusUnit: 'µm' or 'um'
38
+ // after resolving https://github.com/vitessce/vitessce/issues/1760
39
+ // featureValueColormapRange: [0, 1],
40
+ // obsHighlight: null,
41
+ // obsSetColor: null,
42
+ // obsSetSelection: null,
43
+ // additionalObsSets: null,
44
+ }),
45
+ };
28
46
  return Promise.all([
29
47
  this.dataSource.loadObsIndex(path),
30
48
  this.loadSpots(),
31
- ]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult({ obsIndex, obsSpots }, null)));
49
+ ]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult({ obsIndex, obsSpots }, null, coordinationValues)));
32
50
  }
33
51
  }
@@ -0,0 +1,4 @@
1
+ export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
2
+ }
3
+ import OmeZarrLoader from "./OmeZarrLoader.js";
4
+ //# sourceMappingURL=OmeZarrAsObsSegmentationsLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OmeZarrAsObsSegmentationsLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrAsObsSegmentationsLoader.js"],"names":[],"mappings":"AAIA;CA4CC"}
@@ -0,0 +1,41 @@
1
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
+ import { LoaderResult } from '@vitessce/vit-s';
3
+ import OmeZarrLoader from './OmeZarrLoader.js';
4
+ export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
5
+ async load() {
6
+ const { obsTypesFromChannelNames } = this.options || {};
7
+ const result = await super.load();
8
+ const imageWrapper = result.data.image.instance;
9
+ const channelObjects = imageWrapper.getChannelObjects();
10
+ const channelCoordination = channelObjects.slice(0, 5).map((channelObj, i) => ({
11
+ spatialTargetC: i,
12
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
13
+ spatialChannelVisible: true,
14
+ spatialChannelOpacity: 1.0,
15
+ spatialChannelWindow: channelObj.defaultWindow || null,
16
+ // featureType: 'feature',
17
+ // featureValueType: 'value',
18
+ obsColorEncoding: 'spatialChannelColor',
19
+ spatialSegmentationFilled: true,
20
+ spatialSegmentationStrokeWidth: 1.0,
21
+ obsHighlight: null,
22
+ ...(obsTypesFromChannelNames ? { obsType: channelObj.name } : {}),
23
+ }));
24
+ const coordinationValues = {
25
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
26
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
27
+ segmentationLayer: CL([
28
+ {
29
+ fileUid: this.coordinationValues?.fileUid || null,
30
+ spatialLayerOpacity: 1.0,
31
+ spatialLayerVisible: true,
32
+ segmentationChannel: CL(channelCoordination),
33
+ },
34
+ ]),
35
+ };
36
+ return Promise.resolve(new LoaderResult({
37
+ obsSegmentationsType: 'bitmask',
38
+ obsSegmentations: result.data.image,
39
+ }, result.url, coordinationValues));
40
+ }
41
+ }
@@ -1,4 +1,6 @@
1
1
  export default class OmeZarrLoader {
2
+ constructor(dataSource: any, params: any);
3
+ storeRoot: any;
2
4
  load(): Promise<any>;
3
5
  }
4
6
  //# sourceMappingURL=OmeZarrLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OmeZarrLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrLoader.js"],"names":[],"mappings":"AAkBA;IACE,qBAyJC;CACF"}
1
+ {"version":3,"file":"OmeZarrLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrLoader.js"],"names":[],"mappings":"AAmBA;IACE,0CAGC;IADC,eAA0C;IAG5C,qBAqLC;CACF"}
@@ -1,14 +1,22 @@
1
1
  import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, hexToRgb, normalizeCoordinateTransformations, loadOmeZarr, } from '@vitessce/spatial-utils';
2
2
  import { ImageWrapper, } from '@vitessce/image-utils';
3
3
  import { AbstractLoaderError, LoaderResult, AbstractTwoStepLoader, } from '@vitessce/vit-s';
4
+ import { CoordinationLevel as CL } from '@vitessce/config';
4
5
  export default class OmeZarrLoader extends AbstractTwoStepLoader {
6
+ constructor(dataSource, params) {
7
+ super(dataSource, params);
8
+ this.storeRoot = this.dataSource.storeRoot;
9
+ }
5
10
  async load() {
6
- const payload = await this.dataSource.getJson('.zattrs').catch(reason => Promise.resolve(reason));
11
+ const payload = await this.dataSource.getJson('.zattrs', this.storeRoot).catch(reason => Promise.resolve(reason));
7
12
  if (payload instanceof AbstractLoaderError) {
8
13
  return Promise.reject(payload);
9
14
  }
10
15
  const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options || {};
11
- const loader = await loadOmeZarr(this.url, this.requestInit);
16
+ // Here, we use this.storeRoot as opposed to this.dataSource.storeRoot.
17
+ // Loader sub-classes may override this.storeRoot in their constructor
18
+ // if their OME-Zarr image is not at the root of the store.
19
+ const loader = await loadOmeZarr(this.storeRoot);
12
20
  const imageWrapper = new ImageWrapper(loader, this.options);
13
21
  const { metadata, data } = loader;
14
22
  const { omero, multiscales, channels_metadata: spatialDataChannels, 'image-label': imageLabel } = metadata;
@@ -109,8 +117,31 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
109
117
  // TODO: use options for initial selection of channels
110
118
  // which omit domain/slider ranges.
111
119
  const [autoImageLayers, imageLayerLoaders, imageLayerMeta,] = await initializeRasterLayersAndChannels(imagesWithLoaderCreators, undefined);
120
+ const channelObjects2 = imageWrapper.getChannelObjects();
121
+ const channelCoordination = channelObjects2.slice(0, 5).map((channelObj, i) => ({
122
+ spatialTargetC: i,
123
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
124
+ spatialChannelVisible: true,
125
+ spatialChannelOpacity: 1.0,
126
+ spatialChannelWindow: channelObj.defaultWindow || null,
127
+ }));
112
128
  const coordinationValues = {
129
+ // Old
113
130
  spatialImageLayer: autoImageLayers,
131
+ // New
132
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
133
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
134
+ imageLayer: CL([
135
+ {
136
+ fileUid: this.coordinationValues?.fileUid || null,
137
+ spatialLayerOpacity: 1.0,
138
+ spatialLayerVisible: true,
139
+ photometricInterpretation: imageWrapper.getPhotometricInterpretation(),
140
+ volumetricRenderingAlgorithm: 'maximumIntensityProjection',
141
+ spatialTargetResolution: null,
142
+ imageChannel: CL(channelCoordination),
143
+ },
144
+ ]),
114
145
  };
115
146
  return Promise.resolve(new LoaderResult({
116
147
  image: {
@@ -119,6 +150,6 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
119
150
  instance: imageWrapper, // TODO: make this the root value of LoaderResult.image.
120
151
  },
121
152
  featureIndex: imageWrapper.getChannelNames(),
122
- }, [], coordinationValues));
153
+ }, null, coordinationValues));
123
154
  }
124
155
  }
@@ -1,2 +1,3 @@
1
1
  export { default as OmeZarrLoader } from "./OmeZarrLoader.js";
2
+ export { default as OmeZarrAsObsSegmentationsLoader } from "./OmeZarrAsObsSegmentationsLoader.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1,2 @@
1
1
  export { default as OmeZarrLoader } from './OmeZarrLoader.js';
2
+ export { default as OmeZarrAsObsSegmentationsLoader } from './OmeZarrAsObsSegmentationsLoader.js';
@@ -1,6 +1,4 @@
1
1
  export default class SpatialDataImageLoader extends OmeZarrLoader {
2
- constructor(dataSource: any, params: any);
3
- dataSource: any;
4
2
  }
5
3
  import { OmeZarrLoader } from "../ome-loaders/index.js";
6
4
  //# sourceMappingURL=SpatialDataImageLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialDataImageLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataImageLoader.js"],"names":[],"mappings":"AAEA;IACE,0CASC;IADC,gBAA4B;CAE/B"}
1
+ {"version":3,"file":"SpatialDataImageLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataImageLoader.js"],"names":[],"mappings":"AAEA;CAQC"}
@@ -1,13 +1,9 @@
1
1
  import { OmeZarrLoader } from '../ome-loaders/index.js';
2
2
  export default class SpatialDataImageLoader extends OmeZarrLoader {
3
3
  constructor(dataSource, params) {
4
- // Re-use the OmeZarrLoader, but change the url to point
4
+ super(dataSource, params);
5
+ // Re-use the OmeZarrLoader, but change the store root to point
5
6
  // to the specified OME-NGFF image within the SpatialData store.
6
- const newParams = {
7
- ...params,
8
- url: `${params.url}/${params.options.path}`,
9
- };
10
- super(dataSource, newParams);
11
- this.dataSource = dataSource;
7
+ this.storeRoot = this.dataSource.getStoreRoot(params.options.path);
12
8
  }
13
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialDataLabelsLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataLabelsLoader.js"],"names":[],"mappings":"AAKA;CAaC"}
1
+ {"version":3,"file":"SpatialDataLabelsLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataLabelsLoader.js"],"names":[],"mappings":"AAMA;CA8CC"}
@@ -1,4 +1,5 @@
1
1
  import { AbstractLoaderError, } from '@vitessce/vit-s';
2
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
3
  import SpatialDataImageLoader from './SpatialDataImageLoader.js';
3
4
  export default class SpatialDataLabelsLoader extends SpatialDataImageLoader {
4
5
  async load() {
@@ -10,6 +11,35 @@ export default class SpatialDataLabelsLoader extends SpatialDataImageLoader {
10
11
  obsSegmentations: result.data.image,
11
12
  obsSegmentationsType: 'bitmask',
12
13
  };
14
+ const imageWrapper = result.data.obsSegmentations.instance;
15
+ const channelObjects = imageWrapper.getChannelObjects();
16
+ const channelCoordination = channelObjects.slice(0, 5).map((channelObj, i) => ({
17
+ spatialTargetC: i,
18
+ // obsType: channelObj.name,
19
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
20
+ spatialChannelVisible: true,
21
+ spatialChannelOpacity: 1.0,
22
+ spatialChannelWindow: channelObj.defaultWindow || null,
23
+ // featureType: 'feature',
24
+ // featureValueType: 'value',
25
+ obsColorEncoding: 'spatialChannelColor',
26
+ spatialSegmentationFilled: true,
27
+ spatialSegmentationStrokeWidth: 1.0,
28
+ obsHighlight: null,
29
+ }));
30
+ const coordinationValues = {
31
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
32
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
33
+ segmentationLayer: CL([
34
+ {
35
+ fileUid: this.coordinationValues?.fileUid || null,
36
+ spatialLayerOpacity: 1.0,
37
+ spatialLayerVisible: true,
38
+ segmentationChannel: CL(channelCoordination),
39
+ },
40
+ ]),
41
+ };
42
+ result.coordinationValues = coordinationValues;
13
43
  return Promise.resolve(result);
14
44
  }
15
45
  }
@@ -8,6 +8,8 @@ export default class SpatialDataObsSpotsLoader {
8
8
  */
9
9
  loadSpots(): Promise<any>;
10
10
  locations: any;
11
+ loadRadius(): any;
12
+ radius: any;
11
13
  load(): Promise<any>;
12
14
  }
13
15
  //# sourceMappingURL=SpatialDataObsSpotsLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialDataObsSpotsLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataObsSpotsLoader.js"],"names":[],"mappings":"AAQA;;KAEK;AACL;IACE;;;SAGK;IACL,0BAWC;IALG,eAA8E;IAOlF,qBAaC;CACF"}
1
+ {"version":3,"file":"SpatialDataObsSpotsLoader.d.ts","sourceRoot":"","sources":["../../src/spatialdata-loaders/SpatialDataObsSpotsLoader.js"],"names":[],"mappings":"AAaA;;KAEK;AACL;IACE;;;SAGK;IACL,0BAWC;IALG,eAA8E;IAOlF,kBAWC;IALG,YAA8D;IAOlE,qBAsCC;CACF"}
@@ -1,7 +1,11 @@
1
1
  import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/vit-s';
2
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
3
  function getCoordsPath(path) {
3
4
  return `${path}/coords`;
4
5
  }
6
+ function getRadiusPath(path) {
7
+ return `${path}/radius`;
8
+ }
5
9
  /**
6
10
  * Loader for embedding arrays located in anndata.zarr stores.
7
11
  */
@@ -22,6 +26,18 @@ export default class SpatialDataObsSpotsLoader extends AbstractTwoStepLoader {
22
26
  this.locations = Promise.resolve(null);
23
27
  return this.locations;
24
28
  }
29
+ loadRadius() {
30
+ const { path } = this.options;
31
+ if (this.radius) {
32
+ return this.radius;
33
+ }
34
+ if (!this.radius) {
35
+ this.radius = this.dataSource.loadNumeric(getRadiusPath(path));
36
+ return this.radius;
37
+ }
38
+ this.radius = Promise.resolve(null);
39
+ return this.radius;
40
+ }
25
41
  async load() {
26
42
  const { path, tablePath } = this.options;
27
43
  const superResult = await super.load().catch(reason => Promise.resolve(reason));
@@ -31,6 +47,27 @@ export default class SpatialDataObsSpotsLoader extends AbstractTwoStepLoader {
31
47
  return Promise.all([
32
48
  this.dataSource.loadObsIndex(getCoordsPath(path), tablePath),
33
49
  this.loadSpots(),
34
- ]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult({ obsIndex, obsSpots }, null)));
50
+ this.loadRadius(),
51
+ ]).then(([obsIndex, obsSpots, obsRadius]) => {
52
+ const spatialSpotRadius = obsRadius?.data?.[0];
53
+ const coordinationValues = {
54
+ spotLayer: CL({
55
+ obsType: 'spot',
56
+ // obsColorEncoding: 'spatialLayerColor',
57
+ // spatialLayerColor: [255, 255, 255],
58
+ spatialLayerVisible: true,
59
+ spatialLayerOpacity: 1.0,
60
+ spatialSpotRadius,
61
+ // TODO: spatialSpotRadiusUnit: 'µm' or 'um'
62
+ // after resolving https://github.com/vitessce/vitessce/issues/1760
63
+ // featureValueColormapRange: [0, 1],
64
+ // obsHighlight: null,
65
+ // obsSetColor: null,
66
+ // obsSetSelection: null,
67
+ // additionalObsSets: null,
68
+ }),
69
+ };
70
+ return Promise.resolve(new LoaderResult({ obsIndex, obsSpots }, null, coordinationValues));
71
+ });
35
72
  }
36
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/zarr",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,14 +19,15 @@
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarrita": "0.4.0-next.4",
22
- "@vitessce/constants-internal": "3.3.2",
23
- "@vitessce/spatial-utils": "3.3.2",
24
- "@vitessce/sets-utils": "3.3.2",
25
- "@vitessce/image-utils": "3.3.2",
26
- "@vitessce/utils": "3.3.2",
27
- "@vitessce/gl": "3.3.2",
28
- "@vitessce/vit-s": "3.3.2",
29
- "@vitessce/zarr-utils": "3.3.2"
22
+ "@vitessce/constants-internal": "3.3.3",
23
+ "@vitessce/gl": "3.3.3",
24
+ "@vitessce/sets-utils": "3.3.3",
25
+ "@vitessce/image-utils": "3.3.3",
26
+ "@vitessce/spatial-utils": "3.3.3",
27
+ "@vitessce/utils": "3.3.3",
28
+ "@vitessce/vit-s": "3.3.3",
29
+ "@vitessce/zarr-utils": "3.3.3",
30
+ "@vitessce/config": "3.3.3"
30
31
  },
31
32
  "scripts": {
32
33
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
@@ -15,6 +15,10 @@ export default class ZarrDataSource {
15
15
  }
16
16
  }
17
17
 
18
+ getStoreRoot(path) {
19
+ return this.storeRoot.resolve(path);
20
+ }
21
+
18
22
  /**
19
23
  * Class method for decoding json from the store.
20
24
  * @param {string} key A path to the item.
@@ -22,14 +26,16 @@ export default class ZarrDataSource {
22
26
  * that resolves to the parsed JSON if successful.
23
27
  * @throws This may throw an error.
24
28
  */
25
- async getJson(key) {
29
+ async getJson(key, storeRootParam = null) {
26
30
  const { storeRoot } = this;
27
31
 
32
+ const storeRootToUse = storeRootParam || storeRoot;
33
+
28
34
  let dirKey = key;
29
35
  // TODO: update calls to not include these file names in the first place.
30
36
  if (key.endsWith('.zattrs') || key.endsWith('.zarray') || key.endsWith('.zgroup')) {
31
37
  dirKey = key.substring(0, key.length - 8);
32
38
  }
33
- return (await zarrOpen(storeRoot.resolve(dirKey))).attrs;
39
+ return (await zarrOpen(storeRootToUse.resolve(dirKey))).attrs;
34
40
  }
35
41
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
3
3
  } from '@vitessce/vit-s';
4
+ import { CoordinationLevel as CL } from '@vitessce/config';
4
5
 
5
6
  /**
6
7
  * Loader for embedding arrays located in anndata.zarr stores.
@@ -29,12 +30,31 @@ export default class ObsPointsAnndataLoader extends AbstractTwoStepLoader {
29
30
  if (superResult instanceof AbstractLoaderError) {
30
31
  return Promise.reject(superResult);
31
32
  }
33
+
34
+ const coordinationValues = {
35
+ pointLayer: CL({
36
+ obsType: 'point',
37
+ // obsColorEncoding: 'spatialLayerColor',
38
+ // spatialLayerColor: [255, 255, 255],
39
+ spatialLayerVisible: true,
40
+ spatialLayerOpacity: 1.0,
41
+ // TODO: support a point radius?
42
+ // featureValueColormapRange: [0, 1],
43
+ // obsHighlight: null,
44
+ // obsSetColor: null,
45
+ // obsSetSelection: null,
46
+ // additionalObsSets: null,
47
+ // obsLabelsType: null,
48
+ }),
49
+ };
50
+
32
51
  return Promise.all([
33
52
  this.dataSource.loadObsIndex(path),
34
53
  this.loadPoints(),
35
54
  ]).then(([obsIndex, obsPoints]) => Promise.resolve(new LoaderResult(
36
55
  { obsIndex, obsPoints },
37
56
  null,
57
+ coordinationValues,
38
58
  )));
39
59
  }
40
60
  }