@vitessce/json 3.0.0 → 3.0.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-8cb529a4.js";
1
+ import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-7338c21e.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-8cb529a4.js";
1
+ import { B as BaseDecoder } from "./index-7338c21e.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, L as LercParameters, a as LercAddCompression } from "./index-8cb529a4.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-7338c21e.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  var LercDecode = { exports: {} };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-8cb529a4.js";
1
+ import { B as BaseDecoder } from "./index-7338c21e.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-8cb529a4.js";
1
+ import { B as BaseDecoder } from "./index-7338c21e.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-8cb529a4.js";
1
+ import { B as BaseDecoder } from "./index-7338c21e.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-8cb529a4.js";
1
+ import { B as BaseDecoder } from "./index-7338c21e.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class WebImageDecoder extends BaseDecoder {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import JsonLoader from './JsonLoader.js';
2
3
  import cellsGoodFixture from '../legacy-loaders/schemas/fixtures/cells.good.json';
3
4
  import cellsBadFixture from '../legacy-loaders/schemas/fixtures/cells.bad.json';
@@ -19,7 +19,7 @@ describe('loaders/json-loaders/ObsSetsJson', () => {
19
19
  it('can load obsSets', async () => {
20
20
  const loader = createLoader(ObsSetsJsonLoader, {
21
21
  fileType: 'obsSets.cells.json',
22
- }, 'http://localhost:51204/@fixtures/vit-s/obsSets.good.json');
22
+ }, 'http://localhost:4204/@fixtures/vit-s/obsSets.good.json');
23
23
  const result = await loader.load();
24
24
  expect(result).toBeInstanceOf(LoaderResult);
25
25
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import CellsJsonAsObsEmbeddingLoader from './CellsJsonAsObsEmbedding.js';
3
4
  import CellsJsonAsObsLabelsLoader from './CellsJsonAsObsLabels.js';
@@ -19,7 +20,7 @@ describe('loaders/cells-json-loaders', () => {
19
20
  coordinationValues: {
20
21
  embeddingType: 'PCA',
21
22
  },
22
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
23
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
23
24
  const result = await loader.load();
24
25
  expect(result).toBeInstanceOf(LoaderResult);
25
26
  const payload = result.data;
@@ -36,7 +37,7 @@ describe('loaders/cells-json-loaders', () => {
36
37
  coordinationValues: {
37
38
  obsLabelsType: 'cluster',
38
39
  },
39
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
40
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
40
41
  const result = await loader.load();
41
42
  expect(result).toBeInstanceOf(LoaderResult);
42
43
  const payload = result.data;
@@ -49,7 +50,7 @@ describe('loaders/cells-json-loaders', () => {
49
50
  it('can load obsSegmentations', async () => {
50
51
  const loader = createLoader(CellsJsonAsObsSegmentationsLoader, {
51
52
  fileType: 'obsSegmentations.cells.json',
52
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
53
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
53
54
  const result = await loader.load();
54
55
  expect(result).toBeInstanceOf(LoaderResult);
55
56
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import ClustersJsonAsObsFeatureMatrixLoader from './ClustersJsonAsObsFeatureMatrix.js';
3
4
  import JsonSource from '../JsonSource.js';
@@ -14,7 +15,7 @@ describe('loaders/clusters-json-loaders', () => {
14
15
  it('can load obsFeatureMatrix', async () => {
15
16
  const loader = createLoader(ClustersJsonAsObsFeatureMatrixLoader, {
16
17
  fileType: 'obsFeatureMatrix.clusters.json',
17
- }, 'http://localhost:51204/@fixtures/json-legacy/clusters.good.json');
18
+ }, 'http://localhost:4204/@fixtures/json-legacy/clusters.good.json');
18
19
  const result = await loader.load();
19
20
  expect(result).toBeInstanceOf(LoaderResult);
20
21
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import GenesJsonAsObsFeatureMatrixLoader from './GenesJsonAsObsFeatureMatrix.js';
3
4
  import JsonSource from '../JsonSource.js';
@@ -14,7 +15,7 @@ describe('loaders/genes-json-loaders', () => {
14
15
  it('can load obsFeatureMatrix', async () => {
15
16
  const loader = createLoader(GenesJsonAsObsFeatureMatrixLoader, {
16
17
  fileType: 'obsFeatureMatrix.genes.json',
17
- }, 'http://localhost:51204/@fixtures/json-legacy/genes.good.json');
18
+ }, 'http://localhost:4204/@fixtures/json-legacy/genes.good.json');
18
19
  const result = await loader.load();
19
20
  expect(result).toBeInstanceOf(LoaderResult);
20
21
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import MoleculesJsonAsObsLocationsLoader from './MoleculesJsonAsObsLocations.js';
3
4
  import MoleculesJsonAsObsLabelsLoader from './MoleculesJsonAsObsLabels.js';
@@ -15,7 +16,7 @@ describe('loaders/molecules-json-loaders', () => {
15
16
  it('can load obsLocations', async () => {
16
17
  const loader = createLoader(MoleculesJsonAsObsLocationsLoader, {
17
18
  fileType: 'obsLocations.molecules.json',
18
- }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
19
+ }, 'http://localhost:4204/@fixtures/json-legacy/molecules.good.json');
19
20
  const result = await loader.load();
20
21
  expect(result).toBeInstanceOf(LoaderResult);
21
22
  const payload = result.data;
@@ -32,7 +33,7 @@ describe('loaders/molecules-json-loaders', () => {
32
33
  coordinationValues: {
33
34
  obsLabelsType: 'gene',
34
35
  },
35
- }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
36
+ }, 'http://localhost:4204/@fixtures/json-legacy/molecules.good.json');
36
37
  const result = await loader.load();
37
38
  expect(result).toBeInstanceOf(LoaderResult);
38
39
  const payload = result.data;
@@ -1 +1 @@
1
- {"version":3,"file":"RasterJsonLoader.d.ts","sourceRoot":"","sources":["../../src/raster-json-loaders/RasterJsonLoader.js"],"names":[],"mappings":"AA0EA;IAWE,qBAyCC;IAnBG,oBAIC;CAgBN"}
1
+ {"version":3,"file":"RasterJsonLoader.d.ts","sourceRoot":"","sources":["../../src/raster-json-loaders/RasterJsonLoader.js"],"names":[],"mappings":"AAyHA;IAWE,qBAyCC;IAnBG,oBAIC;CAgBN"}
@@ -1,5 +1,5 @@
1
1
  import { viv } from '@vitessce/gl';
2
- import { initializeRasterLayersAndChannels } from '@vitessce/spatial-utils';
2
+ import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, } from '@vitessce/spatial-utils';
3
3
  import { openArray } from 'zarr';
4
4
  import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
5
5
  import { rasterJsonSchema as rasterSchema } from '@vitessce/schemas';
@@ -57,6 +57,37 @@ async function initLoader(imageData) {
57
57
  : [Channels.Name || `Channel ${0}`];
58
58
  return { ...loader, channels };
59
59
  }
60
+ case ('ome-zarr'): {
61
+ // Reference: https://github.com/vitessce/vitessce-python/issues/242#issuecomment-1517930964
62
+ // Most of the following has been copied from OmeZarrLoader.js.
63
+ // Reference: https://github.com/vitessce/vitessce/blob/fb0e7f/packages/file-types/zarr/src/ome-loaders/OmeZarrLoader.js#L29
64
+ const { coordinateTransformations: coordinateTransformationsFromOptions } = metadata || {};
65
+ const loader = await viv.loadOmeZarr(url, { fetchOptions: requestInit, type: 'multiscales' });
66
+ const { metadata: loaderMetadata } = loader;
67
+ const { omero, multiscales } = loaderMetadata;
68
+ if (!Array.isArray(multiscales) || multiscales.length === 0) {
69
+ console.error('Multiscales array must exist and have at least one element');
70
+ }
71
+ const { coordinateTransformations } = multiscales[0];
72
+ // Axes in v0.4 format.
73
+ const axes = getNgffAxes(multiscales[0].axes);
74
+ const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, axes);
75
+ const transformMatrixFromFile = coordinateTransformationsToMatrix(coordinateTransformations, axes);
76
+ const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
77
+ const { channels, name: omeroName } = omero;
78
+ return {
79
+ name: omeroName || 'Image',
80
+ channels: channels.map((c, i) => c.label || `Channel ${i}`),
81
+ ...(transformMatrix ? {
82
+ metadata: {
83
+ transform: {
84
+ matrix: transformMatrix,
85
+ },
86
+ },
87
+ } : {}),
88
+ ...loader,
89
+ };
90
+ }
60
91
  default: {
61
92
  throw Error(`Image type (${type}) is not supported`);
62
93
  }
@@ -82,7 +113,7 @@ export default class RasterLoader extends JsonLoader {
82
113
  // Get image name and URL tuples.
83
114
  const urls = images
84
115
  .filter(image => !image.url.includes('zarr'))
85
- .map(image => ([image.url, image.name]));
116
+ .map(image => ({ url: image.url, name: image.name }));
86
117
  // Add a loaderCreator function for each image layer.
87
118
  const imagesWithLoaderCreators = images.map(image => ({
88
119
  ...image,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/json",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,17 +20,17 @@
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarr": "0.5.1",
22
22
  "zod": "^3.21.4",
23
- "@vitessce/constants-internal": "3.0.0",
24
- "@vitessce/gl": "3.0.0",
25
- "@vitessce/schemas": "3.0.0",
26
- "@vitessce/sets-utils": "3.0.0",
27
- "@vitessce/spatial-utils": "3.0.0",
28
- "@vitessce/utils": "3.0.0",
29
- "@vitessce/vit-s": "3.0.0"
23
+ "@vitessce/constants-internal": "3.0.1",
24
+ "@vitessce/gl": "3.0.1",
25
+ "@vitessce/schemas": "3.0.1",
26
+ "@vitessce/sets-utils": "3.0.1",
27
+ "@vitessce/spatial-utils": "3.0.1",
28
+ "@vitessce/utils": "3.0.1",
29
+ "@vitessce/vit-s": "3.0.1"
30
30
  },
31
31
  "scripts": {
32
32
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
33
- "test": "pnpm exec vitest --run -r ../../../ --dir ."
33
+ "test": "pnpm exec vitest --run"
34
34
  },
35
35
  "module": "dist/index.js",
36
36
  "exports": {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import JsonLoader from './JsonLoader.js';
2
3
  import cellsGoodFixture from '../legacy-loaders/schemas/fixtures/cells.good.json';
3
4
  import cellsBadFixture from '../legacy-loaders/schemas/fixtures/cells.bad.json';
@@ -18,7 +18,7 @@ describe('loaders/json-loaders/ObsSetsJson', () => {
18
18
  it('can load obsSets', async () => {
19
19
  const loader = createLoader(ObsSetsJsonLoader, {
20
20
  fileType: 'obsSets.cells.json',
21
- }, 'http://localhost:51204/@fixtures/vit-s/obsSets.good.json');
21
+ }, 'http://localhost:4204/@fixtures/vit-s/obsSets.good.json');
22
22
  const result = await loader.load();
23
23
  expect(result).toBeInstanceOf(LoaderResult);
24
24
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import CellsJsonAsObsEmbeddingLoader from './CellsJsonAsObsEmbedding.js';
3
4
  import CellsJsonAsObsLabelsLoader from './CellsJsonAsObsLabels.js';
@@ -21,7 +22,7 @@ describe('loaders/cells-json-loaders', () => {
21
22
  coordinationValues: {
22
23
  embeddingType: 'PCA',
23
24
  },
24
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
25
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
25
26
  const result = await loader.load();
26
27
  expect(result).toBeInstanceOf(LoaderResult);
27
28
  const payload = result.data;
@@ -38,7 +39,7 @@ describe('loaders/cells-json-loaders', () => {
38
39
  coordinationValues: {
39
40
  obsLabelsType: 'cluster',
40
41
  },
41
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
42
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
42
43
  const result = await loader.load();
43
44
  expect(result).toBeInstanceOf(LoaderResult);
44
45
  const payload = result.data;
@@ -51,7 +52,7 @@ describe('loaders/cells-json-loaders', () => {
51
52
  it('can load obsSegmentations', async () => {
52
53
  const loader = createLoader(CellsJsonAsObsSegmentationsLoader, {
53
54
  fileType: 'obsSegmentations.cells.json',
54
- }, 'http://localhost:51204/@fixtures/json-legacy/cells.good.json');
55
+ }, 'http://localhost:4204/@fixtures/json-legacy/cells.good.json');
55
56
  const result = await loader.load();
56
57
  expect(result).toBeInstanceOf(LoaderResult);
57
58
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import ClustersJsonAsObsFeatureMatrixLoader from './ClustersJsonAsObsFeatureMatrix.js';
3
4
  import JsonSource from '../JsonSource.js';
@@ -16,7 +17,7 @@ describe('loaders/clusters-json-loaders', () => {
16
17
  it('can load obsFeatureMatrix', async () => {
17
18
  const loader = createLoader(ClustersJsonAsObsFeatureMatrixLoader, {
18
19
  fileType: 'obsFeatureMatrix.clusters.json',
19
- }, 'http://localhost:51204/@fixtures/json-legacy/clusters.good.json');
20
+ }, 'http://localhost:4204/@fixtures/json-legacy/clusters.good.json');
20
21
  const result = await loader.load();
21
22
  expect(result).toBeInstanceOf(LoaderResult);
22
23
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import GenesJsonAsObsFeatureMatrixLoader from './GenesJsonAsObsFeatureMatrix.js';
3
4
  import JsonSource from '../JsonSource.js';
@@ -16,7 +17,7 @@ describe('loaders/genes-json-loaders', () => {
16
17
  it('can load obsFeatureMatrix', async () => {
17
18
  const loader = createLoader(GenesJsonAsObsFeatureMatrixLoader, {
18
19
  fileType: 'obsFeatureMatrix.genes.json',
19
- }, 'http://localhost:51204/@fixtures/json-legacy/genes.good.json');
20
+ }, 'http://localhost:4204/@fixtures/json-legacy/genes.good.json');
20
21
  const result = await loader.load();
21
22
  expect(result).toBeInstanceOf(LoaderResult);
22
23
  const payload = result.data;
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { LoaderResult } from '@vitessce/vit-s';
2
3
  import MoleculesJsonAsObsLocationsLoader from './MoleculesJsonAsObsLocations.js';
3
4
  import MoleculesJsonAsObsLabelsLoader from './MoleculesJsonAsObsLabels.js';
@@ -17,7 +18,7 @@ describe('loaders/molecules-json-loaders', () => {
17
18
  it('can load obsLocations', async () => {
18
19
  const loader = createLoader(MoleculesJsonAsObsLocationsLoader, {
19
20
  fileType: 'obsLocations.molecules.json',
20
- }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
21
+ }, 'http://localhost:4204/@fixtures/json-legacy/molecules.good.json');
21
22
  const result = await loader.load();
22
23
  expect(result).toBeInstanceOf(LoaderResult);
23
24
  const payload = result.data;
@@ -34,7 +35,7 @@ describe('loaders/molecules-json-loaders', () => {
34
35
  coordinationValues: {
35
36
  obsLabelsType: 'gene',
36
37
  },
37
- }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
38
+ }, 'http://localhost:4204/@fixtures/json-legacy/molecules.good.json');
38
39
  const result = await loader.load();
39
40
  expect(result).toBeInstanceOf(LoaderResult);
40
41
  const payload = result.data;
@@ -1,5 +1,9 @@
1
1
  import { viv } from '@vitessce/gl';
2
- import { initializeRasterLayersAndChannels } from '@vitessce/spatial-utils';
2
+ import {
3
+ initializeRasterLayersAndChannels,
4
+ coordinateTransformationsToMatrix,
5
+ getNgffAxes,
6
+ } from '@vitessce/spatial-utils';
3
7
  import { openArray } from 'zarr';
4
8
  import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
5
9
  import { rasterJsonSchema as rasterSchema } from '@vitessce/schemas';
@@ -66,6 +70,49 @@ async function initLoader(imageData) {
66
70
  : [Channels.Name || `Channel ${0}`];
67
71
  return { ...loader, channels };
68
72
  }
73
+ case ('ome-zarr'): {
74
+ // Reference: https://github.com/vitessce/vitessce-python/issues/242#issuecomment-1517930964
75
+ // Most of the following has been copied from OmeZarrLoader.js.
76
+ // Reference: https://github.com/vitessce/vitessce/blob/fb0e7f/packages/file-types/zarr/src/ome-loaders/OmeZarrLoader.js#L29
77
+ const { coordinateTransformations: coordinateTransformationsFromOptions } = metadata || {};
78
+
79
+ const loader = await viv.loadOmeZarr(url, { fetchOptions: requestInit, type: 'multiscales' });
80
+ const { metadata: loaderMetadata } = loader;
81
+
82
+ const { omero, multiscales } = loaderMetadata;
83
+
84
+ if (!Array.isArray(multiscales) || multiscales.length === 0) {
85
+ console.error('Multiscales array must exist and have at least one element');
86
+ }
87
+ const { coordinateTransformations } = multiscales[0];
88
+
89
+ // Axes in v0.4 format.
90
+ const axes = getNgffAxes(multiscales[0].axes);
91
+
92
+ const transformMatrixFromOptions = coordinateTransformationsToMatrix(
93
+ coordinateTransformationsFromOptions, axes,
94
+ );
95
+ const transformMatrixFromFile = coordinateTransformationsToMatrix(
96
+ coordinateTransformations, axes,
97
+ );
98
+
99
+ const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
100
+
101
+ const { channels, name: omeroName } = omero;
102
+
103
+ return {
104
+ name: omeroName || 'Image',
105
+ channels: channels.map((c, i) => c.label || `Channel ${i}`),
106
+ ...(transformMatrix ? {
107
+ metadata: {
108
+ transform: {
109
+ matrix: transformMatrix,
110
+ },
111
+ },
112
+ } : {}),
113
+ ...loader,
114
+ };
115
+ }
69
116
  default: {
70
117
  throw Error(`Image type (${type}) is not supported`);
71
118
  }
@@ -94,7 +141,7 @@ export default class RasterLoader extends JsonLoader {
94
141
  // Get image name and URL tuples.
95
142
  const urls = images
96
143
  .filter(image => !image.url.includes('zarr'))
97
- .map(image => ([image.url, image.name]));
144
+ .map(image => ({ url: image.url, name: image.name }));
98
145
 
99
146
  // Add a loaderCreator function for each image layer.
100
147
  const imagesWithLoaderCreators = images.map(image => ({