@vitessce/image-utils 3.6.10 → 3.6.12
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-F8grfDh6.js → deflate-B1WFcaes.js} +1 -1
- package/dist/{index-BpnGGDv2.js → index-BbTJFIrH.js} +174 -46
- package/dist/index.js +1 -1
- package/dist/{jpeg-Dvu4OTul.js → jpeg-CuuzsL-b.js} +1 -1
- package/dist/{lerc-Dqw24LZ0.js → lerc-DYxL2LGE.js} +1 -1
- package/dist/{lzw-C6ogUnun.js → lzw-1_s14ynQ.js} +1 -1
- package/dist/{packbits-BbCLrc81.js → packbits-C_zxEcEq.js} +1 -1
- package/dist/{raw-BTn6dLCD.js → raw-Dh_XQWs1.js} +1 -1
- package/dist/{webimage-C9hqCa1B.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;
|
|
@@ -119135,7 +119135,8 @@ const PIXELATED_TEXTURE_PARAMETERS = {
|
|
|
119135
119135
|
const GLSL_COLORMAPS = [
|
|
119136
119136
|
"plasma",
|
|
119137
119137
|
"viridis",
|
|
119138
|
-
"jet"
|
|
119138
|
+
"jet",
|
|
119139
|
+
"greys"
|
|
119139
119140
|
];
|
|
119140
119141
|
const GLSL_COLORMAP_DEFAULT = "plasma";
|
|
119141
119142
|
const COLORMAP_SHADER_PLACEHOLDER = "COLORMAP_FUNC";
|
|
@@ -120224,22 +120225,22 @@ function addDecoder(cases, importFn) {
|
|
|
120224
120225
|
}
|
|
120225
120226
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
120226
120227
|
}
|
|
120227
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
120228
|
-
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));
|
|
120229
120230
|
addDecoder(6, () => {
|
|
120230
120231
|
throw new Error("old style JPEG compression is not supported.");
|
|
120231
120232
|
});
|
|
120232
|
-
addDecoder(7, () => import("./jpeg-
|
|
120233
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
120234
|
-
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));
|
|
120235
120236
|
addDecoder(
|
|
120236
120237
|
34887,
|
|
120237
|
-
() => import("./lerc-
|
|
120238
|
+
() => import("./lerc-DYxL2LGE.js").then(async (m) => {
|
|
120238
120239
|
await m.zstd.init();
|
|
120239
120240
|
return m;
|
|
120240
120241
|
}).then((m) => m.default)
|
|
120241
120242
|
);
|
|
120242
|
-
addDecoder(50001, () => import("./webimage-
|
|
120243
|
+
addDecoder(50001, () => import("./webimage-44VOmBRw.js").then((m) => m.default));
|
|
120243
120244
|
function decodeRowAcc(row, stride) {
|
|
120244
120245
|
let length2 = row.length - stride;
|
|
120245
120246
|
let offset = 0;
|
|
@@ -137295,6 +137296,101 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
137295
137296
|
}
|
|
137296
137297
|
ContourLayerWithText.layerName = "ContourLayerWithText";
|
|
137297
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
|
+
}
|
|
137298
137394
|
function getSourceFromLoader(loader, level) {
|
|
137299
137395
|
const { data } = loader;
|
|
137300
137396
|
const source = Array.isArray(data) ? data[data.length - 1] : data;
|
|
@@ -137434,8 +137530,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137434
137530
|
}
|
|
137435
137531
|
} else if (spatialOutputAxes.length === 2) {
|
|
137436
137532
|
const nextMat = new Matrix4().fromArray([
|
|
137437
|
-
|
|
137438
|
-
|
|
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],
|
|
137439
137541
|
0,
|
|
137440
137542
|
0,
|
|
137441
137543
|
1,
|
|
@@ -137451,6 +137553,7 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137451
137553
|
const swapMat = new Matrix4().fromArray(swapMatNested.flat());
|
|
137452
137554
|
mat = mat.multiplyLeft(swapMat);
|
|
137453
137555
|
}
|
|
137556
|
+
mat = mat.transpose();
|
|
137454
137557
|
} else {
|
|
137455
137558
|
throw new Error("Affine transformation must have 2 or 3 rows.");
|
|
137456
137559
|
}
|
|
@@ -137477,6 +137580,9 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
137477
137580
|
}
|
|
137478
137581
|
});
|
|
137479
137582
|
}
|
|
137583
|
+
if (mat.some((value) => Number.isNaN(value))) {
|
|
137584
|
+
throw new Error("Matrix contains NaN values");
|
|
137585
|
+
}
|
|
137480
137586
|
return mat;
|
|
137481
137587
|
}
|
|
137482
137588
|
function hexToRgb(hex) {
|
|
@@ -137487,6 +137593,17 @@ function hexToRgb(hex) {
|
|
|
137487
137593
|
parseInt(result[3].toLowerCase(), 16)
|
|
137488
137594
|
];
|
|
137489
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
|
+
}
|
|
137490
137607
|
function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
|
|
137491
137608
|
var _a3;
|
|
137492
137609
|
let result = [];
|
|
@@ -137494,35 +137611,13 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
137494
137611
|
result = coordinateTransformations.flatMap((transform2) => {
|
|
137495
137612
|
if (transform2.input && transform2.output) {
|
|
137496
137613
|
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
137614
|
if (type === "sequence") {
|
|
137523
|
-
return normalizeCoordinateTransformations(transform2.transformations,
|
|
137615
|
+
return normalizeCoordinateTransformations(transform2.transformations, null);
|
|
137524
137616
|
}
|
|
137525
|
-
|
|
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.`);
|
|
137526
137621
|
}
|
|
137527
137622
|
return transform2;
|
|
137528
137623
|
});
|
|
@@ -137535,6 +137630,27 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
137535
137630
|
}
|
|
137536
137631
|
return result;
|
|
137537
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
|
+
}
|
|
137538
137654
|
function getDomains() {
|
|
137539
137655
|
const domains = {};
|
|
137540
137656
|
const needMin = ["Int8", "Int16", "Int32"];
|
|
@@ -137589,7 +137705,10 @@ class ImageWrapper {
|
|
|
137589
137705
|
return this.modelMatrix;
|
|
137590
137706
|
}
|
|
137591
137707
|
_getModelMatrix() {
|
|
137592
|
-
const {
|
|
137708
|
+
const {
|
|
137709
|
+
coordinateSystem = "global",
|
|
137710
|
+
coordinateTransformations: coordinateTransformationsFromOptions
|
|
137711
|
+
} = this.options;
|
|
137593
137712
|
if ("multiscales" in this.vivLoader.metadata) {
|
|
137594
137713
|
const {
|
|
137595
137714
|
multiscales: [
|
|
@@ -137605,14 +137724,23 @@ class ImageWrapper {
|
|
|
137605
137724
|
coordinateTransformationsFromOptions,
|
|
137606
137725
|
ngffAxes
|
|
137607
137726
|
);
|
|
137608
|
-
|
|
137609
|
-
|
|
137610
|
-
|
|
137611
|
-
|
|
137612
|
-
|
|
137613
|
-
|
|
137614
|
-
|
|
137615
|
-
|
|
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
|
+
}
|
|
137616
137744
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
137617
137745
|
return transformMatrix;
|
|
137618
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.12",
|
|
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.12",
|
|
21
|
+
"@vitessce/spatial-utils": "3.6.12",
|
|
22
|
+
"@vitessce/utils": "3.6.12",
|
|
23
|
+
"@vitessce/globals": "3.6.12"
|
|
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
|
}
|