@vitessce/zarr 3.1.3 → 3.2.1
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-7cf024eb.js → deflate-2b2b285b.js} +1 -1
- package/dist/{index-58807fea.js → index-9ae02eab.js} +1117 -92
- package/dist/index.js +8 -6
- package/dist/{jpeg-d96062a4.js → jpeg-af2abb26.js} +1 -1
- package/dist/{lerc-6865e403.js → lerc-ac5abe1c.js} +1 -1
- package/dist/{lzw-5712b930.js → lzw-b264d65a.js} +1 -1
- package/dist/{packbits-ed7b9205.js → packbits-58bf813f.js} +1 -1
- package/dist/{raw-bf0fb054.js → raw-4015af9c.js} +1 -1
- package/dist/{webimage-a8d94527.js → webimage-d31de7e9.js} +1 -1
- package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.js +33 -0
- package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.js +33 -0
- package/dist-tsc/anndata-loaders/index.d.ts +2 -0
- package/dist-tsc/anndata-loaders/index.js +2 -0
- package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts.map +1 -1
- package/dist-tsc/ome-loaders/OmeZarrLoader.js +11 -10
- package/package.json +8 -7
- package/src/anndata-loaders/ObsPointsAnndataLoader.js +40 -0
- package/src/anndata-loaders/ObsSpotsAnndataLoader.js +40 -0
- package/src/anndata-loaders/index.js +2 -0
- package/src/ome-loaders/OmeZarrLoader.js +15 -9
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
import { AbstractTwoStepLoader, LoaderResult, AbstractLoaderError } from "@vitessce/vit-s";
|
|
2
8
|
import "react";
|
|
3
9
|
function _mergeNamespaces(n3, m) {
|
|
@@ -9633,6 +9639,70 @@ class ObsEmbeddingAnndataLoader extends AbstractTwoStepLoader {
|
|
|
9633
9639
|
)));
|
|
9634
9640
|
}
|
|
9635
9641
|
}
|
|
9642
|
+
class ObsSpotsAnndataLoader extends AbstractTwoStepLoader {
|
|
9643
|
+
/**
|
|
9644
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
9645
|
+
* @returns {Promise} A promise for an array of columns.
|
|
9646
|
+
*/
|
|
9647
|
+
loadSpots() {
|
|
9648
|
+
const { path, dims = [0, 1] } = this.options;
|
|
9649
|
+
if (this.locations) {
|
|
9650
|
+
return this.locations;
|
|
9651
|
+
}
|
|
9652
|
+
if (!this.locations) {
|
|
9653
|
+
this.locations = this.dataSource.loadNumericForDims(path, dims);
|
|
9654
|
+
return this.locations;
|
|
9655
|
+
}
|
|
9656
|
+
this.locations = Promise.resolve(null);
|
|
9657
|
+
return this.locations;
|
|
9658
|
+
}
|
|
9659
|
+
async load() {
|
|
9660
|
+
const { path } = this.options;
|
|
9661
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
9662
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
9663
|
+
return Promise.reject(superResult);
|
|
9664
|
+
}
|
|
9665
|
+
return Promise.all([
|
|
9666
|
+
this.dataSource.loadObsIndex(path),
|
|
9667
|
+
this.loadSpots()
|
|
9668
|
+
]).then(([obsIndex, obsSpots]) => Promise.resolve(new LoaderResult(
|
|
9669
|
+
{ obsIndex, obsSpots },
|
|
9670
|
+
null
|
|
9671
|
+
)));
|
|
9672
|
+
}
|
|
9673
|
+
}
|
|
9674
|
+
class ObsPointsAnndataLoader extends AbstractTwoStepLoader {
|
|
9675
|
+
/**
|
|
9676
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
9677
|
+
* @returns {Promise} A promise for an array of columns.
|
|
9678
|
+
*/
|
|
9679
|
+
loadPoints() {
|
|
9680
|
+
const { path, dims = [0, 1] } = this.options;
|
|
9681
|
+
if (this.locations) {
|
|
9682
|
+
return this.locations;
|
|
9683
|
+
}
|
|
9684
|
+
if (!this.locations) {
|
|
9685
|
+
this.locations = this.dataSource.loadNumericForDims(path, dims);
|
|
9686
|
+
return this.locations;
|
|
9687
|
+
}
|
|
9688
|
+
this.locations = Promise.resolve(null);
|
|
9689
|
+
return this.locations;
|
|
9690
|
+
}
|
|
9691
|
+
async load() {
|
|
9692
|
+
const { path } = this.options;
|
|
9693
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
9694
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
9695
|
+
return Promise.reject(superResult);
|
|
9696
|
+
}
|
|
9697
|
+
return Promise.all([
|
|
9698
|
+
this.dataSource.loadObsIndex(path),
|
|
9699
|
+
this.loadPoints()
|
|
9700
|
+
]).then(([obsIndex, obsPoints]) => Promise.resolve(new LoaderResult(
|
|
9701
|
+
{ obsIndex, obsPoints },
|
|
9702
|
+
null
|
|
9703
|
+
)));
|
|
9704
|
+
}
|
|
9705
|
+
}
|
|
9636
9706
|
class ObsLocationsAnndataLoader extends AbstractTwoStepLoader {
|
|
9637
9707
|
/**
|
|
9638
9708
|
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
@@ -10420,7 +10490,7 @@ function negate(out, a2) {
|
|
|
10420
10490
|
out[2] = -a2[2];
|
|
10421
10491
|
return out;
|
|
10422
10492
|
}
|
|
10423
|
-
function normalize$
|
|
10493
|
+
function normalize$4(out, a2) {
|
|
10424
10494
|
var x2 = a2[0];
|
|
10425
10495
|
var y2 = a2[1];
|
|
10426
10496
|
var z2 = a2[2];
|
|
@@ -11729,7 +11799,7 @@ function squaredLength$1(a2) {
|
|
|
11729
11799
|
var w2 = a2[3];
|
|
11730
11800
|
return x2 * x2 + y2 * y2 + z2 * z2 + w2 * w2;
|
|
11731
11801
|
}
|
|
11732
|
-
function normalize$
|
|
11802
|
+
function normalize$3(out, a2) {
|
|
11733
11803
|
var x2 = a2[0];
|
|
11734
11804
|
var y2 = a2[1];
|
|
11735
11805
|
var z2 = a2[2];
|
|
@@ -12366,7 +12436,7 @@ var dot$2 = dot$3;
|
|
|
12366
12436
|
var lerp$1 = lerp$2;
|
|
12367
12437
|
var length$2 = length$3;
|
|
12368
12438
|
var squaredLength = squaredLength$1;
|
|
12369
|
-
var normalize$
|
|
12439
|
+
var normalize$2 = normalize$3;
|
|
12370
12440
|
var rotationTo = function() {
|
|
12371
12441
|
var tmpvec3 = create$3();
|
|
12372
12442
|
var xUnitVec3 = fromValues(1, 0, 0);
|
|
@@ -12377,7 +12447,7 @@ var rotationTo = function() {
|
|
|
12377
12447
|
cross$1(tmpvec3, xUnitVec3, a2);
|
|
12378
12448
|
if (len(tmpvec3) < 1e-6)
|
|
12379
12449
|
cross$1(tmpvec3, yUnitVec3, a2);
|
|
12380
|
-
normalize$
|
|
12450
|
+
normalize$4(tmpvec3, tmpvec3);
|
|
12381
12451
|
setAxisAngle(out, tmpvec3, Math.PI);
|
|
12382
12452
|
return out;
|
|
12383
12453
|
} else if (dot2 > 0.999999) {
|
|
@@ -12392,7 +12462,7 @@ var rotationTo = function() {
|
|
|
12392
12462
|
out[1] = tmpvec3[1];
|
|
12393
12463
|
out[2] = tmpvec3[2];
|
|
12394
12464
|
out[3] = 1 + dot2;
|
|
12395
|
-
return normalize$
|
|
12465
|
+
return normalize$2(out, out);
|
|
12396
12466
|
}
|
|
12397
12467
|
};
|
|
12398
12468
|
}();
|
|
@@ -12418,7 +12488,7 @@ var rotationTo = function() {
|
|
|
12418
12488
|
matr[2] = -view[0];
|
|
12419
12489
|
matr[5] = -view[1];
|
|
12420
12490
|
matr[8] = -view[2];
|
|
12421
|
-
return normalize$
|
|
12491
|
+
return normalize$2(out, fromMat3(out, matr));
|
|
12422
12492
|
};
|
|
12423
12493
|
})();
|
|
12424
12494
|
const IDENTITY_QUATERNION = [0, 0, 0, 1];
|
|
@@ -37046,8 +37116,10 @@ const ViewType$1 = {
|
|
|
37046
37116
|
STATUS: "status",
|
|
37047
37117
|
SCATTERPLOT: "scatterplot",
|
|
37048
37118
|
SPATIAL: "spatial",
|
|
37119
|
+
SPATIAL_BETA: "spatialBeta",
|
|
37049
37120
|
HEATMAP: "heatmap",
|
|
37050
37121
|
LAYER_CONTROLLER: "layerController",
|
|
37122
|
+
LAYER_CONTROLLER_BETA: "layerControllerBeta",
|
|
37051
37123
|
GENOMIC_PROFILES: "genomicProfiles",
|
|
37052
37124
|
GATING: "gating",
|
|
37053
37125
|
FEATURE_LIST: "featureList",
|
|
@@ -37059,20 +37131,24 @@ const ViewType$1 = {
|
|
|
37059
37131
|
const DataType$2 = {
|
|
37060
37132
|
OBS_LABELS: "obsLabels",
|
|
37061
37133
|
OBS_EMBEDDING: "obsEmbedding",
|
|
37062
|
-
OBS_LOCATIONS: "obsLocations",
|
|
37063
37134
|
OBS_FEATURE_MATRIX: "obsFeatureMatrix",
|
|
37064
37135
|
OBS_SETS: "obsSets",
|
|
37065
37136
|
FEATURE_LABELS: "featureLabels",
|
|
37066
37137
|
IMAGE: "image",
|
|
37067
37138
|
OBS_SEGMENTATIONS: "obsSegmentations",
|
|
37068
37139
|
NEIGHBORHOODS: "neighborhoods",
|
|
37069
|
-
GENOMIC_PROFILES: "genomic-profiles"
|
|
37140
|
+
GENOMIC_PROFILES: "genomic-profiles",
|
|
37141
|
+
OBS_SPOTS: "obsSpots",
|
|
37142
|
+
OBS_POINTS: "obsPoints",
|
|
37143
|
+
OBS_LOCATIONS: "obsLocations"
|
|
37070
37144
|
};
|
|
37071
37145
|
const FileType$1 = {
|
|
37072
37146
|
// Joint file types
|
|
37073
37147
|
ANNDATA_ZARR: "anndata.zarr",
|
|
37074
37148
|
// Atomic file types
|
|
37075
37149
|
OBS_EMBEDDING_CSV: "obsEmbedding.csv",
|
|
37150
|
+
OBS_SPOTS_CSV: "obsSpots.csv",
|
|
37151
|
+
OBS_POINTS_CSV: "obsPoints.csv",
|
|
37076
37152
|
OBS_LOCATIONS_CSV: "obsLocations.csv",
|
|
37077
37153
|
OBS_LABELS_CSV: "obsLabels.csv",
|
|
37078
37154
|
FEATURE_LABELS_CSV: "featureLabels.csv",
|
|
@@ -37085,6 +37161,8 @@ const FileType$1 = {
|
|
|
37085
37161
|
OBS_FEATURE_MATRIX_ANNDATA_ZARR: "obsFeatureMatrix.anndata.zarr",
|
|
37086
37162
|
OBS_SETS_ANNDATA_ZARR: "obsSets.anndata.zarr",
|
|
37087
37163
|
OBS_EMBEDDING_ANNDATA_ZARR: "obsEmbedding.anndata.zarr",
|
|
37164
|
+
OBS_SPOTS_ANNDATA_ZARR: "obsSpots.anndata.zarr",
|
|
37165
|
+
OBS_POINTS_ANNDATA_ZARR: "obsPoints.anndata.zarr",
|
|
37088
37166
|
OBS_LOCATIONS_ANNDATA_ZARR: "obsLocations.anndata.zarr",
|
|
37089
37167
|
OBS_SEGMENTATIONS_ANNDATA_ZARR: "obsSegmentations.anndata.zarr",
|
|
37090
37168
|
OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
|
|
@@ -37093,6 +37171,8 @@ const FileType$1 = {
|
|
|
37093
37171
|
OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
|
|
37094
37172
|
OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
|
|
37095
37173
|
OBS_EMBEDDING_MUDATA_ZARR: "obsEmbedding.mudata.zarr",
|
|
37174
|
+
OBS_SPOTS_MUDATA_ZARR: "obsSpots.mudata.zarr",
|
|
37175
|
+
OBS_POINTS_MUDATA_ZARR: "obsPoints.mudata.zarr",
|
|
37096
37176
|
OBS_LOCATIONS_MUDATA_ZARR: "obsLocations.mudata.zarr",
|
|
37097
37177
|
OBS_SEGMENTATIONS_MUDATA_ZARR: "obsSegmentations.mudata.zarr",
|
|
37098
37178
|
OBS_LABELS_MUDATA_ZARR: "obsLabels.mudata.zarr",
|
|
@@ -37136,10 +37216,8 @@ const FileType$1 = {
|
|
|
37136
37216
|
ANNDATA_EXPRESSION_MATRIX_ZARR: "anndata-expression-matrix.zarr"
|
|
37137
37217
|
};
|
|
37138
37218
|
const CoordinationType$1 = {
|
|
37139
|
-
// Meta coordination scopes
|
|
37140
37219
|
META_COORDINATION_SCOPES: "metaCoordinationScopes",
|
|
37141
37220
|
META_COORDINATION_SCOPES_BY: "metaCoordinationScopesBy",
|
|
37142
|
-
// Other coordination scopes
|
|
37143
37221
|
DATASET: "dataset",
|
|
37144
37222
|
// Entity types
|
|
37145
37223
|
OBS_TYPE: "obsType",
|
|
@@ -37165,6 +37243,7 @@ const CoordinationType$1 = {
|
|
|
37165
37243
|
SPATIAL_TARGET_X: "spatialTargetX",
|
|
37166
37244
|
SPATIAL_TARGET_Y: "spatialTargetY",
|
|
37167
37245
|
SPATIAL_TARGET_Z: "spatialTargetZ",
|
|
37246
|
+
SPATIAL_TARGET_T: "spatialTargetT",
|
|
37168
37247
|
SPATIAL_ROTATION_X: "spatialRotationX",
|
|
37169
37248
|
SPATIAL_ROTATION_Y: "spatialRotationY",
|
|
37170
37249
|
SPATIAL_ROTATION_Z: "spatialRotationZ",
|
|
@@ -37202,7 +37281,46 @@ const CoordinationType$1 = {
|
|
|
37202
37281
|
GATING_FEATURE_SELECTION_X: "gatingFeatureSelectionX",
|
|
37203
37282
|
GATING_FEATURE_SELECTION_Y: "gatingFeatureSelectionY",
|
|
37204
37283
|
FEATURE_VALUE_TRANSFORM_COEFFICIENT: "featureValueTransformCoefficient",
|
|
37205
|
-
TOOLTIPS_VISIBLE: "tooltipsVisible"
|
|
37284
|
+
TOOLTIPS_VISIBLE: "tooltipsVisible",
|
|
37285
|
+
FILE_UID: "fileUid",
|
|
37286
|
+
IMAGE_LAYER: "imageLayer",
|
|
37287
|
+
IMAGE_CHANNEL: "imageChannel",
|
|
37288
|
+
SEGMENTATION_LAYER: "segmentationLayer",
|
|
37289
|
+
SEGMENTATION_CHANNEL: "segmentationChannel",
|
|
37290
|
+
SPATIAL_TARGET_C: "spatialTargetC",
|
|
37291
|
+
SPATIAL_LAYER_VISIBLE: "spatialLayerVisible",
|
|
37292
|
+
SPATIAL_LAYER_OPACITY: "spatialLayerOpacity",
|
|
37293
|
+
SPATIAL_LAYER_COLORMAP: "spatialLayerColormap",
|
|
37294
|
+
SPATIAL_LAYER_TRANSPARENT_COLOR: "spatialLayerTransparentColor",
|
|
37295
|
+
SPATIAL_LAYER_MODEL_MATRIX: "spatialLayerModelMatrix",
|
|
37296
|
+
SPATIAL_SEGMENTATION_FILLED: "spatialSegmentationFilled",
|
|
37297
|
+
SPATIAL_SEGMENTATION_STROKE_WIDTH: "spatialSegmentationStrokeWidth",
|
|
37298
|
+
SPATIAL_CHANNEL_COLOR: "spatialChannelColor",
|
|
37299
|
+
SPATIAL_CHANNEL_VISIBLE: "spatialChannelVisible",
|
|
37300
|
+
SPATIAL_CHANNEL_OPACITY: "spatialChannelOpacity",
|
|
37301
|
+
SPATIAL_CHANNEL_WINDOW: "spatialChannelWindow",
|
|
37302
|
+
PHOTOMETRIC_INTERPRETATION: "photometricInterpretation",
|
|
37303
|
+
// For 3D volume rendering
|
|
37304
|
+
SPATIAL_RENDERING_MODE: "spatialRenderingMode",
|
|
37305
|
+
VOLUMETRIC_RENDERING_ALGORITHM: "volumetricRenderingAlgorithm",
|
|
37306
|
+
SPATIAL_TARGET_RESOLUTION: "spatialTargetResolution",
|
|
37307
|
+
// For clipping plane sliders
|
|
37308
|
+
SPATIAL_SLICE_X: "spatialSliceX",
|
|
37309
|
+
SPATIAL_SLICE_Y: "spatialSliceY",
|
|
37310
|
+
SPATIAL_SLICE_Z: "spatialSliceZ",
|
|
37311
|
+
// For spatial spot and point layers
|
|
37312
|
+
SPOT_LAYER: "spotLayer",
|
|
37313
|
+
POINT_LAYER: "pointLayer",
|
|
37314
|
+
SPATIAL_SPOT_RADIUS: "spatialSpotRadius",
|
|
37315
|
+
SPATIAL_SPOT_FILLED: "spatialSpotFilled",
|
|
37316
|
+
SPATIAL_SPOT_STROKE_WIDTH: "spatialSpotStrokeWidth",
|
|
37317
|
+
SPATIAL_LAYER_COLOR: "spatialLayerColor",
|
|
37318
|
+
PIXEL_HIGHLIGHT: "pixelHighlight",
|
|
37319
|
+
TOOLTIP_CROSSHAIRS_VISIBLE: "tooltipCrosshairsVisible",
|
|
37320
|
+
LEGEND_VISIBLE: "legendVisible",
|
|
37321
|
+
SPATIAL_CHANNEL_LABELS_VISIBLE: "spatialChannelLabelsVisible",
|
|
37322
|
+
SPATIAL_CHANNEL_LABELS_ORIENTATION: "spatialChannelLabelsOrientation",
|
|
37323
|
+
SPATIAL_CHANNEL_LABEL_SIZE: "spatialChannelLabelSize"
|
|
37206
37324
|
};
|
|
37207
37325
|
const ViewType = {
|
|
37208
37326
|
GENES: [
|
|
@@ -37463,6 +37581,8 @@ const annDataObsSets = z.array(z.object({
|
|
|
37463
37581
|
]),
|
|
37464
37582
|
scorePath: z.string().optional().describe("The location in the AnnData store for the set confidence scores, like 'obs/celltype_prediction_score.'")
|
|
37465
37583
|
}));
|
|
37584
|
+
const annDataObsSpots = annDataObsm;
|
|
37585
|
+
const annDataObsPoints = annDataObsm;
|
|
37466
37586
|
const annDataObsLocations = annDataObsm;
|
|
37467
37587
|
const annDataObsEmbedding = annDataObsm;
|
|
37468
37588
|
const annDataObsSegmentations = annDataObs;
|
|
@@ -37489,10 +37609,21 @@ z.object({
|
|
|
37489
37609
|
z.object({
|
|
37490
37610
|
obsIndex: z.string(),
|
|
37491
37611
|
obsEmbedding: z.array(z.string()).length(2)
|
|
37612
|
+
// TODO: support 3D?
|
|
37613
|
+
});
|
|
37614
|
+
z.object({
|
|
37615
|
+
obsIndex: z.string(),
|
|
37616
|
+
obsSpots: z.array(z.string()).length(2)
|
|
37617
|
+
// TODO: support 3D?
|
|
37618
|
+
});
|
|
37619
|
+
z.object({
|
|
37620
|
+
obsIndex: z.string(),
|
|
37621
|
+
obsPoints: z.array(z.string()).length(3)
|
|
37492
37622
|
});
|
|
37493
37623
|
z.object({
|
|
37494
37624
|
obsIndex: z.string(),
|
|
37495
37625
|
obsLocations: z.array(z.string()).length(2)
|
|
37626
|
+
// TODO: support 3D?
|
|
37496
37627
|
});
|
|
37497
37628
|
z.object({
|
|
37498
37629
|
obsIndex: z.string(),
|
|
@@ -37524,6 +37655,8 @@ z.object({
|
|
|
37524
37655
|
]),
|
|
37525
37656
|
obsFeatureMatrix: annDataObsFeatureMatrix,
|
|
37526
37657
|
obsSets: annDataObsSets,
|
|
37658
|
+
obsSpots: annDataObsSpots,
|
|
37659
|
+
obsPoints: annDataObsPoints,
|
|
37527
37660
|
obsLocations: annDataObsLocations,
|
|
37528
37661
|
obsSegmentations: annDataObsSegmentations,
|
|
37529
37662
|
obsEmbedding: z.union([
|
|
@@ -45685,17 +45818,17 @@ let COLOR;
|
|
|
45685
45818
|
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
45686
45819
|
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
45687
45820
|
})(COLOR || (COLOR = {}));
|
|
45688
|
-
function getColor(color) {
|
|
45821
|
+
function getColor$1(color) {
|
|
45689
45822
|
return typeof color === "string" ? COLOR[color.toUpperCase()] || COLOR.WHITE : color;
|
|
45690
45823
|
}
|
|
45691
45824
|
function addColor(string, color, background) {
|
|
45692
45825
|
if (!isBrowser$1 && typeof string === "string") {
|
|
45693
45826
|
if (color) {
|
|
45694
|
-
color = getColor(color);
|
|
45827
|
+
color = getColor$1(color);
|
|
45695
45828
|
string = "\x1B[".concat(color, "m").concat(string, "\x1B[39m");
|
|
45696
45829
|
}
|
|
45697
45830
|
if (background) {
|
|
45698
|
-
color = getColor(background);
|
|
45831
|
+
color = getColor$1(background);
|
|
45699
45832
|
string = "\x1B[".concat(background + 10, "m").concat(string, "\x1B[49m");
|
|
45700
45833
|
}
|
|
45701
45834
|
}
|
|
@@ -75805,7 +75938,7 @@ function copyFlatRing(target, targetStartIndex, positions, size2, srcStartIndex
|
|
|
75805
75938
|
modifyPolygonWindingDirection(target, windingDirection, windingOptions);
|
|
75806
75939
|
return targetIndex;
|
|
75807
75940
|
}
|
|
75808
|
-
function normalize(polygon2, positionSize) {
|
|
75941
|
+
function normalize$1(polygon2, positionSize) {
|
|
75809
75942
|
validate(polygon2);
|
|
75810
75943
|
const positions = [];
|
|
75811
75944
|
const holeIndices = [];
|
|
@@ -75911,7 +76044,7 @@ class PolygonTesselator extends Tesselator {
|
|
|
75911
76044
|
}
|
|
75912
76045
|
normalizeGeometry(polygon2) {
|
|
75913
76046
|
if (this.normalize) {
|
|
75914
|
-
const normalizedPolygon = normalize(polygon2, this.positionSize);
|
|
76047
|
+
const normalizedPolygon = normalize$1(polygon2, this.positionSize);
|
|
75915
76048
|
if (this.opts.resolution) {
|
|
75916
76049
|
return cutPolygonByGrid(getPositions(normalizedPolygon), getHoleIndices(normalizedPolygon), {
|
|
75917
76050
|
size: this.positionSize,
|
|
@@ -76533,7 +76666,7 @@ class PolygonLayer extends CompositeLayer {
|
|
|
76533
76666
|
objectInfo.index++;
|
|
76534
76667
|
let polygon2 = getPolygon(object2, objectInfo);
|
|
76535
76668
|
if (_normalize) {
|
|
76536
|
-
polygon2 = normalize(polygon2, positionSize);
|
|
76669
|
+
polygon2 = normalize$1(polygon2, positionSize);
|
|
76537
76670
|
}
|
|
76538
76671
|
const {
|
|
76539
76672
|
holeIndices
|
|
@@ -120360,7 +120493,7 @@ function clipExtent(x02, y02, x12, y12) {
|
|
|
120360
120493
|
return clipStream;
|
|
120361
120494
|
};
|
|
120362
120495
|
}
|
|
120363
|
-
function extent() {
|
|
120496
|
+
function extent$1() {
|
|
120364
120497
|
var x02 = 0, y02 = 0, x12 = 960, y12 = 500, cache2, cacheStream, clip2;
|
|
120365
120498
|
return clip2 = {
|
|
120366
120499
|
stream: function(stream) {
|
|
@@ -121767,7 +121900,7 @@ const d3Geo$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
121767
121900
|
geoBounds: bounds,
|
|
121768
121901
|
geoCentroid: centroid$3,
|
|
121769
121902
|
geoCircle: circle$2,
|
|
121770
|
-
geoClipExtent: extent,
|
|
121903
|
+
geoClipExtent: extent$1,
|
|
121771
121904
|
geoConicConformal: conicConformal,
|
|
121772
121905
|
geoConicConformalRaw: conicConformalRaw,
|
|
121773
121906
|
geoConicEqualArea: conicEqualArea,
|
|
@@ -140970,28 +141103,38 @@ const PASS_THROUGH_PROPS = [
|
|
|
140970
141103
|
];
|
|
140971
141104
|
class SelectionLayer extends CompositeLayer {
|
|
140972
141105
|
_selectPolygonObjects(coordinates2) {
|
|
140973
|
-
const {
|
|
141106
|
+
const { flipY, obsLayers } = this.props;
|
|
140974
141107
|
const flippedCoordinates = flipY ? coordinates2.map((poly) => poly.map((p) => [p[0], -p[1]])) : coordinates2;
|
|
140975
141108
|
const selectedPolygon = polygon(flippedCoordinates);
|
|
140976
|
-
|
|
140977
|
-
|
|
140978
|
-
const
|
|
140979
|
-
|
|
140980
|
-
|
|
140981
|
-
|
|
140982
|
-
|
|
140983
|
-
|
|
140984
|
-
|
|
140985
|
-
|
|
140986
|
-
|
|
140987
|
-
|
|
140988
|
-
|
|
140989
|
-
|
|
141109
|
+
obsLayers.forEach((obsLayer) => {
|
|
141110
|
+
const { getObsCoords, obsQuadTree, obsIndex, onSelect: layerOnSelect } = obsLayer;
|
|
141111
|
+
const pickingInfos = [];
|
|
141112
|
+
obsQuadTree == null ? void 0 : obsQuadTree.visit((node2, x02, y02, x12, y12) => {
|
|
141113
|
+
const nodePoints = [[[x02, y02], [x12, y02], [x12, y12], [x02, y12], [x02, y02]]];
|
|
141114
|
+
const nodePolygon = polygon(nodePoints);
|
|
141115
|
+
const nodePolygonContainsSelectedPolygon = booleanContains(nodePolygon, selectedPolygon);
|
|
141116
|
+
const nodePolygonWithinSelectedPolygon = booleanWithin(nodePolygon, selectedPolygon);
|
|
141117
|
+
const nodePolygonOverlapsSelectedPolgyon = booleanOverlap(nodePolygon, selectedPolygon);
|
|
141118
|
+
if (!nodePolygonContainsSelectedPolygon && !nodePolygonWithinSelectedPolygon && !nodePolygonOverlapsSelectedPolgyon) {
|
|
141119
|
+
return true;
|
|
141120
|
+
}
|
|
141121
|
+
if (node2.data && booleanPointInPolygon$1(point([].slice.call(getObsCoords(node2.data))), selectedPolygon)) {
|
|
141122
|
+
pickingInfos.push(node2.data);
|
|
141123
|
+
}
|
|
141124
|
+
return false;
|
|
141125
|
+
});
|
|
141126
|
+
const pickingIds = pickingInfos.map((obsI) => obsIndex[obsI]);
|
|
141127
|
+
layerOnSelect(pickingIds);
|
|
141128
|
+
});
|
|
141129
|
+
}
|
|
141130
|
+
_selectEmpty() {
|
|
141131
|
+
const { obsLayers } = this.props;
|
|
141132
|
+
obsLayers.forEach((obsLayer) => {
|
|
141133
|
+
const { onSelect: layerOnSelect } = obsLayer;
|
|
141134
|
+
layerOnSelect([]);
|
|
140990
141135
|
});
|
|
140991
|
-
onSelect({ pickingInfos });
|
|
140992
141136
|
}
|
|
140993
141137
|
renderLayers() {
|
|
140994
|
-
const { onSelect } = this.props;
|
|
140995
141138
|
const mode = MODE_MAP[this.props.selectionType] || distEs6.ViewMode;
|
|
140996
141139
|
const inheritedProps = {};
|
|
140997
141140
|
PASS_THROUGH_PROPS.forEach((p) => {
|
|
@@ -141013,7 +141156,7 @@ class SelectionLayer extends CompositeLayer {
|
|
|
141013
141156
|
const { coordinates: coordinates2 } = updatedData.features[0].geometry;
|
|
141014
141157
|
this._selectPolygonObjects(coordinates2);
|
|
141015
141158
|
} else if (editType === EDIT_TYPE_CLEAR) {
|
|
141016
|
-
|
|
141159
|
+
this._selectEmpty();
|
|
141017
141160
|
}
|
|
141018
141161
|
},
|
|
141019
141162
|
_subLayerProps: {
|
|
@@ -142153,16 +142296,16 @@ function addDecoder(cases, importFn) {
|
|
|
142153
142296
|
}
|
|
142154
142297
|
cases.forEach((c) => registry.set(c, importFn));
|
|
142155
142298
|
}
|
|
142156
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
142157
|
-
addDecoder(5, () => import("./lzw-
|
|
142299
|
+
addDecoder([void 0, 1], () => import("./raw-4015af9c.js").then((m) => m.default));
|
|
142300
|
+
addDecoder(5, () => import("./lzw-b264d65a.js").then((m) => m.default));
|
|
142158
142301
|
addDecoder(6, () => {
|
|
142159
142302
|
throw new Error("old style JPEG compression is not supported.");
|
|
142160
142303
|
});
|
|
142161
|
-
addDecoder(7, () => import("./jpeg-
|
|
142162
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
142163
|
-
addDecoder(32773, () => import("./packbits-
|
|
142164
|
-
addDecoder(34887, () => import("./lerc-
|
|
142165
|
-
addDecoder(50001, () => import("./webimage-
|
|
142304
|
+
addDecoder(7, () => import("./jpeg-af2abb26.js").then((m) => m.default));
|
|
142305
|
+
addDecoder([8, 32946], () => import("./deflate-2b2b285b.js").then((m) => m.default));
|
|
142306
|
+
addDecoder(32773, () => import("./packbits-58bf813f.js").then((m) => m.default));
|
|
142307
|
+
addDecoder(34887, () => import("./lerc-ac5abe1c.js").then((m) => m.default));
|
|
142308
|
+
addDecoder(50001, () => import("./webimage-d31de7e9.js").then((m) => m.default));
|
|
142166
142309
|
function decodeRowAcc(row, stride) {
|
|
142167
142310
|
let length2 = row.length - stride;
|
|
142168
142311
|
let offset = 0;
|
|
@@ -143872,7 +144015,7 @@ async function loadOmeZarr(source, options = {}) {
|
|
|
143872
144015
|
}
|
|
143873
144016
|
const MAX_COLOR_INTENSITY = 255;
|
|
143874
144017
|
const DEFAULT_COLOR_OFF = [0, 0, 0];
|
|
143875
|
-
const MAX_CHANNELS = 6;
|
|
144018
|
+
const MAX_CHANNELS$1 = 6;
|
|
143876
144019
|
const DEFAULT_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
143877
144020
|
const DTYPE_VALUES = {
|
|
143878
144021
|
Uint8: {
|
|
@@ -145394,7 +145537,7 @@ const AdditiveColormapExtension = class extends LayerExtension {
|
|
|
145394
145537
|
};
|
|
145395
145538
|
AdditiveColormapExtension.extensionName = "AdditiveColormapExtension";
|
|
145396
145539
|
AdditiveColormapExtension.defaultProps = defaultProps$4$1;
|
|
145397
|
-
const fs$1$
|
|
145540
|
+
const fs$1$2 = `uniform vec3 transparentColor;
|
|
145398
145541
|
uniform bool useTransparentColor;
|
|
145399
145542
|
uniform float opacity;
|
|
145400
145543
|
|
|
@@ -145421,12 +145564,12 @@ rgba = apply_opacity(rgb);
|
|
|
145421
145564
|
`;
|
|
145422
145565
|
const colorPalette = {
|
|
145423
145566
|
name: "color-palette-module",
|
|
145424
|
-
fs: fs$1$
|
|
145567
|
+
fs: fs$1$2,
|
|
145425
145568
|
inject: {
|
|
145426
145569
|
"fs:DECKGL_MUTATE_COLOR": DECKGL_MUTATE_COLOR
|
|
145427
145570
|
}
|
|
145428
145571
|
};
|
|
145429
|
-
function padWithDefault$
|
|
145572
|
+
function padWithDefault$3(arr, defaultValue2, padWidth) {
|
|
145430
145573
|
for (let i2 = 0; i2 < padWidth; i2 += 1) {
|
|
145431
145574
|
arr.push(defaultValue2);
|
|
145432
145575
|
}
|
|
@@ -145452,8 +145595,8 @@ function padColors({ colors, channelsVisible }) {
|
|
|
145452
145595
|
const newColors = colors.map(
|
|
145453
145596
|
(color, i2) => channelsVisible[i2] ? color.map((c) => c / MAX_COLOR_INTENSITY) : DEFAULT_COLOR_OFF
|
|
145454
145597
|
);
|
|
145455
|
-
const padSize = MAX_CHANNELS - newColors.length;
|
|
145456
|
-
const paddedColors = padWithDefault$
|
|
145598
|
+
const padSize = MAX_CHANNELS$1 - newColors.length;
|
|
145599
|
+
const paddedColors = padWithDefault$3(
|
|
145457
145600
|
newColors,
|
|
145458
145601
|
DEFAULT_COLOR_OFF,
|
|
145459
145602
|
padSize
|
|
@@ -145697,7 +145840,7 @@ vec4 colormap(float intensity, float opacity) {
|
|
|
145697
145840
|
fs: fs2
|
|
145698
145841
|
};
|
|
145699
145842
|
}
|
|
145700
|
-
const defaultProps$1$
|
|
145843
|
+
const defaultProps$1$2 = {
|
|
145701
145844
|
colormap: { type: "string", value: "viridis", compare: true }
|
|
145702
145845
|
};
|
|
145703
145846
|
const BaseExtension$1 = class extends LayerExtension {
|
|
@@ -145707,7 +145850,7 @@ const BaseExtension$1 = class extends LayerExtension {
|
|
|
145707
145850
|
}
|
|
145708
145851
|
getShaders() {
|
|
145709
145852
|
var _a2;
|
|
145710
|
-
const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$1$
|
|
145853
|
+
const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$1$2.colormap.value;
|
|
145711
145854
|
const apply_cmap = cmaps[name2];
|
|
145712
145855
|
return {
|
|
145713
145856
|
...super.getShaders(),
|
|
@@ -145726,7 +145869,7 @@ const BaseExtension$1 = class extends LayerExtension {
|
|
|
145726
145869
|
}
|
|
145727
145870
|
};
|
|
145728
145871
|
BaseExtension$1.extensionName = "BaseExtension";
|
|
145729
|
-
BaseExtension$1.defaultProps = defaultProps$1$
|
|
145872
|
+
BaseExtension$1.defaultProps = defaultProps$1$2;
|
|
145730
145873
|
const _BEFORE_RENDER$5 = "";
|
|
145731
145874
|
const _RENDER$5 = ` float intensityArray[6] = float[6](intensityValue0, intensityValue1, intensityValue2, intensityValue3, intensityValue4, intensityValue5);
|
|
145732
145875
|
float total = 0.0;
|
|
@@ -145925,7 +146068,7 @@ const channels = {
|
|
|
145925
146068
|
function range(len2) {
|
|
145926
146069
|
return [...Array(len2).keys()];
|
|
145927
146070
|
}
|
|
145928
|
-
function padWithDefault$
|
|
146071
|
+
function padWithDefault$2(arr, defaultValue2, padWidth) {
|
|
145929
146072
|
for (let i2 = 0; i2 < padWidth; i2 += 1) {
|
|
145930
146073
|
arr.push(defaultValue2);
|
|
145931
146074
|
}
|
|
@@ -145949,13 +146092,13 @@ function padContrastLimits({
|
|
|
145949
146092
|
const newContrastLimits = contrastLimits.map(
|
|
145950
146093
|
(slider, i2) => channelsVisible[i2] ? slider : [maxSliderValue, maxSliderValue]
|
|
145951
146094
|
);
|
|
145952
|
-
const padSize = MAX_CHANNELS - newContrastLimits.length;
|
|
146095
|
+
const padSize = MAX_CHANNELS$1 - newContrastLimits.length;
|
|
145953
146096
|
if (padSize < 0) {
|
|
145954
146097
|
throw Error(
|
|
145955
146098
|
`${newContrastLimits.lengths} channels passed in, but only 6 are allowed.`
|
|
145956
146099
|
);
|
|
145957
146100
|
}
|
|
145958
|
-
const paddedContrastLimits = padWithDefault$
|
|
146101
|
+
const paddedContrastLimits = padWithDefault$2(
|
|
145959
146102
|
newContrastLimits,
|
|
145960
146103
|
[maxSliderValue, maxSliderValue],
|
|
145961
146104
|
padSize
|
|
@@ -145985,7 +146128,7 @@ function makeBoundingBox(viewState) {
|
|
|
145985
146128
|
viewport.unproject([0, viewport.height])
|
|
145986
146129
|
];
|
|
145987
146130
|
}
|
|
145988
|
-
const fs$1 = `#define SHADER_NAME xr-layer-fragment-shader
|
|
146131
|
+
const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
|
|
145989
146132
|
|
|
145990
146133
|
precision highp float;
|
|
145991
146134
|
precision highp int;
|
|
@@ -146026,7 +146169,7 @@ void main() {
|
|
|
146026
146169
|
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
146027
146170
|
}
|
|
146028
146171
|
`;
|
|
146029
|
-
const vs$1 = `#define SHADER_NAME xr-layer-vertex-shader
|
|
146172
|
+
const vs$1$1 = `#define SHADER_NAME xr-layer-vertex-shader
|
|
146030
146173
|
|
|
146031
146174
|
attribute vec2 texCoords;
|
|
146032
146175
|
attribute vec3 positions;
|
|
@@ -146045,7 +146188,7 @@ void main(void) {
|
|
|
146045
146188
|
DECKGL_FILTER_COLOR(color, geometry);
|
|
146046
146189
|
}
|
|
146047
146190
|
`;
|
|
146048
|
-
const coreShaderModule = { fs: fs$1, vs: vs$1 };
|
|
146191
|
+
const coreShaderModule = { fs: fs$1$1, vs: vs$1$1 };
|
|
146049
146192
|
function validateWebGL2Filter(gl, interpolation) {
|
|
146050
146193
|
const canShowFloat = hasFeature(gl, FEATURES$1.TEXTURE_FLOAT);
|
|
146051
146194
|
const canShowLinear = hasFeature(gl, FEATURES$1.TEXTURE_FILTER_LINEAR_FLOAT);
|
|
@@ -147136,7 +147279,7 @@ const CUBE_STRIP = [
|
|
|
147136
147279
|
0
|
|
147137
147280
|
];
|
|
147138
147281
|
const NUM_PLANES_DEFAULT = 1;
|
|
147139
|
-
const defaultProps$1 = {
|
|
147282
|
+
const defaultProps$1$1 = {
|
|
147140
147283
|
pickable: false,
|
|
147141
147284
|
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
147142
147285
|
channelData: { type: "object", value: {}, compare: true },
|
|
@@ -147278,7 +147421,7 @@ const XR3DLayer = class extends Layer {
|
|
|
147278
147421
|
});
|
|
147279
147422
|
const invertedScaleMatrix = scaleMatrix.clone().invert();
|
|
147280
147423
|
const invertedResolutionMatrix = resolutionMatrix.clone().invert();
|
|
147281
|
-
const paddedClippingPlanes = padWithDefault$
|
|
147424
|
+
const paddedClippingPlanes = padWithDefault$2(
|
|
147282
147425
|
clippingPlanes.map(
|
|
147283
147426
|
(p) => p.clone().transform(invertedScaleMatrix).transform(invertedResolutionMatrix)
|
|
147284
147427
|
),
|
|
@@ -147368,7 +147511,7 @@ const XR3DLayer = class extends Layer {
|
|
|
147368
147511
|
}
|
|
147369
147512
|
};
|
|
147370
147513
|
XR3DLayer.layerName = "XR3DLayer";
|
|
147371
|
-
XR3DLayer.defaultProps = defaultProps$1;
|
|
147514
|
+
XR3DLayer.defaultProps = defaultProps$1$1;
|
|
147372
147515
|
async function getVolume({
|
|
147373
147516
|
source,
|
|
147374
147517
|
selection,
|
|
@@ -147590,7 +147733,7 @@ const VolumeLayer = class extends CompositeLayer {
|
|
|
147590
147733
|
};
|
|
147591
147734
|
VolumeLayer.layerName = "VolumeLayer";
|
|
147592
147735
|
VolumeLayer.defaultProps = defaultProps$9;
|
|
147593
|
-
const vs = `
|
|
147736
|
+
const vs$1 = `
|
|
147594
147737
|
#define SHADER_NAME bitmask-layer-vertex-shader
|
|
147595
147738
|
|
|
147596
147739
|
attribute vec2 texCoords;
|
|
@@ -147611,7 +147754,7 @@ void main(void) {
|
|
|
147611
147754
|
DECKGL_FILTER_COLOR(color, geometry);
|
|
147612
147755
|
}
|
|
147613
147756
|
`;
|
|
147614
|
-
const fs = `
|
|
147757
|
+
const fs$1 = `
|
|
147615
147758
|
#define SHADER_NAME bitmask-layer-fragment-shader
|
|
147616
147759
|
precision highp float;
|
|
147617
147760
|
|
|
@@ -147679,14 +147822,14 @@ void main() {
|
|
|
147679
147822
|
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
147680
147823
|
}
|
|
147681
147824
|
`;
|
|
147682
|
-
function padWithDefault(arr, defaultValue2, padWidth) {
|
|
147825
|
+
function padWithDefault$1(arr, defaultValue2, padWidth) {
|
|
147683
147826
|
const newArr = [...arr];
|
|
147684
147827
|
for (let i2 = 0; i2 < padWidth; i2 += 1) {
|
|
147685
147828
|
newArr.push(defaultValue2);
|
|
147686
147829
|
}
|
|
147687
147830
|
return newArr;
|
|
147688
147831
|
}
|
|
147689
|
-
const defaultProps = {
|
|
147832
|
+
const defaultProps$1 = {
|
|
147690
147833
|
hoveredCell: { type: "number", value: null, compare: true },
|
|
147691
147834
|
// We do not want to deep-compare cellColorData,
|
|
147692
147835
|
// as it is potentially a TypedArray with millions of elements.
|
|
@@ -147698,13 +147841,13 @@ const defaultProps = {
|
|
|
147698
147841
|
// Same as with cellColorData, we do not want to deep-compare expressionData.
|
|
147699
147842
|
expressionData: { type: "object", value: null, compare: 0 }
|
|
147700
147843
|
};
|
|
147701
|
-
class BitmaskLayer extends XRLayer {
|
|
147844
|
+
let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
|
|
147702
147845
|
// eslint-disable-next-line class-methods-use-this
|
|
147703
147846
|
getShaders() {
|
|
147704
147847
|
const { colormap } = this.props;
|
|
147705
147848
|
return {
|
|
147706
|
-
fs,
|
|
147707
|
-
vs,
|
|
147849
|
+
fs: fs$1,
|
|
147850
|
+
vs: vs$1,
|
|
147708
147851
|
modules: [project32, picking],
|
|
147709
147852
|
defines: {
|
|
147710
147853
|
[COLORMAP_SHADER_PLACEHOLDER]: GLSL_COLORMAPS.includes(colormap) ? colormap : GLSL_COLORMAP_DEFAULT
|
|
@@ -147764,7 +147907,7 @@ class BitmaskLayer extends XRLayer {
|
|
|
147764
147907
|
expressionTex,
|
|
147765
147908
|
colorTexHeight: colorTex.height,
|
|
147766
147909
|
colorTexWidth: colorTex.width,
|
|
147767
|
-
channelsVisible: padWithDefault(
|
|
147910
|
+
channelsVisible: padWithDefault$1(
|
|
147768
147911
|
channelsVisible,
|
|
147769
147912
|
false,
|
|
147770
147913
|
// There are six texture entries on the shaders
|
|
@@ -147801,28 +147944,628 @@ class BitmaskLayer extends XRLayer {
|
|
|
147801
147944
|
type: GL$1.FLOAT
|
|
147802
147945
|
});
|
|
147803
147946
|
}
|
|
147947
|
+
};
|
|
147948
|
+
BitmaskLayer$1.layerName = "BitmaskLayer";
|
|
147949
|
+
BitmaskLayer$1.defaultProps = defaultProps$1;
|
|
147950
|
+
const vs = `
|
|
147951
|
+
#define SHADER_NAME bitmask-layer-vertex-shader
|
|
147952
|
+
|
|
147953
|
+
attribute vec2 texCoords;
|
|
147954
|
+
attribute vec3 positions;
|
|
147955
|
+
attribute vec3 positions64Low;
|
|
147956
|
+
attribute vec3 instancePickingColors;
|
|
147957
|
+
|
|
147958
|
+
varying vec2 vTexCoord;
|
|
147959
|
+
|
|
147960
|
+
void main(void) {
|
|
147961
|
+
geometry.worldPosition = positions;
|
|
147962
|
+
geometry.uv = texCoords;
|
|
147963
|
+
geometry.pickingColor = instancePickingColors;
|
|
147964
|
+
gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
|
|
147965
|
+
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
147966
|
+
vTexCoord = texCoords;
|
|
147967
|
+
vec4 color = vec4(0.0);
|
|
147968
|
+
DECKGL_FILTER_COLOR(color, geometry);
|
|
147969
|
+
}
|
|
147970
|
+
`;
|
|
147971
|
+
const fs = `
|
|
147972
|
+
#define SHADER_NAME bitmask-layer-fragment-shader
|
|
147973
|
+
precision highp float;
|
|
147974
|
+
|
|
147975
|
+
${colormaps}
|
|
147976
|
+
|
|
147977
|
+
// Note: can have a maximum of 16 textures in most browsers
|
|
147978
|
+
// Reference: https://webglreport.com/
|
|
147979
|
+
|
|
147980
|
+
// Data (mask) texture
|
|
147981
|
+
uniform sampler2D channel0;
|
|
147982
|
+
uniform sampler2D channel1;
|
|
147983
|
+
uniform sampler2D channel2;
|
|
147984
|
+
uniform sampler2D channel3;
|
|
147985
|
+
uniform sampler2D channel4;
|
|
147986
|
+
uniform sampler2D channel5;
|
|
147987
|
+
uniform sampler2D channel6;
|
|
147988
|
+
|
|
147989
|
+
// Color texture
|
|
147990
|
+
uniform float hovered;
|
|
147991
|
+
|
|
147992
|
+
// Channel-specific properties
|
|
147993
|
+
uniform bool channelsVisible[7];
|
|
147994
|
+
uniform float channelOpacities[7];
|
|
147995
|
+
uniform bool channelIsStaticColorMode[7]; // TODO: should this be a single float?
|
|
147996
|
+
uniform bool channelIsSetColorMode[7]; // TODO: should this be a single float?
|
|
147997
|
+
|
|
147998
|
+
// TODO: can array of tuples/vec2 be used?
|
|
147999
|
+
uniform float channelColormapRangeStarts[7];
|
|
148000
|
+
uniform float channelColormapRangeEnds[7];
|
|
148001
|
+
|
|
148002
|
+
uniform float multiFeatureTexSize;
|
|
148003
|
+
|
|
148004
|
+
// Use one expressionTex for all channels, using an offset mechanism.
|
|
148005
|
+
uniform sampler2D valueTex;
|
|
148006
|
+
uniform float valueTexOffsets[7];
|
|
148007
|
+
uniform float valueTexHeight;
|
|
148008
|
+
|
|
148009
|
+
// Textures for set colors, using the same offset mechanism.
|
|
148010
|
+
uniform sampler2D colorTex;
|
|
148011
|
+
uniform float colorTexOffsets[7];
|
|
148012
|
+
uniform float colorTexHeight;
|
|
148013
|
+
|
|
148014
|
+
|
|
148015
|
+
// Static colors
|
|
148016
|
+
// TODO: For some reason I cannot use uniform vec3 colors[7]; and i cannot figure out why.
|
|
148017
|
+
uniform vec3 color0;
|
|
148018
|
+
uniform vec3 color1;
|
|
148019
|
+
uniform vec3 color2;
|
|
148020
|
+
uniform vec3 color3;
|
|
148021
|
+
uniform vec3 color4;
|
|
148022
|
+
uniform vec3 color5;
|
|
148023
|
+
uniform vec3 color6;
|
|
148024
|
+
|
|
148025
|
+
// Info for edge-only mode
|
|
148026
|
+
uniform float scaleFactor;
|
|
148027
|
+
uniform bool channelsFilled[7];
|
|
148028
|
+
uniform float channelStrokeWidths[7];
|
|
148029
|
+
|
|
148030
|
+
// opacity
|
|
148031
|
+
uniform float opacity;
|
|
148032
|
+
|
|
148033
|
+
varying vec2 vTexCoord;
|
|
148034
|
+
|
|
148035
|
+
vec3 sampleAndGetData(sampler2D dataTex, vec2 coord, bool isFilled, float strokeWidth, bool isOn) {
|
|
148036
|
+
float sampledData = texture(dataTex, coord).r;
|
|
148037
|
+
float clampedSampledData = max(0., min(sampledData, 1.));
|
|
148038
|
+
|
|
148039
|
+
bool isEdge = true;
|
|
148040
|
+
|
|
148041
|
+
if(!isFilled) {
|
|
148042
|
+
vec2 uTextureSize = vec2(2048.0, 2048.0);
|
|
148043
|
+
vec2 onePixel = vec2(1.0, 1.0) / uTextureSize;
|
|
148044
|
+
|
|
148045
|
+
// Vary the edgeSize based on user-defined stroke width.
|
|
148046
|
+
float edgeSize = 150.0 * strokeWidth * scaleFactor;
|
|
148047
|
+
|
|
148048
|
+
float pixN = texture(dataTex, coord + vec2(0.0, onePixel.y * edgeSize)).r;
|
|
148049
|
+
float pixS = texture(dataTex, coord - vec2(0.0, onePixel.y * edgeSize)).r;
|
|
148050
|
+
float pixW = texture(dataTex, coord + vec2(onePixel.x * edgeSize, 0.0)).r;
|
|
148051
|
+
float pixE = texture(dataTex, coord - vec2(onePixel.x * edgeSize, 0.0)).r;
|
|
148052
|
+
|
|
148053
|
+
float pixNW = texture(dataTex, coord + vec2(onePixel.y * edgeSize, onePixel.y * edgeSize)).r;
|
|
148054
|
+
float pixNE = texture(dataTex, coord + vec2(-1.0 * onePixel.x * edgeSize, onePixel.y * edgeSize)).r;
|
|
148055
|
+
float pixSW = texture(dataTex, coord - vec2(onePixel.x * edgeSize, onePixel.y * edgeSize)).r;
|
|
148056
|
+
float pixSE = texture(dataTex, coord - vec2(-1.0 * onePixel.x * edgeSize, onePixel.y * edgeSize)).r;
|
|
148057
|
+
|
|
148058
|
+
isEdge = (pixN != sampledData || pixS != sampledData || pixW != sampledData || pixE != sampledData || pixNW != sampledData || pixNE != sampledData || pixSW != sampledData || pixSE != sampledData);
|
|
148059
|
+
}
|
|
148060
|
+
// Return a tuple of (sampledData, isEdge)
|
|
148061
|
+
return vec3(clampedSampledData * float(isOn), sampledData, float(isEdge));
|
|
148062
|
+
}
|
|
148063
|
+
|
|
148064
|
+
vec4 dataToColor(vec3 sampledDataAndIsEdge, bool isStaticColorMode, vec3 channelColor, float channelOpacity, float valueOffset, float rangeStart, float rangeEnd, bool isSetColorMode, float setColorOffset) {
|
|
148065
|
+
float clampedSampledDataAndIsOn = sampledDataAndIsEdge.x;
|
|
148066
|
+
float sampledData = sampledDataAndIsEdge.y;
|
|
148067
|
+
float isEdge = sampledDataAndIsEdge.z;
|
|
148068
|
+
|
|
148069
|
+
|
|
148070
|
+
vec4 hoveredColor = float(sampledData == hovered && sampledData > 0. && hovered > 0.) * vec4(0., 0., 1., 1.);
|
|
148071
|
+
|
|
148072
|
+
// Colors are laid out corresponding to ids in row-major order in the texture. So if width of the texture is 10, and you want ID 25,
|
|
148073
|
+
// you need coordinate (1, 4) (i.e 2 rows down, and 5 columns over indexed from 0 for a total of 25 units covered in row major order).
|
|
148074
|
+
float offsetSampledData = sampledData + valueOffset - 1.0;
|
|
148075
|
+
vec2 colorTexCoord = vec2(mod(offsetSampledData, multiFeatureTexSize) / multiFeatureTexSize, floor(offsetSampledData / multiFeatureTexSize) / (valueTexHeight - 1.));
|
|
148076
|
+
|
|
148077
|
+
// Get expression value
|
|
148078
|
+
float expressionValue = texture(valueTex, colorTexCoord).r / 255.;
|
|
148079
|
+
float scaledExpressionValue = (expressionValue - rangeStart) / max(0.005, (rangeEnd - rangeStart));
|
|
148080
|
+
|
|
148081
|
+
|
|
148082
|
+
// Get set color index value
|
|
148083
|
+
vec2 setIndicesTexCoord = vec2(mod(offsetSampledData, multiFeatureTexSize) / multiFeatureTexSize, floor(offsetSampledData / multiFeatureTexSize) / (valueTexHeight - 1.));
|
|
148084
|
+
float setColorIndex = texture(valueTex, setIndicesTexCoord).r;
|
|
148085
|
+
|
|
148086
|
+
// Initialize to the default "null" color.
|
|
148087
|
+
vec3 setColor = vec3(200. / 255., 200. / 255., 200. / 255.);
|
|
148088
|
+
if(setColorIndex != 0.) {
|
|
148089
|
+
// Subtract one from setColorIndex because we have already checked for the "null" value.
|
|
148090
|
+
setColorIndex = setColorIndex - 1.;
|
|
148091
|
+
|
|
148092
|
+
float setColorOffsetR = (setColorIndex + setColorOffset) * 3.0 + 0.0;
|
|
148093
|
+
vec2 setColorTexCoordR = vec2(mod(setColorOffsetR, multiFeatureTexSize) / multiFeatureTexSize, floor(setColorOffsetR / multiFeatureTexSize) / (colorTexHeight - 1.));
|
|
148094
|
+
float setColorR = texture(colorTex, setColorTexCoordR).r / 255.;
|
|
148095
|
+
|
|
148096
|
+
float setColorOffsetG = (setColorIndex + setColorOffset) * 3.0 + 1.0;
|
|
148097
|
+
vec2 setColorTexCoordG = vec2(mod(setColorOffsetG, multiFeatureTexSize) / multiFeatureTexSize, floor(setColorOffsetG / multiFeatureTexSize) / (colorTexHeight - 1.));
|
|
148098
|
+
float setColorG = texture(colorTex, setColorTexCoordG).r / 255.;
|
|
148099
|
+
|
|
148100
|
+
float setColorOffsetB = (setColorIndex + setColorOffset) * 3.0 + 2.0;
|
|
148101
|
+
vec2 setColorTexCoordB = vec2(mod(setColorOffsetB, multiFeatureTexSize) / multiFeatureTexSize, floor(setColorOffsetB / multiFeatureTexSize) / (colorTexHeight - 1.));
|
|
148102
|
+
float setColorB = texture(colorTex, setColorTexCoordB).r / 255.;
|
|
148103
|
+
|
|
148104
|
+
setColor = vec3(setColorR, setColorG, setColorB);
|
|
148105
|
+
}
|
|
148106
|
+
|
|
148107
|
+
|
|
148108
|
+
vec4 sampledColor = (1. - (float(isStaticColorMode) + float(isSetColorMode))) * vec4(COLORMAP_FUNC(clamp(scaledExpressionValue, 0.0, 1.0)).rgb, channelOpacity) + float(isStaticColorMode) * vec4(channelColor.rgb, channelOpacity) + float(isSetColorMode) * vec4(setColor, channelOpacity);
|
|
148109
|
+
// Only return a color if the data is non-zero.
|
|
148110
|
+
|
|
148111
|
+
return clampedSampledDataAndIsOn * isEdge * sampledColor;
|
|
148112
|
+
}
|
|
148113
|
+
|
|
148114
|
+
void main() {
|
|
148115
|
+
|
|
148116
|
+
// Get the color and alpha value for each channel.
|
|
148117
|
+
vec3 dat0 = sampleAndGetData(channel0, vTexCoord, channelsFilled[0], channelStrokeWidths[0], channelsVisible[0]);
|
|
148118
|
+
vec3 dat1 = sampleAndGetData(channel1, vTexCoord, channelsFilled[1], channelStrokeWidths[1], channelsVisible[1]);
|
|
148119
|
+
vec3 dat2 = sampleAndGetData(channel2, vTexCoord, channelsFilled[2], channelStrokeWidths[2], channelsVisible[2]);
|
|
148120
|
+
vec3 dat3 = sampleAndGetData(channel3, vTexCoord, channelsFilled[3], channelStrokeWidths[3], channelsVisible[3]);
|
|
148121
|
+
vec3 dat4 = sampleAndGetData(channel4, vTexCoord, channelsFilled[4], channelStrokeWidths[4], channelsVisible[4]);
|
|
148122
|
+
vec3 dat5 = sampleAndGetData(channel5, vTexCoord, channelsFilled[5], channelStrokeWidths[5], channelsVisible[5]);
|
|
148123
|
+
vec3 dat6 = sampleAndGetData(channel6, vTexCoord, channelsFilled[6], channelStrokeWidths[6], channelsVisible[6]);
|
|
148124
|
+
|
|
148125
|
+
vec4 val0 = dataToColor(dat0, channelIsStaticColorMode[0], color0, channelOpacities[0], valueTexOffsets[0], channelColormapRangeStarts[0], channelColormapRangeEnds[0], channelIsSetColorMode[0], colorTexOffsets[0]);
|
|
148126
|
+
vec4 val1 = dataToColor(dat1, channelIsStaticColorMode[1], color1, channelOpacities[1], valueTexOffsets[1], channelColormapRangeStarts[1], channelColormapRangeEnds[1], channelIsSetColorMode[1], colorTexOffsets[1]);
|
|
148127
|
+
vec4 val2 = dataToColor(dat2, channelIsStaticColorMode[2], color2, channelOpacities[2], valueTexOffsets[2], channelColormapRangeStarts[2], channelColormapRangeEnds[2], channelIsSetColorMode[2], colorTexOffsets[2]);
|
|
148128
|
+
vec4 val3 = dataToColor(dat3, channelIsStaticColorMode[3], color3, channelOpacities[3], valueTexOffsets[3], channelColormapRangeStarts[3], channelColormapRangeEnds[3], channelIsSetColorMode[3], colorTexOffsets[3]);
|
|
148129
|
+
vec4 val4 = dataToColor(dat4, channelIsStaticColorMode[4], color4, channelOpacities[4], valueTexOffsets[4], channelColormapRangeStarts[4], channelColormapRangeEnds[4], channelIsSetColorMode[4], colorTexOffsets[4]);
|
|
148130
|
+
vec4 val5 = dataToColor(dat5, channelIsStaticColorMode[5], color5, channelOpacities[5], valueTexOffsets[5], channelColormapRangeStarts[5], channelColormapRangeEnds[5], channelIsSetColorMode[5], colorTexOffsets[5]);
|
|
148131
|
+
vec4 val6 = dataToColor(dat6, channelIsStaticColorMode[6], color6, channelOpacities[6], valueTexOffsets[6], channelColormapRangeStarts[6], channelColormapRangeEnds[6], channelIsSetColorMode[6], colorTexOffsets[6]);
|
|
148132
|
+
|
|
148133
|
+
// If all of the channels are "empty", then discard this pixel so that it is not considered during picking.
|
|
148134
|
+
float emptyDat = 0.;
|
|
148135
|
+
if(dat0.x == emptyDat && dat1.x == emptyDat && dat2.x == emptyDat && dat3.x == emptyDat && dat4.x == emptyDat && dat5.x == emptyDat && dat6.x == emptyDat) {
|
|
148136
|
+
discard;
|
|
148137
|
+
}
|
|
148138
|
+
|
|
148139
|
+
// If the next channel color and the currently stored color (gl_FragColor) are identical,
|
|
148140
|
+
// or the next channel color is transparent black,
|
|
148141
|
+
// just use the currently stored color. Repeat this for all channels.
|
|
148142
|
+
|
|
148143
|
+
// Mix colors where necessary, using the alpha value of the next channel as the weight.
|
|
148144
|
+
// Use the maximum alpha value as the resulting alpha value.
|
|
148145
|
+
gl_FragColor = val0;
|
|
148146
|
+
gl_FragColor = (val1 == gl_FragColor || val1 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val1, val1.a).rgb, max(gl_FragColor.a, val1.a));
|
|
148147
|
+
gl_FragColor = (val2 == gl_FragColor || val2 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val2, val2.a).rgb, max(gl_FragColor.a, val2.a));
|
|
148148
|
+
gl_FragColor = (val3 == gl_FragColor || val3 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val3, val3.a).rgb, max(gl_FragColor.a, val3.a));
|
|
148149
|
+
gl_FragColor = (val4 == gl_FragColor || val4 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val4, val4.a).rgb, max(gl_FragColor.a, val4.a));
|
|
148150
|
+
gl_FragColor = (val5 == gl_FragColor || val5 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val5, val5.a).rgb, max(gl_FragColor.a, val5.a));
|
|
148151
|
+
gl_FragColor = (val6 == gl_FragColor || val6 == vec4(0.)) ? gl_FragColor : vec4(mix(gl_FragColor, val6, val6.a).rgb, max(gl_FragColor.a, val6.a));
|
|
148152
|
+
|
|
148153
|
+
|
|
148154
|
+
|
|
148155
|
+
// TODO: multiply the resulting channel-level opacity value by the layer-level opacity value.
|
|
148156
|
+
|
|
148157
|
+
geometry.uv = vTexCoord;
|
|
148158
|
+
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
148159
|
+
}
|
|
148160
|
+
`;
|
|
148161
|
+
function extent(values, valueof) {
|
|
148162
|
+
let min2;
|
|
148163
|
+
let max2;
|
|
148164
|
+
if (valueof === void 0) {
|
|
148165
|
+
for (const value of values) {
|
|
148166
|
+
if (value != null) {
|
|
148167
|
+
if (min2 === void 0) {
|
|
148168
|
+
if (value >= value)
|
|
148169
|
+
min2 = max2 = value;
|
|
148170
|
+
} else {
|
|
148171
|
+
if (min2 > value)
|
|
148172
|
+
min2 = value;
|
|
148173
|
+
if (max2 < value)
|
|
148174
|
+
max2 = value;
|
|
148175
|
+
}
|
|
148176
|
+
}
|
|
148177
|
+
}
|
|
148178
|
+
} else {
|
|
148179
|
+
let index2 = -1;
|
|
148180
|
+
for (let value of values) {
|
|
148181
|
+
if ((value = valueof(value, ++index2, values)) != null) {
|
|
148182
|
+
if (min2 === void 0) {
|
|
148183
|
+
if (value >= value)
|
|
148184
|
+
min2 = max2 = value;
|
|
148185
|
+
} else {
|
|
148186
|
+
if (min2 > value)
|
|
148187
|
+
min2 = value;
|
|
148188
|
+
if (max2 < value)
|
|
148189
|
+
max2 = value;
|
|
148190
|
+
}
|
|
148191
|
+
}
|
|
148192
|
+
}
|
|
148193
|
+
}
|
|
148194
|
+
return [min2, max2];
|
|
148195
|
+
}
|
|
148196
|
+
function normalize(arr) {
|
|
148197
|
+
const [min2, max2] = extent(arr);
|
|
148198
|
+
const ratio = 255 / (max2 - min2);
|
|
148199
|
+
const data = new Uint8Array(arr.map((i2) => Math.floor((i2 - min2) * ratio)));
|
|
148200
|
+
return data;
|
|
148201
|
+
}
|
|
148202
|
+
function multiSetsToTextureData(multiFeatureValues, setColorValues, channelIsSetColorMode, texSize) {
|
|
148203
|
+
let totalValuesLength = 0;
|
|
148204
|
+
let totalColorsLength = 0;
|
|
148205
|
+
channelIsSetColorMode.forEach((isSetColorMode, channelIndex) => {
|
|
148206
|
+
var _a2, _b, _c, _d, _e;
|
|
148207
|
+
if (isSetColorMode) {
|
|
148208
|
+
totalValuesLength += ((_b = (_a2 = setColorValues[channelIndex]) == null ? void 0 : _a2.obsIndex) == null ? void 0 : _b.length) || 0;
|
|
148209
|
+
totalColorsLength += (((_d = (_c = setColorValues[channelIndex]) == null ? void 0 : _c.setColors) == null ? void 0 : _d.length) || 0) * 3;
|
|
148210
|
+
} else {
|
|
148211
|
+
totalValuesLength += ((_e = multiFeatureValues[channelIndex]) == null ? void 0 : _e.length) || 0;
|
|
148212
|
+
}
|
|
148213
|
+
});
|
|
148214
|
+
const valueTexHeight = Math.max(2, Math.ceil(totalValuesLength / texSize));
|
|
148215
|
+
const colorTexHeight = Math.max(2, Math.ceil(totalColorsLength / texSize));
|
|
148216
|
+
if (valueTexHeight > texSize) {
|
|
148217
|
+
console.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
|
|
148218
|
+
}
|
|
148219
|
+
if (colorTexHeight > texSize) {
|
|
148220
|
+
console.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
|
|
148221
|
+
}
|
|
148222
|
+
const totalData = new Uint8Array(texSize * valueTexHeight);
|
|
148223
|
+
const totalColors = new Uint8Array(texSize * colorTexHeight);
|
|
148224
|
+
const indicesOffsets = [];
|
|
148225
|
+
const colorsOffsets = [];
|
|
148226
|
+
let indexOffset = 0;
|
|
148227
|
+
let colorOffset = 0;
|
|
148228
|
+
channelIsSetColorMode.forEach((isSetColorMode, channelIndex) => {
|
|
148229
|
+
if (isSetColorMode) {
|
|
148230
|
+
const { setColorIndices, setColors, obsIndex } = setColorValues[channelIndex] || {};
|
|
148231
|
+
if (setColorIndices && setColors && obsIndex) {
|
|
148232
|
+
for (let i2 = 0; i2 < obsIndex.length; i2++) {
|
|
148233
|
+
const colorIndex = setColorIndices.get(String(i2 + 1));
|
|
148234
|
+
totalData[indexOffset + i2] = colorIndex === void 0 ? 0 : colorIndex + 1;
|
|
148235
|
+
}
|
|
148236
|
+
for (let i2 = 0; i2 < setColors.length; i2++) {
|
|
148237
|
+
const { color: [r2, g2, b] } = setColors[i2];
|
|
148238
|
+
totalColors[(colorOffset + i2) * 3 + 0] = r2;
|
|
148239
|
+
totalColors[(colorOffset + i2) * 3 + 1] = g2;
|
|
148240
|
+
totalColors[(colorOffset + i2) * 3 + 2] = b;
|
|
148241
|
+
}
|
|
148242
|
+
}
|
|
148243
|
+
indicesOffsets.push(indexOffset);
|
|
148244
|
+
colorsOffsets.push(colorOffset);
|
|
148245
|
+
indexOffset += (obsIndex == null ? void 0 : obsIndex.length) || 0;
|
|
148246
|
+
colorOffset += (setColors == null ? void 0 : setColors.length) || 0;
|
|
148247
|
+
} else {
|
|
148248
|
+
const featureArr = multiFeatureValues[channelIndex];
|
|
148249
|
+
totalData.set(normalize(featureArr), indexOffset);
|
|
148250
|
+
indicesOffsets.push(indexOffset);
|
|
148251
|
+
indexOffset += featureArr.length;
|
|
148252
|
+
colorsOffsets.push(colorOffset);
|
|
148253
|
+
}
|
|
148254
|
+
});
|
|
148255
|
+
return [
|
|
148256
|
+
totalData,
|
|
148257
|
+
valueTexHeight,
|
|
148258
|
+
indicesOffsets,
|
|
148259
|
+
totalColors,
|
|
148260
|
+
colorTexHeight,
|
|
148261
|
+
colorsOffsets
|
|
148262
|
+
];
|
|
148263
|
+
}
|
|
148264
|
+
const MAX_CHANNELS = 7;
|
|
148265
|
+
const MULTI_FEATURE_TEX_SIZE = 2048;
|
|
148266
|
+
function padWithDefault(arr, defaultValue2, padWidth) {
|
|
148267
|
+
const newArr = [...arr];
|
|
148268
|
+
for (let i2 = 0; i2 < padWidth; i2 += 1) {
|
|
148269
|
+
newArr.push(defaultValue2);
|
|
148270
|
+
}
|
|
148271
|
+
return newArr;
|
|
148272
|
+
}
|
|
148273
|
+
function getColor(arr) {
|
|
148274
|
+
return arr ? arr.map((v) => v / 255) : [0, 0, 0];
|
|
148275
|
+
}
|
|
148276
|
+
const defaultProps = {
|
|
148277
|
+
channelStrokeWidths: { type: "array", value: null, compare: true },
|
|
148278
|
+
channelsFilled: { type: "array", value: null, compare: true },
|
|
148279
|
+
channelOpacities: { type: "array", value: null, compare: true },
|
|
148280
|
+
channelColors: { type: "array", value: null, compare: true },
|
|
148281
|
+
hoveredCell: { type: "number", value: null, compare: true },
|
|
148282
|
+
colormap: { type: "string", value: GLSL_COLORMAP_DEFAULT, compare: true },
|
|
148283
|
+
expressionData: { type: "object", value: null, compare: true },
|
|
148284
|
+
multiFeatureValues: { type: "array", value: null, compare: true },
|
|
148285
|
+
setColorValues: { type: "array", value: null, compare: true },
|
|
148286
|
+
channelFeatureValueColormaps: { type: "array", value: null, compare: true },
|
|
148287
|
+
channelFeatureValueColormapRanges: { type: "array", value: null, compare: true },
|
|
148288
|
+
channelIsStaticColorMode: { type: "array", value: null, compare: true },
|
|
148289
|
+
channelIsSetColorMode: { type: "array", value: null, compare: true }
|
|
148290
|
+
};
|
|
148291
|
+
class BitmaskLayer2 extends XRLayer {
|
|
148292
|
+
// eslint-disable-next-line class-methods-use-this
|
|
148293
|
+
getShaders() {
|
|
148294
|
+
const { colormap } = this.props;
|
|
148295
|
+
return {
|
|
148296
|
+
fs,
|
|
148297
|
+
vs,
|
|
148298
|
+
modules: [project32, picking],
|
|
148299
|
+
defines: {
|
|
148300
|
+
[COLORMAP_SHADER_PLACEHOLDER]: GLSL_COLORMAPS.includes(colormap) ? colormap : GLSL_COLORMAP_DEFAULT
|
|
148301
|
+
}
|
|
148302
|
+
};
|
|
148303
|
+
}
|
|
148304
|
+
/**
|
|
148305
|
+
* Override the parent loadChannelTextures to enable
|
|
148306
|
+
* up to eight channels (rather than six).
|
|
148307
|
+
* Reference: https://github.com/hms-dbmi/viv/blob/v0.13.3/packages/layers/src/xr-layer/xr-layer.js#L316
|
|
148308
|
+
*/
|
|
148309
|
+
loadChannelTextures(channelData) {
|
|
148310
|
+
const textures = {
|
|
148311
|
+
channel0: null,
|
|
148312
|
+
channel1: null,
|
|
148313
|
+
channel2: null,
|
|
148314
|
+
channel3: null,
|
|
148315
|
+
channel4: null,
|
|
148316
|
+
channel5: null,
|
|
148317
|
+
channel6: null
|
|
148318
|
+
};
|
|
148319
|
+
if (this.state.textures) {
|
|
148320
|
+
Object.values(this.state.textures).forEach((tex) => tex && tex.delete());
|
|
148321
|
+
}
|
|
148322
|
+
if (channelData && Object.keys(channelData).length > 0 && channelData.data) {
|
|
148323
|
+
channelData.data.forEach((d, i2) => {
|
|
148324
|
+
textures[`channel${i2}`] = this.dataToTexture(d, channelData.width, channelData.height);
|
|
148325
|
+
}, this);
|
|
148326
|
+
this.setState({ textures });
|
|
148327
|
+
}
|
|
148328
|
+
}
|
|
148329
|
+
updateState({ props: props2, oldProps, changeFlags }) {
|
|
148330
|
+
super.updateState({ props: props2, oldProps, changeFlags });
|
|
148331
|
+
if (props2.multiFeatureValues !== oldProps.multiFeatureValues || props2.setColorValues !== oldProps.setColorValues || props2.channelIsSetColorMode !== oldProps.channelIsSetColorMode) {
|
|
148332
|
+
const { multiFeatureValues, setColorValues, channelIsSetColorMode } = this.props;
|
|
148333
|
+
const [valueTex, colorTex, valueTexOffsets, colorTexOffsets, valueTexHeight, colorTexHeight] = this.multiSetsToTexture(multiFeatureValues, setColorValues, channelIsSetColorMode);
|
|
148334
|
+
this.setState({
|
|
148335
|
+
valueTex,
|
|
148336
|
+
colorTex,
|
|
148337
|
+
valueTexOffsets,
|
|
148338
|
+
colorTexOffsets,
|
|
148339
|
+
valueTexHeight,
|
|
148340
|
+
colorTexHeight
|
|
148341
|
+
});
|
|
148342
|
+
}
|
|
148343
|
+
if (props2.colormap !== oldProps.colormap) {
|
|
148344
|
+
const { gl } = this.context;
|
|
148345
|
+
if (this.state.model) {
|
|
148346
|
+
this.state.model.delete();
|
|
148347
|
+
}
|
|
148348
|
+
this.setState({ model: this._getModel(gl) });
|
|
148349
|
+
this.getAttributeManager().invalidateAll();
|
|
148350
|
+
}
|
|
148351
|
+
}
|
|
148352
|
+
draw(opts2) {
|
|
148353
|
+
const { uniforms } = opts2;
|
|
148354
|
+
const {
|
|
148355
|
+
channelStrokeWidths,
|
|
148356
|
+
channelsFilled,
|
|
148357
|
+
channelOpacities,
|
|
148358
|
+
channelColors,
|
|
148359
|
+
channelsVisible,
|
|
148360
|
+
// TODO: use `channelFeatureValueColormaps` in shader,
|
|
148361
|
+
// figure out how to call multiple GLSL colormap functions
|
|
148362
|
+
channelFeatureValueColormaps,
|
|
148363
|
+
channelFeatureValueColormapRanges,
|
|
148364
|
+
channelIsStaticColorMode,
|
|
148365
|
+
channelIsSetColorMode,
|
|
148366
|
+
hoveredCell,
|
|
148367
|
+
colorScaleLo,
|
|
148368
|
+
colorScaleHi,
|
|
148369
|
+
isExpressionMode,
|
|
148370
|
+
zoom,
|
|
148371
|
+
minZoom,
|
|
148372
|
+
maxZoom,
|
|
148373
|
+
zoomOffset
|
|
148374
|
+
// TODO: figure out if this needs to be used or not
|
|
148375
|
+
} = this.props;
|
|
148376
|
+
const {
|
|
148377
|
+
textures,
|
|
148378
|
+
model,
|
|
148379
|
+
// Expression and set index (and colors) textures with offsets
|
|
148380
|
+
valueTex,
|
|
148381
|
+
colorTex,
|
|
148382
|
+
valueTexOffsets,
|
|
148383
|
+
colorTexOffsets,
|
|
148384
|
+
valueTexHeight,
|
|
148385
|
+
colorTexHeight
|
|
148386
|
+
} = this.state;
|
|
148387
|
+
if (textures && model) {
|
|
148388
|
+
const scaleFactor = 1 / 2 ** (maxZoom - zoom);
|
|
148389
|
+
const colors = fromEntries(range$5(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
|
|
148390
|
+
model.setUniforms(Object.assign({}, uniforms, {
|
|
148391
|
+
...colors,
|
|
148392
|
+
// Bitmask image channel data textures
|
|
148393
|
+
...textures,
|
|
148394
|
+
multiFeatureTexSize: MULTI_FEATURE_TEX_SIZE,
|
|
148395
|
+
// Expression textures with offsets
|
|
148396
|
+
valueTex,
|
|
148397
|
+
valueTexOffsets: padWithDefault(valueTexOffsets, 0, MAX_CHANNELS - valueTexOffsets.length),
|
|
148398
|
+
valueTexHeight,
|
|
148399
|
+
// Set indices and colors textures with offsets
|
|
148400
|
+
colorTex,
|
|
148401
|
+
colorTexOffsets: padWithDefault(colorTexOffsets, 0, MAX_CHANNELS - colorTexOffsets.length),
|
|
148402
|
+
colorTexHeight,
|
|
148403
|
+
// Visualization properties
|
|
148404
|
+
channelsFilled: padWithDefault(
|
|
148405
|
+
channelsFilled,
|
|
148406
|
+
true,
|
|
148407
|
+
// There are six texture entries on the shaders
|
|
148408
|
+
MAX_CHANNELS - channelsFilled.length
|
|
148409
|
+
),
|
|
148410
|
+
channelOpacities: padWithDefault(
|
|
148411
|
+
channelOpacities,
|
|
148412
|
+
0,
|
|
148413
|
+
// There are six texture entries on the shaders
|
|
148414
|
+
MAX_CHANNELS - channelOpacities.length
|
|
148415
|
+
),
|
|
148416
|
+
channelStrokeWidths: padWithDefault(
|
|
148417
|
+
channelStrokeWidths,
|
|
148418
|
+
1,
|
|
148419
|
+
// There are six texture entries on the shaders
|
|
148420
|
+
MAX_CHANNELS - channelStrokeWidths.length
|
|
148421
|
+
),
|
|
148422
|
+
channelColormapRangeStarts: padWithDefault(
|
|
148423
|
+
channelFeatureValueColormapRanges.map((r2) => (r2 == null ? void 0 : r2[0]) || 0),
|
|
148424
|
+
0,
|
|
148425
|
+
// There are six texture entries on the shaders
|
|
148426
|
+
MAX_CHANNELS - channelFeatureValueColormapRanges.length
|
|
148427
|
+
),
|
|
148428
|
+
channelColormapRangeEnds: padWithDefault(
|
|
148429
|
+
channelFeatureValueColormapRanges.map((r2) => (r2 == null ? void 0 : r2[1]) || 1),
|
|
148430
|
+
1,
|
|
148431
|
+
// There are six texture entries on the shaders
|
|
148432
|
+
MAX_CHANNELS - channelFeatureValueColormapRanges.length
|
|
148433
|
+
),
|
|
148434
|
+
channelIsStaticColorMode: padWithDefault(
|
|
148435
|
+
channelIsStaticColorMode,
|
|
148436
|
+
true,
|
|
148437
|
+
// There are six texture entries on the shaders
|
|
148438
|
+
MAX_CHANNELS - channelIsStaticColorMode.length
|
|
148439
|
+
),
|
|
148440
|
+
channelIsSetColorMode: padWithDefault(
|
|
148441
|
+
channelIsSetColorMode,
|
|
148442
|
+
false,
|
|
148443
|
+
// There are six texture entries on the shaders
|
|
148444
|
+
MAX_CHANNELS - channelIsSetColorMode.length
|
|
148445
|
+
),
|
|
148446
|
+
hovered: hoveredCell || 0,
|
|
148447
|
+
channelsVisible: padWithDefault(
|
|
148448
|
+
channelsVisible,
|
|
148449
|
+
false,
|
|
148450
|
+
// There are six texture entries on the shaders
|
|
148451
|
+
MAX_CHANNELS - channelsVisible.length
|
|
148452
|
+
),
|
|
148453
|
+
// uColorScaleRange: [colorScaleLo, colorScaleHi],
|
|
148454
|
+
// uIsExpressionMode: isExpressionMode,
|
|
148455
|
+
// uIsOutlined: false,
|
|
148456
|
+
scaleFactor
|
|
148457
|
+
})).draw();
|
|
148458
|
+
}
|
|
148459
|
+
}
|
|
148460
|
+
/**
|
|
148461
|
+
* This function creates textures from the data
|
|
148462
|
+
*/
|
|
148463
|
+
dataToTexture(data, width, height) {
|
|
148464
|
+
const isWebGL2On = isWebGL2$1(this.context.gl);
|
|
148465
|
+
return new Texture2D(this.context.gl, {
|
|
148466
|
+
width,
|
|
148467
|
+
height,
|
|
148468
|
+
// Only use Float32 so we don't have to write two shaders
|
|
148469
|
+
data: new Float32Array(data),
|
|
148470
|
+
// we don't want or need mimaps
|
|
148471
|
+
mipmaps: false,
|
|
148472
|
+
parameters: {
|
|
148473
|
+
// NEAREST for integer data
|
|
148474
|
+
[GL$1.TEXTURE_MIN_FILTER]: GL$1.NEAREST,
|
|
148475
|
+
[GL$1.TEXTURE_MAG_FILTER]: GL$1.NEAREST,
|
|
148476
|
+
// CLAMP_TO_EDGE to remove tile artifacts
|
|
148477
|
+
[GL$1.TEXTURE_WRAP_S]: GL$1.CLAMP_TO_EDGE,
|
|
148478
|
+
[GL$1.TEXTURE_WRAP_T]: GL$1.CLAMP_TO_EDGE
|
|
148479
|
+
},
|
|
148480
|
+
format: isWebGL2On ? GL$1.R32F : GL$1.LUMINANCE,
|
|
148481
|
+
dataFormat: isWebGL2On ? GL$1.RED : GL$1.LUMINANCE,
|
|
148482
|
+
type: GL$1.FLOAT
|
|
148483
|
+
});
|
|
148484
|
+
}
|
|
148485
|
+
multiSetsToTexture(multiFeatureValues, setColorValues, channelIsSetColorMode) {
|
|
148486
|
+
const isWebGL2On = isWebGL2$1(this.context.gl);
|
|
148487
|
+
const [totalData, valueTexHeight, indicesOffsets, totalColors, colorTexHeight, colorsOffsets] = multiSetsToTextureData(multiFeatureValues, setColorValues, channelIsSetColorMode, MULTI_FEATURE_TEX_SIZE);
|
|
148488
|
+
return [
|
|
148489
|
+
// Color indices texture
|
|
148490
|
+
new Texture2D(this.context.gl, {
|
|
148491
|
+
width: MULTI_FEATURE_TEX_SIZE,
|
|
148492
|
+
height: valueTexHeight,
|
|
148493
|
+
// Only use Float32 so we don't have to write two shaders
|
|
148494
|
+
data: new Float32Array(totalData),
|
|
148495
|
+
// we don't want or need mimaps
|
|
148496
|
+
mipmaps: false,
|
|
148497
|
+
parameters: {
|
|
148498
|
+
// NEAREST for integer data
|
|
148499
|
+
[GL$1.TEXTURE_MIN_FILTER]: GL$1.NEAREST,
|
|
148500
|
+
[GL$1.TEXTURE_MAG_FILTER]: GL$1.NEAREST,
|
|
148501
|
+
// CLAMP_TO_EDGE to remove tile artifacts
|
|
148502
|
+
[GL$1.TEXTURE_WRAP_S]: GL$1.CLAMP_TO_EDGE,
|
|
148503
|
+
[GL$1.TEXTURE_WRAP_T]: GL$1.CLAMP_TO_EDGE
|
|
148504
|
+
},
|
|
148505
|
+
format: isWebGL2On ? GL$1.R32F : GL$1.LUMINANCE,
|
|
148506
|
+
dataFormat: isWebGL2On ? GL$1.RED : GL$1.LUMINANCE,
|
|
148507
|
+
type: GL$1.FLOAT
|
|
148508
|
+
}),
|
|
148509
|
+
// Colors texture
|
|
148510
|
+
new Texture2D(this.context.gl, {
|
|
148511
|
+
width: MULTI_FEATURE_TEX_SIZE,
|
|
148512
|
+
height: colorTexHeight,
|
|
148513
|
+
// Only use Float32 so we don't have to write two shaders
|
|
148514
|
+
data: new Float32Array(totalColors),
|
|
148515
|
+
// we don't want or need mimaps
|
|
148516
|
+
mipmaps: false,
|
|
148517
|
+
parameters: {
|
|
148518
|
+
// NEAREST for integer data
|
|
148519
|
+
[GL$1.TEXTURE_MIN_FILTER]: GL$1.NEAREST,
|
|
148520
|
+
[GL$1.TEXTURE_MAG_FILTER]: GL$1.NEAREST,
|
|
148521
|
+
// CLAMP_TO_EDGE to remove tile artifacts
|
|
148522
|
+
[GL$1.TEXTURE_WRAP_S]: GL$1.CLAMP_TO_EDGE,
|
|
148523
|
+
[GL$1.TEXTURE_WRAP_T]: GL$1.CLAMP_TO_EDGE
|
|
148524
|
+
},
|
|
148525
|
+
format: isWebGL2On ? GL$1.R32F : GL$1.LUMINANCE,
|
|
148526
|
+
dataFormat: isWebGL2On ? GL$1.RED : GL$1.LUMINANCE,
|
|
148527
|
+
type: GL$1.FLOAT
|
|
148528
|
+
}),
|
|
148529
|
+
// Offsets
|
|
148530
|
+
indicesOffsets,
|
|
148531
|
+
colorsOffsets,
|
|
148532
|
+
// Texture heights
|
|
148533
|
+
valueTexHeight,
|
|
148534
|
+
colorTexHeight
|
|
148535
|
+
];
|
|
148536
|
+
}
|
|
148537
|
+
}
|
|
148538
|
+
BitmaskLayer2.layerName = "BitmaskLayer";
|
|
148539
|
+
BitmaskLayer2.defaultProps = defaultProps;
|
|
148540
|
+
function filterSelection(loader, selection) {
|
|
148541
|
+
if (!selection) {
|
|
148542
|
+
return selection;
|
|
148543
|
+
}
|
|
148544
|
+
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
|
|
148545
|
+
const { labels } = data;
|
|
148546
|
+
return fromEntries(Object.entries(selection).filter(([key]) => labels.includes(key)));
|
|
147804
148547
|
}
|
|
147805
|
-
BitmaskLayer.layerName = "BitmaskLayer";
|
|
147806
|
-
BitmaskLayer.defaultProps = defaultProps;
|
|
147807
148548
|
async function getSingleSelectionStats2D({ loader, selection }) {
|
|
147808
148549
|
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
|
|
147809
|
-
const
|
|
148550
|
+
const filteredSelection = filterSelection(loader, selection);
|
|
148551
|
+
const raster = await data.getRaster({ selection: filteredSelection });
|
|
147810
148552
|
const selectionStats = getChannelStats(raster.data);
|
|
147811
148553
|
const { domain, contrastLimits: slider } = selectionStats;
|
|
147812
148554
|
return { domain, slider };
|
|
147813
148555
|
}
|
|
147814
148556
|
async function getSingleSelectionStats3D({ loader, selection }) {
|
|
147815
148557
|
const lowResSource = loader[loader.length - 1];
|
|
148558
|
+
const filteredSelection = filterSelection(lowResSource, selection);
|
|
147816
148559
|
const { shape, labels } = lowResSource;
|
|
147817
148560
|
const sizeZ = shape[labels.indexOf("z")] >> loader.length - 1;
|
|
147818
148561
|
const raster0 = await lowResSource.getRaster({
|
|
147819
|
-
selection: { ...
|
|
148562
|
+
selection: { ...filteredSelection, z: 0 }
|
|
147820
148563
|
});
|
|
147821
148564
|
const rasterMid = await lowResSource.getRaster({
|
|
147822
|
-
selection: { ...
|
|
148565
|
+
selection: { ...filteredSelection, z: Math.floor(sizeZ / 2) }
|
|
147823
148566
|
});
|
|
147824
148567
|
const rasterTop = await lowResSource.getRaster({
|
|
147825
|
-
selection: { ...
|
|
148568
|
+
selection: { ...filteredSelection, z: Math.max(0, sizeZ - 1) }
|
|
147826
148569
|
});
|
|
147827
148570
|
const stats0 = getChannelStats(raster0.data);
|
|
147828
148571
|
const statsMid = getChannelStats(rasterMid.data);
|
|
@@ -147870,6 +148613,27 @@ function getSourceFromLoader(loader, level) {
|
|
|
147870
148613
|
const source = Array.isArray(data) ? data[level || data.length - 1] : data;
|
|
147871
148614
|
return source;
|
|
147872
148615
|
}
|
|
148616
|
+
const getStatsForResolution = (loader, resolution) => {
|
|
148617
|
+
const { shape, labels } = loader[resolution];
|
|
148618
|
+
const height = shape[labels.indexOf("y")];
|
|
148619
|
+
const width = shape[labels.indexOf("x")];
|
|
148620
|
+
const depth = shape[labels.indexOf("z")];
|
|
148621
|
+
const depthDownsampled = Math.max(1, depth >> resolution);
|
|
148622
|
+
const totalBytes = 4 * height * width * depthDownsampled;
|
|
148623
|
+
return {
|
|
148624
|
+
height,
|
|
148625
|
+
width,
|
|
148626
|
+
depthDownsampled,
|
|
148627
|
+
totalBytes
|
|
148628
|
+
};
|
|
148629
|
+
};
|
|
148630
|
+
const canLoadResolution = (loader, resolution) => {
|
|
148631
|
+
var _a2, _b, _c;
|
|
148632
|
+
const { totalBytes, height, width, depthDownsampled } = getStatsForResolution(loader, resolution);
|
|
148633
|
+
const maxHeapSize = ((_a2 = window.performance) == null ? void 0 : _a2.memory) && ((_c = (_b = window.performance) == null ? void 0 : _b.memory) == null ? void 0 : _c.jsHeapSizeLimit) / 2;
|
|
148634
|
+
const maxSize = maxHeapSize || 2 ** 31 - 1;
|
|
148635
|
+
return totalBytes < maxSize && height <= 2048 && depthDownsampled <= 2048 && width <= 2048 && depthDownsampled > 1;
|
|
148636
|
+
};
|
|
147873
148637
|
function isRgb(loader, channels2) {
|
|
147874
148638
|
const source = getSourceFromLoader(loader);
|
|
147875
148639
|
const { shape, dtype, labels } = source;
|
|
@@ -147882,6 +148646,32 @@ function isRgb(loader, channels2) {
|
|
|
147882
148646
|
}
|
|
147883
148647
|
return false;
|
|
147884
148648
|
}
|
|
148649
|
+
function physicalSizeToMatrix(xSize, ySize, zSize, xUnit, yUnit, zUnit) {
|
|
148650
|
+
const hasZPhyscialSize = Boolean(zSize) && Boolean(zUnit);
|
|
148651
|
+
const hasYPhyscialSize = Boolean(ySize) && Boolean(yUnit);
|
|
148652
|
+
const hasXPhyscialSize = Boolean(xSize) && Boolean(xUnit);
|
|
148653
|
+
if (!hasXPhyscialSize || !hasYPhyscialSize) {
|
|
148654
|
+
return new Matrix4().identity();
|
|
148655
|
+
}
|
|
148656
|
+
const sizes = [
|
|
148657
|
+
unit(`${xSize} ${xUnit}`.replace("µ", "u")),
|
|
148658
|
+
unit(`${ySize} ${yUnit}`.replace("µ", "u"))
|
|
148659
|
+
];
|
|
148660
|
+
if (hasZPhyscialSize) {
|
|
148661
|
+
sizes.push(unit(`${zSize} ${zUnit}`.replace("µ", "u")));
|
|
148662
|
+
}
|
|
148663
|
+
const scale2 = sizes.map((i2) => divide(i2, unit("1 um")));
|
|
148664
|
+
if (!sizes[0].equals(sizes[1])) {
|
|
148665
|
+
scale2[1] = divide(sizes[1], sizes[0]);
|
|
148666
|
+
}
|
|
148667
|
+
if (!scale2[2]) {
|
|
148668
|
+
scale2[2] = 1;
|
|
148669
|
+
}
|
|
148670
|
+
if (isEqual$1(scale2, [1, 1, 1])) {
|
|
148671
|
+
return new Matrix4().identity();
|
|
148672
|
+
}
|
|
148673
|
+
return new Matrix4().scale([...scale2]);
|
|
148674
|
+
}
|
|
147885
148675
|
function getMetaWithTransformMatrices(imageMeta, imageLoaders) {
|
|
147886
148676
|
const sources = imageLoaders.map((loader) => getSourceFromLoader(loader));
|
|
147887
148677
|
if (imageMeta.map((meta2) => {
|
|
@@ -148076,6 +148866,12 @@ function getNgffAxes(firstMultiscalesAxes) {
|
|
|
148076
148866
|
}
|
|
148077
148867
|
return axes;
|
|
148078
148868
|
}
|
|
148869
|
+
function getNgffAxesForTiff(dimOrder) {
|
|
148870
|
+
return dimOrder.toLowerCase().split("").map((name2) => ({
|
|
148871
|
+
name: name2,
|
|
148872
|
+
type: getDefaultAxisType(name2)
|
|
148873
|
+
}));
|
|
148874
|
+
}
|
|
148079
148875
|
function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
148080
148876
|
let mat = new Matrix4().identity();
|
|
148081
148877
|
if (coordinateTransformations && axes) {
|
|
@@ -148105,6 +148901,14 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
|
|
|
148105
148901
|
}
|
|
148106
148902
|
return mat;
|
|
148107
148903
|
}
|
|
148904
|
+
function hexToRgb(hex) {
|
|
148905
|
+
const result = /^#?([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})$/i.exec(hex);
|
|
148906
|
+
return [
|
|
148907
|
+
parseInt(result[1].toLowerCase(), 16),
|
|
148908
|
+
parseInt(result[2].toLowerCase(), 16),
|
|
148909
|
+
parseInt(result[3].toLowerCase(), 16)
|
|
148910
|
+
];
|
|
148911
|
+
}
|
|
148108
148912
|
function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
|
|
148109
148913
|
var _a2;
|
|
148110
148914
|
let result = [];
|
|
@@ -148140,6 +148944,17 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
|
|
|
148140
148944
|
}
|
|
148141
148945
|
return result;
|
|
148142
148946
|
}
|
|
148947
|
+
function getDomains() {
|
|
148948
|
+
const domains = {};
|
|
148949
|
+
const needMin = ["Int8", "Int16", "Int32"];
|
|
148950
|
+
Object.keys(DTYPE_VALUES).forEach((dtype) => {
|
|
148951
|
+
const { max: max2 } = DTYPE_VALUES[dtype];
|
|
148952
|
+
const min2 = needMin.includes(dtype) ? -(max2 + 1) : 0;
|
|
148953
|
+
domains[dtype] = [min2, max2];
|
|
148954
|
+
});
|
|
148955
|
+
return domains;
|
|
148956
|
+
}
|
|
148957
|
+
getDomains();
|
|
148143
148958
|
class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader {
|
|
148144
148959
|
/**
|
|
148145
148960
|
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
@@ -148311,13 +149126,210 @@ class FeatureLabelsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
148311
149126
|
)));
|
|
148312
149127
|
}
|
|
148313
149128
|
}
|
|
148314
|
-
|
|
148315
|
-
|
|
148316
|
-
|
|
148317
|
-
|
|
148318
|
-
|
|
148319
|
-
|
|
148320
|
-
|
|
149129
|
+
class ImageWrapper {
|
|
149130
|
+
constructor(vivLoader, options) {
|
|
149131
|
+
__publicField(this, "vivLoader");
|
|
149132
|
+
__publicField(this, "options");
|
|
149133
|
+
this.options = options || {};
|
|
149134
|
+
this.vivLoader = vivLoader;
|
|
149135
|
+
}
|
|
149136
|
+
getType() {
|
|
149137
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149138
|
+
return "ome-tiff";
|
|
149139
|
+
}
|
|
149140
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149141
|
+
return "ome-zarr";
|
|
149142
|
+
}
|
|
149143
|
+
throw new Error("Unknown image type.");
|
|
149144
|
+
}
|
|
149145
|
+
hasPhysicalSize() {
|
|
149146
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149147
|
+
const { Pixels: { PhysicalSizeX, PhysicalSizeXUnit, PhysicalSizeY, PhysicalSizeYUnit } } = this.vivLoader.metadata;
|
|
149148
|
+
return Boolean(PhysicalSizeX && PhysicalSizeXUnit && PhysicalSizeY && PhysicalSizeYUnit);
|
|
149149
|
+
}
|
|
149150
|
+
return true;
|
|
149151
|
+
}
|
|
149152
|
+
getData() {
|
|
149153
|
+
return this.vivLoader.data;
|
|
149154
|
+
}
|
|
149155
|
+
getModelMatrix() {
|
|
149156
|
+
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options;
|
|
149157
|
+
if ("multiscales" in this.vivLoader.metadata) {
|
|
149158
|
+
const { multiscales: [{ coordinateTransformations, axes }] } = this.vivLoader.metadata;
|
|
149159
|
+
const ngffAxes = getNgffAxes(axes);
|
|
149160
|
+
const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
|
|
149161
|
+
const transformMatrixFromFile = coordinateTransformationsToMatrix(coordinateTransformations, ngffAxes);
|
|
149162
|
+
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
149163
|
+
return transformMatrix;
|
|
149164
|
+
}
|
|
149165
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149166
|
+
const { Pixels: { PhysicalSizeX, PhysicalSizeXUnit, PhysicalSizeY, PhysicalSizeYUnit, PhysicalSizeZ, PhysicalSizeZUnit, DimensionOrder } } = this.vivLoader.metadata;
|
|
149167
|
+
const ngffAxes = getNgffAxesForTiff(DimensionOrder);
|
|
149168
|
+
const transformMatrixFromOptions = coordinateTransformationsToMatrix(coordinateTransformationsFromOptions, ngffAxes);
|
|
149169
|
+
const transformMatrixFromFile = physicalSizeToMatrix(PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, PhysicalSizeXUnit, PhysicalSizeYUnit, PhysicalSizeZUnit);
|
|
149170
|
+
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
149171
|
+
return transformMatrix;
|
|
149172
|
+
}
|
|
149173
|
+
throw new Error("Unknown image type.");
|
|
149174
|
+
}
|
|
149175
|
+
getDefaultTargetT() {
|
|
149176
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149177
|
+
const { omero: { rdefs: { defaultT } } } = this.vivLoader.metadata;
|
|
149178
|
+
return defaultT || 0;
|
|
149179
|
+
}
|
|
149180
|
+
return 0;
|
|
149181
|
+
}
|
|
149182
|
+
getDefaultTargetZ() {
|
|
149183
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149184
|
+
const { omero: { rdefs: { defaultZ } } } = this.vivLoader.metadata;
|
|
149185
|
+
return defaultZ || 0;
|
|
149186
|
+
}
|
|
149187
|
+
return 0;
|
|
149188
|
+
}
|
|
149189
|
+
getName() {
|
|
149190
|
+
let result;
|
|
149191
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149192
|
+
const { Name } = this.vivLoader.metadata;
|
|
149193
|
+
result = Name;
|
|
149194
|
+
}
|
|
149195
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149196
|
+
const { omero: { name: name2 } } = this.vivLoader.metadata;
|
|
149197
|
+
result = name2;
|
|
149198
|
+
}
|
|
149199
|
+
if (!result) {
|
|
149200
|
+
result = "Image";
|
|
149201
|
+
}
|
|
149202
|
+
return result;
|
|
149203
|
+
}
|
|
149204
|
+
getNumChannels() {
|
|
149205
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149206
|
+
const { Pixels: { Channels } } = this.vivLoader.metadata;
|
|
149207
|
+
return Channels.length;
|
|
149208
|
+
}
|
|
149209
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149210
|
+
const { omero: { channels: channels2 } } = this.vivLoader.metadata;
|
|
149211
|
+
return channels2.length;
|
|
149212
|
+
}
|
|
149213
|
+
return 0;
|
|
149214
|
+
}
|
|
149215
|
+
getChannelNames() {
|
|
149216
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149217
|
+
const { Pixels: { Channels } } = this.vivLoader.metadata;
|
|
149218
|
+
return Channels.map((channel, i2) => channel.Name || `Channel ${i2}`);
|
|
149219
|
+
}
|
|
149220
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149221
|
+
const { omero: { channels: channels2 } } = this.vivLoader.metadata;
|
|
149222
|
+
return channels2.map((channel, i2) => channel.label || `Channel ${i2}`);
|
|
149223
|
+
}
|
|
149224
|
+
return [];
|
|
149225
|
+
}
|
|
149226
|
+
getChannelObjects() {
|
|
149227
|
+
if ("omero" in this.vivLoader.metadata) {
|
|
149228
|
+
const { omero: { channels: channels2 } } = this.vivLoader.metadata;
|
|
149229
|
+
return channels2.map((channel, i2) => ({
|
|
149230
|
+
name: channel.label || `Channel ${i2}`,
|
|
149231
|
+
defaultColor: channel.color ? hexToRgb(channel.color) : void 0,
|
|
149232
|
+
defaultWindow: channel.window ? [channel.window.start, channel.window.end] : void 0,
|
|
149233
|
+
autoDefaultColor: VIEWER_PALETTE[i2 % VIEWER_PALETTE.length]
|
|
149234
|
+
}));
|
|
149235
|
+
}
|
|
149236
|
+
if ("Pixels" in this.vivLoader.metadata) {
|
|
149237
|
+
const { Pixels: { Channels } } = this.vivLoader.metadata;
|
|
149238
|
+
return Channels.map((channel, i2) => ({
|
|
149239
|
+
name: channel.Name || `Channel ${i2}`,
|
|
149240
|
+
defaultColor: channel.Color ? channel.Color : void 0,
|
|
149241
|
+
defaultWindow: void 0,
|
|
149242
|
+
autoDefaultColor: VIEWER_PALETTE[i2 % VIEWER_PALETTE.length]
|
|
149243
|
+
}));
|
|
149244
|
+
}
|
|
149245
|
+
return [];
|
|
149246
|
+
}
|
|
149247
|
+
getDtype() {
|
|
149248
|
+
const loader = this.vivLoader;
|
|
149249
|
+
const source = getSourceFromLoader(loader);
|
|
149250
|
+
if ("dtype" in source) {
|
|
149251
|
+
return source.dtype;
|
|
149252
|
+
}
|
|
149253
|
+
return void 0;
|
|
149254
|
+
}
|
|
149255
|
+
hasZStack() {
|
|
149256
|
+
const loader = this.vivLoader;
|
|
149257
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149258
|
+
const hasZStack = shape[labels.indexOf("z")] > 1;
|
|
149259
|
+
return hasZStack;
|
|
149260
|
+
}
|
|
149261
|
+
hasTStack() {
|
|
149262
|
+
const loader = this.vivLoader;
|
|
149263
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149264
|
+
const hasTStack = shape[labels.indexOf("t")] > 1;
|
|
149265
|
+
return hasTStack;
|
|
149266
|
+
}
|
|
149267
|
+
getNumZ() {
|
|
149268
|
+
const loader = this.vivLoader;
|
|
149269
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149270
|
+
return shape[labels.indexOf("z")];
|
|
149271
|
+
}
|
|
149272
|
+
getNumT() {
|
|
149273
|
+
const loader = this.vivLoader;
|
|
149274
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149275
|
+
return shape[labels.indexOf("t")];
|
|
149276
|
+
}
|
|
149277
|
+
isMultiResolution() {
|
|
149278
|
+
const loader = this.vivLoader;
|
|
149279
|
+
const hasViewableResolutions = Boolean(Array.from({
|
|
149280
|
+
length: loader.data.length
|
|
149281
|
+
}).filter((_, resolution) => canLoadResolution(loader.data, resolution)).length);
|
|
149282
|
+
return hasViewableResolutions;
|
|
149283
|
+
}
|
|
149284
|
+
getMultiResolutionStats() {
|
|
149285
|
+
const loader = this.vivLoader;
|
|
149286
|
+
return Array.from({ length: loader.data.length }).fill(0).map((_, resolution) => {
|
|
149287
|
+
const { height, width, depthDownsampled, totalBytes } = getStatsForResolution(loader.data, resolution);
|
|
149288
|
+
return {
|
|
149289
|
+
canLoad: canLoadResolution(loader.data, resolution),
|
|
149290
|
+
height,
|
|
149291
|
+
width,
|
|
149292
|
+
depthDownsampled,
|
|
149293
|
+
totalBytes
|
|
149294
|
+
};
|
|
149295
|
+
});
|
|
149296
|
+
}
|
|
149297
|
+
/**
|
|
149298
|
+
* Compute an index of an array element returned by getMultiResolutionStats()
|
|
149299
|
+
* which corresponds to a "good" automatic target resolution to select.
|
|
149300
|
+
* In the future, we could make this more sophisticated, for example
|
|
149301
|
+
* to take into account the network speed.
|
|
149302
|
+
*/
|
|
149303
|
+
getAutoTargetResolution() {
|
|
149304
|
+
const multiResStats = this.getMultiResolutionStats();
|
|
149305
|
+
if (multiResStats.length === 0) {
|
|
149306
|
+
return null;
|
|
149307
|
+
}
|
|
149308
|
+
let nextTargetResolution = -1;
|
|
149309
|
+
let totalBytes = Infinity;
|
|
149310
|
+
do {
|
|
149311
|
+
nextTargetResolution += 1;
|
|
149312
|
+
totalBytes = multiResStats[nextTargetResolution].totalBytes;
|
|
149313
|
+
} while (totalBytes > 5e7 && nextTargetResolution < multiResStats.length - 1);
|
|
149314
|
+
return nextTargetResolution;
|
|
149315
|
+
}
|
|
149316
|
+
getBoundingCube() {
|
|
149317
|
+
const loader = this.vivLoader;
|
|
149318
|
+
const { labels, shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149319
|
+
const physicalSizeScalingMatrix = this.getModelMatrix();
|
|
149320
|
+
const xSlice = [0, physicalSizeScalingMatrix[0] * shape[labels.indexOf("x")]];
|
|
149321
|
+
const ySlice = [0, physicalSizeScalingMatrix[5] * shape[labels.indexOf("y")]];
|
|
149322
|
+
const zSlice = [
|
|
149323
|
+
0,
|
|
149324
|
+
physicalSizeScalingMatrix[10] * shape[labels.indexOf("z")]
|
|
149325
|
+
];
|
|
149326
|
+
return [xSlice, ySlice, zSlice];
|
|
149327
|
+
}
|
|
149328
|
+
isInterleaved() {
|
|
149329
|
+
const loader = this.vivLoader;
|
|
149330
|
+
const { shape } = Array.isArray(loader.data) ? loader.data[0] : loader.data;
|
|
149331
|
+
return isInterleaved(shape);
|
|
149332
|
+
}
|
|
148321
149333
|
}
|
|
148322
149334
|
class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
148323
149335
|
async load() {
|
|
@@ -148327,6 +149339,7 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
|
148327
149339
|
}
|
|
148328
149340
|
const { coordinateTransformations: coordinateTransformationsFromOptions } = this.options || {};
|
|
148329
149341
|
const loader = await loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: "multiscales" });
|
|
149342
|
+
const imageWrapper = new ImageWrapper(loader, this.options);
|
|
148330
149343
|
const { metadata, data } = loader;
|
|
148331
149344
|
const { omero, multiscales, channels_metadata: spatialDataChannels } = metadata;
|
|
148332
149345
|
const isSpatialData = !!spatialDataChannels;
|
|
@@ -148356,7 +149369,7 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
|
148356
149369
|
axes
|
|
148357
149370
|
);
|
|
148358
149371
|
const transformMatrix = transformMatrixFromFile.multiplyLeft(transformMatrixFromOptions);
|
|
148359
|
-
const
|
|
149372
|
+
const filterSelection2 = (sel) => {
|
|
148360
149373
|
if (data.length > 0) {
|
|
148361
149374
|
const nextSel = {};
|
|
148362
149375
|
const labels = data[0].labels;
|
|
@@ -148376,7 +149389,7 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
|
148376
149389
|
if (isSpatialData) {
|
|
148377
149390
|
const { channels: channels2 } = spatialDataChannels;
|
|
148378
149391
|
channelObjects = channels2.map((channel, i2) => ({
|
|
148379
|
-
selection:
|
|
149392
|
+
selection: filterSelection2({ z: initialTargetZ, t: initialTargetT, c: i2 }),
|
|
148380
149393
|
slider: [0, 255],
|
|
148381
149394
|
color: [255, 255, 255]
|
|
148382
149395
|
}));
|
|
@@ -148390,7 +149403,7 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
|
148390
149403
|
initialTargetZ = rdefs.defaultZ;
|
|
148391
149404
|
}
|
|
148392
149405
|
channelObjects = channels2.map((channel, i2) => ({
|
|
148393
|
-
selection:
|
|
149406
|
+
selection: filterSelection2({ z: initialTargetZ, t: initialTargetT, c: i2 }),
|
|
148394
149407
|
slider: [channel.window.start, channel.window.end],
|
|
148395
149408
|
color: hexToRgb(channel.color)
|
|
148396
149409
|
}));
|
|
@@ -148422,7 +149435,17 @@ class OmeZarrLoader extends AbstractTwoStepLoader {
|
|
|
148422
149435
|
spatialImageLayer: autoImageLayers
|
|
148423
149436
|
};
|
|
148424
149437
|
return Promise.resolve(new LoaderResult(
|
|
148425
|
-
{
|
|
149438
|
+
{
|
|
149439
|
+
image: {
|
|
149440
|
+
loaders: imageLayerLoaders,
|
|
149441
|
+
// TODO: replace with imageWrapper
|
|
149442
|
+
meta: imageLayerMeta,
|
|
149443
|
+
// TODO: replace with imageWrapper
|
|
149444
|
+
instance: imageWrapper
|
|
149445
|
+
// TODO: make this the root value of LoaderResult.image.
|
|
149446
|
+
},
|
|
149447
|
+
featureIndex: imageWrapper.getChannelNames()
|
|
149448
|
+
},
|
|
148426
149449
|
[],
|
|
148427
149450
|
coordinationValues
|
|
148428
149451
|
));
|
|
@@ -148451,10 +149474,12 @@ export {
|
|
|
148451
149474
|
ZarrDataSource as Z,
|
|
148452
149475
|
MatrixZarrAsObsFeatureMatrixLoader as a,
|
|
148453
149476
|
ObsEmbeddingAnndataLoader as b,
|
|
148454
|
-
|
|
148455
|
-
|
|
148456
|
-
|
|
148457
|
-
|
|
149477
|
+
ObsSpotsAnndataLoader as c,
|
|
149478
|
+
ObsPointsAnndataLoader as d,
|
|
149479
|
+
ObsLocationsAnndataLoader as e,
|
|
149480
|
+
ObsSegmentationsAnndataLoader as f,
|
|
148458
149481
|
getDefaultExportFromCjs as g,
|
|
148459
|
-
|
|
149482
|
+
ObsSetsAnndataLoader as h,
|
|
149483
|
+
ObsLabelsAnndataLoader as i,
|
|
149484
|
+
OmeZarrLoader as j
|
|
148460
149485
|
};
|