@vitessce/image-utils 3.6.6 → 3.6.8
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/{deflate-C_JiGtg2.js → deflate-F8grfDh6.js} +1 -1
- package/dist/{index-DM2-ZM-A.js → index-BpnGGDv2.js} +173 -9
- package/dist/index.js +1 -1
- package/dist/{jpeg-BqomB91U.js → jpeg-Dvu4OTul.js} +1 -1
- package/dist/{lerc-QsX1FZrM.js → lerc-Dqw24LZ0.js} +1 -1
- package/dist/{lzw-CleychH0.js → lzw-C6ogUnun.js} +1 -1
- package/dist/{packbits-vczGr1n0.js → packbits-BbCLrc81.js} +1 -1
- package/dist/{raw-Bz42nnyn.js → raw-BTn6dLCD.js} +1 -1
- package/dist/{webimage-CE6ZfP1L.js → webimage-C9hqCa1B.js} +1 -1
- package/dist-tsc/ImageWrapper.d.ts +7 -0
- package/dist-tsc/ImageWrapper.d.ts.map +1 -1
- package/dist-tsc/ImageWrapper.js +51 -3
- package/package.json +5 -5
- package/src/ImageWrapper.ts +62 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as inflate_1 } from "./pako.esm-SxljTded.js";
|
|
2
|
-
import { B as BaseDecoder } from "./index-
|
|
2
|
+
import { B as BaseDecoder } from "./index-BpnGGDv2.js";
|
|
3
3
|
class DeflateDecoder extends BaseDecoder {
|
|
4
4
|
decodeBlock(buffer) {
|
|
5
5
|
return inflate_1(new Uint8Array(buffer)).buffer;
|
|
@@ -120224,22 +120224,22 @@ function addDecoder(cases, importFn) {
|
|
|
120224
120224
|
}
|
|
120225
120225
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
120226
120226
|
}
|
|
120227
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
120228
|
-
addDecoder(5, () => import("./lzw-
|
|
120227
|
+
addDecoder([void 0, 1], () => import("./raw-BTn6dLCD.js").then((m) => m.default));
|
|
120228
|
+
addDecoder(5, () => import("./lzw-C6ogUnun.js").then((m) => m.default));
|
|
120229
120229
|
addDecoder(6, () => {
|
|
120230
120230
|
throw new Error("old style JPEG compression is not supported.");
|
|
120231
120231
|
});
|
|
120232
|
-
addDecoder(7, () => import("./jpeg-
|
|
120233
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
120234
|
-
addDecoder(32773, () => import("./packbits-
|
|
120232
|
+
addDecoder(7, () => import("./jpeg-Dvu4OTul.js").then((m) => m.default));
|
|
120233
|
+
addDecoder([8, 32946], () => import("./deflate-F8grfDh6.js").then((m) => m.default));
|
|
120234
|
+
addDecoder(32773, () => import("./packbits-BbCLrc81.js").then((m) => m.default));
|
|
120235
120235
|
addDecoder(
|
|
120236
120236
|
34887,
|
|
120237
|
-
() => import("./lerc-
|
|
120237
|
+
() => import("./lerc-Dqw24LZ0.js").then(async (m) => {
|
|
120238
120238
|
await m.zstd.init();
|
|
120239
120239
|
return m;
|
|
120240
120240
|
}).then((m) => m.default)
|
|
120241
120241
|
);
|
|
120242
|
-
addDecoder(50001, () => import("./webimage-
|
|
120242
|
+
addDecoder(50001, () => import("./webimage-C9hqCa1B.js").then((m) => m.default));
|
|
120243
120243
|
function decodeRowAcc(row, stride) {
|
|
120244
120244
|
let length2 = row.length - stride;
|
|
120245
120245
|
let offset = 0;
|
|
@@ -137381,11 +137381,80 @@ function getNgffAxesForTiff(dimOrder) {
|
|
|
137381
137381
|
type: getDefaultAxisType(name2)
|
|
137382
137382
|
}));
|
|
137383
137383
|
}
|
|
137384
|
+
function getSwapAxesMatrix(inputAxes, outputAxes) {
|
|
137385
|
+
const size2 = inputAxes.length;
|
|
137386
|
+
if (!(size2 === 2 || size2 === 3)) {
|
|
137387
|
+
throw new Error(`Expected input and output axes to have 2 or 3 elements, got ${size2}.`);
|
|
137388
|
+
}
|
|
137389
|
+
const matrix2 = [
|
|
137390
|
+
[0, 0, 0, 0],
|
|
137391
|
+
[0, 0, 0, 0],
|
|
137392
|
+
[0, 0, size2 === 2 ? 1 : 0, 0],
|
|
137393
|
+
// In 2D, leave Z unchanged.
|
|
137394
|
+
[0, 0, 0, 1]
|
|
137395
|
+
];
|
|
137396
|
+
for (let outRow = 0; outRow < size2; outRow++) {
|
|
137397
|
+
const axis = outputAxes[outRow];
|
|
137398
|
+
const inCol = inputAxes.indexOf(axis);
|
|
137399
|
+
if (inCol === -1) {
|
|
137400
|
+
throw new Error(`Axis "${axis}" not found in inputAxes`);
|
|
137401
|
+
}
|
|
137402
|
+
matrix2[outRow][inCol] = 1;
|
|
137403
|
+
}
|
|
137404
|
+
return matrix2;
|
|
137405
|
+
}
|
|
137384
137406
|
function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
137385
137407
|
let mat = new Matrix4().identity();
|
|
137386
137408
|
if (coordinateTransformations && axes) {
|
|
137387
137409
|
const xyzIndices = ["x", "y", "z"].map((name2) => axes.findIndex((axisObj) => axisObj.type === "space" && axisObj.name === name2));
|
|
137388
137410
|
coordinateTransformations.forEach((transform2) => {
|
|
137411
|
+
if (transform2.type === "affine") {
|
|
137412
|
+
const { affine, input, output } = transform2;
|
|
137413
|
+
const excludeEntries = input.axes.map((axis, i2) => [axis, i2]).filter(([axis, i2]) => axis.type !== "space").map(([axis, i2]) => i2);
|
|
137414
|
+
const filteredAffine = affine.filter((_, i2) => !excludeEntries.includes(i2)).map((row) => row.filter((_, i2) => !excludeEntries.includes(i2)));
|
|
137415
|
+
const spatialInputAxes = input.axes.filter((axis) => axis.type === "space");
|
|
137416
|
+
const spatialOutputAxes = output.axes.filter((axis) => axis.type === "space");
|
|
137417
|
+
const inputAxisNames = spatialInputAxes.map((axis) => axis.name);
|
|
137418
|
+
const outputAxisNames = spatialOutputAxes.map((axis) => axis.name);
|
|
137419
|
+
if (spatialInputAxes.length === 3) {
|
|
137420
|
+
const nextMat = new Matrix4().fromArray([
|
|
137421
|
+
...filteredAffine[0],
|
|
137422
|
+
...filteredAffine[1],
|
|
137423
|
+
...filteredAffine[2],
|
|
137424
|
+
0,
|
|
137425
|
+
0,
|
|
137426
|
+
0,
|
|
137427
|
+
1
|
|
137428
|
+
]);
|
|
137429
|
+
mat = mat.multiplyLeft(nextMat);
|
|
137430
|
+
if (!isEqual$1(inputAxisNames, outputAxisNames)) {
|
|
137431
|
+
const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
|
|
137432
|
+
const swapMat = new Matrix4().fromArray(swapMatNested.flat());
|
|
137433
|
+
mat = mat.multiplyLeft(swapMat);
|
|
137434
|
+
}
|
|
137435
|
+
} else if (spatialOutputAxes.length === 2) {
|
|
137436
|
+
const nextMat = new Matrix4().fromArray([
|
|
137437
|
+
...filteredAffine[0],
|
|
137438
|
+
...filteredAffine[1],
|
|
137439
|
+
0,
|
|
137440
|
+
0,
|
|
137441
|
+
1,
|
|
137442
|
+
0,
|
|
137443
|
+
0,
|
|
137444
|
+
0,
|
|
137445
|
+
0,
|
|
137446
|
+
1
|
|
137447
|
+
]);
|
|
137448
|
+
mat = mat.multiplyLeft(nextMat);
|
|
137449
|
+
if (!isEqual$1(inputAxisNames, outputAxisNames)) {
|
|
137450
|
+
const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
|
|
137451
|
+
const swapMat = new Matrix4().fromArray(swapMatNested.flat());
|
|
137452
|
+
mat = mat.multiplyLeft(swapMat);
|
|
137453
|
+
}
|
|
137454
|
+
} else {
|
|
137455
|
+
throw new Error("Affine transformation must have 2 or 3 rows.");
|
|
137456
|
+
}
|
|
137457
|
+
}
|
|
137389
137458
|
if (transform2.type === "translation") {
|
|
137390
137459
|
const { translation: axisOrderedTranslation } = transform2;
|
|
137391
137460
|
if (axisOrderedTranslation.length !== axes.length) {
|
|
@@ -137418,6 +137487,54 @@ function hexToRgb(hex) {
|
|
|
137418
137487
|
parseInt(result[3].toLowerCase(), 16)
|
|
137419
137488
|
];
|
|
137420
137489
|
}
|
|
137490
|
+
function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
|
|
137491
|
+
var _a3;
|
|
137492
|
+
let result = [];
|
|
137493
|
+
if (Array.isArray(coordinateTransformations)) {
|
|
137494
|
+
result = coordinateTransformations.flatMap((transform2) => {
|
|
137495
|
+
if (transform2.input && transform2.output) {
|
|
137496
|
+
const { type } = transform2;
|
|
137497
|
+
if (type === "translation") {
|
|
137498
|
+
return {
|
|
137499
|
+
type,
|
|
137500
|
+
translation: transform2.translation
|
|
137501
|
+
};
|
|
137502
|
+
}
|
|
137503
|
+
if (type === "scale") {
|
|
137504
|
+
return {
|
|
137505
|
+
type,
|
|
137506
|
+
scale: transform2.scale
|
|
137507
|
+
};
|
|
137508
|
+
}
|
|
137509
|
+
if (type === "affine") {
|
|
137510
|
+
return {
|
|
137511
|
+
type,
|
|
137512
|
+
affine: transform2.affine,
|
|
137513
|
+
// Affine transformations can potentially swap axes,
|
|
137514
|
+
// so we need to include the input and output axes.
|
|
137515
|
+
input: transform2.input,
|
|
137516
|
+
output: transform2.output
|
|
137517
|
+
};
|
|
137518
|
+
}
|
|
137519
|
+
if (type === "identity") {
|
|
137520
|
+
return { type };
|
|
137521
|
+
}
|
|
137522
|
+
if (type === "sequence") {
|
|
137523
|
+
return normalizeCoordinateTransformations(transform2.transformations, datasets);
|
|
137524
|
+
}
|
|
137525
|
+
log$5.warn(`Coordinate transformation type "${type}" is not supported.`);
|
|
137526
|
+
}
|
|
137527
|
+
return transform2;
|
|
137528
|
+
});
|
|
137529
|
+
}
|
|
137530
|
+
if (Array.isArray((_a3 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a3.coordinateTransformations)) {
|
|
137531
|
+
result = [
|
|
137532
|
+
...datasets[0].coordinateTransformations,
|
|
137533
|
+
...result
|
|
137534
|
+
];
|
|
137535
|
+
}
|
|
137536
|
+
return result;
|
|
137537
|
+
}
|
|
137421
137538
|
function getDomains() {
|
|
137422
137539
|
const domains = {};
|
|
137423
137540
|
const needMin = ["Int8", "Int16", "Int32"];
|
|
@@ -137433,6 +137550,7 @@ class ImageWrapper {
|
|
|
137433
137550
|
constructor(vivLoader, options) {
|
|
137434
137551
|
__publicField(this, "vivLoader");
|
|
137435
137552
|
__publicField(this, "options");
|
|
137553
|
+
__publicField(this, "modelMatrix", null);
|
|
137436
137554
|
this.options = options || {};
|
|
137437
137555
|
this.vivLoader = vivLoader;
|
|
137438
137556
|
}
|
|
@@ -137465,12 +137583,19 @@ class ImageWrapper {
|
|
|
137465
137583
|
return this.vivLoader.data;
|
|
137466
137584
|
}
|
|
137467
137585
|
getModelMatrix() {
|
|
137586
|
+
if (!this.modelMatrix) {
|
|
137587
|
+
this.modelMatrix = this._getModelMatrix();
|
|
137588
|
+
}
|
|
137589
|
+
return this.modelMatrix;
|
|
137590
|
+
}
|
|
137591
|
+
_getModelMatrix() {
|
|
137468
137592
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
137469
137593
|
if ("multiscales" in this.vivLoader.metadata) {
|
|
137470
137594
|
const {
|
|
137471
137595
|
multiscales: [
|
|
137472
137596
|
{
|
|
137473
|
-
|
|
137597
|
+
datasets,
|
|
137598
|
+
coordinateTransformations: coordinateTransformationsFromFile,
|
|
137474
137599
|
axes
|
|
137475
137600
|
}
|
|
137476
137601
|
]
|
|
@@ -137480,8 +137605,12 @@ class ImageWrapper {
|
|
|
137480
137605
|
coordinateTransformationsFromOptions,
|
|
137481
137606
|
ngffAxes
|
|
137482
137607
|
);
|
|
137608
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
|
|
137609
|
+
coordinateTransformationsFromFile,
|
|
137610
|
+
datasets
|
|
137611
|
+
);
|
|
137483
137612
|
const transformMatrixFromFile = coordinateTransformationsToMatrix(
|
|
137484
|
-
|
|
137613
|
+
normCoordinateTransformationsFromFile,
|
|
137485
137614
|
ngffAxes
|
|
137486
137615
|
);
|
|
137487
137616
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
@@ -137696,15 +137825,45 @@ class ImageWrapper {
|
|
|
137696
137825
|
hasZStack() {
|
|
137697
137826
|
const loader = this.vivLoader;
|
|
137698
137827
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137828
|
+
if (!labels.includes("z")) {
|
|
137829
|
+
return false;
|
|
137830
|
+
}
|
|
137699
137831
|
const hasZStack = shape[labels.indexOf("z")] > 1;
|
|
137700
137832
|
return hasZStack;
|
|
137701
137833
|
}
|
|
137702
137834
|
hasTStack() {
|
|
137703
137835
|
const loader = this.vivLoader;
|
|
137704
137836
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137837
|
+
if (!labels.includes("t")) {
|
|
137838
|
+
return false;
|
|
137839
|
+
}
|
|
137705
137840
|
const hasTStack = shape[labels.indexOf("t")] > 1;
|
|
137706
137841
|
return hasTStack;
|
|
137707
137842
|
}
|
|
137843
|
+
hasCStack() {
|
|
137844
|
+
const loader = this.vivLoader;
|
|
137845
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137846
|
+
if (!labels.includes("c")) {
|
|
137847
|
+
return false;
|
|
137848
|
+
}
|
|
137849
|
+
const hasCStack = shape[labels.indexOf("c")] > 1;
|
|
137850
|
+
return hasCStack;
|
|
137851
|
+
}
|
|
137852
|
+
hasDimZ() {
|
|
137853
|
+
const loader = this.vivLoader;
|
|
137854
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137855
|
+
return labels.includes("z");
|
|
137856
|
+
}
|
|
137857
|
+
hasDimT() {
|
|
137858
|
+
const loader = this.vivLoader;
|
|
137859
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137860
|
+
return labels.includes("t");
|
|
137861
|
+
}
|
|
137862
|
+
hasDimC() {
|
|
137863
|
+
const loader = this.vivLoader;
|
|
137864
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137865
|
+
return labels.includes("c");
|
|
137866
|
+
}
|
|
137708
137867
|
getNumZ() {
|
|
137709
137868
|
const loader = this.vivLoader;
|
|
137710
137869
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -137715,6 +137874,11 @@ class ImageWrapper {
|
|
|
137715
137874
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137716
137875
|
return shape[labels.indexOf("t")];
|
|
137717
137876
|
}
|
|
137877
|
+
getNumC() {
|
|
137878
|
+
const loader = this.vivLoader;
|
|
137879
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137880
|
+
return shape[labels.indexOf("c")];
|
|
137881
|
+
}
|
|
137718
137882
|
isMultiResolution() {
|
|
137719
137883
|
const loader = this.vivLoader;
|
|
137720
137884
|
const hasViewableResolutions = Boolean(
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as inflate_1 } from "./pako.esm-SxljTded.js";
|
|
2
|
-
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-
|
|
2
|
+
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-BpnGGDv2.js";
|
|
3
3
|
const LercParameters = {
|
|
4
4
|
AddCompression: 1
|
|
5
5
|
};
|
|
@@ -6,11 +6,13 @@ import type { AbstractImageWrapper, VivLoaderType, VivLoaderDataType, ImageOptio
|
|
|
6
6
|
export default class ImageWrapper implements AbstractImageWrapper {
|
|
7
7
|
vivLoader: VivLoaderType;
|
|
8
8
|
options: ImageOptions;
|
|
9
|
+
modelMatrix: number[] | null;
|
|
9
10
|
constructor(vivLoader: VivLoaderType, options: ImageOptions);
|
|
10
11
|
getType(): 'ome-tiff' | 'ome-zarr';
|
|
11
12
|
hasPhysicalSize(): boolean;
|
|
12
13
|
getData(): VivLoaderDataType;
|
|
13
14
|
getModelMatrix(): number[];
|
|
15
|
+
_getModelMatrix(): number[];
|
|
14
16
|
getDefaultTargetT(): number;
|
|
15
17
|
getDefaultTargetZ(): number;
|
|
16
18
|
getName(): string;
|
|
@@ -21,8 +23,13 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
21
23
|
getDtype(): string | undefined;
|
|
22
24
|
hasZStack(): boolean;
|
|
23
25
|
hasTStack(): boolean;
|
|
26
|
+
hasCStack(): boolean;
|
|
27
|
+
hasDimZ(): boolean;
|
|
28
|
+
hasDimT(): boolean;
|
|
29
|
+
hasDimC(): boolean;
|
|
24
30
|
getNumZ(): number;
|
|
25
31
|
getNumT(): number;
|
|
32
|
+
getNumC(): number;
|
|
26
33
|
isMultiResolution(): boolean;
|
|
27
34
|
getMultiResolutionStats(): ResolutionObject[];
|
|
28
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../src/ImageWrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../src/ImageWrapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAezB;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,oBAAoB;IAC/D,SAAS,EAAE,aAAa,CAAC;IAEzB,OAAO,EAAE,YAAY,CAAC;IAEtB,WAAW,EAAE,MAAM,EAAE,GAAC,IAAI,CAAQ;gBAEtB,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY;IAK3D,OAAO,IAAI,UAAU,GAAG,UAAU;IAUlC,eAAe,IAAI,OAAO;IAuB1B,OAAO,IAAI,iBAAiB;IAI5B,cAAc,IAAI,MAAM,EAAE;IAQ1B,eAAe,IAAI,MAAM,EAAE;IA8D3B,iBAAiB,IAAI,MAAM;IAe3B,iBAAiB,IAAI,MAAM;IAe3B,OAAO,IAAI,MAAM;IAyBjB,cAAc,IAAI,MAAM;IAmCxB,eAAe,IAAI,MAAM,EAAE;IAiC3B,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAC,MAAM,GAAG,MAAM;IAexD,iBAAiB,IAAI,aAAa,EAAE;IA6DpC,QAAQ,IAAI,MAAM,GAAG,SAAS;IAS9B,SAAS,IAAI,OAAO;IAWpB,SAAS,IAAI,OAAO;IAWpB,SAAS,IAAI,OAAO;IAWpB,OAAO,IAAI,OAAO;IAMlB,OAAO,IAAI,OAAO;IAMlB,OAAO,IAAI,OAAO;IAMlB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAMjB,iBAAiB,IAAI,OAAO;IAU5B,uBAAuB,IAAI,gBAAgB,EAAE;IAsB7C;;;;;OAKG;IACH,uBAAuB,IAAI,MAAM,GAAC,IAAI;IAetC,eAAe,IAAI,YAAY;IAc/B,aAAa,IAAI,OAAO;IAMxB,4BAA4B,IAAK,KAAK,GAAG,aAAa;CA+BvD"}
|
package/dist-tsc/ImageWrapper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { coordinateTransformationsToMatrix, getNgffAxes, getNgffAxesForTiff, physicalSizeToMatrix, hexToRgb, getSourceFromLoader, canLoadResolution, getStatsForResolution, isInterleaved as isInterleavedUtil, } from '@vitessce/spatial-utils';
|
|
1
|
+
import { normalizeCoordinateTransformations, coordinateTransformationsToMatrix, getNgffAxes, getNgffAxesForTiff, physicalSizeToMatrix, hexToRgb, getSourceFromLoader, canLoadResolution, getStatsForResolution, isInterleaved as isInterleavedUtil, } from '@vitessce/spatial-utils';
|
|
2
2
|
import { VIEWER_PALETTE } from '@vitessce/utils';
|
|
3
3
|
import { log } from '@vitessce/globals';
|
|
4
4
|
/**
|
|
@@ -8,6 +8,7 @@ import { log } from '@vitessce/globals';
|
|
|
8
8
|
export default class ImageWrapper {
|
|
9
9
|
vivLoader;
|
|
10
10
|
options;
|
|
11
|
+
modelMatrix = null;
|
|
11
12
|
constructor(vivLoader, options) {
|
|
12
13
|
this.options = options || {};
|
|
13
14
|
this.vivLoader = vivLoader;
|
|
@@ -38,6 +39,13 @@ export default class ImageWrapper {
|
|
|
38
39
|
return this.vivLoader.data;
|
|
39
40
|
}
|
|
40
41
|
getModelMatrix() {
|
|
42
|
+
if (!this.modelMatrix) {
|
|
43
|
+
// Cache the model matrix
|
|
44
|
+
this.modelMatrix = this._getModelMatrix();
|
|
45
|
+
}
|
|
46
|
+
return this.modelMatrix;
|
|
47
|
+
}
|
|
48
|
+
_getModelMatrix() {
|
|
41
49
|
// The user can always provide an additional transform matrix
|
|
42
50
|
// via the file definition options property.
|
|
43
51
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
@@ -45,11 +53,13 @@ export default class ImageWrapper {
|
|
|
45
53
|
// from the image file.
|
|
46
54
|
if ('multiscales' in this.vivLoader.metadata) {
|
|
47
55
|
// OME-Zarr case.
|
|
48
|
-
const { multiscales: [{ coordinateTransformations, axes, },], } = this.vivLoader.metadata;
|
|
56
|
+
const { multiscales: [{ datasets, coordinateTransformations: coordinateTransformationsFromFile, axes, },], } = this.vivLoader.metadata;
|
|
49
57
|
// Axes in v0.4 format.
|
|
50
58
|
const ngffAxes = getNgffAxes(axes);
|
|
51
59
|
const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
|
|
52
|
-
|
|
60
|
+
// Normalize the coordinate transformations from the file.
|
|
61
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
|
|
62
|
+
const transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, ngffAxes);
|
|
53
63
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
54
64
|
return transformMatrix;
|
|
55
65
|
}
|
|
@@ -221,15 +231,48 @@ export default class ImageWrapper {
|
|
|
221
231
|
hasZStack() {
|
|
222
232
|
const loader = this.vivLoader;
|
|
223
233
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
234
|
+
if (!labels.includes('z')) {
|
|
235
|
+
// If there is no 'z' dimension, then there is no z stack.
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
224
238
|
const hasZStack = shape[labels.indexOf('z')] > 1;
|
|
225
239
|
return hasZStack;
|
|
226
240
|
}
|
|
227
241
|
hasTStack() {
|
|
228
242
|
const loader = this.vivLoader;
|
|
229
243
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
244
|
+
if (!labels.includes('t')) {
|
|
245
|
+
// If there is no 't' dimension, then there is no time stack.
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
230
248
|
const hasTStack = shape[labels.indexOf('t')] > 1;
|
|
231
249
|
return hasTStack;
|
|
232
250
|
}
|
|
251
|
+
hasCStack() {
|
|
252
|
+
const loader = this.vivLoader;
|
|
253
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
254
|
+
if (!labels.includes('c')) {
|
|
255
|
+
// If there is no 'c' dimension, then there is no channel stack.
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
const hasCStack = shape[labels.indexOf('c')] > 1;
|
|
259
|
+
return hasCStack;
|
|
260
|
+
}
|
|
261
|
+
hasDimZ() {
|
|
262
|
+
const loader = this.vivLoader;
|
|
263
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
264
|
+
return labels.includes('z');
|
|
265
|
+
}
|
|
266
|
+
hasDimT() {
|
|
267
|
+
const loader = this.vivLoader;
|
|
268
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
269
|
+
return labels.includes('t');
|
|
270
|
+
}
|
|
271
|
+
hasDimC() {
|
|
272
|
+
const loader = this.vivLoader;
|
|
273
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
274
|
+
return labels.includes('c');
|
|
275
|
+
}
|
|
233
276
|
getNumZ() {
|
|
234
277
|
const loader = this.vivLoader;
|
|
235
278
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -240,6 +283,11 @@ export default class ImageWrapper {
|
|
|
240
283
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
241
284
|
return shape[labels.indexOf('t')];
|
|
242
285
|
}
|
|
286
|
+
getNumC() {
|
|
287
|
+
const loader = this.vivLoader;
|
|
288
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
289
|
+
return shape[labels.indexOf('c')];
|
|
290
|
+
}
|
|
243
291
|
isMultiResolution() {
|
|
244
292
|
const loader = this.vivLoader;
|
|
245
293
|
const hasViewableResolutions = Boolean(Array.from({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/image-utils",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.8",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@hms-dbmi/viv": "~0.16.0",
|
|
20
|
-
"@vitessce/types": "3.6.
|
|
21
|
-
"@vitessce/spatial-utils": "3.6.
|
|
22
|
-
"@vitessce/utils": "3.6.
|
|
23
|
-
"@vitessce/globals": "3.6.
|
|
20
|
+
"@vitessce/types": "3.6.8",
|
|
21
|
+
"@vitessce/spatial-utils": "3.6.8",
|
|
22
|
+
"@vitessce/utils": "3.6.8",
|
|
23
|
+
"@vitessce/globals": "3.6.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"vite": "^6.3.5",
|
package/src/ImageWrapper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
1
2
|
import type {
|
|
2
3
|
AbstractImageWrapper,
|
|
3
4
|
VivLoaderType,
|
|
@@ -8,6 +9,7 @@ import type {
|
|
|
8
9
|
BoundingCube,
|
|
9
10
|
} from '@vitessce/types';
|
|
10
11
|
import {
|
|
12
|
+
normalizeCoordinateTransformations,
|
|
11
13
|
coordinateTransformationsToMatrix,
|
|
12
14
|
getNgffAxes,
|
|
13
15
|
getNgffAxesForTiff,
|
|
@@ -29,6 +31,8 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
29
31
|
|
|
30
32
|
options: ImageOptions;
|
|
31
33
|
|
|
34
|
+
modelMatrix: number[]|null = null;
|
|
35
|
+
|
|
32
36
|
constructor(vivLoader: VivLoaderType, options: ImageOptions) {
|
|
33
37
|
this.options = options || {};
|
|
34
38
|
this.vivLoader = vivLoader;
|
|
@@ -72,6 +76,14 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
getModelMatrix(): number[] {
|
|
79
|
+
if (!this.modelMatrix) {
|
|
80
|
+
// Cache the model matrix
|
|
81
|
+
this.modelMatrix = this._getModelMatrix();
|
|
82
|
+
}
|
|
83
|
+
return this.modelMatrix;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_getModelMatrix(): number[] {
|
|
75
87
|
// The user can always provide an additional transform matrix
|
|
76
88
|
// via the file definition options property.
|
|
77
89
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
@@ -82,7 +94,8 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
82
94
|
const {
|
|
83
95
|
multiscales: [
|
|
84
96
|
{
|
|
85
|
-
|
|
97
|
+
datasets,
|
|
98
|
+
coordinateTransformations: coordinateTransformationsFromFile,
|
|
86
99
|
axes,
|
|
87
100
|
},
|
|
88
101
|
],
|
|
@@ -92,8 +105,12 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
92
105
|
const transformMatrixFromOptions = coordinateTransformationsToMatrix(
|
|
93
106
|
coordinateTransformationsFromOptions, ngffAxes,
|
|
94
107
|
);
|
|
108
|
+
// Normalize the coordinate transformations from the file.
|
|
109
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
|
|
110
|
+
coordinateTransformationsFromFile, datasets,
|
|
111
|
+
);
|
|
95
112
|
const transformMatrixFromFile = coordinateTransformationsToMatrix(
|
|
96
|
-
|
|
113
|
+
normCoordinateTransformationsFromFile, ngffAxes,
|
|
97
114
|
);
|
|
98
115
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
99
116
|
return transformMatrix;
|
|
@@ -339,6 +356,10 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
339
356
|
hasZStack(): boolean {
|
|
340
357
|
const loader = this.vivLoader;
|
|
341
358
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
359
|
+
if (!labels.includes('z')) {
|
|
360
|
+
// If there is no 'z' dimension, then there is no z stack.
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
342
363
|
const hasZStack = shape[labels.indexOf('z')] > 1;
|
|
343
364
|
return hasZStack;
|
|
344
365
|
}
|
|
@@ -346,10 +367,43 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
346
367
|
hasTStack(): boolean {
|
|
347
368
|
const loader = this.vivLoader;
|
|
348
369
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
370
|
+
if (!labels.includes('t')) {
|
|
371
|
+
// If there is no 't' dimension, then there is no time stack.
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
349
374
|
const hasTStack = shape[labels.indexOf('t')] > 1;
|
|
350
375
|
return hasTStack;
|
|
351
376
|
}
|
|
352
377
|
|
|
378
|
+
hasCStack(): boolean {
|
|
379
|
+
const loader = this.vivLoader;
|
|
380
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
381
|
+
if (!labels.includes('c')) {
|
|
382
|
+
// If there is no 'c' dimension, then there is no channel stack.
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
const hasCStack = shape[labels.indexOf('c')] > 1;
|
|
386
|
+
return hasCStack;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
hasDimZ(): boolean {
|
|
390
|
+
const loader = this.vivLoader;
|
|
391
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
392
|
+
return labels.includes('z');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
hasDimT(): boolean {
|
|
396
|
+
const loader = this.vivLoader;
|
|
397
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
398
|
+
return labels.includes('t');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
hasDimC(): boolean {
|
|
402
|
+
const loader = this.vivLoader;
|
|
403
|
+
const { labels } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
404
|
+
return labels.includes('c');
|
|
405
|
+
}
|
|
406
|
+
|
|
353
407
|
getNumZ(): number {
|
|
354
408
|
const loader = this.vivLoader;
|
|
355
409
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -362,6 +416,12 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
362
416
|
return shape[labels.indexOf('t')];
|
|
363
417
|
}
|
|
364
418
|
|
|
419
|
+
getNumC(): number {
|
|
420
|
+
const loader = this.vivLoader;
|
|
421
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
422
|
+
return shape[labels.indexOf('c')];
|
|
423
|
+
}
|
|
424
|
+
|
|
365
425
|
isMultiResolution(): boolean {
|
|
366
426
|
const loader = this.vivLoader;
|
|
367
427
|
const hasViewableResolutions = Boolean(
|