@vitessce/image-utils 3.6.11 → 3.6.13
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-DpUWNzaA.js → deflate-B1WFcaes.js} +1 -1
- package/dist/{index-C6BUzI7I.js → index-BbTJFIrH.js} +172 -45
- package/dist/index.js +1 -1
- package/dist/{jpeg-DjPWl9ba.js → jpeg-CuuzsL-b.js} +1 -1
- package/dist/{lerc-Bx0nEWwc.js → lerc-DYxL2LGE.js} +1 -1
- package/dist/{lzw-DoTQYaZG.js → lzw-1_s14ynQ.js} +1 -1
- package/dist/{packbits-OCRRZ5vn.js → packbits-C_zxEcEq.js} +1 -1
- package/dist/{raw-DF1Hc6aN.js → raw-Dh_XQWs1.js} +1 -1
- package/dist/{webimage-la2HMraT.js → webimage-44VOmBRw.js} +1 -1
- package/dist-tsc/ImageWrapper.d.ts.map +1 -1
- package/dist-tsc/ImageWrapper.js +17 -5
- package/package.json +5 -5
- package/src/ImageWrapper.ts +26 -8
|
@@ -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-BbTJFIrH.js";
|
|
3
3
|
class DeflateDecoder extends BaseDecoder {
|
|
4
4
|
decodeBlock(buffer) {
|
|
5
5
|
return inflate_1(new Uint8Array(buffer)).buffer;
|
|
@@ -120225,22 +120225,22 @@ function addDecoder(cases, importFn) {
|
|
|
120225
120225
|
}
|
|
120226
120226
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
120227
120227
|
}
|
|
120228
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
120229
|
-
addDecoder(5, () => import("./lzw-
|
|
120228
|
+
addDecoder([void 0, 1], () => import("./raw-Dh_XQWs1.js").then((m) => m.default));
|
|
120229
|
+
addDecoder(5, () => import("./lzw-1_s14ynQ.js").then((m) => m.default));
|
|
120230
120230
|
addDecoder(6, () => {
|
|
120231
120231
|
throw new Error("old style JPEG compression is not supported.");
|
|
120232
120232
|
});
|
|
120233
|
-
addDecoder(7, () => import("./jpeg-
|
|
120234
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
120235
|
-
addDecoder(32773, () => import("./packbits-
|
|
120233
|
+
addDecoder(7, () => import("./jpeg-CuuzsL-b.js").then((m) => m.default));
|
|
120234
|
+
addDecoder([8, 32946], () => import("./deflate-B1WFcaes.js").then((m) => m.default));
|
|
120235
|
+
addDecoder(32773, () => import("./packbits-C_zxEcEq.js").then((m) => m.default));
|
|
120236
120236
|
addDecoder(
|
|
120237
120237
|
34887,
|
|
120238
|
-
() => import("./lerc-
|
|
120238
|
+
() => import("./lerc-DYxL2LGE.js").then(async (m) => {
|
|
120239
120239
|
await m.zstd.init();
|
|
120240
120240
|
return m;
|
|
120241
120241
|
}).then((m) => m.default)
|
|
120242
120242
|
);
|
|
120243
|
-
addDecoder(50001, () => import("./webimage-
|
|
120243
|
+
addDecoder(50001, () => import("./webimage-44VOmBRw.js").then((m) => m.default));
|
|
120244
120244
|
function decodeRowAcc(row, stride) {
|
|
120245
120245
|
let length2 = row.length - stride;
|
|
120246
120246
|
let offset = 0;
|
|
@@ -137296,6 +137296,101 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
137296
137296
|
}
|
|
137297
137297
|
ContourLayerWithText.layerName = "ContourLayerWithText";
|
|
137298
137298
|
ContourLayerWithText.defaultProps = defaultProps;
|
|
137299
|
+
class InternMap extends Map {
|
|
137300
|
+
constructor(entries, key = keyof) {
|
|
137301
|
+
super();
|
|
137302
|
+
Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
|
|
137303
|
+
if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
|
|
137304
|
+
}
|
|
137305
|
+
get(key) {
|
|
137306
|
+
return super.get(intern_get(this, key));
|
|
137307
|
+
}
|
|
137308
|
+
has(key) {
|
|
137309
|
+
return super.has(intern_get(this, key));
|
|
137310
|
+
}
|
|
137311
|
+
set(key, value) {
|
|
137312
|
+
return super.set(intern_set(this, key), value);
|
|
137313
|
+
}
|
|
137314
|
+
delete(key) {
|
|
137315
|
+
return super.delete(intern_delete(this, key));
|
|
137316
|
+
}
|
|
137317
|
+
}
|
|
137318
|
+
function intern_get({ _intern, _key }, value) {
|
|
137319
|
+
const key = _key(value);
|
|
137320
|
+
return _intern.has(key) ? _intern.get(key) : value;
|
|
137321
|
+
}
|
|
137322
|
+
function intern_set({ _intern, _key }, value) {
|
|
137323
|
+
const key = _key(value);
|
|
137324
|
+
if (_intern.has(key)) return _intern.get(key);
|
|
137325
|
+
_intern.set(key, value);
|
|
137326
|
+
return value;
|
|
137327
|
+
}
|
|
137328
|
+
function intern_delete({ _intern, _key }, value) {
|
|
137329
|
+
const key = _key(value);
|
|
137330
|
+
if (_intern.has(key)) {
|
|
137331
|
+
value = _intern.get(key);
|
|
137332
|
+
_intern.delete(key);
|
|
137333
|
+
}
|
|
137334
|
+
return value;
|
|
137335
|
+
}
|
|
137336
|
+
function keyof(value) {
|
|
137337
|
+
return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|
137338
|
+
}
|
|
137339
|
+
class DAG {
|
|
137340
|
+
/**
|
|
137341
|
+
* DAG constructor.
|
|
137342
|
+
* @param {{ from: string, to: string, attributes: any}[]} edges
|
|
137343
|
+
*/
|
|
137344
|
+
constructor(edges) {
|
|
137345
|
+
this.graph = /* @__PURE__ */ new Map();
|
|
137346
|
+
this.edgeData = new InternMap([], JSON.stringify);
|
|
137347
|
+
edges.forEach((edge) => {
|
|
137348
|
+
const { from, to } = edge;
|
|
137349
|
+
if (!this.graph.has(from)) {
|
|
137350
|
+
this.graph.set(from, []);
|
|
137351
|
+
}
|
|
137352
|
+
this.graph.get(from).push(to);
|
|
137353
|
+
this.edgeData.set([from, to], edge.attributes);
|
|
137354
|
+
});
|
|
137355
|
+
}
|
|
137356
|
+
/**
|
|
137357
|
+
* Find a path from start to end using DFS.
|
|
137358
|
+
* @param {string} start
|
|
137359
|
+
* @param {string} end
|
|
137360
|
+
* @returns {{ from: string, to: string, attributes: any }[] | null} Returns
|
|
137361
|
+
* the path as an array of edges or null if no path exists.
|
|
137362
|
+
*/
|
|
137363
|
+
findPath(start, end) {
|
|
137364
|
+
const path = [];
|
|
137365
|
+
const visited = /* @__PURE__ */ new Set();
|
|
137366
|
+
const dfs = (node2) => {
|
|
137367
|
+
if (node2 === end) {
|
|
137368
|
+
return true;
|
|
137369
|
+
}
|
|
137370
|
+
visited.add(node2);
|
|
137371
|
+
const neighbors = this.graph.get(node2) || [];
|
|
137372
|
+
for (const neighbor of neighbors) {
|
|
137373
|
+
if (!visited.has(neighbor)) {
|
|
137374
|
+
path.push([node2, neighbor]);
|
|
137375
|
+
if (dfs(neighbor)) {
|
|
137376
|
+
return true;
|
|
137377
|
+
}
|
|
137378
|
+
path.pop();
|
|
137379
|
+
}
|
|
137380
|
+
}
|
|
137381
|
+
return false;
|
|
137382
|
+
};
|
|
137383
|
+
const found = dfs(start);
|
|
137384
|
+
if (found) {
|
|
137385
|
+
return path.map(([from, to]) => ({
|
|
137386
|
+
from,
|
|
137387
|
+
to,
|
|
137388
|
+
attributes: this.edgeData.get([from, to])
|
|
137389
|
+
}));
|
|
137390
|
+
}
|
|
137391
|
+
return null;
|
|
137392
|
+
}
|
|
137393
|
+
}
|
|
137299
137394
|
function getSourceFromLoader(loader, level) {
|
|
137300
137395
|
const { data } = loader;
|
|
137301
137396
|
const source = Array.isArray(data) ? data[data.length - 1] : data;
|
|
@@ -137435,8 +137530,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137435
137530
|
}
|
|
137436
137531
|
} else if (spatialOutputAxes.length === 2) {
|
|
137437
137532
|
const nextMat = new Matrix4().fromArray([
|
|
137438
|
-
|
|
137439
|
-
|
|
137533
|
+
filteredAffine[0][0],
|
|
137534
|
+
filteredAffine[0][1],
|
|
137535
|
+
0,
|
|
137536
|
+
filteredAffine[0][2],
|
|
137537
|
+
filteredAffine[1][0],
|
|
137538
|
+
filteredAffine[1][1],
|
|
137539
|
+
0,
|
|
137540
|
+
filteredAffine[1][2],
|
|
137440
137541
|
0,
|
|
137441
137542
|
0,
|
|
137442
137543
|
1,
|
|
@@ -137452,6 +137553,7 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137452
137553
|
const swapMat = new Matrix4().fromArray(swapMatNested.flat());
|
|
137453
137554
|
mat = mat.multiplyLeft(swapMat);
|
|
137454
137555
|
}
|
|
137556
|
+
mat = mat.transpose();
|
|
137455
137557
|
} else {
|
|
137456
137558
|
throw new Error("Affine transformation must have 2 or 3 rows.");
|
|
137457
137559
|
}
|
|
@@ -137478,6 +137580,9 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137478
137580
|
}
|
|
137479
137581
|
});
|
|
137480
137582
|
}
|
|
137583
|
+
if (mat.some((value) => Number.isNaN(value))) {
|
|
137584
|
+
throw new Error("Matrix contains NaN values");
|
|
137585
|
+
}
|
|
137481
137586
|
return mat;
|
|
137482
137587
|
}
|
|
137483
137588
|
function hexToRgb(hex) {
|
|
@@ -137488,6 +137593,17 @@ function hexToRgb(hex) {
|
|
|
137488
137593
|
parseInt(result[3].toLowerCase(), 16)
|
|
137489
137594
|
];
|
|
137490
137595
|
}
|
|
137596
|
+
function normalizeAxes(axes) {
|
|
137597
|
+
return axes.map((axisInfo) => {
|
|
137598
|
+
if (typeof axisInfo === "string") {
|
|
137599
|
+
return { name: axisInfo, type: "space" };
|
|
137600
|
+
}
|
|
137601
|
+
return axisInfo;
|
|
137602
|
+
});
|
|
137603
|
+
}
|
|
137604
|
+
function getIntrinsicCoordinateSystem(normAxes) {
|
|
137605
|
+
return normAxes.map((axis) => axis.name).join("");
|
|
137606
|
+
}
|
|
137491
137607
|
function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
|
|
137492
137608
|
var _a3;
|
|
137493
137609
|
let result = [];
|
|
@@ -137495,35 +137611,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
137495
137611
|
result = coordinateTransformations.flatMap((transform2) => {
|
|
137496
137612
|
if (transform2.input && transform2.output) {
|
|
137497
137613
|
const { type } = transform2;
|
|
137498
|
-
if (type === "translation") {
|
|
137499
|
-
return {
|
|
137500
|
-
type,
|
|
137501
|
-
translation: transform2.translation
|
|
137502
|
-
};
|
|
137503
|
-
}
|
|
137504
|
-
if (type === "scale") {
|
|
137505
|
-
return {
|
|
137506
|
-
type,
|
|
137507
|
-
scale: transform2.scale
|
|
137508
|
-
};
|
|
137509
|
-
}
|
|
137510
|
-
if (type === "affine") {
|
|
137511
|
-
return {
|
|
137512
|
-
type,
|
|
137513
|
-
affine: transform2.affine,
|
|
137514
|
-
// Affine transformations can potentially swap axes,
|
|
137515
|
-
// so we need to include the input and output axes.
|
|
137516
|
-
input: transform2.input,
|
|
137517
|
-
output: transform2.output
|
|
137518
|
-
};
|
|
137519
|
-
}
|
|
137520
|
-
if (type === "identity") {
|
|
137521
|
-
return { type };
|
|
137522
|
-
}
|
|
137523
137614
|
if (type === "sequence") {
|
|
137524
|
-
return normalizeCoordinateTransformations(transform2.transformations,
|
|
137615
|
+
return normalizeCoordinateTransformations(transform2.transformations, null);
|
|
137525
137616
|
}
|
|
137526
|
-
|
|
137617
|
+
if (type === "affine" || type === "translation" || type === "scale" || type === "identity") {
|
|
137618
|
+
return transform2;
|
|
137619
|
+
}
|
|
137620
|
+
log$5.error(`Coordinate transformation type "${type}" is not supported.`);
|
|
137527
137621
|
}
|
|
137528
137622
|
return transform2;
|
|
137529
137623
|
});
|
|
@@ -137536,6 +137630,27 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
137536
137630
|
}
|
|
137537
137631
|
return result;
|
|
137538
137632
|
}
|
|
137633
|
+
function coordinateTransformationsToMatrixForSpatialData(ngffMetadata, targetCoordinateSystem) {
|
|
137634
|
+
const { datasets, coordinateTransformations, axes } = ngffMetadata;
|
|
137635
|
+
const normAxes = normalizeAxes(axes);
|
|
137636
|
+
const intrinsicCoordinateSystem = getIntrinsicCoordinateSystem(normAxes);
|
|
137637
|
+
const edges = coordinateTransformations.map((ct) => ({
|
|
137638
|
+
from: ct.input.name,
|
|
137639
|
+
to: ct.output.name,
|
|
137640
|
+
attributes: ct
|
|
137641
|
+
}));
|
|
137642
|
+
const dag = new DAG(edges);
|
|
137643
|
+
const ctPath = dag.findPath(intrinsicCoordinateSystem, targetCoordinateSystem);
|
|
137644
|
+
if (!ctPath) {
|
|
137645
|
+
if (!coordinateTransformations.find((ct) => ct.output.name === targetCoordinateSystem)) {
|
|
137646
|
+
throw new Error(`No coordinate transformation found with output.name "${targetCoordinateSystem}".`);
|
|
137647
|
+
}
|
|
137648
|
+
throw new Error(`No path found from "${intrinsicCoordinateSystem}" to "${targetCoordinateSystem}".`);
|
|
137649
|
+
}
|
|
137650
|
+
const filteredTransformations = ctPath.map((ctEdge) => ctEdge.attributes);
|
|
137651
|
+
const normalizedTransformations = normalizeCoordinateTransformations(filteredTransformations, datasets);
|
|
137652
|
+
return coordinateTransformationsToMatrix(normalizedTransformations, normAxes);
|
|
137653
|
+
}
|
|
137539
137654
|
function getDomains() {
|
|
137540
137655
|
const domains = {};
|
|
137541
137656
|
const needMin = ["Int8", "Int16", "Int32"];
|
|
@@ -137590,7 +137705,10 @@ class ImageWrapper {
|
|
|
137590
137705
|
return this.modelMatrix;
|
|
137591
137706
|
}
|
|
137592
137707
|
_getModelMatrix() {
|
|
137593
|
-
const {
|
|
137708
|
+
const {
|
|
137709
|
+
coordinateSystem = "global",
|
|
137710
|
+
coordinateTransformations: coordinateTransformationsFromOptions
|
|
137711
|
+
} = this.options;
|
|
137594
137712
|
if ("multiscales" in this.vivLoader.metadata) {
|
|
137595
137713
|
const {
|
|
137596
137714
|
multiscales: [
|
|
@@ -137606,14 +137724,23 @@ class ImageWrapper {
|
|
|
137606
137724
|
coordinateTransformationsFromOptions,
|
|
137607
137725
|
ngffAxes
|
|
137608
137726
|
);
|
|
137609
|
-
|
|
137610
|
-
|
|
137611
|
-
|
|
137612
|
-
|
|
137613
|
-
|
|
137614
|
-
|
|
137615
|
-
|
|
137616
|
-
|
|
137727
|
+
let transformMatrixFromFile;
|
|
137728
|
+
if ("spatialdata_attrs" in this.vivLoader.metadata) {
|
|
137729
|
+
transformMatrixFromFile = coordinateTransformationsToMatrixForSpatialData(
|
|
137730
|
+
// Pass the first multiscales element.
|
|
137731
|
+
this.vivLoader.metadata.multiscales[0],
|
|
137732
|
+
coordinateSystem
|
|
137733
|
+
);
|
|
137734
|
+
} else {
|
|
137735
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
|
|
137736
|
+
coordinateTransformationsFromFile,
|
|
137737
|
+
datasets
|
|
137738
|
+
);
|
|
137739
|
+
transformMatrixFromFile = coordinateTransformationsToMatrix(
|
|
137740
|
+
normCoordinateTransformationsFromFile,
|
|
137741
|
+
ngffAxes
|
|
137742
|
+
);
|
|
137743
|
+
}
|
|
137617
137744
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
137618
137745
|
return transformMatrix;
|
|
137619
137746
|
}
|
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-BbTJFIrH.js";
|
|
3
3
|
const LercParameters = {
|
|
4
4
|
AddCompression: 1
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAgBzB;;;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;IA+E3B,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 { normalizeCoordinateTransformations, coordinateTransformationsToMatrix, getNgffAxes, getNgffAxesForTiff, physicalSizeToMatrix, hexToRgb, getSourceFromLoader, canLoadResolution, getStatsForResolution, isInterleaved as isInterleavedUtil, } from '@vitessce/spatial-utils';
|
|
1
|
+
import { normalizeCoordinateTransformations, coordinateTransformationsToMatrix, coordinateTransformationsToMatrixForSpatialData, 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
|
/**
|
|
@@ -48,7 +48,7 @@ export default class ImageWrapper {
|
|
|
48
48
|
_getModelMatrix() {
|
|
49
49
|
// The user can always provide an additional transform matrix
|
|
50
50
|
// via the file definition options property.
|
|
51
|
-
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
51
|
+
const { coordinateSystem = 'global', coordinateTransformations: coordinateTransformationsFromOptions, } = this.options;
|
|
52
52
|
// We combine any user-provided transform matrix with the one
|
|
53
53
|
// from the image file.
|
|
54
54
|
if ('multiscales' in this.vivLoader.metadata) {
|
|
@@ -57,9 +57,21 @@ export default class ImageWrapper {
|
|
|
57
57
|
// Axes in v0.4 format.
|
|
58
58
|
const ngffAxes = getNgffAxes(axes);
|
|
59
59
|
const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let transformMatrixFromFile;
|
|
61
|
+
// Note: Older SpatialData objects did not include 'spatialdata_attrs'
|
|
62
|
+
// in the image Element metadata.
|
|
63
|
+
if ('spatialdata_attrs' in this.vivLoader.metadata) {
|
|
64
|
+
// This is a SpatialData images or labels element.
|
|
65
|
+
transformMatrixFromFile = coordinateTransformationsToMatrixForSpatialData(
|
|
66
|
+
// Pass the first multiscales element.
|
|
67
|
+
this.vivLoader.metadata.multiscales[0], coordinateSystem);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// TODO: update this if NGFF eventually supports named coordinate systems.
|
|
71
|
+
// Normalize the coordinate transformations from the file.
|
|
72
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(coordinateTransformationsFromFile, datasets);
|
|
73
|
+
transformMatrixFromFile = coordinateTransformationsToMatrix(normCoordinateTransformationsFromFile, ngffAxes);
|
|
74
|
+
}
|
|
63
75
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
64
76
|
return transformMatrix;
|
|
65
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/image-utils",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.13",
|
|
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.13",
|
|
21
|
+
"@vitessce/spatial-utils": "3.6.13",
|
|
22
|
+
"@vitessce/utils": "3.6.13",
|
|
23
|
+
"@vitessce/globals": "3.6.13"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"vite": "^6.3.5",
|
package/src/ImageWrapper.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import {
|
|
12
12
|
normalizeCoordinateTransformations,
|
|
13
13
|
coordinateTransformationsToMatrix,
|
|
14
|
+
coordinateTransformationsToMatrixForSpatialData,
|
|
14
15
|
getNgffAxes,
|
|
15
16
|
getNgffAxesForTiff,
|
|
16
17
|
physicalSizeToMatrix,
|
|
@@ -86,7 +87,10 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
86
87
|
_getModelMatrix(): number[] {
|
|
87
88
|
// The user can always provide an additional transform matrix
|
|
88
89
|
// via the file definition options property.
|
|
89
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
coordinateSystem = 'global',
|
|
92
|
+
coordinateTransformations: coordinateTransformationsFromOptions,
|
|
93
|
+
} = this.options;
|
|
90
94
|
// We combine any user-provided transform matrix with the one
|
|
91
95
|
// from the image file.
|
|
92
96
|
if ('multiscales' in this.vivLoader.metadata) {
|
|
@@ -105,13 +109,27 @@ export default class ImageWrapper implements AbstractImageWrapper {
|
|
|
105
109
|
const transformMatrixFromOptions = coordinateTransformationsToMatrix(
|
|
106
110
|
coordinateTransformationsFromOptions, ngffAxes,
|
|
107
111
|
);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
|
|
113
|
+
let transformMatrixFromFile;
|
|
114
|
+
// Note: Older SpatialData objects did not include 'spatialdata_attrs'
|
|
115
|
+
// in the image Element metadata.
|
|
116
|
+
if ('spatialdata_attrs' in this.vivLoader.metadata) {
|
|
117
|
+
// This is a SpatialData images or labels element.
|
|
118
|
+
transformMatrixFromFile = coordinateTransformationsToMatrixForSpatialData(
|
|
119
|
+
// Pass the first multiscales element.
|
|
120
|
+
this.vivLoader.metadata.multiscales[0],
|
|
121
|
+
coordinateSystem,
|
|
122
|
+
);
|
|
123
|
+
} else {
|
|
124
|
+
// TODO: update this if NGFF eventually supports named coordinate systems.
|
|
125
|
+
// Normalize the coordinate transformations from the file.
|
|
126
|
+
const normCoordinateTransformationsFromFile = normalizeCoordinateTransformations(
|
|
127
|
+
coordinateTransformationsFromFile, datasets,
|
|
128
|
+
);
|
|
129
|
+
transformMatrixFromFile = coordinateTransformationsToMatrix(
|
|
130
|
+
normCoordinateTransformationsFromFile, ngffAxes,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
115
133
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
116
134
|
return transformMatrix;
|
|
117
135
|
}
|