@loaders.gl/geotiff 4.2.0-alpha.4 → 4.2.0-alpha.6
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/dist.dev.js +222 -284
- package/dist/dist.min.js +30 -0
- package/dist/geotiff-loader.js +71 -52
- package/dist/index.cjs +23 -20
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/load-geotiff.d.ts +1 -1
- package/dist/lib/load-geotiff.d.ts.map +1 -1
- package/dist/lib/load-geotiff.js +57 -21
- package/dist/lib/ome/load-ome-tiff.d.ts +1 -1
- package/dist/lib/ome/load-ome-tiff.d.ts.map +1 -1
- package/dist/lib/ome/load-ome-tiff.js +35 -41
- package/dist/lib/ome/ome-indexers.d.ts +1 -1
- package/dist/lib/ome/ome-indexers.d.ts.map +1 -1
- package/dist/lib/ome/ome-indexers.js +102 -114
- package/dist/lib/ome/ome-utils.d.ts +1 -1
- package/dist/lib/ome/ome-utils.d.ts.map +1 -1
- package/dist/lib/ome/ome-utils.js +56 -60
- package/dist/lib/ome/omexml.js +53 -55
- package/dist/lib/ome/utils.d.ts +2 -2
- package/dist/lib/ome/utils.d.ts.map +1 -1
- package/dist/lib/ome/utils.js +23 -12
- package/dist/lib/tiff-pixel-source.d.ts +1 -1
- package/dist/lib/tiff-pixel-source.d.ts.map +1 -1
- package/dist/lib/tiff-pixel-source.js +64 -84
- package/dist/lib/utils/tiff-utils.d.ts +1 -1
- package/dist/lib/utils/tiff-utils.d.ts.map +1 -1
- package/dist/lib/utils/tiff-utils.js +31 -18
- package/dist/loaders.js +40 -27
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/package.json +9 -4
- package/dist/geotiff-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/load-geotiff.js.map +0 -1
- package/dist/lib/ome/load-ome-tiff.js.map +0 -1
- package/dist/lib/ome/ome-indexers.js.map +0 -1
- package/dist/lib/ome/ome-utils.js.map +0 -1
- package/dist/lib/ome/omexml.js.map +0 -1
- package/dist/lib/ome/utils.js.map +0 -1
- package/dist/lib/tiff-pixel-source.js.map +0 -1
- package/dist/lib/utils/Pool.ts.disabled +0 -99
- package/dist/lib/utils/decoder.worker.ts.disabled +0 -21
- package/dist/lib/utils/proxies.ts.disabled +0 -96
- package/dist/lib/utils/tiff-utils.js.map +0 -1
- package/dist/loaders.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1,120 +1,108 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/*
|
|
5
|
+
* An "indexer" for a GeoTIFF-based source is a function that takes a
|
|
6
|
+
* "selection" (e.g. { z, t, c }) and returns a Promise for the GeoTIFFImage
|
|
7
|
+
* object corresponding to that selection.
|
|
8
|
+
*
|
|
9
|
+
* For OME-TIFF images, the "selection" object is the same regardless of
|
|
10
|
+
* the format version. However, modern version of Bioformats have a different
|
|
11
|
+
* memory layout for pyramidal resolutions. Thus, we have two different "indexers"
|
|
12
|
+
* depending on which format version is detected.
|
|
13
|
+
*
|
|
14
|
+
* TODO: We currently only support indexing the first image in the OME-TIFF with
|
|
15
|
+
* our indexers. There can be multiple images in an OME-TIFF, so supporting these
|
|
16
|
+
* images will require extending these indexers or creating new methods.
|
|
17
|
+
*/
|
|
18
|
+
/*
|
|
19
|
+
* Returns an indexer for legacy Bioformats images. This assumes that
|
|
20
|
+
* downsampled resolutions are stored sequentially in the OME-TIFF.
|
|
21
|
+
*/
|
|
1
22
|
export function getOmeLegacyIndexer(tiff, rootMeta) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
23
|
+
const imgMeta = rootMeta[0];
|
|
24
|
+
const { SizeT, SizeC, SizeZ } = imgMeta.Pixels;
|
|
25
|
+
const ifdIndexer = getOmeIFDIndexer(imgMeta);
|
|
26
|
+
return (sel, pyramidLevel) => {
|
|
27
|
+
// Get IFD index at base pyramid level
|
|
28
|
+
const index = ifdIndexer(sel);
|
|
29
|
+
// Get index of first image at pyramidal level
|
|
30
|
+
const pyramidIndex = pyramidLevel * SizeZ * SizeT * SizeC;
|
|
31
|
+
// Return image at IFD index for pyramidal level
|
|
32
|
+
return tiff.getImage(index + pyramidIndex);
|
|
33
|
+
};
|
|
14
34
|
}
|
|
35
|
+
/*
|
|
36
|
+
* Returns an indexer for modern Bioforamts images that store multiscale
|
|
37
|
+
* resolutions using SubIFDs.
|
|
38
|
+
*
|
|
39
|
+
* The ifdIndexer returns the 'index' to the base resolution for a
|
|
40
|
+
* particular 'selection'. The SubIFDs to the downsampled resolutions
|
|
41
|
+
* of the 'selection' are stored within the `baseImage.fileDirectory`.
|
|
42
|
+
* We use the SubIFDs to get the IFD for the corresponding sub-resolution.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: This function create a custom IFD cache rather than mutating
|
|
45
|
+
* `GeoTIFF.ifdRequests` with a random offset. The IFDs are cached in
|
|
46
|
+
* an ES6 Map that maps a string key that identifies the selection uniquely
|
|
47
|
+
* to the corresponding IFD.
|
|
48
|
+
*/
|
|
15
49
|
export function getOmeSubIFDIndexer(tiff, rootMeta) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
const imgMeta = rootMeta[0];
|
|
51
|
+
const ifdIndexer = getOmeIFDIndexer(imgMeta);
|
|
52
|
+
const ifdCache = new Map();
|
|
53
|
+
return async (sel, pyramidLevel) => {
|
|
54
|
+
const index = ifdIndexer(sel);
|
|
55
|
+
const baseImage = await tiff.getImage(index);
|
|
56
|
+
// It's the highest resolution, no need to look up SubIFDs.
|
|
57
|
+
if (pyramidLevel === 0) {
|
|
58
|
+
return baseImage;
|
|
59
|
+
}
|
|
60
|
+
const { SubIFDs } = baseImage.fileDirectory;
|
|
61
|
+
if (!SubIFDs) {
|
|
62
|
+
throw Error('Indexing Error: OME-TIFF is missing SubIFDs.');
|
|
63
|
+
}
|
|
64
|
+
// Get IFD for the selection at the pyramidal level
|
|
65
|
+
const key = `${sel.t}-${sel.c}-${sel.z}-${pyramidLevel}`;
|
|
66
|
+
if (!ifdCache.has(key)) {
|
|
67
|
+
// Only create a new request if we don't have the key.
|
|
68
|
+
const subIfdOffset = SubIFDs[pyramidLevel - 1];
|
|
69
|
+
ifdCache.set(key, tiff.parseFileDirectoryAt(subIfdOffset));
|
|
70
|
+
}
|
|
71
|
+
const ifd = await ifdCache.get(key);
|
|
72
|
+
// Create a new image object manually from IFD
|
|
73
|
+
// https://github.com/geotiffjs/geotiff.js/blob/8ef472f41b51d18074aece2300b6a8ad91a21ae1/src/geotiff.js#L447-L453
|
|
74
|
+
return new baseImage.constructor(ifd.fileDirectory, ifd.geoKeyDirectory,
|
|
75
|
+
// @ts-expect-error
|
|
76
|
+
tiff.dataView, tiff.littleEndian, tiff.cache, tiff.source);
|
|
77
|
+
};
|
|
39
78
|
}
|
|
79
|
+
/*
|
|
80
|
+
* Returns a function that computes the image index based on the dimension
|
|
81
|
+
* order and dimension sizes.
|
|
82
|
+
*/
|
|
40
83
|
function getOmeIFDIndexer(imgMeta) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
c,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
z
|
|
66
|
-
} = _ref2;
|
|
67
|
-
return c * SizeZ * SizeT + t * SizeZ + z;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
case 'XYCTZ':
|
|
71
|
-
{
|
|
72
|
-
return _ref3 => {
|
|
73
|
-
let {
|
|
74
|
-
t,
|
|
75
|
-
c,
|
|
76
|
-
z
|
|
77
|
-
} = _ref3;
|
|
78
|
-
return z * SizeC * SizeT + t * SizeC + c;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
case 'XYCZT':
|
|
82
|
-
{
|
|
83
|
-
return _ref4 => {
|
|
84
|
-
let {
|
|
85
|
-
t,
|
|
86
|
-
c,
|
|
87
|
-
z
|
|
88
|
-
} = _ref4;
|
|
89
|
-
return t * SizeC * SizeZ + z * SizeC + c;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
case 'XYTCZ':
|
|
93
|
-
{
|
|
94
|
-
return _ref5 => {
|
|
95
|
-
let {
|
|
96
|
-
t,
|
|
97
|
-
c,
|
|
98
|
-
z
|
|
99
|
-
} = _ref5;
|
|
100
|
-
return z * SizeT * SizeC + c * SizeT + t;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
case 'XYTZC':
|
|
104
|
-
{
|
|
105
|
-
return _ref6 => {
|
|
106
|
-
let {
|
|
107
|
-
t,
|
|
108
|
-
c,
|
|
109
|
-
z
|
|
110
|
-
} = _ref6;
|
|
111
|
-
return c * SizeT * SizeZ + z * SizeT + t;
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
default:
|
|
115
|
-
{
|
|
116
|
-
throw new Error(`Invalid OME-XML DimensionOrder, got ${DimensionOrder}.`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
84
|
+
const { SizeC, SizeZ, SizeT, DimensionOrder } = imgMeta.Pixels;
|
|
85
|
+
switch (DimensionOrder) {
|
|
86
|
+
case 'XYZCT': {
|
|
87
|
+
return ({ t, c, z }) => t * SizeZ * SizeC + c * SizeZ + z;
|
|
88
|
+
}
|
|
89
|
+
case 'XYZTC': {
|
|
90
|
+
return ({ t, c, z }) => c * SizeZ * SizeT + t * SizeZ + z;
|
|
91
|
+
}
|
|
92
|
+
case 'XYCTZ': {
|
|
93
|
+
return ({ t, c, z }) => z * SizeC * SizeT + t * SizeC + c;
|
|
94
|
+
}
|
|
95
|
+
case 'XYCZT': {
|
|
96
|
+
return ({ t, c, z }) => t * SizeC * SizeZ + z * SizeC + c;
|
|
97
|
+
}
|
|
98
|
+
case 'XYTCZ': {
|
|
99
|
+
return ({ t, c, z }) => z * SizeT * SizeC + c * SizeT + t;
|
|
100
|
+
}
|
|
101
|
+
case 'XYTZC': {
|
|
102
|
+
return ({ t, c, z }) => c * SizeT * SizeZ + z * SizeT + t;
|
|
103
|
+
}
|
|
104
|
+
default: {
|
|
105
|
+
throw new Error(`Invalid OME-XML DimensionOrder, got ${DimensionOrder}.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
119
108
|
}
|
|
120
|
-
//# sourceMappingURL=ome-indexers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ome-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/ome-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,
|
|
1
|
+
{"version":3,"file":"ome-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/ome-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,oBAAiB;AAElD,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,EAAC,MAAM,EAAC,EAAE,MAAM,CAAC,CAAC,CAAC;;sBAoB9B,MAAM;;;kBAcP,MAAM;kBAAQ,WAAW;;;;;;sBAdxB,MAAM;;;EAmChC"}
|
|
@@ -1,66 +1,62 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { getDims, getLabels } from "./utils.js";
|
|
2
5
|
export const DTYPE_LOOKUP = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
uint8: 'Uint8',
|
|
7
|
+
uint16: 'Uint16',
|
|
8
|
+
uint32: 'Uint32',
|
|
9
|
+
float: 'Float32',
|
|
10
|
+
double: 'Float64',
|
|
11
|
+
int8: 'Int8',
|
|
12
|
+
int16: 'Int16',
|
|
13
|
+
int32: 'Int32'
|
|
11
14
|
};
|
|
12
|
-
export function getOmePixelSourceMeta(
|
|
13
|
-
|
|
14
|
-
Pixels
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const getShape = level => {
|
|
27
|
-
const s = [...shape];
|
|
28
|
-
s[dims('x')] = Pixels.SizeX >> level;
|
|
29
|
-
s[dims('y')] = Pixels.SizeY >> level;
|
|
30
|
-
return s;
|
|
31
|
-
};
|
|
32
|
-
if (!(Pixels.Type in DTYPE_LOOKUP)) {
|
|
33
|
-
throw Error(`Pixel type ${Pixels.Type} not supported.`);
|
|
34
|
-
}
|
|
35
|
-
const dtype = DTYPE_LOOKUP[Pixels.Type];
|
|
36
|
-
if (Pixels.PhysicalSizeX && Pixels.PhysicalSizeY) {
|
|
37
|
-
const physicalSizes = {
|
|
38
|
-
x: {
|
|
39
|
-
size: Pixels.PhysicalSizeX,
|
|
40
|
-
unit: Pixels.PhysicalSizeXUnit
|
|
41
|
-
},
|
|
42
|
-
y: {
|
|
43
|
-
size: Pixels.PhysicalSizeY,
|
|
44
|
-
unit: Pixels.PhysicalSizeYUnit
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
if (Pixels.PhysicalSizeZ) {
|
|
48
|
-
physicalSizes.z = {
|
|
49
|
-
size: Pixels.PhysicalSizeZ,
|
|
50
|
-
unit: Pixels.PhysicalSizeZUnit
|
|
51
|
-
};
|
|
15
|
+
export function getOmePixelSourceMeta({ Pixels }) {
|
|
16
|
+
// e.g. 'XYZCT' -> ['t', 'c', 'z', 'y', 'x']
|
|
17
|
+
const labels = getLabels(Pixels.DimensionOrder);
|
|
18
|
+
// Compute "shape" of image
|
|
19
|
+
const dims = getDims(labels);
|
|
20
|
+
const shape = Array(labels.length).fill(0);
|
|
21
|
+
shape[dims('t')] = Pixels.SizeT;
|
|
22
|
+
shape[dims('c')] = Pixels.SizeC;
|
|
23
|
+
shape[dims('z')] = Pixels.SizeZ;
|
|
24
|
+
// Push extra dimension if data are interleaved.
|
|
25
|
+
if (Pixels.Interleaved) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
labels.push('_c');
|
|
28
|
+
shape.push(3);
|
|
52
29
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
// Creates a new shape for different level of pyramid.
|
|
31
|
+
// Assumes factor-of-two downsampling.
|
|
32
|
+
const getShape = (level) => {
|
|
33
|
+
const s = [...shape];
|
|
34
|
+
s[dims('x')] = Pixels.SizeX >> level;
|
|
35
|
+
s[dims('y')] = Pixels.SizeY >> level;
|
|
36
|
+
return s;
|
|
58
37
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
if (!(Pixels.Type in DTYPE_LOOKUP)) {
|
|
39
|
+
throw Error(`Pixel type ${Pixels.Type} not supported.`);
|
|
40
|
+
}
|
|
41
|
+
const dtype = DTYPE_LOOKUP[Pixels.Type];
|
|
42
|
+
if (Pixels.PhysicalSizeX && Pixels.PhysicalSizeY) {
|
|
43
|
+
const physicalSizes = {
|
|
44
|
+
x: {
|
|
45
|
+
size: Pixels.PhysicalSizeX,
|
|
46
|
+
unit: Pixels.PhysicalSizeXUnit
|
|
47
|
+
},
|
|
48
|
+
y: {
|
|
49
|
+
size: Pixels.PhysicalSizeY,
|
|
50
|
+
unit: Pixels.PhysicalSizeYUnit
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (Pixels.PhysicalSizeZ) {
|
|
54
|
+
physicalSizes.z = {
|
|
55
|
+
size: Pixels.PhysicalSizeZ,
|
|
56
|
+
unit: Pixels.PhysicalSizeZUnit
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return { labels, getShape, physicalSizes, dtype };
|
|
60
|
+
}
|
|
61
|
+
return { labels, getShape, dtype };
|
|
65
62
|
}
|
|
66
|
-
//# sourceMappingURL=ome-utils.js.map
|
package/dist/lib/ome/omexml.js
CHANGED
|
@@ -1,64 +1,62 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { XMLParser } from 'fast-xml-parser';
|
|
2
5
|
import { ensureArray, intToRgba } from "../utils/tiff-utils.js";
|
|
6
|
+
// WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.
|
|
3
7
|
const xmlParser = new XMLParser({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
// Nests attributes withtout prefix under 'attr' key for each node
|
|
9
|
+
attributeNamePrefix: '',
|
|
10
|
+
attributesGroupName: 'attr',
|
|
11
|
+
// Parses numbers for both attributes and nodes
|
|
12
|
+
parseTagValue: true,
|
|
13
|
+
parseAttributeValue: true,
|
|
14
|
+
// Forces attributes to be parsed
|
|
15
|
+
ignoreAttributes: false
|
|
9
16
|
});
|
|
10
|
-
const parse = str => xmlParser.parse(str);
|
|
17
|
+
const parse = (str) => xmlParser.parse(str);
|
|
11
18
|
export function fromString(str) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const res = parse(str);
|
|
20
|
+
if (!res.OME) {
|
|
21
|
+
throw Error('Failed to parse OME-XML metadata.');
|
|
22
|
+
}
|
|
23
|
+
return ensureArray(res.OME.Image).map((img) => {
|
|
24
|
+
const Channels = ensureArray(img.Pixels.Channel).map((c) => {
|
|
25
|
+
if ('Color' in c.attr) {
|
|
26
|
+
return { ...c.attr, Color: intToRgba(c.attr.Color) };
|
|
27
|
+
}
|
|
28
|
+
return { ...c.attr };
|
|
29
|
+
});
|
|
30
|
+
const { AquisitionDate = '', Description = '' } = img;
|
|
31
|
+
const image = {
|
|
32
|
+
...img.attr,
|
|
33
|
+
AquisitionDate,
|
|
34
|
+
Description,
|
|
35
|
+
Pixels: {
|
|
36
|
+
...img.Pixels.attr,
|
|
37
|
+
Channels
|
|
38
|
+
}
|
|
22
39
|
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
...c.attr
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
const {
|
|
29
|
-
AquisitionDate = '',
|
|
30
|
-
Description = ''
|
|
31
|
-
} = img;
|
|
32
|
-
const image = {
|
|
33
|
-
...img.attr,
|
|
34
|
-
AquisitionDate,
|
|
35
|
-
Description,
|
|
36
|
-
Pixels: {
|
|
37
|
-
...img.Pixels.attr,
|
|
38
|
-
Channels
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
...image,
|
|
43
|
-
format() {
|
|
44
|
-
const {
|
|
45
|
-
Pixels
|
|
46
|
-
} = image;
|
|
47
|
-
const sizes = ['X', 'Y', 'Z'].map(name => {
|
|
48
|
-
const size = Pixels[`PhysicalSize${name}`];
|
|
49
|
-
const unit = Pixels[`PhysicalSize${name}Unit`];
|
|
50
|
-
return size && unit ? `${size} ${unit}` : '-';
|
|
51
|
-
}).join(' x ');
|
|
52
40
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
...image,
|
|
42
|
+
format() {
|
|
43
|
+
const { Pixels } = image;
|
|
44
|
+
const sizes = ['X', 'Y', 'Z']
|
|
45
|
+
.map((name) => {
|
|
46
|
+
const size = Pixels[`PhysicalSize${name}`];
|
|
47
|
+
const unit = Pixels[`PhysicalSize${name}Unit`];
|
|
48
|
+
return size && unit ? `${size} ${unit}` : '-';
|
|
49
|
+
})
|
|
50
|
+
.join(' x ');
|
|
51
|
+
return {
|
|
52
|
+
'Acquisition Date': image.AquisitionDate,
|
|
53
|
+
'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,
|
|
54
|
+
'Pixels Type': Pixels.Type,
|
|
55
|
+
'Pixels Size (XYZ)': sizes,
|
|
56
|
+
'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,
|
|
57
|
+
Channels: Pixels.SizeC
|
|
58
|
+
};
|
|
59
|
+
}
|
|
59
60
|
};
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
});
|
|
61
|
+
});
|
|
63
62
|
}
|
|
64
|
-
//# sourceMappingURL=omexml.js.map
|
package/dist/lib/ome/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OMEXML } from
|
|
2
|
-
import type { Labels } from
|
|
1
|
+
import type { OMEXML } from "../ome/omexml.js";
|
|
2
|
+
import type { Labels } from "../../types.js";
|
|
3
3
|
export declare function getLabels(dimOrder: OMEXML[0]['Pixels']['DimensionOrder']): Labels<["t", "c", "z"] | ["c", "t", "z"] | ["z", "t", "c"] | ["t", "z", "c"] | ["z", "c", "t"] | ["c", "z", "t"]>;
|
|
4
4
|
export declare function getDims<S extends string>(labels: S[]): (name: S) => number;
|
|
5
5
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,yBAAsB;AAC1C,OAAO,KAAK,EAAC,MAAM,EAAC,uBAAoB;AAYxC,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,qHAExE;AAWD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,UAKrC,CAAC,YAOhB"}
|
package/dist/lib/ome/utils.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
export function getLabels(dimOrder) {
|
|
2
|
-
|
|
5
|
+
return dimOrder.toLowerCase().split('').reverse();
|
|
3
6
|
}
|
|
7
|
+
/*
|
|
8
|
+
* Creates an ES6 map of 'label' -> index
|
|
9
|
+
* > const labels = ['a', 'b', 'c', 'd'];
|
|
10
|
+
* > const dims = getDims(labels);
|
|
11
|
+
* > dims('a') === 0;
|
|
12
|
+
* > dims('b') === 1;
|
|
13
|
+
* > dims('c') === 2;
|
|
14
|
+
* > dims('hi!'); // throws
|
|
15
|
+
*/
|
|
4
16
|
export function getDims(labels) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return name => {
|
|
10
|
-
const index = lookup.get(name);
|
|
11
|
-
if (index === undefined) {
|
|
12
|
-
throw Error('Invalid dimension.');
|
|
17
|
+
const lookup = new Map(labels.map((name, i) => [name, i]));
|
|
18
|
+
if (lookup.size !== labels.length) {
|
|
19
|
+
throw Error('Labels must be unique, found duplicated label.');
|
|
13
20
|
}
|
|
14
|
-
return
|
|
15
|
-
|
|
21
|
+
return (name) => {
|
|
22
|
+
const index = lookup.get(name);
|
|
23
|
+
if (index === undefined) {
|
|
24
|
+
throw Error('Invalid dimension.');
|
|
25
|
+
}
|
|
26
|
+
return index;
|
|
27
|
+
};
|
|
16
28
|
}
|
|
17
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GeoTIFFImage } from 'geotiff';
|
|
2
|
-
import type { PixelSource, PixelSourceSelection, PixelSourceMeta, Dtype, Labels, RasterSelection, TileSelection, PixelData } from
|
|
2
|
+
import type { PixelSource, PixelSourceSelection, PixelSourceMeta, Dtype, Labels, RasterSelection, TileSelection, PixelData } from "../types.js";
|
|
3
3
|
export declare class TiffPixelSource<S extends string[]> implements PixelSource<S> {
|
|
4
4
|
dtype: Dtype;
|
|
5
5
|
tileSize: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiff-pixel-source.d.ts","sourceRoot":"","sources":["../../src/lib/tiff-pixel-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,KAAK,EACL,MAAM,EACN,eAAe,EACf,aAAa,EACb,SAAS,EAEV,
|
|
1
|
+
{"version":3,"file":"tiff-pixel-source.d.ts","sourceRoot":"","sources":["../../src/lib/tiff-pixel-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,KAAK,EACL,MAAM,EACN,eAAe,EACf,aAAa,EACb,SAAS,EAEV,oBAAiB;AAIlB,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACjE,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,QAAQ,CAA0D;gBAIxE,OAAO,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,EAChE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,IAAI,CAAC,EAAE,eAAe;IAUlB,SAAS,CAAC,EAAC,SAAS,EAAE,MAAM,EAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IAKjD,OAAO,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAC,EAAE,aAAa,CAAC,CAAC,CAAC;YAU3C,YAAY;IAuB1B,OAAO,CAAC,cAAc;IAetB,WAAW,CAAC,GAAG,EAAE,KAAK;CAGvB"}
|