@vitessce/json 3.2.1 → 3.3.0

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 +1 @@
1
- {"version":3,"file":"RasterJsonLoader.d.ts","sourceRoot":"","sources":["../../src/raster-json-loaders/RasterJsonLoader.js"],"names":[],"mappings":"AAyHA;IAWE,qBAyCC;IAnBG,oBAIC;CAgBN"}
1
+ {"version":3,"file":"RasterJsonLoader.d.ts","sourceRoot":"","sources":["../../src/raster-json-loaders/RasterJsonLoader.js"],"names":[],"mappings":"AA6HA;IAWE,qBAyCC;IAnBG,oBAIC;CAgBN"}
@@ -1,6 +1,7 @@
1
1
  import { viv } from '@vitessce/gl';
2
- import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, } from '@vitessce/spatial-utils';
3
- import { openArray } from 'zarr';
2
+ import { initializeRasterLayersAndChannels, coordinateTransformationsToMatrix, getNgffAxes, loadOmeZarr, guessTileSize, ZarritaPixelSource, } from '@vitessce/spatial-utils';
3
+ import { open as zarrOpen } from 'zarrita';
4
+ import { zarrOpenRoot, createZarrArrayAdapter } from '@vitessce/zarr-utils';
4
5
  import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
5
6
  import { rasterJsonSchema as rasterSchema } from '@vitessce/schemas';
6
7
  import JsonLoader from '../json-loaders/JsonLoader.js';
@@ -8,9 +9,11 @@ async function initLoader(imageData) {
8
9
  const { type, url, metadata, requestInit, } = imageData;
9
10
  switch (type) {
10
11
  case ('zarr'): {
12
+ // Bioformats-Zarr case
11
13
  const { dimensions, isPyramid, transform, } = metadata || {};
12
14
  const labels = dimensions.map(d => d.field);
13
15
  let source;
16
+ const root = await zarrOpenRoot(url, requestInit);
14
17
  if (isPyramid) {
15
18
  const metadataUrl = `${url}${url.slice(-1) === '/' ? '' : '/'}.zmetadata`;
16
19
  const response = await fetch(metadataUrl);
@@ -18,16 +21,13 @@ async function initLoader(imageData) {
18
21
  const paths = Object.keys(zarrMetadata)
19
22
  .filter(metaKey => metaKey.includes('.zarray'))
20
23
  .map(arrMetaKeys => arrMetaKeys.slice(0, -7));
21
- const data = await Promise.all(paths.map(path => openArray({ store: url, path })));
22
- const [yChunk, xChunk] = data[0].chunks.slice(-2);
23
- const size = Math.min(yChunk, xChunk);
24
- // deck.gl requirement for power-of-two tile size.
25
- const tileSize = 2 ** Math.floor(Math.log2(size));
26
- source = data.map(d => new viv.ZarrPixelSource(d, labels, tileSize));
24
+ const data = await Promise.all(paths.map(path => zarrOpen(root.resolve(path), { kind: 'array' })));
25
+ const tileSize = guessTileSize(data[0]);
26
+ source = data.map(d => new ZarritaPixelSource(createZarrArrayAdapter(d), labels, tileSize));
27
27
  }
28
28
  else {
29
- const data = await openArray({ store: url });
30
- source = new viv.ZarrPixelSource(data, labels);
29
+ const data = await zarrOpen(root, { kind: 'array' });
30
+ source = new ZarritaPixelSource(createZarrArrayAdapter(data), labels);
31
31
  }
32
32
  return { data: source, metadata: { dimensions, transform }, channels: (dimensions.find(d => d.field === 'channel') || dimensions[0]).values };
33
33
  }
@@ -58,11 +58,12 @@ async function initLoader(imageData) {
58
58
  return { ...loader, channels };
59
59
  }
60
60
  case ('ome-zarr'): {
61
+ // OME-NGFF case
61
62
  // Reference: https://github.com/vitessce/vitessce-python/issues/242#issuecomment-1517930964
62
63
  // Most of the following has been copied from OmeZarrLoader.js.
63
64
  // Reference: https://github.com/vitessce/vitessce/blob/fb0e7f/packages/file-types/zarr/src/ome-loaders/OmeZarrLoader.js#L29
64
65
  const { coordinateTransformations: coordinateTransformationsFromOptions } = metadata || {};
65
- const loader = await viv.loadOmeZarr(url, { fetchOptions: requestInit, type: 'multiscales' });
66
+ const loader = await loadOmeZarr(url, requestInit);
66
67
  const { metadata: loaderMetadata } = loader;
67
68
  const { omero, multiscales } = loaderMetadata;
68
69
  if (!Array.isArray(multiscales) || multiscales.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/json",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -18,15 +18,16 @@
18
18
  "dependencies": {
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
- "zarr": "0.5.1",
21
+ "zarrita": "0.4.0-next.4",
22
22
  "zod": "^3.21.4",
23
- "@vitessce/constants-internal": "3.2.1",
24
- "@vitessce/gl": "3.2.1",
25
- "@vitessce/schemas": "3.2.1",
26
- "@vitessce/sets-utils": "3.2.1",
27
- "@vitessce/spatial-utils": "3.2.1",
28
- "@vitessce/utils": "3.2.1",
29
- "@vitessce/vit-s": "3.2.1"
23
+ "@vitessce/constants-internal": "3.3.0",
24
+ "@vitessce/schemas": "3.3.0",
25
+ "@vitessce/gl": "3.3.0",
26
+ "@vitessce/sets-utils": "3.3.0",
27
+ "@vitessce/spatial-utils": "3.3.0",
28
+ "@vitessce/utils": "3.3.0",
29
+ "@vitessce/vit-s": "3.3.0",
30
+ "@vitessce/zarr-utils": "3.3.0"
30
31
  },
31
32
  "scripts": {
32
33
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
@@ -3,8 +3,12 @@ import {
3
3
  initializeRasterLayersAndChannels,
4
4
  coordinateTransformationsToMatrix,
5
5
  getNgffAxes,
6
+ loadOmeZarr,
7
+ guessTileSize,
8
+ ZarritaPixelSource,
6
9
  } from '@vitessce/spatial-utils';
7
- import { openArray } from 'zarr';
10
+ import { open as zarrOpen } from 'zarrita';
11
+ import { zarrOpenRoot, createZarrArrayAdapter } from '@vitessce/zarr-utils';
8
12
  import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
9
13
  import { rasterJsonSchema as rasterSchema } from '@vitessce/schemas';
10
14
  import JsonLoader from '../json-loaders/JsonLoader.js';
@@ -15,11 +19,13 @@ async function initLoader(imageData) {
15
19
  } = imageData;
16
20
  switch (type) {
17
21
  case ('zarr'): {
22
+ // Bioformats-Zarr case
18
23
  const {
19
24
  dimensions, isPyramid, transform,
20
25
  } = metadata || {};
21
26
  const labels = dimensions.map(d => d.field);
22
27
  let source;
28
+ const root = await zarrOpenRoot(url, requestInit);
23
29
  if (isPyramid) {
24
30
  const metadataUrl = `${url}${
25
31
  url.slice(-1) === '/' ? '' : '/'
@@ -30,16 +36,13 @@ async function initLoader(imageData) {
30
36
  .filter(metaKey => metaKey.includes('.zarray'))
31
37
  .map(arrMetaKeys => arrMetaKeys.slice(0, -7));
32
38
  const data = await Promise.all(
33
- paths.map(path => openArray({ store: url, path })),
39
+ paths.map(path => zarrOpen(root.resolve(path), { kind: 'array' })),
34
40
  );
35
- const [yChunk, xChunk] = data[0].chunks.slice(-2);
36
- const size = Math.min(yChunk, xChunk);
37
- // deck.gl requirement for power-of-two tile size.
38
- const tileSize = 2 ** Math.floor(Math.log2(size));
39
- source = data.map(d => new viv.ZarrPixelSource(d, labels, tileSize));
41
+ const tileSize = guessTileSize(data[0]);
42
+ source = data.map(d => new ZarritaPixelSource(createZarrArrayAdapter(d), labels, tileSize));
40
43
  } else {
41
- const data = await openArray({ store: url });
42
- source = new viv.ZarrPixelSource(data, labels);
44
+ const data = await zarrOpen(root, { kind: 'array' });
45
+ source = new ZarritaPixelSource(createZarrArrayAdapter(data), labels);
43
46
  }
44
47
  return { data: source, metadata: { dimensions, transform }, channels: (dimensions.find(d => d.field === 'channel') || dimensions[0]).values };
45
48
  }
@@ -71,12 +74,13 @@ async function initLoader(imageData) {
71
74
  return { ...loader, channels };
72
75
  }
73
76
  case ('ome-zarr'): {
77
+ // OME-NGFF case
74
78
  // Reference: https://github.com/vitessce/vitessce-python/issues/242#issuecomment-1517930964
75
79
  // Most of the following has been copied from OmeZarrLoader.js.
76
80
  // Reference: https://github.com/vitessce/vitessce/blob/fb0e7f/packages/file-types/zarr/src/ome-loaders/OmeZarrLoader.js#L29
77
81
  const { coordinateTransformations: coordinateTransformationsFromOptions } = metadata || {};
78
82
 
79
- const loader = await viv.loadOmeZarr(url, { fetchOptions: requestInit, type: 'multiscales' });
83
+ const loader = await loadOmeZarr(url, requestInit);
80
84
  const { metadata: loaderMetadata } = loader;
81
85
 
82
86
  const { omero, multiscales } = loaderMetadata;