@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
@@ -2,6 +2,7 @@ import {
2
2
  LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
3
3
  } from '@vitessce/vit-s';
4
4
  import { DEFAULT_CELLS_LAYER } from '@vitessce/spatial-utils';
5
+ import { CoordinationLevel as CL } from '@vitessce/config';
5
6
 
6
7
 
7
8
  /**
@@ -53,9 +54,37 @@ export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader
53
54
  if (superResult instanceof AbstractLoaderError) {
54
55
  return Promise.reject(superResult);
55
56
  }
57
+
58
+ const channelCoordination = [{
59
+ // obsType: null,
60
+ spatialChannelColor: [255, 255, 255],
61
+ spatialChannelVisible: true,
62
+ spatialChannelOpacity: 1.0,
63
+ spatialChannelWindow: null,
64
+ // featureType: 'feature',
65
+ // featureValueType: 'value',
66
+ obsColorEncoding: 'spatialChannelColor',
67
+ spatialSegmentationFilled: true,
68
+ spatialSegmentationStrokeWidth: 1.0,
69
+ obsHighlight: null,
70
+ }];
71
+
56
72
  const coordinationValues = {
73
+ // Old
57
74
  spatialSegmentationLayer: DEFAULT_CELLS_LAYER,
75
+ // New
76
+ // spatialTargetZ: imageWrapper.getDefaultTargetZ(),
77
+ // spatialTargetT: imageWrapper.getDefaultTargetT(),
78
+ segmentationLayer: CL([
79
+ {
80
+ fileUid: this.coordinationValues?.fileUid || null,
81
+ spatialLayerOpacity: 1.0,
82
+ spatialLayerVisible: true,
83
+ segmentationChannel: CL(channelCoordination),
84
+ },
85
+ ]),
58
86
  };
87
+
59
88
  return Promise.all([
60
89
  this.dataSource.loadObsIndex(path),
61
90
  this.loadSegmentations(),
@@ -65,6 +94,7 @@ export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader
65
94
  obsSegmentations,
66
95
  obsSegmentationsType: 'polygon',
67
96
  },
97
+ null,
68
98
  coordinationValues,
69
99
  )));
70
100
  }
@@ -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,32 @@ export default class ObsSpotsAnndataLoader extends AbstractTwoStepLoader {
29
30
  if (superResult instanceof AbstractLoaderError) {
30
31
  return Promise.reject(superResult);
31
32
  }
33
+
34
+ const coordinationValues = {
35
+ spotLayer: CL({
36
+ obsType: 'spot',
37
+ // obsColorEncoding: 'spatialLayerColor',
38
+ // spatialLayerColor: [255, 255, 255],
39
+ spatialLayerVisible: true,
40
+ spatialLayerOpacity: 1.0,
41
+ spatialSpotRadius: 10.0, // TODO: get this from adata.uns if possible.
42
+ // TODO: spatialSpotRadiusUnit: 'µm' or 'um'
43
+ // after resolving https://github.com/vitessce/vitessce/issues/1760
44
+ // featureValueColormapRange: [0, 1],
45
+ // obsHighlight: null,
46
+ // obsSetColor: null,
47
+ // obsSetSelection: null,
48
+ // additionalObsSets: null,
49
+ }),
50
+ };
51
+
32
52
  return Promise.all([
33
53
  this.dataSource.loadObsIndex(path),
34
54
  this.loadSpots(),
35
55
  ]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult(
36
56
  { obsIndex, obsSpots },
37
57
  null,
58
+ coordinationValues,
38
59
  )));
39
60
  }
40
61
  }
@@ -0,0 +1,49 @@
1
+ import { CoordinationLevel as CL } from '@vitessce/config';
2
+ import { LoaderResult } from '@vitessce/vit-s';
3
+ import OmeZarrLoader from './OmeZarrLoader.js';
4
+
5
+ export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
6
+ async load() {
7
+ const { obsTypesFromChannelNames } = this.options || {};
8
+ const result = await super.load();
9
+
10
+ const imageWrapper = result.data.image.instance;
11
+ const channelObjects = imageWrapper.getChannelObjects();
12
+ const channelCoordination = channelObjects.slice(0, 5).map((channelObj, i) => ({
13
+ spatialTargetC: i,
14
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
15
+ spatialChannelVisible: true,
16
+ spatialChannelOpacity: 1.0,
17
+ spatialChannelWindow: channelObj.defaultWindow || null,
18
+ // featureType: 'feature',
19
+ // featureValueType: 'value',
20
+ obsColorEncoding: 'spatialChannelColor',
21
+ spatialSegmentationFilled: true,
22
+ spatialSegmentationStrokeWidth: 1.0,
23
+ obsHighlight: null,
24
+ ...(obsTypesFromChannelNames ? { obsType: channelObj.name } : {}),
25
+ }));
26
+
27
+ const coordinationValues = {
28
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
29
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
30
+ segmentationLayer: CL([
31
+ {
32
+ fileUid: this.coordinationValues?.fileUid || null,
33
+ spatialLayerOpacity: 1.0,
34
+ spatialLayerVisible: true,
35
+ segmentationChannel: CL(channelCoordination),
36
+ },
37
+ ]),
38
+ };
39
+
40
+ return Promise.resolve(new LoaderResult(
41
+ {
42
+ obsSegmentationsType: 'bitmask',
43
+ obsSegmentations: result.data.image,
44
+ },
45
+ result.url,
46
+ coordinationValues,
47
+ ));
48
+ }
49
+ }
@@ -14,18 +14,27 @@ import {
14
14
  LoaderResult,
15
15
  AbstractTwoStepLoader,
16
16
  } from '@vitessce/vit-s';
17
+ import { CoordinationLevel as CL } from '@vitessce/config';
17
18
 
18
19
 
19
20
  export default class OmeZarrLoader extends AbstractTwoStepLoader {
21
+ constructor(dataSource, params) {
22
+ super(dataSource, params);
23
+ this.storeRoot = this.dataSource.storeRoot;
24
+ }
25
+
20
26
  async load() {
21
- const payload = await this.dataSource.getJson('.zattrs').catch(reason => Promise.resolve(reason));
27
+ const payload = await this.dataSource.getJson('.zattrs', this.storeRoot).catch(reason => Promise.resolve(reason));
22
28
  if (payload instanceof AbstractLoaderError) {
23
29
  return Promise.reject(payload);
24
30
  }
25
31
 
26
32
  const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options || {};
27
33
 
28
- const loader = await loadOmeZarr(this.url, this.requestInit);
34
+ // Here, we use this.storeRoot as opposed to this.dataSource.storeRoot.
35
+ // Loader sub-classes may override this.storeRoot in their constructor
36
+ // if their OME-Zarr image is not at the root of the store.
37
+ const loader = await loadOmeZarr(this.storeRoot);
29
38
  const imageWrapper = new ImageWrapper(loader, this.options);
30
39
 
31
40
  const { metadata, data } = loader;
@@ -154,8 +163,33 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
154
163
  imagesWithLoaderCreators, undefined,
155
164
  );
156
165
 
166
+ const channelObjects2 = imageWrapper.getChannelObjects();
167
+ const channelCoordination = channelObjects2.slice(0, 5).map((channelObj, i) => ({
168
+ spatialTargetC: i,
169
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
170
+ spatialChannelVisible: true,
171
+ spatialChannelOpacity: 1.0,
172
+ spatialChannelWindow: channelObj.defaultWindow || null,
173
+ }));
174
+
175
+
157
176
  const coordinationValues = {
177
+ // Old
158
178
  spatialImageLayer: autoImageLayers,
179
+ // New
180
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
181
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
182
+ imageLayer: CL([
183
+ {
184
+ fileUid: this.coordinationValues?.fileUid || null,
185
+ spatialLayerOpacity: 1.0,
186
+ spatialLayerVisible: true,
187
+ photometricInterpretation: imageWrapper.getPhotometricInterpretation(),
188
+ volumetricRenderingAlgorithm: 'maximumIntensityProjection',
189
+ spatialTargetResolution: null,
190
+ imageChannel: CL(channelCoordination),
191
+ },
192
+ ]),
159
193
  };
160
194
 
161
195
  return Promise.resolve(new LoaderResult(
@@ -167,7 +201,7 @@ export default class OmeZarrLoader extends AbstractTwoStepLoader {
167
201
  },
168
202
  featureIndex: imageWrapper.getChannelNames(),
169
203
  },
170
- [],
204
+ null,
171
205
  coordinationValues,
172
206
  ));
173
207
  }
@@ -1 +1,2 @@
1
1
  export { default as OmeZarrLoader } from './OmeZarrLoader.js';
2
+ export { default as OmeZarrAsObsSegmentationsLoader } from './OmeZarrAsObsSegmentationsLoader.js';
@@ -2,13 +2,10 @@ import { OmeZarrLoader } from '../ome-loaders/index.js';
2
2
 
3
3
  export default class SpatialDataImageLoader extends OmeZarrLoader {
4
4
  constructor(dataSource, params) {
5
- // Re-use the OmeZarrLoader, but change the url to point
5
+ super(dataSource, params);
6
+
7
+ // Re-use the OmeZarrLoader, but change the store root to point
6
8
  // to the specified OME-NGFF image within the SpatialData store.
7
- const newParams = {
8
- ...params,
9
- url: `${params.url}/${params.options.path}`,
10
- };
11
- super(dataSource, newParams);
12
- this.dataSource = dataSource;
9
+ this.storeRoot = this.dataSource.getStoreRoot(params.options.path);
13
10
  }
14
11
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AbstractLoaderError,
3
3
  } from '@vitessce/vit-s';
4
+ import { CoordinationLevel as CL } from '@vitessce/config';
4
5
  import SpatialDataImageLoader from './SpatialDataImageLoader.js';
5
6
 
6
7
  export default class SpatialDataLabelsLoader extends SpatialDataImageLoader {
@@ -14,6 +15,39 @@ export default class SpatialDataLabelsLoader extends SpatialDataImageLoader {
14
15
  obsSegmentations: result.data.image,
15
16
  obsSegmentationsType: 'bitmask',
16
17
  };
18
+
19
+ const imageWrapper = result.data.obsSegmentations.instance;
20
+ const channelObjects = imageWrapper.getChannelObjects();
21
+ const channelCoordination = channelObjects.slice(0, 5).map((channelObj, i) => ({
22
+ spatialTargetC: i,
23
+ // obsType: channelObj.name,
24
+ spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
25
+ spatialChannelVisible: true,
26
+ spatialChannelOpacity: 1.0,
27
+ spatialChannelWindow: channelObj.defaultWindow || null,
28
+ // featureType: 'feature',
29
+ // featureValueType: 'value',
30
+ obsColorEncoding: 'spatialChannelColor',
31
+ spatialSegmentationFilled: true,
32
+ spatialSegmentationStrokeWidth: 1.0,
33
+ obsHighlight: null,
34
+ }));
35
+
36
+ const coordinationValues = {
37
+ spatialTargetZ: imageWrapper.getDefaultTargetZ(),
38
+ spatialTargetT: imageWrapper.getDefaultTargetT(),
39
+ segmentationLayer: CL([
40
+ {
41
+ fileUid: this.coordinationValues?.fileUid || null,
42
+ spatialLayerOpacity: 1.0,
43
+ spatialLayerVisible: true,
44
+ segmentationChannel: CL(channelCoordination),
45
+ },
46
+ ]),
47
+ };
48
+
49
+ result.coordinationValues = coordinationValues;
50
+
17
51
  return Promise.resolve(result);
18
52
  }
19
53
  }
@@ -1,11 +1,16 @@
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
  function getCoordsPath(path) {
6
7
  return `${path}/coords`;
7
8
  }
8
9
 
10
+ function getRadiusPath(path) {
11
+ return `${path}/radius`;
12
+ }
13
+
9
14
  /**
10
15
  * Loader for embedding arrays located in anndata.zarr stores.
11
16
  */
@@ -27,18 +32,56 @@ export default class SpatialDataObsSpotsLoader extends AbstractTwoStepLoader {
27
32
  return this.locations;
28
33
  }
29
34
 
35
+ loadRadius() {
36
+ const { path } = this.options;
37
+ if (this.radius) {
38
+ return this.radius;
39
+ }
40
+ if (!this.radius) {
41
+ this.radius = this.dataSource.loadNumeric(getRadiusPath(path));
42
+ return this.radius;
43
+ }
44
+ this.radius = Promise.resolve(null);
45
+ return this.radius;
46
+ }
47
+
30
48
  async load() {
31
49
  const { path, tablePath } = this.options;
32
50
  const superResult = await super.load().catch(reason => Promise.resolve(reason));
33
51
  if (superResult instanceof AbstractLoaderError) {
34
52
  return Promise.reject(superResult);
35
53
  }
54
+
36
55
  return Promise.all([
37
56
  this.dataSource.loadObsIndex(getCoordsPath(path), tablePath),
38
57
  this.loadSpots(),
39
- ]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult(
40
- { obsIndex, obsSpots },
41
- null,
42
- )));
58
+ this.loadRadius(),
59
+ ]).then(([obsIndex, obsSpots, obsRadius]) => {
60
+ const spatialSpotRadius = obsRadius?.data?.[0];
61
+
62
+ const coordinationValues = {
63
+ spotLayer: CL({
64
+ obsType: 'spot',
65
+ // obsColorEncoding: 'spatialLayerColor',
66
+ // spatialLayerColor: [255, 255, 255],
67
+ spatialLayerVisible: true,
68
+ spatialLayerOpacity: 1.0,
69
+ spatialSpotRadius,
70
+ // TODO: spatialSpotRadiusUnit: 'µm' or 'um'
71
+ // after resolving https://github.com/vitessce/vitessce/issues/1760
72
+ // featureValueColormapRange: [0, 1],
73
+ // obsHighlight: null,
74
+ // obsSetColor: null,
75
+ // obsSetSelection: null,
76
+ // additionalObsSets: null,
77
+ }),
78
+ };
79
+
80
+ return Promise.resolve(new LoaderResult(
81
+ { obsIndex, obsSpots },
82
+ null,
83
+ coordinationValues,
84
+ ));
85
+ });
43
86
  }
44
87
  }