@vitessce/zarr 2.0.3-beta.0 → 2.0.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.
- package/dist/deflate.9bff78ef.mjs +12 -0
- package/dist/index.ae29d0d3.mjs +139533 -0
- package/dist/index.mjs +18 -0
- package/dist/jpeg.7d8fcd34.mjs +839 -0
- package/dist/lerc.242ab449.mjs +1942 -0
- package/dist/lzw.801ba405.mjs +127 -0
- package/dist/packbits.300e46d9.mjs +29 -0
- package/dist/pako.esm.4b234125.mjs +3940 -0
- package/dist/raw.de2b32d2.mjs +11 -0
- package/dist/webimage.97478b33.mjs +31 -0
- package/{dist → dist-tsc}/index.js +1 -0
- package/package.json +11 -11
- package/src/AnnDataSource.js +270 -0
- package/src/AnnDataSource.test.js +55 -0
- package/src/MuDataSource.js +78 -0
- package/src/MuDataSource.test.js +48 -0
- package/src/ZarrDataSource.js +36 -0
- package/src/anndata-loaders/FeatureLabelsAnndataLoader.js +63 -0
- package/src/anndata-loaders/ObsEmbeddingAnndataLoader.js +48 -0
- package/src/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +79 -0
- package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +387 -0
- package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +124 -0
- package/src/anndata-loaders/ObsLabelsAnndataLoader.js +47 -0
- package/src/anndata-loaders/ObsLocationsAnndataLoader.js +45 -0
- package/src/anndata-loaders/ObsSegmentationsAnndataLoader.js +61 -0
- package/src/anndata-loaders/ObsSetsAnndataLoader.js +83 -0
- package/{dist → src}/anndata-loaders/index.js +0 -0
- package/src/genomic-loaders/GenomicProfilesZarrLoader.js +17 -0
- package/{dist → src}/genomic-loaders/index.js +0 -0
- package/src/index.js +7 -0
- package/src/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +36 -0
- package/{dist → src}/matrix-loaders/index.js +0 -0
- package/src/ome-loaders/OmeZarrLoader.js +81 -0
- package/{dist → src}/ome-loaders/index.js +0 -0
- package/src/utils.js +5 -0
- package/dist/AnnDataSource.js +0 -245
- package/dist/AnnDataSource.test.js +0 -49
- package/dist/MuDataSource.js +0 -70
- package/dist/MuDataSource.test.js +0 -42
- package/dist/ZarrDataSource.js +0 -35
- package/dist/anndata-loaders/FeatureLabelsAnndataLoader.js +0 -52
- package/dist/anndata-loaders/ObsEmbeddingAnndataLoader.js +0 -36
- package/dist/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +0 -31
- package/dist/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +0 -363
- package/dist/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +0 -72
- package/dist/anndata-loaders/ObsLabelsAnndataLoader.js +0 -37
- package/dist/anndata-loaders/ObsLocationsAnndataLoader.js +0 -36
- package/dist/anndata-loaders/ObsSegmentationsAnndataLoader.js +0 -51
- package/dist/anndata-loaders/ObsSetsAnndataLoader.js +0 -50
- package/dist/genomic-loaders/GenomicProfilesZarrLoader.js +0 -15
- package/dist/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +0 -30
- package/dist/ome-loaders/OmeZarrLoader.js +0 -62
- package/dist/utils.js +0 -5
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable func-names */
|
|
2
|
-
import ObsFeatureMatrixAnndataLoader from './ObsFeatureMatrixAnndataLoader';
|
|
3
|
-
import AnnDataSource from '../AnnDataSource';
|
|
4
|
-
const createMatrixLoader = (url) => {
|
|
5
|
-
const config = {
|
|
6
|
-
url,
|
|
7
|
-
fileType: 'obsFeatureMatrix.anndata.zarr',
|
|
8
|
-
options: {
|
|
9
|
-
path: 'X',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
const source = new AnnDataSource(config);
|
|
13
|
-
return new ObsFeatureMatrixAnndataLoader(source, config);
|
|
14
|
-
};
|
|
15
|
-
describe('loaders/ObsFeatureMatrixAnndataLoader', () => {
|
|
16
|
-
describe('AnnData v0.7', () => {
|
|
17
|
-
it('loadFilteredGeneNames returns gene names', async () => {
|
|
18
|
-
const loader = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
19
|
-
const names = await loader.loadFilteredGeneNames();
|
|
20
|
-
expect(names).toEqual(Array.from({ length: 15 }).map((_, i) => `gene_${i}`));
|
|
21
|
-
});
|
|
22
|
-
it('loadGeneSelection matches across storage methods', async () => {
|
|
23
|
-
const selection = { selection: ['gene_1', 'gene_5'] };
|
|
24
|
-
const loaderCsr = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csr.zarr');
|
|
25
|
-
const csrSelection = await loaderCsr.loadGeneSelection(selection);
|
|
26
|
-
const loaderDense = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
27
|
-
const denseSelection = await loaderDense.loadGeneSelection(selection);
|
|
28
|
-
const loaderCsc = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csc.zarr');
|
|
29
|
-
const cscSelection = await loaderCsc.loadGeneSelection(selection);
|
|
30
|
-
expect(cscSelection).toEqual(denseSelection);
|
|
31
|
-
expect(csrSelection).toEqual(denseSelection);
|
|
32
|
-
});
|
|
33
|
-
it('loadCellXGene matches across storage methods', async () => {
|
|
34
|
-
const loaderCsr = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csr.zarr');
|
|
35
|
-
const csrMatrix = await loaderCsr.loadCellXGene();
|
|
36
|
-
const loaderDense = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
37
|
-
const denseMatrix = await loaderDense.loadCellXGene();
|
|
38
|
-
const loaderCsc = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csc.zarr');
|
|
39
|
-
const cscMatrix = await loaderCsc.loadCellXGene();
|
|
40
|
-
expect(cscMatrix).toEqual(denseMatrix);
|
|
41
|
-
expect(csrMatrix).toEqual(denseMatrix);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('AnnData v0.8', () => {
|
|
45
|
-
it('loadFilteredGeneNames returns gene names', async () => {
|
|
46
|
-
const loader = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
47
|
-
const names = await loader.loadFilteredGeneNames();
|
|
48
|
-
expect(names).toEqual(Array.from({ length: 15 }).map((_, i) => `gene_${i}`));
|
|
49
|
-
});
|
|
50
|
-
it('loadGeneSelection matches across storage methods', async () => {
|
|
51
|
-
const selection = { selection: ['gene_1', 'gene_5'] };
|
|
52
|
-
const loaderCsr = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csr.zarr');
|
|
53
|
-
const csrSelection = await loaderCsr.loadGeneSelection(selection);
|
|
54
|
-
const loaderDense = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
55
|
-
const denseSelection = await loaderDense.loadGeneSelection(selection);
|
|
56
|
-
const loaderCsc = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csc.zarr');
|
|
57
|
-
const cscSelection = await loaderCsc.loadGeneSelection(selection);
|
|
58
|
-
expect(cscSelection).toEqual(denseSelection);
|
|
59
|
-
expect(csrSelection).toEqual(denseSelection);
|
|
60
|
-
});
|
|
61
|
-
it('loadCellXGene matches across storage methods', async () => {
|
|
62
|
-
const loaderCsr = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csr.zarr');
|
|
63
|
-
const csrMatrix = await loaderCsr.loadCellXGene();
|
|
64
|
-
const loaderDense = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
65
|
-
const denseMatrix = await loaderDense.loadCellXGene();
|
|
66
|
-
const loaderCsc = createMatrixLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csc.zarr');
|
|
67
|
-
const cscMatrix = await loaderCsc.loadCellXGene();
|
|
68
|
-
expect(cscMatrix).toEqual(denseMatrix);
|
|
69
|
-
expect(csrMatrix).toEqual(denseMatrix);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsLabelsAnndataSchema, } from '@vitessce/vit-s';
|
|
2
|
-
/**
|
|
3
|
-
* Loader for string arrays located in anndata.zarr stores.
|
|
4
|
-
*/
|
|
5
|
-
export default class ObsLabelsAnndataLoader extends AbstractTwoStepLoader {
|
|
6
|
-
constructor(dataSource, params) {
|
|
7
|
-
super(dataSource, params);
|
|
8
|
-
this.optionsSchema = obsLabelsAnndataSchema;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Class method for loading observation string labels.
|
|
12
|
-
* @returns {Promise} A promise for the array.
|
|
13
|
-
*/
|
|
14
|
-
loadLabels() {
|
|
15
|
-
const { path } = this.options;
|
|
16
|
-
if (this.labels) {
|
|
17
|
-
return this.labels;
|
|
18
|
-
}
|
|
19
|
-
if (!this.labels) {
|
|
20
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
21
|
-
this.labels = this.dataSource._loadColumn(path);
|
|
22
|
-
return this.labels;
|
|
23
|
-
}
|
|
24
|
-
this.labels = Promise.resolve(null);
|
|
25
|
-
return this.labels;
|
|
26
|
-
}
|
|
27
|
-
async load() {
|
|
28
|
-
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
29
|
-
if (superResult instanceof AbstractLoaderError) {
|
|
30
|
-
return Promise.reject(superResult);
|
|
31
|
-
}
|
|
32
|
-
return Promise.all([
|
|
33
|
-
this.dataSource.loadObsIndex(),
|
|
34
|
-
this.loadLabels(),
|
|
35
|
-
]).then(([obsIndex, obsLabels]) => Promise.resolve(new LoaderResult({ obsIndex, obsLabels }, null)));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsLocationsAnndataSchema, } from '@vitessce/vit-s';
|
|
2
|
-
/**
|
|
3
|
-
* Loader for embedding arrays located in anndata.zarr stores.
|
|
4
|
-
*/
|
|
5
|
-
export default class ObsLocationsAnndataLoader extends AbstractTwoStepLoader {
|
|
6
|
-
constructor(dataSource, params) {
|
|
7
|
-
super(dataSource, params);
|
|
8
|
-
this.optionsSchema = obsLocationsAnndataSchema;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
12
|
-
* @returns {Promise} A promise for an array of columns.
|
|
13
|
-
*/
|
|
14
|
-
loadLocations() {
|
|
15
|
-
const { path, dims = [0, 1] } = this.options;
|
|
16
|
-
if (this.locations) {
|
|
17
|
-
return this.locations;
|
|
18
|
-
}
|
|
19
|
-
if (!this.locations) {
|
|
20
|
-
this.locations = this.dataSource.loadNumericForDims(path, dims);
|
|
21
|
-
return this.locations;
|
|
22
|
-
}
|
|
23
|
-
this.locations = Promise.resolve(null);
|
|
24
|
-
return this.locations;
|
|
25
|
-
}
|
|
26
|
-
async load() {
|
|
27
|
-
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
28
|
-
if (superResult instanceof AbstractLoaderError) {
|
|
29
|
-
return Promise.reject(superResult);
|
|
30
|
-
}
|
|
31
|
-
return Promise.all([
|
|
32
|
-
this.dataSource.loadObsIndex(),
|
|
33
|
-
this.loadLocations(),
|
|
34
|
-
]).then(([obsIndex, obsLocations]) => Promise.resolve(new LoaderResult({ obsIndex, obsLocations }, null)));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsSegmentationsAnndataSchema, } from '@vitessce/vit-s';
|
|
2
|
-
import { DEFAULT_CELLS_LAYER } from '@vitessce/spatial-utils';
|
|
3
|
-
/**
|
|
4
|
-
* Loader for embedding arrays located in anndata.zarr stores.
|
|
5
|
-
*/
|
|
6
|
-
export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader {
|
|
7
|
-
constructor(dataSource, params) {
|
|
8
|
-
super(dataSource, params);
|
|
9
|
-
this.optionsSchema = obsSegmentationsAnndataSchema;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
13
|
-
* @returns {Promise} A promise for an array of columns.
|
|
14
|
-
*/
|
|
15
|
-
loadSegmentations() {
|
|
16
|
-
const { path } = this.options;
|
|
17
|
-
if (this.segmentations) {
|
|
18
|
-
return this.segmentations;
|
|
19
|
-
}
|
|
20
|
-
if (!this.segmentations) {
|
|
21
|
-
this.segmentations = this.dataSource.loadNumeric(path).then(arr => ({
|
|
22
|
-
...arr,
|
|
23
|
-
// Bug introduced from DeckGL v8.6.x to v8.8.x:
|
|
24
|
-
// Polygon vertices cannot be passed via Uint32Arrays, which is how they load via Zarr.
|
|
25
|
-
// For now, a workaround is to cast each vertex to a plain Array.
|
|
26
|
-
data: arr.data
|
|
27
|
-
.map(poly => poly.map(vertex => Array.from(vertex))),
|
|
28
|
-
}));
|
|
29
|
-
return this.segmentations;
|
|
30
|
-
}
|
|
31
|
-
this.segmentations = Promise.resolve(null);
|
|
32
|
-
return this.segmentations;
|
|
33
|
-
}
|
|
34
|
-
async load() {
|
|
35
|
-
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
36
|
-
if (superResult instanceof AbstractLoaderError) {
|
|
37
|
-
return Promise.reject(superResult);
|
|
38
|
-
}
|
|
39
|
-
const coordinationValues = {
|
|
40
|
-
spatialSegmentationLayer: DEFAULT_CELLS_LAYER,
|
|
41
|
-
};
|
|
42
|
-
return Promise.all([
|
|
43
|
-
this.dataSource.loadObsIndex(),
|
|
44
|
-
this.loadSegmentations(),
|
|
45
|
-
]).then(([obsIndex, obsSegmentations]) => Promise.resolve(new LoaderResult({
|
|
46
|
-
obsIndex,
|
|
47
|
-
obsSegmentations,
|
|
48
|
-
obsSegmentationsType: 'polygon',
|
|
49
|
-
}, coordinationValues)));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsSetsAnndataSchema, } from '@vitessce/vit-s';
|
|
2
|
-
import { initializeCellSetColor, treeToMembershipMap, dataToCellSetsTree, } from '@vitessce/sets-utils';
|
|
3
|
-
/**
|
|
4
|
-
* Loader for converting zarr into the cell sets json schema.
|
|
5
|
-
*/
|
|
6
|
-
export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
7
|
-
constructor(dataSource, params) {
|
|
8
|
-
super(dataSource, params);
|
|
9
|
-
this.optionsSchema = obsSetsAnndataSchema;
|
|
10
|
-
}
|
|
11
|
-
loadCellSetIds() {
|
|
12
|
-
const { options } = this;
|
|
13
|
-
const cellSetZarrLocation = options.map(({ path }) => path);
|
|
14
|
-
return this.dataSource.loadObsColumns(cellSetZarrLocation);
|
|
15
|
-
}
|
|
16
|
-
loadCellSetScores() {
|
|
17
|
-
const { options } = this;
|
|
18
|
-
const cellSetScoreZarrLocation = options.map(option => option.scorePath || undefined);
|
|
19
|
-
return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
|
|
20
|
-
}
|
|
21
|
-
async load() {
|
|
22
|
-
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
23
|
-
if (superResult instanceof AbstractLoaderError) {
|
|
24
|
-
return Promise.reject(superResult);
|
|
25
|
-
}
|
|
26
|
-
if (!this.cachedResult) {
|
|
27
|
-
const { options } = this;
|
|
28
|
-
this.cachedResult = Promise.all([
|
|
29
|
-
this.dataSource.loadObsIndex(),
|
|
30
|
-
this.loadCellSetIds(),
|
|
31
|
-
this.loadCellSetScores(),
|
|
32
|
-
]).then(data => [data[0], dataToCellSetsTree(data, options)]);
|
|
33
|
-
}
|
|
34
|
-
const [obsIndex, obsSets] = await this.cachedResult;
|
|
35
|
-
const obsSetsMembership = treeToMembershipMap(obsSets);
|
|
36
|
-
const coordinationValues = {};
|
|
37
|
-
const { tree } = obsSets;
|
|
38
|
-
const newAutoSetSelectionParentName = tree[0].name;
|
|
39
|
-
// Create a list of set paths to initally select.
|
|
40
|
-
const newAutoSetSelections = tree[0].children.map(node => [
|
|
41
|
-
newAutoSetSelectionParentName,
|
|
42
|
-
node.name,
|
|
43
|
-
]);
|
|
44
|
-
// Create a list of cell set objects with color mappings.
|
|
45
|
-
const newAutoSetColors = initializeCellSetColor(obsSets, []);
|
|
46
|
-
coordinationValues.obsSetSelection = newAutoSetSelections;
|
|
47
|
-
coordinationValues.obsSetColor = newAutoSetColors;
|
|
48
|
-
return Promise.resolve(new LoaderResult({ obsIndex, obsSets, obsSetsMembership }, null, coordinationValues));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AbstractTwoStepLoader, LoaderResult } from '@vitessce/vit-s';
|
|
2
|
-
export default class GenomicProfilesZarrLoader extends AbstractTwoStepLoader {
|
|
3
|
-
loadAttrs() {
|
|
4
|
-
if (this.attrs) {
|
|
5
|
-
return this.attrs;
|
|
6
|
-
}
|
|
7
|
-
this.attrs = this.dataSource.getJson('.zattrs');
|
|
8
|
-
return this.attrs;
|
|
9
|
-
}
|
|
10
|
-
load() {
|
|
11
|
-
const { url } = this;
|
|
12
|
-
return this.loadAttrs()
|
|
13
|
-
.then(attrs => Promise.resolve(new LoaderResult(attrs, url)));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { openArray } from 'zarr';
|
|
2
|
-
import { AbstractTwoStepLoader, LoaderResult } from '@vitessce/vit-s';
|
|
3
|
-
export default class MatrixZarrAsObsFeatureMatrixLoader extends AbstractTwoStepLoader {
|
|
4
|
-
async loadAttrs() {
|
|
5
|
-
if (this.attrs) {
|
|
6
|
-
return this.attrs;
|
|
7
|
-
}
|
|
8
|
-
this.attrs = {
|
|
9
|
-
data: await this.dataSource.getJson('.zattrs'),
|
|
10
|
-
url: null,
|
|
11
|
-
};
|
|
12
|
-
return this.attrs;
|
|
13
|
-
}
|
|
14
|
-
loadArr() {
|
|
15
|
-
const { store } = this.dataSource;
|
|
16
|
-
if (this.arr) {
|
|
17
|
-
return this.arr;
|
|
18
|
-
}
|
|
19
|
-
this.arr = openArray({ store, path: '/', mode: 'r' }).then(z => new Promise((resolve) => {
|
|
20
|
-
z.getRaw([null, null])
|
|
21
|
-
.then(resolve);
|
|
22
|
-
}));
|
|
23
|
-
return this.arr;
|
|
24
|
-
}
|
|
25
|
-
load() {
|
|
26
|
-
return Promise
|
|
27
|
-
.all([this.loadAttrs(), this.loadArr()])
|
|
28
|
-
.then(([attrs, arr]) => Promise.resolve(new LoaderResult({ obsIndex: attrs.data.rows, featureIndex: attrs.data.cols, obsFeatureMatrix: arr }, null)));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { viv } from '@vitessce/gl';
|
|
2
|
-
import { initializeRasterLayersAndChannels } from '@vitessce/spatial-utils';
|
|
3
|
-
import { AbstractLoaderError, LoaderResult, AbstractTwoStepLoader } from '@vitessce/vit-s';
|
|
4
|
-
function hexToRgb(hex) {
|
|
5
|
-
const result = /^#?([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})$/i.exec(hex);
|
|
6
|
-
return [
|
|
7
|
-
parseInt(result[1].toLowerCase(), 16),
|
|
8
|
-
parseInt(result[2].toLowerCase(), 16),
|
|
9
|
-
parseInt(result[3].toLowerCase(), 16),
|
|
10
|
-
];
|
|
11
|
-
}
|
|
12
|
-
export default class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
13
|
-
async load() {
|
|
14
|
-
const payload = await this.dataSource.getJson('.zattrs').catch(reason => Promise.resolve(reason));
|
|
15
|
-
if (payload instanceof AbstractLoaderError) {
|
|
16
|
-
return Promise.reject(payload);
|
|
17
|
-
}
|
|
18
|
-
const loader = await viv.loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: 'multiscales' });
|
|
19
|
-
const { metadata, data } = loader;
|
|
20
|
-
const { omero } = metadata;
|
|
21
|
-
if (!omero) {
|
|
22
|
-
console.error('Path for image not valid');
|
|
23
|
-
return Promise.reject(payload);
|
|
24
|
-
}
|
|
25
|
-
const { rdefs, channels } = omero;
|
|
26
|
-
const t = rdefs.defaultT ?? 0;
|
|
27
|
-
const z = rdefs.defaultZ ?? 0;
|
|
28
|
-
const filterSelection = (sel) => {
|
|
29
|
-
// Remove selection keys for which there is no dimension.
|
|
30
|
-
if (data.length > 0) {
|
|
31
|
-
const nextSel = {};
|
|
32
|
-
// eslint-disable-next-line prefer-destructuring
|
|
33
|
-
const labels = data[0].labels;
|
|
34
|
-
Object.keys(sel).forEach((key) => {
|
|
35
|
-
if (labels.includes(key)) {
|
|
36
|
-
nextSel[key] = sel[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return nextSel;
|
|
40
|
-
}
|
|
41
|
-
return sel;
|
|
42
|
-
};
|
|
43
|
-
const imagesWithLoaderCreators = [
|
|
44
|
-
{
|
|
45
|
-
name: omero.name || 'Image',
|
|
46
|
-
channels: channels.map((channel, i) => ({
|
|
47
|
-
selection: filterSelection({ z, t, c: i }),
|
|
48
|
-
slider: [channel.window.start, channel.window.end],
|
|
49
|
-
color: hexToRgb(channel.color),
|
|
50
|
-
})),
|
|
51
|
-
loaderCreator: async () => ({ ...loader, channels: channels.map(c => c.label) }),
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
// TODO: use options for initial selection of channels
|
|
55
|
-
// which omit domain/slider ranges.
|
|
56
|
-
const [autoImageLayers, imageLayerLoaders, imageLayerMeta,] = await initializeRasterLayersAndChannels(imagesWithLoaderCreators, undefined);
|
|
57
|
-
const coordinationValues = {
|
|
58
|
-
spatialImageLayer: autoImageLayers,
|
|
59
|
-
};
|
|
60
|
-
return Promise.resolve(new LoaderResult({ image: { loaders: imageLayerLoaders, meta: imageLayerMeta } }, [], coordinationValues));
|
|
61
|
-
}
|
|
62
|
-
}
|