Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/file-types/spatial-zarr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@
"dist-tsc"
],
"scripts": {
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config2.mjs",
"test": "pnpm exec vitest --run"
},
"dependencies": {
"@vitessce/abstract": "workspace:*",
"@vitessce/error": "workspace:*",
"@vitessce/gl": "workspace:*",
"@vitessce/spatial-utils": "workspace:*",
"@vitessce/image-utils": "workspace:*",
"@vitessce/zarr": "workspace:*",
"@vitessce/config": "workspace:*",
"@vitessce/globals": "workspace:*",
"@math.gl/core": "catalog:",
"d3-array": "catalog:",
"lodash-es": "catalog:",
"zarrita": "catalog:",
"apache-arrow": "catalog:",
"parquet-wasm": "catalog:",
"ol": "^10.2.1"
},
"peerDependencies": {
"zarrita": "catalog:"
},
"devDependencies": {
"@vitessce/types": "workspace:*",
"@zarrita/storage": "catalog:"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CoordinationLevel as CL } from '@vitessce/config';
import { LoaderResult } from '@vitessce/abstract';
import { GLSL_COLORMAP_DEFAULT } from '@vitessce/gl';
import OmeZarrLoader from './OmeZarrLoader.js';

import OmeZarrLoader from './OmeZarrLoader.js';
const GLSL_COLORMAP_DEFAULT = 'plasma';
export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
async load() {
const { obsTypesFromChannelNames } = this.options || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { CoordinationLevel as CL } from '@vitessce/config';
import {
coordinateTransformationsToMatrixForSpatialData,
} from '@vitessce/spatial-utils';
import { GLSL_COLORMAP_DEFAULT, math } from '@vitessce/gl';
import { Vector2 } from '@math.gl/core';
import {
OLD_SHAPES_DEFAULT_AXES,
OLD_SHAPES_DEFAULT_COORDINATE_TRANSFORMATIONS,
} from './old-defaults.js';

const GLSL_COLORMAP_DEFAULT = 'plasma';
function getGeometryPath(path) {
return `${path}/geometry`;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class SpatialDataObsSegmentationsLoader extends AbstractTwoStepLo

// Apply transformation matrix to the coordinates
const transformedCoords = polygons.map(polygon => polygon.map((coord) => {
const transformed = new math.Vector2(coord[0], coord[1])
const transformed = new Vector2(coord[0], coord[1])
.transformAsPoint(modelMatrix);
return [transformed[0], transformed[1]];
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CoordinationLevel as CL } from '@vitessce/config';
import {
coordinateTransformationsToMatrixForSpatialData,
} from '@vitessce/spatial-utils';
import { math } from '@vitessce/gl';
import { Vector2 } from '@math.gl/core';
import {
OLD_SHAPES_DEFAULT_AXES,
OLD_SHAPES_DEFAULT_COORDINATE_TRANSFORMATIONS,
Expand Down Expand Up @@ -86,7 +86,7 @@ export default class SpatialDataObsSpotsLoader extends AbstractTwoStepLoader {
for (let i = 0; i < this.locations.shape[1]; i++) {
const xCoord = this.locations.data[0][i];
const yCoord = this.locations.data[1][i];
const transformed = new math.Vector2(xCoord, yCoord)
const transformed = new Vector2(xCoord, yCoord)
.transformAsPoint(modelMatrix);
// eslint-disable-next-line prefer-destructuring
this.locations.data[0][i] = transformed[0];
Expand Down
6 changes: 4 additions & 2 deletions packages/file-types/zarr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dist-tsc"
],
"scripts": {
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config2.mjs",
"test": "pnpm exec vitest --run"
},
"dependencies": {
Expand All @@ -41,11 +41,13 @@
"@vitessce/globals": "workspace:*",
"d3-array": "catalog:",
"lodash-es": "catalog:",
"zarrita": "catalog:",
"apache-arrow": "catalog:",
"parquet-wasm": "catalog:",
"ol": "^10.2.1"
},
"peerDependencies": {
"zarrita": "catalog:"
},
"devDependencies": {
"@vitessce/types": "workspace:*"
}
Expand Down
28 changes: 0 additions & 28 deletions packages/file-types/zarr/src/json-fixtures/README.md

This file was deleted.

3 changes: 2 additions & 1 deletion packages/utils/image-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"@vitessce/spatial-utils": "workspace:*",
"@vitessce/utils": "workspace:*",
"@vitessce/globals": "workspace:*",
"@hms-dbmi/viv": "catalog:"
"@vivjs/loaders": "^0.16.0",
"quickselect": "^2.0.0"
},
"devDependencies": {
"vite": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/image-utils/src/ome-tiff-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TiffPixelSource } from '@hms-dbmi/viv';
import type { TiffPixelSource } from '@vivjs/loaders';

type DimensionOrder = 'XYZCT'
| 'XYZTC'
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/image-utils/src/ome-zarr-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ZarrPixelSource } from '@hms-dbmi/viv';
import type { ZarrPixelSource } from '@vivjs/loaders';

type Channel = {
channelsVisible: boolean;
Expand Down
9 changes: 6 additions & 3 deletions packages/utils/spatial-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@
"dist-tsc"
],
"scripts": {
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config2.mjs",
"test": "pnpm exec vitest --run"
},
"peerDependencies": {
"zarrita": "catalog:"
},
"dependencies": {
"@vitessce/gl": "workspace:*",
"@vivjs/loaders": "^0.16.0",
"quickselect": "^2.0.0",
"@vitessce/utils": "workspace:*",
"@vitessce/zarr-utils": "workspace:*",
"@vitessce/constants-internal": "workspace:*",
"@vitessce/globals": "workspace:*",
"@vitessce/error": "workspace:*",
"lodash-es": "catalog:",
"zarrita": "catalog:",
"math.gl": "catalog:",
"mathjs": "catalog:",
"internmap": "catalog:"
Expand Down
32 changes: 29 additions & 3 deletions packages/utils/spatial-utils/src/constants.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
import { viv } from '@vitessce/gl';
export const DTYPE_VALUES = {
Uint8: {
max: 2 ** 8 - 1,
},
Uint16: {
max: 2 ** 16 - 1,
},
Uint32: {
max: 2 ** 32 - 1,
},
Float32: {
max: 3.4 * 10 ** 38,
},
Int8: {
max: 2 ** (8 - 1) - 1,
},
Int16: {
max: 2 ** (16 - 1) - 1,
},
Int32: {
max: 2 ** (32 - 1) - 1,
},
// Cast Float64 as 32 bit float point so it can be rendered.
Float64: {
max: 3.4 * 10 ** 38,
}
};

function getDomains() {
const domains = {};
const needMin = ['Int8', 'Int16', 'Int32'];
Object.keys(viv.DTYPE_VALUES).forEach((dtype) => {
const { max } = viv.DTYPE_VALUES[dtype];
Object.keys(DTYPE_VALUES).forEach((dtype) => {
const { max } = DTYPE_VALUES[dtype];
const min = needMin.includes(dtype) ? -(max + 1) : 0;
domains[dtype] = [min, max];
});
Expand Down
10 changes: 5 additions & 5 deletions packages/utils/spatial-utils/src/layer-controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { viv } from '@vitessce/gl';
import { getChannelStats } from '@vivjs/loaders';
import { Matrix4 } from 'math.gl';

// Returns an rgb string for display, and changes the color (arr)
Expand Down Expand Up @@ -31,7 +31,7 @@ async function getSingleSelectionStats2D({ loader, selection }) {
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
const filteredSelection = filterSelection(loader, selection);
const raster = await data.getRaster({ selection: filteredSelection });
const selectionStats = viv.getChannelStats(raster.data);
const selectionStats = getChannelStats(raster.data);
const { domain, contrastLimits: slider } = selectionStats;
return { domain, slider };
}
Expand All @@ -50,9 +50,9 @@ async function getSingleSelectionStats3D({ loader, selection }) {
const rasterTop = await lowResSource.getRaster({
selection: { ...filteredSelection, z: Math.max(0, sizeZ - 1) },
});
const stats0 = viv.getChannelStats(raster0.data);
const statsMid = viv.getChannelStats(rasterMid.data);
const statsTop = viv.getChannelStats(rasterTop.data);
const stats0 = getChannelStats(raster0.data);
const statsMid = getChannelStats(rasterMid.data);
const statsTop = getChannelStats(rasterTop.data);
return {
domain: [
Math.min(stats0.domain[0], statsMid.domain[0], statsTop.domain[0]),
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/spatial-utils/src/load-ome-zarr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { viv } from '@vitessce/gl';
import { ZarrPixelSource } from '@vivjs/loaders';
import { open as zarrOpen } from 'zarrita';
import { createZarrArrayAdapter } from '@vitessce/zarr-utils';
import { ZarrNodeNotFoundError } from '@vitessce/error';
Expand Down Expand Up @@ -68,7 +68,7 @@ async function loadMultiscales(root) {
};
}

export class ZarritaPixelSource extends viv.ZarrPixelSource {
export class ZarritaPixelSource extends ZarrPixelSource {
constructor(arr, labels, tileSize) {
super(arr, labels, tileSize);
// We prevent reading chunks directly, since Zarrita does not
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/zarr-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
"dist-tsc"
],
"scripts": {
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config2.mjs",
"test": "pnpm exec vitest --run"
},
"dependencies": {
"zarrita": "catalog:",
"@zarrita/storage": "catalog:",
"@vitessce/globals": "workspace:*"
},
"devDependencies": {
"unzipit": "^1.4.3"
"unzipit": "^1.4.3",
"zarrita": "catalog:"
}
}
30 changes: 30 additions & 0 deletions packages/utils/zarr-utils/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { serveTestFixtures, svgLoaderForNeuroglancerIcons } from '../../vite.config.mjs';


export default defineConfig({
base: './',
plugins: [
react({
jsxRuntime: 'classic',
}),
serveTestFixtures(),
svgLoaderForNeuroglancerIcons(),
],
define: {
// References:
// - https://github.com/smnhgn/vite-plugin-package-version/blob/master/src/index.ts#L10
// - https://stackoverflow.com/a/70524430
'import.meta.env.PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version),
},
server: {
fs: {
// Without this, Vite blocks data-URI query parameters,
// such as http://localhost:3000/?url=data:,{}
strict: false,
},
},
});


Loading