Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total voxel count and dataset extent to tooltip in dataset info tab #8229

Merged
merged 8 commits into from
Dec 2, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Added
- When exploring remote URIs pasted from Neuroglancer, the format prefixes like `precomputed://` are now ignored, so users don’t have to remove them. [#8195](https://github.com/scalableminds/webknossos/pull/8195)
- Added the total volume of a dataset to a tooltip in the dataset info tab. [#8229](https://github.com/scalableminds/webknossos/pull/8229)

### Changed
- Reading image files on datastore filesystem is now done asynchronously. [#8126](https://github.com/scalableminds/webknossos/pull/8126)
Expand Down
5 changes: 4 additions & 1 deletion frontend/javascripts/libs/format_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,12 @@ export function formatBytes(nbytes: number) {
}

export function formatVoxels(voxelCount: number) {
if (voxelCount == null || !Number.isFinite(voxelCount)) {
if (voxelCount == null) {
return "";
}
if (!Number.isFinite(voxelCount)) {
return "Infinity";
}
if (voxelCount > 2 ** 50) {
return `${(voxelCount / 2 ** 50).toPrecision(4)} PVx`;
}
Expand Down
13 changes: 13 additions & 0 deletions frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ export function getDatasetExtentAsString(
formatNumberToLength(length, LongUnitToShortUnitMap[dataset.dataSource.scale.unit]),
);
}
function getDatasetExtentAsProduct(extent: {
width: number;
height: number;
depth: number;
}) {
return extent.width * extent.height * extent.depth;
}
export function getDatasetExtentInVoxelAsProduct(dataset: APIDataset) {
return getDatasetExtentAsProduct(getDatasetExtentInVoxel(dataset));
}
export function getDatasetExtentInUnitAsProduct(dataset: APIDataset) {
return getDatasetExtentAsProduct(getDatasetExtentInUnit(dataset));
}
export function determineAllowedModes(settings?: Settings): {
preferredMode: APIAllowedMode | null | undefined;
allowedModes: Array<APIAllowedMode>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import Markdown from "libs/markdown_adapter";
import React, { type CSSProperties } from "react";
import { Link } from "react-router-dom";
import type { APIDataset, APIUser } from "types/api_flow_types";
import { ControlModeEnum } from "oxalis/constants";
import { formatScale } from "libs/format_utils";
import { ControlModeEnum, LongUnitToShortUnitMap } from "oxalis/constants";
import { formatNumberToVolume, formatScale, formatVoxels } from "libs/format_utils";
import {
getDatasetExtentAsString,
getDatasetExtentInUnitAsProduct,
getDatasetExtentInVoxelAsProduct,
getMagnificationUnion,
getReadableURLPart,
} from "oxalis/model/accessors/dataset_accessor";
Expand Down Expand Up @@ -127,9 +129,27 @@ const shortcuts = [
export function DatasetExtentRow({ dataset }: { dataset: APIDataset }) {
const extentInVoxel = getDatasetExtentAsString(dataset, true);
const extentInLength = getDatasetExtentAsString(dataset, false);
const extentProductInVx = getDatasetExtentInVoxelAsProduct(dataset);
const extentProductInUnit = getDatasetExtentInUnitAsProduct(dataset);
const formattedExtentInUnit = formatNumberToVolume(
extentProductInUnit,
LongUnitToShortUnitMap[dataset.dataSource.scale.unit],
);

const renderDSExtentTooltip = () => {
return (
<div>
Dataset extent:
<br />
{formatVoxels(extentProductInVx)}
<br />
{formattedExtentInUnit}
</div>
);
};

return (
<FastTooltip title="Dataset extent" placement="left" wrapper="tr">
<FastTooltip dynamicRenderer={renderDSExtentTooltip} placement="left" wrapper="tr">
<td
style={{
paddingRight: 20,
Expand Down