omezarr-tilesource 0.2.0 → 0.4.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.
- package/README.md +77 -7
- package/dist/{__vite-browser-external-BIIyDRRX.js → __vite-browser-external-B2tgTj77.js} +1 -1
- package/dist/{__vite-browser-external-YbutIfMq-Cv1_GH0S.js → __vite-browser-external-YbutIfMq-DmIpWUUk.js} +1 -1
- package/dist/dist-DXBnbeGc.js +90 -0
- package/dist/omezarr-tilesource.d.ts +29 -23
- package/dist/omezarr-tilesource.js +1759 -61283
- package/dist/omezarr-tilesource.umd.cjs +8 -8
- package/dist/{png-K1gqQ34g-FkA_MCNO.js → png-K1gqQ34g-aB7GLn6k.js} +245 -245
- package/package.json +5 -5
- package/dist/chunk-BXES_1_E.js +0 -13
- package/dist/dist-DIvEDGnZ.js +0 -87
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ An OpenSeadragon tile source for the OME-Zarr bioimage file format
|
|
|
12
12
|
|
|
13
13
|
## Prerequisites
|
|
14
14
|
|
|
15
|
-
OpenSeadragon
|
|
15
|
+
OpenSeadragon 6 or newer
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -39,9 +39,11 @@ const tileSource2 = {
|
|
|
39
39
|
type: "ome-zarr",
|
|
40
40
|
url: url,
|
|
41
41
|
// zip: undefined, // undefined = OME-Zarr ZIP auto-detection based on .ozx suffix
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
42
|
+
// c: undefined, // undefined = composite of all active channels (requires dataType "context2d")
|
|
43
|
+
// z: undefined, // undefined = omero rdefs default (middle z-slice if missing)
|
|
44
|
+
// t: undefined, // undefined = omero rdefs default (middle timepoint if missing)
|
|
45
|
+
// dataType: undefined, // "context2d" (default, rendered tiles) or "ome-zarr" (raw single-channel chunks)
|
|
46
|
+
// autoBoost: undefined // boost brightness of dark tiles (default false)
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
// direct instantiation with URL (works with any OME-Zarr storage backend)
|
|
@@ -51,9 +53,11 @@ const tileSource3 = new OMEZarrTileSource(url);
|
|
|
51
53
|
const tileSource4 = new OMEZarrTileSource({
|
|
52
54
|
url: url,
|
|
53
55
|
// zip: undefined, // undefined = OME-Zarr ZIP auto-detection based on .ozx suffix
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
56
|
+
// c: undefined, // undefined = composite of all active channels (requires dataType "context2d")
|
|
57
|
+
// z: undefined, // undefined = omero rdefs default (middle z-slice if missing)
|
|
58
|
+
// t: undefined, // undefined = omero rdefs default (middle timepoint if missing)
|
|
59
|
+
// dataType: undefined, // "context2d" (default, rendered tiles) or "ome-zarr" (raw single-channel chunks)
|
|
60
|
+
// autoBoost: undefined // boost brightness of dark tiles (default false)
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
const viewer = OpenSeadragon(
|
|
@@ -67,6 +71,72 @@ const viewer = OpenSeadragon(
|
|
|
67
71
|
);
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
### Accessing OME-Zarr metadata
|
|
75
|
+
|
|
76
|
+
Directly instantiated tile sources start loading the OME-Zarr metadata
|
|
77
|
+
immediately. Await `whenReady()` (or use the `OMEZarrTileSource.open` shortcut)
|
|
78
|
+
to access the `NgffImage` instance (ome-zarr.js) and the opened zarrita arrays
|
|
79
|
+
(one per resolution level) before adding the tile source to a viewer:
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const tileSource = await OMEZarrTileSource.open({ url: url, c: 0 });
|
|
83
|
+
// equivalent: await new OMEZarrTileSource({ url: url, c: 0 }).whenReady();
|
|
84
|
+
|
|
85
|
+
console.log(tileSource.image.getAxesNames()); // e.g. ["t", "z", "c", "y", "x"]
|
|
86
|
+
console.log(tileSource.image.omero?.channels); // omero channel metadata
|
|
87
|
+
console.log(tileSource.arrays[0].shape); // full-resolution array shape
|
|
88
|
+
|
|
89
|
+
viewer.addTiledImage({ tileSource: tileSource }); // no second metadata request
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The metadata is loaded once per tile source instance: OpenSeadragon reuses a
|
|
93
|
+
tile source instance passed to it as-is (waiting for it to become ready if
|
|
94
|
+
necessary), whereas a URL or an inline configuration object makes OpenSeadragon
|
|
95
|
+
create (and load) a new instance. `whenReady()` rejects (and `image`/`arrays`
|
|
96
|
+
throw) if loading fails.
|
|
97
|
+
|
|
98
|
+
### Sharing OME-Zarr metadata between tile sources
|
|
99
|
+
|
|
100
|
+
A loaded `NgffImage` can be reused by other directly instantiated tile sources
|
|
101
|
+
for the same URL (e.g. one tile source per channel) by passing it as the second
|
|
102
|
+
constructor argument (also supported by `OMEZarrTileSource.open`). This skips
|
|
103
|
+
loading the OME-Zarr metadata (the `zip` option is ignored) and reuses the
|
|
104
|
+
opened zarrita arrays, which ome-zarr.js caches on the `NgffImage` instance.
|
|
105
|
+
The tile source never modifies the `NgffImage`, so sharing is safe:
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
const tileSource1 = await OMEZarrTileSource.open({ url: url, c: 0 });
|
|
109
|
+
const tileSource2 = new OMEZarrTileSource(
|
|
110
|
+
{ url: url, c: 1 },
|
|
111
|
+
tileSource1.image,
|
|
112
|
+
);
|
|
113
|
+
// or, without a first tile source: NgffImage.load(url) from ome-zarr.js
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Data pipeline
|
|
117
|
+
|
|
118
|
+
By default (`dataType: "context2d"`), tiles are rendered by the tile source and
|
|
119
|
+
passed to OpenSeadragon as 2D canvas contexts, using the rendering settings
|
|
120
|
+
(color, color LUT/map, contrast limits, inversion) from the omero metadata. For
|
|
121
|
+
multi-channel images without `c`, all active channels are rendered into a
|
|
122
|
+
composite image.
|
|
123
|
+
|
|
124
|
+
Contrast limits are taken from the omero channel windows (`window.start`,
|
|
125
|
+
`window.end`). Channels without them are rendered using the data type range
|
|
126
|
+
for integer types (e.g. `[0, 65535]` for `uint16`) and `[0, 1]` for floating
|
|
127
|
+
point types.
|
|
128
|
+
|
|
129
|
+
With `dataType: "ome-zarr"`, tiles are instead downloaded as raw single-channel
|
|
130
|
+
zarrita chunks and passed to OpenSeadragon with the data type `ome-zarr` (see
|
|
131
|
+
the `OMEZarrTileData` type). Multi-channel images therefore require the `c`
|
|
132
|
+
option. A converter from `ome-zarr` to `context2d` is registered on
|
|
133
|
+
`OpenSeadragon.converter` when the module is imported (and by
|
|
134
|
+
`OMEZarrTileSource.enable`). It reads the rendering settings at conversion time
|
|
135
|
+
from the omero channel referenced by the tile data (`OMEZarrTileData.channel`).
|
|
136
|
+
The channel object is shared by all tiles of a tile source, so advanced users
|
|
137
|
+
may modify it (e.g. from a `tile-invalidated` handler) and re-render the cached
|
|
138
|
+
tiles using `viewer.requestInvalidate()`.
|
|
139
|
+
|
|
70
140
|
## Example
|
|
71
141
|
|
|
72
142
|
[Example](https://tissuumaps.github.io/OMEZarrTileSource)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/ome-zarr.js@0.0.
|
|
1
|
+
//#region node_modules/.pnpm/ome-zarr.js@0.0.20/node_modules/ome-zarr.js/dist/__vite-browser-external-YbutIfMq.js
|
|
2
2
|
var e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
default: {}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/vite-plugin-node-polyfills@0.28.0_vite@8.0.14_yaml@2.9.0_/node_modules/vite-plugin-node-polyfills/shims/process/dist/index.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
+
}
|
|
5
|
+
var t = { exports: {} }, n = t.exports = {}, r, i;
|
|
6
|
+
function a() {
|
|
7
|
+
throw Error("setTimeout has not been defined");
|
|
8
|
+
}
|
|
9
|
+
function o() {
|
|
10
|
+
throw Error("clearTimeout has not been defined");
|
|
11
|
+
}
|
|
12
|
+
(function() {
|
|
13
|
+
try {
|
|
14
|
+
r = typeof setTimeout == "function" ? setTimeout : a;
|
|
15
|
+
} catch {
|
|
16
|
+
r = a;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
i = typeof clearTimeout == "function" ? clearTimeout : o;
|
|
20
|
+
} catch {
|
|
21
|
+
i = o;
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
24
|
+
function s(e) {
|
|
25
|
+
if (r === setTimeout) return setTimeout(e, 0);
|
|
26
|
+
if ((r === a || !r) && setTimeout) return r = setTimeout, setTimeout(e, 0);
|
|
27
|
+
try {
|
|
28
|
+
return r(e, 0);
|
|
29
|
+
} catch {
|
|
30
|
+
try {
|
|
31
|
+
return r.call(null, e, 0);
|
|
32
|
+
} catch {
|
|
33
|
+
return r.call(this, e, 0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function c(e) {
|
|
38
|
+
if (i === clearTimeout) return clearTimeout(e);
|
|
39
|
+
if ((i === o || !i) && clearTimeout) return i = clearTimeout, clearTimeout(e);
|
|
40
|
+
try {
|
|
41
|
+
return i(e);
|
|
42
|
+
} catch {
|
|
43
|
+
try {
|
|
44
|
+
return i.call(null, e);
|
|
45
|
+
} catch {
|
|
46
|
+
return i.call(this, e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var l = [], u = !1, d, f = -1;
|
|
51
|
+
function p() {
|
|
52
|
+
!u || !d || (u = !1, d.length ? l = d.concat(l) : f = -1, l.length && m());
|
|
53
|
+
}
|
|
54
|
+
function m() {
|
|
55
|
+
if (!u) {
|
|
56
|
+
var e = s(p);
|
|
57
|
+
u = !0;
|
|
58
|
+
for (var t = l.length; t;) {
|
|
59
|
+
for (d = l, l = []; ++f < t;) d && d[f].run();
|
|
60
|
+
f = -1, t = l.length;
|
|
61
|
+
}
|
|
62
|
+
d = null, u = !1, c(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
n.nextTick = function(e) {
|
|
66
|
+
var t = Array(arguments.length - 1);
|
|
67
|
+
if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
|
|
68
|
+
l.push(new h(e, t)), l.length === 1 && !u && s(m);
|
|
69
|
+
};
|
|
70
|
+
function h(e, t) {
|
|
71
|
+
this.fun = e, this.array = t;
|
|
72
|
+
}
|
|
73
|
+
h.prototype.run = function() {
|
|
74
|
+
this.fun.apply(null, this.array);
|
|
75
|
+
}, n.title = "browser", n.browser = !0, n.env = {}, n.argv = [], n.version = "", n.versions = {};
|
|
76
|
+
function g() {}
|
|
77
|
+
n.on = g, n.addListener = g, n.once = g, n.off = g, n.removeListener = g, n.removeAllListeners = g, n.emit = g, n.prependListener = g, n.prependOnceListener = g, n.listeners = function(e) {
|
|
78
|
+
return [];
|
|
79
|
+
}, n.binding = function(e) {
|
|
80
|
+
throw Error("process.binding is not supported");
|
|
81
|
+
}, n.cwd = function() {
|
|
82
|
+
return "/";
|
|
83
|
+
}, n.chdir = function(e) {
|
|
84
|
+
throw Error("process.chdir is not supported");
|
|
85
|
+
}, n.umask = function() {
|
|
86
|
+
return 0;
|
|
87
|
+
};
|
|
88
|
+
var _ = t.exports, v = /* @__PURE__ */ e(_);
|
|
89
|
+
//#endregion
|
|
90
|
+
export { v as t };
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
+
import { Channel } from 'ome-zarr.js';
|
|
1
2
|
import { default as default_2 } from 'openseadragon';
|
|
3
|
+
import { NgffImage } from 'ome-zarr.js';
|
|
4
|
+
import * as zarr from 'zarrita';
|
|
5
|
+
|
|
6
|
+
export declare interface OMEZarrTileData {
|
|
7
|
+
chunk: zarr.Chunk<zarr.NumberDataType | zarr.BigintDataType>;
|
|
8
|
+
channel: Channel;
|
|
9
|
+
autoBoost?: boolean;
|
|
10
|
+
}
|
|
2
11
|
|
|
3
12
|
export declare class OMEZarrTileSource extends default_2.TileSource {
|
|
4
|
-
static readonly DUMMY_XHR: XMLHttpRequest;
|
|
5
13
|
readonly url: string;
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
aspectRatio: number;
|
|
9
|
-
dimensions: default_2.Point;
|
|
10
|
-
maxLevel: number;
|
|
11
|
-
ready: boolean;
|
|
12
14
|
readonly zip?: boolean;
|
|
13
|
-
readonly t?: number;
|
|
14
15
|
readonly c?: number;
|
|
15
16
|
readonly z?: number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
readonly t?: number;
|
|
18
|
+
readonly dataType: "ome-zarr" | "context2d";
|
|
19
|
+
readonly autoBoost?: boolean;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
private _image?;
|
|
19
23
|
private _arrays?;
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
private readonly _readyPromise;
|
|
25
|
+
static open(config: string | OMEZarrTileSourceOptions, image?: NgffImage): Promise<OMEZarrTileSource>;
|
|
26
|
+
constructor(url: string, image?: NgffImage);
|
|
27
|
+
constructor(options: OMEZarrTileSourceOptions, image?: NgffImage);
|
|
28
|
+
get image(): NgffImage;
|
|
29
|
+
get arrays(): zarr.Array<zarr.NumberDataType | zarr.BigintDataType>[];
|
|
30
|
+
whenReady(): Promise<this>;
|
|
22
31
|
supports(data: string | object | object[] | Document): boolean;
|
|
23
32
|
configure(data: string | object | object[] | Document, _url: string, postData?: string | null): OMEZarrTileSourceOptions;
|
|
24
33
|
equals(other: default_2.TileSource): boolean;
|
|
@@ -31,24 +40,21 @@ export declare class OMEZarrTileSource extends default_2.TileSource {
|
|
|
31
40
|
downloadTileStart(context: default_2.ImageJob): void;
|
|
32
41
|
downloadTileAbort(context: default_2.ImageJob): void;
|
|
33
42
|
static enable(os?: typeof default_2): void;
|
|
34
|
-
private static
|
|
35
|
-
private
|
|
43
|
+
private static _learnConverters;
|
|
44
|
+
private _getActiveChannelIndices;
|
|
45
|
+
private static _render;
|
|
46
|
+
private static _getDataTypeRange;
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
export declare type OMEZarrTileSourceClass = typeof OMEZarrTileSource;
|
|
39
|
-
|
|
40
49
|
export declare interface OMEZarrTileSourceOptions {
|
|
41
50
|
type?: "ome-zarr";
|
|
42
51
|
url: string;
|
|
43
52
|
zip?: boolean;
|
|
44
|
-
t?: number;
|
|
45
53
|
c?: number;
|
|
46
54
|
z?: number;
|
|
55
|
+
t?: number;
|
|
56
|
+
dataType?: "ome-zarr" | "context2d";
|
|
57
|
+
autoBoost?: boolean;
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
export { }
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
declare module "openseadragon" {
|
|
53
|
-
let OMEZarrTileSource: OMEZarrTileSourceClass;
|
|
54
|
-
}
|