@vitessce/image-utils 3.6.7 → 3.6.9
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-CYCHQGYv.js → deflate-F8grfDh6.js} +1 -1
- package/dist/{index-DAesl-Fs.js → index-BpnGGDv2.js} +128 -7
- package/dist/index.js +1 -1
- package/dist/{jpeg-RS5nId0k.js → jpeg-Dvu4OTul.js} +1 -1
- package/dist/{lerc-frA8I8i3.js → lerc-Dqw24LZ0.js} +1 -1
- package/dist/{lzw-DmH9LNuu.js → lzw-C6ogUnun.js} +1 -1
- package/dist/{packbits-wJQ_J7RA.js → packbits-BbCLrc81.js} +1 -1
- package/dist/{raw-D2BhjYdV.js → raw-BTn6dLCD.js} +1 -1
- package/dist/{webimage-BAE-tDiz.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 +46 -0
- package/package.json +5 -5
- package/src/ImageWrapper.ts +54 -0
|
@@ -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) {
|
|
@@ -137437,6 +137506,16 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
137437
137506
|
scale: transform2.scale
|
|
137438
137507
|
};
|
|
137439
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
|
+
}
|
|
137440
137519
|
if (type === "identity") {
|
|
137441
137520
|
return { type };
|
|
137442
137521
|
}
|
|
@@ -137471,6 +137550,7 @@ class ImageWrapper {
|
|
|
137471
137550
|
constructor(vivLoader, options) {
|
|
137472
137551
|
__publicField(this, "vivLoader");
|
|
137473
137552
|
__publicField(this, "options");
|
|
137553
|
+
__publicField(this, "modelMatrix", null);
|
|
137474
137554
|
this.options = options || {};
|
|
137475
137555
|
this.vivLoader = vivLoader;
|
|
137476
137556
|
}
|
|
@@ -137503,6 +137583,12 @@ class ImageWrapper {
|
|
|
137503
137583
|
return this.vivLoader.data;
|
|
137504
137584
|
}
|
|
137505
137585
|
getModelMatrix() {
|
|
137586
|
+
if (!this.modelMatrix) {
|
|
137587
|
+
this.modelMatrix = this._getModelMatrix();
|
|
137588
|
+
}
|
|
137589
|
+
return this.modelMatrix;
|
|
137590
|
+
}
|
|
137591
|
+
_getModelMatrix() {
|
|
137506
137592
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
137507
137593
|
if ("multiscales" in this.vivLoader.metadata) {
|
|
137508
137594
|
const {
|
|
@@ -137739,15 +137825,45 @@ class ImageWrapper {
|
|
|
137739
137825
|
hasZStack() {
|
|
137740
137826
|
const loader = this.vivLoader;
|
|
137741
137827
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137828
|
+
if (!labels.includes("z")) {
|
|
137829
|
+
return false;
|
|
137830
|
+
}
|
|
137742
137831
|
const hasZStack = shape[labels.indexOf("z")] > 1;
|
|
137743
137832
|
return hasZStack;
|
|
137744
137833
|
}
|
|
137745
137834
|
hasTStack() {
|
|
137746
137835
|
const loader = this.vivLoader;
|
|
137747
137836
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137837
|
+
if (!labels.includes("t")) {
|
|
137838
|
+
return false;
|
|
137839
|
+
}
|
|
137748
137840
|
const hasTStack = shape[labels.indexOf("t")] > 1;
|
|
137749
137841
|
return hasTStack;
|
|
137750
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
|
+
}
|
|
137751
137867
|
getNumZ() {
|
|
137752
137868
|
const loader = this.vivLoader;
|
|
137753
137869
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -137758,6 +137874,11 @@ class ImageWrapper {
|
|
|
137758
137874
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
137759
137875
|
return shape[labels.indexOf("t")];
|
|
137760
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
|
+
}
|
|
137761
137882
|
isMultiResolution() {
|
|
137762
137883
|
const loader = this.vivLoader;
|
|
137763
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
|
@@ -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;
|
|
@@ -223,15 +231,48 @@ export default class ImageWrapper {
|
|
|
223
231
|
hasZStack() {
|
|
224
232
|
const loader = this.vivLoader;
|
|
225
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
|
+
}
|
|
226
238
|
const hasZStack = shape[labels.indexOf('z')] > 1;
|
|
227
239
|
return hasZStack;
|
|
228
240
|
}
|
|
229
241
|
hasTStack() {
|
|
230
242
|
const loader = this.vivLoader;
|
|
231
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
|
+
}
|
|
232
248
|
const hasTStack = shape[labels.indexOf('t')] > 1;
|
|
233
249
|
return hasTStack;
|
|
234
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
|
+
}
|
|
235
276
|
getNumZ() {
|
|
236
277
|
const loader = this.vivLoader;
|
|
237
278
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -242,6 +283,11 @@ export default class ImageWrapper {
|
|
|
242
283
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
243
284
|
return shape[labels.indexOf('t')];
|
|
244
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
|
+
}
|
|
245
291
|
isMultiResolution() {
|
|
246
292
|
const loader = this.vivLoader;
|
|
247
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.9",
|
|
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.9",
|
|
21
|
+
"@vitessce/spatial-utils": "3.6.9",
|
|
22
|
+
"@vitessce/utils": "3.6.9",
|
|
23
|
+
"@vitessce/globals": "3.6.9"
|
|
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,
|
|
@@ -30,6 +31,8 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
30
31
|
|
|
31
32
|
options: ImageOptions;
|
|
32
33
|
|
|
34
|
+
modelMatrix: number[]|null = null;
|
|
35
|
+
|
|
33
36
|
constructor(vivLoader: VivLoaderType, options: ImageOptions) {
|
|
34
37
|
this.options = options || {};
|
|
35
38
|
this.vivLoader = vivLoader;
|
|
@@ -73,6 +76,14 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
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[] {
|
|
76
87
|
// The user can always provide an additional transform matrix
|
|
77
88
|
// via the file definition options property.
|
|
78
89
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
@@ -345,6 +356,10 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
345
356
|
hasZStack(): boolean {
|
|
346
357
|
const loader = this.vivLoader;
|
|
347
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
|
+
}
|
|
348
363
|
const hasZStack = shape[labels.indexOf('z')] > 1;
|
|
349
364
|
return hasZStack;
|
|
350
365
|
}
|
|
@@ -352,10 +367,43 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
352
367
|
hasTStack(): boolean {
|
|
353
368
|
const loader = this.vivLoader;
|
|
354
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
|
+
}
|
|
355
374
|
const hasTStack = shape[labels.indexOf('t')] > 1;
|
|
356
375
|
return hasTStack;
|
|
357
376
|
}
|
|
358
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
|
+
|
|
359
407
|
getNumZ(): number {
|
|
360
408
|
const loader = this.vivLoader;
|
|
361
409
|
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
@@ -368,6 +416,12 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
368
416
|
return shape[labels.indexOf('t')];
|
|
369
417
|
}
|
|
370
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
|
+
|
|
371
425
|
isMultiResolution(): boolean {
|
|
372
426
|
const loader = this.vivLoader;
|
|
373
427
|
const hasViewableResolutions = Boolean(
|