omezarr-tilesource 0.4.0 → 0.6.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 +181 -54
- package/dist/omezarr-tilesource.d.ts +506 -24
- package/dist/omezarr-tilesource.js +209 -2779
- package/package.json +10 -11
- package/dist/__vite-browser-external-B2tgTj77.js +0 -7
- package/dist/__vite-browser-external-YbutIfMq-DmIpWUUk.js +0 -7
- package/dist/blosc-D7C3XedS.js +0 -692
- package/dist/chunk-INHXZS53-DODoS5wr.js +0 -13
- package/dist/dist-DXBnbeGc.js +0 -90
- package/dist/lz4-O6H78S8a.js +0 -626
- package/dist/omezarr-tilesource.umd.cjs +0 -45
- package/dist/png-K1gqQ34g-aB7GLn6k.js +0 -1950
- package/dist/zstd-GeB6dyr_.js +0 -583
|
@@ -3,58 +3,540 @@ import { default as default_2 } from 'openseadragon';
|
|
|
3
3
|
import { NgffImage } from 'ome-zarr.js';
|
|
4
4
|
import * as zarr from 'zarrita';
|
|
5
5
|
|
|
6
|
+
/** An RGB color, each component in the range 0-255. */
|
|
7
|
+
export declare type Color = [number, number, number];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 32-bit FNV-1a hash of a string, over its UTF-16 code units.
|
|
11
|
+
*
|
|
12
|
+
* @param text - Text to hash
|
|
13
|
+
* @returns The hash, as an unsigned 32-bit integer
|
|
14
|
+
*/
|
|
15
|
+
export declare function fnv1a(text: string): number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Value range of a chunk's data type, used when a channel has no window.
|
|
19
|
+
*
|
|
20
|
+
* @param chunk - Chunk to get the data type range of
|
|
21
|
+
* @returns The minimum and maximum value of the data type (`[0, 1]` for
|
|
22
|
+
* floating point and boolean data)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDataTypeRange(chunk: zarr.Chunk<zarr.NumberDataType | zarr.BigintDataType>): [number, number];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether a URL points to a zipped OME-Zarr file (`.ozx` path suffix, ignoring
|
|
28
|
+
* any query and fragment).
|
|
29
|
+
*
|
|
30
|
+
* @param url - URL to check, as a string or a `URL`
|
|
31
|
+
* @returns Whether the URL path ends in `.ozx`
|
|
32
|
+
*/
|
|
33
|
+
export declare function isOZX(url: string | URL): boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A color LUT (a color per scaled value, e.g. 256 entries) or a color map (a
|
|
37
|
+
* color per raw pixel value), as used by the omero channels.
|
|
38
|
+
*
|
|
39
|
+
* Unlike {@link Color}, the colors may carry an alpha component, e.g. to render
|
|
40
|
+
* unmapped label values transparently.
|
|
41
|
+
*/
|
|
42
|
+
export declare type LUTOrColorMap = (Color | [number, number, number, number])[] | Map<number, Color | [number, number, number, number]>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A loaded OME-Zarr image: the ome-zarr.js {@link NgffImage} holding the
|
|
46
|
+
* metadata and the opened zarrita arrays of its multiscale pyramid.
|
|
47
|
+
*
|
|
48
|
+
* Created by {@link OMEZarrTileSource.loadOMEZarr} and exposed by
|
|
49
|
+
* {@link OMEZarrTileSource.loaded}. Can be passed to the constructor or to
|
|
50
|
+
* {@link OMEZarrTileSource.open} to share one metadata load across several
|
|
51
|
+
* tile sources for the same URL. The tile source never modifies it.
|
|
52
|
+
*/
|
|
53
|
+
export declare type OMEZarr = {
|
|
54
|
+
/** OME-Zarr metadata (multiscales, axes, omero) */
|
|
55
|
+
image: NgffImage;
|
|
56
|
+
/** One array per resolution level, highest resolution first */
|
|
57
|
+
arrays: zarr.Array<zarr.NumberDataType | zarr.BigintDataType>[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Tile data of the OpenSeadragon data type `ome-zarr`.
|
|
62
|
+
*
|
|
63
|
+
* Every tile is finished with this raw data type; the converter registered by
|
|
64
|
+
* {@link OMEZarrTileSource.enable} (and on import) renders it to `context2d`
|
|
65
|
+
* on demand, so cached tiles can be re-rendered without re-downloading them.
|
|
66
|
+
*
|
|
67
|
+
* The rendering settings are the arguments of ome-zarr.js `renderChunks`, one
|
|
68
|
+
* entry per chunk, fully resolved from the tile source configuration and the
|
|
69
|
+
* omero metadata when the tile was downloaded — so changing either requires
|
|
70
|
+
* re-downloading the tiles.
|
|
71
|
+
*/
|
|
6
72
|
export declare interface OMEZarrTileData {
|
|
7
|
-
chunk
|
|
8
|
-
|
|
9
|
-
|
|
73
|
+
/** One (y, x) chunk per rendered channel, in {@link OMEZarrTileSource.cs} order */
|
|
74
|
+
chunks: zarr.Chunk<zarr.NumberDataType | zarr.BigintDataType>[];
|
|
75
|
+
/**
|
|
76
|
+
* The contrast limits (`[min, max]`) of each chunk
|
|
77
|
+
* ({@link OMEZarrTileSource.ranges}), falling back to the data type range of
|
|
78
|
+
* the chunk. `min` is always less than `max`.
|
|
79
|
+
*/
|
|
80
|
+
ranges: [number, number][];
|
|
81
|
+
/**
|
|
82
|
+
* The RGB color of each chunk ({@link OMEZarrTileSource.colors}), falling
|
|
83
|
+
* back to white. Unused for chunks with a LUT or a color map.
|
|
84
|
+
*/
|
|
85
|
+
colors: Color[];
|
|
86
|
+
/**
|
|
87
|
+
* The color LUT or color map of each chunk
|
|
88
|
+
* ({@link OMEZarrTileSource.lutsOrColorMaps}). `undefined` entries are
|
|
89
|
+
* rendered with their {@link colors} entry instead.
|
|
90
|
+
*/
|
|
91
|
+
lutsOrColorMaps: (LUTOrColorMap | undefined)[];
|
|
92
|
+
/**
|
|
93
|
+
* Whether to invert each chunk ({@link OMEZarrTileSource.inverteds}), falling
|
|
94
|
+
* back to `false`.
|
|
95
|
+
*/
|
|
96
|
+
inverteds: boolean[];
|
|
97
|
+
/** Boost the brightness of dark tiles (ome-zarr.js `renderChunks` option) */
|
|
98
|
+
autoBoost: boolean;
|
|
10
99
|
}
|
|
11
100
|
|
|
101
|
+
/**
|
|
102
|
+
* OpenSeadragon tile source for the OME-Zarr bioimage file format.
|
|
103
|
+
*
|
|
104
|
+
* Tiles correspond to the chunks of the multiscale pyramid stored in the
|
|
105
|
+
* OME-Zarr image; OpenSeadragon level 0 is the lowest resolution and
|
|
106
|
+
* `maxLevel` the highest. Tiles are delivered as raw `ome-zarr` data (see
|
|
107
|
+
* {@link OMEZarrTileData}) and rendered by a registered converter.
|
|
108
|
+
*
|
|
109
|
+
* Constructing a tile source starts loading the OME-Zarr metadata
|
|
110
|
+
* asynchronously (unless an {@link OMEZarr} is passed). Await
|
|
111
|
+
* {@link OMEZarrTileSource.whenReady} or use {@link OMEZarrTileSource.open}
|
|
112
|
+
* before accessing {@link OMEZarrTileSource.loaded} and the resolved
|
|
113
|
+
* {@link OMEZarrTileSource.t}, {@link OMEZarrTileSource.z},
|
|
114
|
+
* {@link OMEZarrTileSource.cs}, {@link OMEZarrTileSource.channels},
|
|
115
|
+
* {@link OMEZarrTileSource.ranges}, {@link OMEZarrTileSource.colors},
|
|
116
|
+
* {@link OMEZarrTileSource.lutsOrColorMaps} and
|
|
117
|
+
* {@link OMEZarrTileSource.inverteds}.
|
|
118
|
+
*
|
|
119
|
+
* Importing this module registers the `ome-zarr` converters on the imported
|
|
120
|
+
* OpenSeadragon instance (and on a global `OpenSeadragon`, if present). Call
|
|
121
|
+
* {@link OMEZarrTileSource.enable} for any other OpenSeadragon instance, and to
|
|
122
|
+
* register the tile source for inline configurations.
|
|
123
|
+
*/
|
|
12
124
|
export declare class OMEZarrTileSource extends default_2.TileSource {
|
|
13
125
|
readonly url: string;
|
|
14
|
-
readonly zip
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
126
|
+
readonly zip: boolean;
|
|
127
|
+
private readonly _t?;
|
|
128
|
+
private readonly _z?;
|
|
129
|
+
private readonly _c?;
|
|
130
|
+
private readonly _renderSettings;
|
|
131
|
+
private readonly _renderSettingsHash;
|
|
20
132
|
width: number;
|
|
21
133
|
height: number;
|
|
22
|
-
private
|
|
23
|
-
private _arrays?;
|
|
134
|
+
private _loaded?;
|
|
24
135
|
private readonly _readyPromise;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Registers the tile source and its `ome-zarr` data type converters with an
|
|
138
|
+
* OpenSeadragon instance.
|
|
139
|
+
*
|
|
140
|
+
* Required for inline configurations (`{ type: "ome-zarr", ... }`) and for
|
|
141
|
+
* rendering tiles with an OpenSeadragon instance other than the one imported
|
|
142
|
+
* by this module.
|
|
143
|
+
*
|
|
144
|
+
* @param os - The OpenSeadragon module to register with
|
|
145
|
+
*/
|
|
146
|
+
static enable(os?: typeof default_2): void;
|
|
147
|
+
/**
|
|
148
|
+
* Loads the OME-Zarr metadata and opens the arrays of all resolution levels.
|
|
149
|
+
*
|
|
150
|
+
* The result can be passed to the constructor or to {@link open} to share one
|
|
151
|
+
* metadata load across several tile sources for the same URL.
|
|
152
|
+
*
|
|
153
|
+
* @param url - URL of the OME-Zarr image or zipped OME-Zarr file, as a string
|
|
154
|
+
* or a `URL`; relative URLs are resolved against the document base URL
|
|
155
|
+
* @param zip - Whether the URL points to a zipped OME-Zarr file; defaults to
|
|
156
|
+
* `true` for URLs whose path ends in `.ozx`
|
|
157
|
+
* @param options - `signal` aborts the load
|
|
158
|
+
* @returns The loaded image and its arrays, highest resolution first
|
|
159
|
+
* @throws If the URL is relative and there is no document base URL
|
|
160
|
+
*/
|
|
161
|
+
static loadOMEZarr(url: string | URL, zip?: boolean, options?: {
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
}): Promise<OMEZarr>;
|
|
164
|
+
/**
|
|
165
|
+
* Constructs a tile source and waits until its OME-Zarr metadata is loaded.
|
|
166
|
+
*
|
|
167
|
+
* Equivalent to `new OMEZarrTileSource(config, loaded).whenReady()`, except
|
|
168
|
+
* that loading the metadata can be aborted with `signal`.
|
|
169
|
+
*
|
|
170
|
+
* @param config - URL or {@link OMEZarrTileSourceOptions}
|
|
171
|
+
* @param loaded - Previously loaded image of the same URL to reuse instead of
|
|
172
|
+
* loading it
|
|
173
|
+
* @param options - `signal` aborts the load
|
|
174
|
+
* @returns The ready tile source; rejects if loading or validation fails
|
|
175
|
+
*/
|
|
176
|
+
static open(config: string | URL | OMEZarrTileSourceOptions, loaded?: OMEZarr, options?: {
|
|
177
|
+
signal?: AbortSignal;
|
|
178
|
+
}): Promise<OMEZarrTileSource>;
|
|
179
|
+
/**
|
|
180
|
+
* Renders `ome-zarr` tile data into a composite 2D canvas context.
|
|
181
|
+
*
|
|
182
|
+
* Called by the `ome-zarr` to `context2d` converter registered by
|
|
183
|
+
* {@link enable} (and on import), and usable directly for rendering chunks
|
|
184
|
+
* loaded with {@link loadChunks} outside of OpenSeadragon.
|
|
185
|
+
*
|
|
186
|
+
* The tile data holds the rendering settings exactly as passed to ome-zarr.js
|
|
187
|
+
* `renderChunks`: each chunk is scaled to its {@link OMEZarrTileData.ranges}
|
|
188
|
+
* entry, colorized with its {@link OMEZarrTileData.colors} entry or with its
|
|
189
|
+
* {@link OMEZarrTileData.lutsOrColorMaps} entry, inverted if its
|
|
190
|
+
* {@link OMEZarrTileData.inverteds} entry is set, and the results are blended
|
|
191
|
+
* additively. Color maps ignore the range and the inversion.
|
|
192
|
+
*
|
|
193
|
+
* @param tileData - Chunks and rendering settings of one tile
|
|
194
|
+
* @returns A 2D canvas context of the chunk size holding the composite
|
|
195
|
+
* @throws If the chunks are empty or no 2D canvas context is available
|
|
196
|
+
*/
|
|
197
|
+
static render(tileData: OMEZarrTileData): CanvasRenderingContext2D;
|
|
198
|
+
/**
|
|
199
|
+
* Creates a tile source and starts loading the OME-Zarr metadata (unless
|
|
200
|
+
* `loaded` is given), raising `ready` or `open-failed` asynchronously.
|
|
201
|
+
*
|
|
202
|
+
* @param url - URL of the OME-Zarr image, as a string or a `URL`, resolved
|
|
203
|
+
* against the document base URL; zipped files are detected by the `.ozx`
|
|
204
|
+
* path suffix
|
|
205
|
+
* @param loaded - Previously loaded image of the same URL to reuse instead of
|
|
206
|
+
* loading it
|
|
207
|
+
* @throws If the URL cannot be resolved
|
|
208
|
+
*/
|
|
209
|
+
constructor(url: string | URL, loaded?: OMEZarr);
|
|
210
|
+
/**
|
|
211
|
+
* Creates a tile source and starts loading the OME-Zarr metadata (unless
|
|
212
|
+
* `loaded` is given), raising `ready` or `open-failed` asynchronously.
|
|
213
|
+
*
|
|
214
|
+
* @param options - Tile source configuration
|
|
215
|
+
* @param loaded - Previously loaded image of the same URL to reuse instead of
|
|
216
|
+
* loading it
|
|
217
|
+
* @throws If the configuration is invalid or the URL cannot be resolved */
|
|
218
|
+
constructor(options: OMEZarrTileSourceOptions, loaded?: OMEZarr);
|
|
219
|
+
/**
|
|
220
|
+
* The loaded OME-Zarr image and arrays.
|
|
221
|
+
*
|
|
222
|
+
* @throws If the tile source is not ready yet (or failed to load)
|
|
223
|
+
*/
|
|
224
|
+
get loaded(): OMEZarr;
|
|
225
|
+
/**
|
|
226
|
+
* The rendered timepoint index: the configured `t`, otherwise the omero
|
|
227
|
+
* `rdefs.defaultT` once loaded, otherwise `undefined` (middle timepoint).
|
|
228
|
+
*/
|
|
229
|
+
get t(): number | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* The rendered z-slice index: the configured `z`, otherwise the omero
|
|
232
|
+
* `rdefs.defaultZ` once loaded, otherwise `undefined` (middle z-slice).
|
|
233
|
+
*/
|
|
234
|
+
get z(): number | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* The rendered channel indices: the configured `c` option (as an array, even if a
|
|
237
|
+
* single index was configured), otherwise the indices of all channels marked
|
|
238
|
+
* active in the omero metadata once loaded, otherwise `undefined` (all
|
|
239
|
+
* channels).
|
|
240
|
+
*/
|
|
241
|
+
get cs(): number[] | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* The omero channels of the rendered channels ({@link cs}): one entry per
|
|
244
|
+
* rendered channel, `undefined` for channels that the omero metadata does
|
|
245
|
+
* not cover.
|
|
246
|
+
*
|
|
247
|
+
* `undefined` instead of the whole array if `c` was not configured and the
|
|
248
|
+
* tile source is not ready or the image has no omero metadata.
|
|
249
|
+
*/
|
|
250
|
+
get channels(): (Channel | undefined)[] | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* The contrast limits (`[min, max]`) of the rendered channels ({@link cs}):
|
|
253
|
+
* the configured `ranges` (as an array, even if a single range was
|
|
254
|
+
* configured), otherwise the windows of the corresponding omero
|
|
255
|
+
* {@link channels}, and `undefined` wherever those are.
|
|
256
|
+
*
|
|
257
|
+
* Channels without contrast limits (`undefined` entries, or `undefined`
|
|
258
|
+
* instead of the whole array) are rendered with their data type range.
|
|
259
|
+
*/
|
|
260
|
+
get ranges(): ([number, number] | undefined)[] | undefined;
|
|
261
|
+
/**
|
|
262
|
+
* The RGB colors of the rendered channels ({@link cs}): the configured
|
|
263
|
+
* `colors` (as an array, even if a single color was configured), otherwise
|
|
264
|
+
* the colors of the corresponding omero {@link channels}, and `undefined`
|
|
265
|
+
* wherever those are.
|
|
266
|
+
*
|
|
267
|
+
* Channels without a color (`undefined` entries, or `undefined` instead of
|
|
268
|
+
* the whole array) are rendered in white.
|
|
269
|
+
*/
|
|
270
|
+
get colors(): (Color | undefined)[] | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* The color LUTs and color maps of the rendered channels ({@link cs}): the
|
|
273
|
+
* configured `lutsOrColorMaps` (as an array, even if a single LUT or color
|
|
274
|
+
* map was configured), otherwise those of the corresponding omero
|
|
275
|
+
* {@link channels}, and `undefined` wherever those are.
|
|
276
|
+
*
|
|
277
|
+
* Channels without a LUT or color map (`undefined` entries, or `undefined`
|
|
278
|
+
* instead of the whole array) are rendered with their {@link colors} entry.
|
|
279
|
+
*/
|
|
280
|
+
get lutsOrColorMaps(): (LUTOrColorMap | undefined)[] | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* Whether the rendered channels ({@link cs}) are inverted: the configured
|
|
283
|
+
* `inverteds` (as an array, even if a single value was configured),
|
|
284
|
+
* otherwise the inversion of the corresponding omero {@link channels}, and
|
|
285
|
+
* `undefined` wherever those are.
|
|
286
|
+
*
|
|
287
|
+
* Channels without an inversion (`undefined` entries, or `undefined` instead
|
|
288
|
+
* of the whole array) are not inverted.
|
|
289
|
+
*/
|
|
290
|
+
get inverteds(): (boolean | undefined)[] | undefined;
|
|
291
|
+
/** Whether the brightness of dark tiles is boosted (the configured `autoBoost`) */
|
|
292
|
+
get autoBoost(): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Waits until the OME-Zarr metadata is loaded and validated.
|
|
295
|
+
*
|
|
296
|
+
* @returns The tile source once `ready` has been raised; rejects with the
|
|
297
|
+
* `open-failed` message otherwise
|
|
298
|
+
*/
|
|
30
299
|
whenReady(): Promise<this>;
|
|
300
|
+
/**
|
|
301
|
+
* Width in pixels of a resolution level.
|
|
302
|
+
*
|
|
303
|
+
* @param level - OpenSeadragon level (0 = lowest resolution); defaults to
|
|
304
|
+
* `maxLevel` (full resolution)
|
|
305
|
+
* @throws If the tile source is not ready or the level is out of bounds
|
|
306
|
+
*/
|
|
307
|
+
getWidth(level?: number): number;
|
|
308
|
+
/**
|
|
309
|
+
* Height in pixels of a resolution level.
|
|
310
|
+
*
|
|
311
|
+
* @param level - OpenSeadragon level (0 = lowest resolution); defaults to
|
|
312
|
+
* `maxLevel` (full resolution)
|
|
313
|
+
* @throws If the tile source is not ready or the level is out of bounds
|
|
314
|
+
*/
|
|
315
|
+
getHeight(level?: number): number;
|
|
316
|
+
/**
|
|
317
|
+
* Loads the (y, x) chunks of the rendered channels ({@link cs}) at the rendered
|
|
318
|
+
* timepoint and z-slice ({@link t}, {@link z}).
|
|
319
|
+
*
|
|
320
|
+
* @param level - OpenSeadragon level (0 = lowest resolution)
|
|
321
|
+
* @param tile - Tile coordinates within the level, or `undefined` to load the
|
|
322
|
+
* whole level plane
|
|
323
|
+
* @param options - `signal` aborts the chunk requests
|
|
324
|
+
* @returns One chunk per rendered channel, in {@link cs} order
|
|
325
|
+
* @throws If the tile source is not ready or the level or tile is out of
|
|
326
|
+
* bounds
|
|
327
|
+
*/
|
|
328
|
+
loadChunks(level: number, tile: {
|
|
329
|
+
x: number;
|
|
330
|
+
y: number;
|
|
331
|
+
} | undefined, options?: {
|
|
332
|
+
signal?: AbortSignal;
|
|
333
|
+
}): Promise<zarr.Chunk<zarr.NumberDataType | zarr.BigintDataType>[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Whether OpenSeadragon should use this tile source for a configuration:
|
|
336
|
+
* URLs whose path ends in `.ozx` and objects with `type: "ome-zarr"`.
|
|
337
|
+
*/
|
|
31
338
|
supports(data: string | object | object[] | Document): boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Normalizes an OpenSeadragon configuration into
|
|
341
|
+
* {@link OMEZarrTileSourceOptions}.
|
|
342
|
+
*
|
|
343
|
+
* @throws For array, XML document and POST data configurations
|
|
344
|
+
*/
|
|
32
345
|
configure(data: string | object | object[] | Document, _url: string, postData?: string | null): OMEZarrTileSourceOptions;
|
|
346
|
+
/**
|
|
347
|
+
* Whether another tile source renders the same data: the URL, `zip`, the
|
|
348
|
+
* resolved {@link t}, {@link z} and {@link cs}, and the hash of the
|
|
349
|
+
* configured rendering settings.
|
|
350
|
+
*
|
|
351
|
+
* These are the components of {@link getTileHashKey}, so tile sources compare
|
|
352
|
+
* equal exactly when they share cached tiles. The resolved indices depend on
|
|
353
|
+
* the loaded metadata, so tile sources that are not ready yet compare by
|
|
354
|
+
* their configured indices.
|
|
355
|
+
*/
|
|
33
356
|
equals(other: default_2.TileSource): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Loads (or reuses) the OME-Zarr metadata, validates it against the
|
|
359
|
+
* configuration and raises `ready`, or raises `open-failed` on error.
|
|
360
|
+
*
|
|
361
|
+
* Called asynchronously by the OpenSeadragon `TileSource` constructor.
|
|
362
|
+
*/
|
|
34
363
|
getImageInfo(url: string): void;
|
|
364
|
+
/** Chunk width of a resolution level in pixels. */
|
|
35
365
|
getTileWidth(level: number): number;
|
|
366
|
+
/** Chunk height of a resolution level in pixels. */
|
|
36
367
|
getTileHeight(level: number): number;
|
|
368
|
+
/** Width of a resolution level relative to the full resolution. */
|
|
37
369
|
getLevelScale(level: number): number;
|
|
370
|
+
/** Number of tiles (chunks) per axis of a resolution level. */
|
|
371
|
+
getNumTiles(level: number): default_2.Point;
|
|
372
|
+
/**
|
|
373
|
+
* Encodes the tile coordinates as `level=…&x=…&y=…` for
|
|
374
|
+
* {@link downloadTileStart}; no network URL is involved.
|
|
375
|
+
*/
|
|
38
376
|
getTileUrl(level: number, x: number, y: number): string;
|
|
377
|
+
/**
|
|
378
|
+
* Cache key of a tile: the image URL plus the resolved data parameters
|
|
379
|
+
* (`zip`, {@link t}, {@link z}, {@link cs}) and tile coordinates, and an
|
|
380
|
+
* FNV-1a hash of the rendering settings (the configured `ranges`, `colors`,
|
|
381
|
+
* `lutsOrColorMaps` and `inverteds`, and `autoBoost`), so that tile sources
|
|
382
|
+
* rendering the same data share cached tiles.
|
|
383
|
+
*
|
|
384
|
+
* Rendering settings that are not configured are omitted from the hash, as
|
|
385
|
+
* they resolve to the same omero values for the same image.
|
|
386
|
+
*/
|
|
39
387
|
getTileHashKey(level: number, x: number, y: number): string;
|
|
388
|
+
/**
|
|
389
|
+
* Loads the chunks of a tile and finishes the job with `ome-zarr` data
|
|
390
|
+
* ({@link OMEZarrTileData}); fails the job if loading fails.
|
|
391
|
+
*/
|
|
40
392
|
downloadTileStart(context: default_2.ImageJob): void;
|
|
393
|
+
/** Aborts the chunk requests of a pending tile download. */
|
|
41
394
|
downloadTileAbort(context: default_2.ImageJob): void;
|
|
42
|
-
|
|
395
|
+
/**
|
|
396
|
+
* Normalizes a configured rendering setting into one entry per rendered
|
|
397
|
+
* channel.
|
|
398
|
+
*
|
|
399
|
+
* @param options - The tile source configuration
|
|
400
|
+
* @param name - Name of the rendering setting to normalize
|
|
401
|
+
* @param isValue - Whether a value is a single value rather than an array of
|
|
402
|
+
* values
|
|
403
|
+
* @param c - The normalized `c` option, to validate the length against and to
|
|
404
|
+
* repeat a single value for
|
|
405
|
+
* @returns One entry per rendered channel (`undefined` entries fall back to
|
|
406
|
+
* the omero metadata), or `undefined` if the setting is not configured; a
|
|
407
|
+
* single value is repeated for every channel in `c`, or kept as the only
|
|
408
|
+
* entry if `c` is not configured, in which case the getters repeat it
|
|
409
|
+
* @throws If the setting is neither a value nor a non-empty array of values,
|
|
410
|
+
* or if its length does not match `c`
|
|
411
|
+
*/
|
|
412
|
+
private static _normalize;
|
|
413
|
+
/**
|
|
414
|
+
* Spreads a normalized rendering setting over the rendered channels.
|
|
415
|
+
*
|
|
416
|
+
* @param values - The normalized rendering setting, if configured
|
|
417
|
+
* @param channels - The omero channels of the rendered channels, if known
|
|
418
|
+
* @returns One entry per rendered channel: the configured entries, a single
|
|
419
|
+
* configured entry repeated for every rendered channel, or one `undefined`
|
|
420
|
+
* entry per rendered channel if the setting is not configured
|
|
421
|
+
*/
|
|
422
|
+
private static _repeat;
|
|
423
|
+
/** Registers the `ome-zarr` → `context2d` and copy converters (once). */
|
|
43
424
|
private static _learnConverters;
|
|
44
|
-
|
|
45
|
-
private static
|
|
46
|
-
private static _getDataTypeRange;
|
|
425
|
+
/** Size of a named axis at a resolution level (`1` if the axis is absent). */
|
|
426
|
+
private static _getAxisSize;
|
|
47
427
|
}
|
|
48
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Configuration of an {@link OMEZarrTileSource}.
|
|
431
|
+
*
|
|
432
|
+
* Also accepted by OpenSeadragon as an inline tile source configuration
|
|
433
|
+
* (`tileSources: { type: "ome-zarr", url, ... }`) once the tile source has been
|
|
434
|
+
* registered with {@link OMEZarrTileSource.enable}.
|
|
435
|
+
*/
|
|
49
436
|
export declare interface OMEZarrTileSourceOptions {
|
|
437
|
+
/** Tile source type for inline OpenSeadragon configurations */
|
|
50
438
|
type?: "ome-zarr";
|
|
51
|
-
|
|
439
|
+
/**
|
|
440
|
+
* URL of the OME-Zarr image (group) or of a zipped OME-Zarr file, as a
|
|
441
|
+
* string or a `URL`.
|
|
442
|
+
*
|
|
443
|
+
* Relative URLs are resolved against the document base URL.
|
|
444
|
+
*/
|
|
445
|
+
url: string | URL;
|
|
446
|
+
/**
|
|
447
|
+
* Whether the URL points to a zipped OME-Zarr file.
|
|
448
|
+
*
|
|
449
|
+
* Defaults to `true` for URLs whose path ends in `.ozx` (ignoring any query
|
|
450
|
+
* and fragment) and `false` otherwise.
|
|
451
|
+
*/
|
|
52
452
|
zip?: boolean;
|
|
53
|
-
|
|
54
|
-
|
|
453
|
+
/**
|
|
454
|
+
* Timepoint index (0-based) to render.
|
|
455
|
+
*
|
|
456
|
+
* Defaults to the omero `rdefs.defaultT`, or to the middle timepoint if the
|
|
457
|
+
* metadata has none. Validated against the image shape when the image is
|
|
458
|
+
* loaded.
|
|
459
|
+
*/
|
|
55
460
|
t?: number;
|
|
56
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Z-slice index (0-based) to render.
|
|
463
|
+
*
|
|
464
|
+
* Defaults to the omero `rdefs.defaultZ`, or to the middle z-slice if the
|
|
465
|
+
* metadata has none. Validated against the image shape when the image is
|
|
466
|
+
* loaded.
|
|
467
|
+
*/
|
|
468
|
+
z?: number;
|
|
469
|
+
/**
|
|
470
|
+
* Channel index or indices (0-based) to render, composited in the given
|
|
471
|
+
* order.
|
|
472
|
+
*
|
|
473
|
+
* A single index is equivalent to an array with one element; arrays must be
|
|
474
|
+
* non-empty. Defaults to all channels marked active in the omero metadata
|
|
475
|
+
* (or to all channels if the metadata has no omero section). Validated
|
|
476
|
+
* against the image shape when the image is loaded.
|
|
477
|
+
*/
|
|
478
|
+
c?: number | number[];
|
|
479
|
+
/**
|
|
480
|
+
* Contrast limits (`[min, max]`) to render the channels ({@link c}) with,
|
|
481
|
+
* overriding the omero channel windows.
|
|
482
|
+
*
|
|
483
|
+
* A single range applies to all rendered channels; arrays must have one
|
|
484
|
+
* entry per rendered channel, which is only checked against {@link c} if
|
|
485
|
+
* that is configured too. `undefined` entries fall back to the omero channel
|
|
486
|
+
* window (`window.start`, `window.end`), as does the default, and to the
|
|
487
|
+
* data type range if the metadata has none. Ignored for channels rendered
|
|
488
|
+
* with a color map.
|
|
489
|
+
*/
|
|
490
|
+
range?: [number, number] | ([number, number] | undefined)[];
|
|
491
|
+
/**
|
|
492
|
+
* RGB color to render the channels ({@link c}) with, overriding the omero
|
|
493
|
+
* channel colors.
|
|
494
|
+
*
|
|
495
|
+
* A single color applies to all rendered channels; arrays must have one
|
|
496
|
+
* color per rendered channel, which is only checked against {@link c} if
|
|
497
|
+
* that is configured too. `undefined` entries fall back to the omero channel
|
|
498
|
+
* color, as does the default, and to white if the metadata has none. Ignored
|
|
499
|
+
* for channels rendered with a LUT or color map.
|
|
500
|
+
*/
|
|
501
|
+
color?: Color | (Color | undefined)[];
|
|
502
|
+
/**
|
|
503
|
+
* Color LUT or color map to render the channels ({@link c}) with, overriding
|
|
504
|
+
* the omero channel LUTs and color maps.
|
|
505
|
+
*
|
|
506
|
+
* A single LUT or color map applies to all rendered channels; arrays must
|
|
507
|
+
* have one entry per rendered channel, which is only checked against
|
|
508
|
+
* {@link c} if that is configured too. `undefined` entries fall back to the
|
|
509
|
+
* omero channel LUT or color map, as does the default, and to rendering with
|
|
510
|
+
* {@link color} if the metadata has none. A color map also overrides
|
|
511
|
+
* {@link range} and {@link inverted}.
|
|
512
|
+
*/
|
|
513
|
+
lutOrColorMap?: LUTOrColorMap | (LUTOrColorMap | undefined)[];
|
|
514
|
+
/**
|
|
515
|
+
* Whether to invert the channels ({@link c}), overriding the omero channel
|
|
516
|
+
* inversion.
|
|
517
|
+
*
|
|
518
|
+
* A single value applies to all rendered channels; arrays must have one
|
|
519
|
+
* entry per rendered channel, which is only checked against {@link c} if
|
|
520
|
+
* that is configured too. `undefined` entries fall back to the omero channel
|
|
521
|
+
* inversion, as does the default, and to `false` if the metadata has none.
|
|
522
|
+
* Ignored for channels rendered with a color map.
|
|
523
|
+
*/
|
|
524
|
+
inverted?: boolean | (boolean | undefined)[];
|
|
525
|
+
/**
|
|
526
|
+
* Boost the brightness of dark tiles (ome-zarr.js `renderChunks` option).
|
|
527
|
+
*
|
|
528
|
+
* Defaults to `false`.
|
|
529
|
+
*/
|
|
57
530
|
autoBoost?: boolean;
|
|
58
531
|
}
|
|
59
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Resolves a URL against the document base URL.
|
|
535
|
+
*
|
|
536
|
+
* @param url - URL of the OME-Zarr image, as a string or a `URL`
|
|
537
|
+
* @returns The absolute URL
|
|
538
|
+
* @throws If the URL is relative and there is no document base URL
|
|
539
|
+
*/
|
|
540
|
+
export declare function resolveUrl(url: string | URL): URL;
|
|
541
|
+
|
|
60
542
|
export { }
|