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

Fix segment stats for layers without segment index #7377

Merged
merged 6 commits into from
Oct 16, 2023
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.released.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed broken creation of tasks using base NMLs. [#6634](https://github.com/scalableminds/webknossos/pull/6634)
- Fixed that the precomputation of meshes didn't take the active mapping into account. [#6651](https://github.com/scalableminds/webknossos/pull/6651)
- Fixed false-positive warning about an outdated annotation version. [#6656](https://github.com/scalableminds/webknossos/pull/6656)
- Fixed that segment statistics seemed to be available but broken for segments without index. [#7377](https://github.com/scalableminds/webknossos/pull/7377)

## [22.11.2](https://github.com/scalableminds/webknossos/releases/tag/22.11.2) - 2022-11-10
[Commits](https://github.com/scalableminds/webknossos/compare/22.11.1...22.11.2)
Expand Down
26 changes: 17 additions & 9 deletions frontend/javascripts/oxalis/view/context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1105,17 +1105,23 @@ function ContextMenuInner(propsWithInputRef: Props) {
datasetScale,
globalPosition,
maybeViewport,
visibleSegmentationLayer,
volumeTracing,
} = props;

const segmentIdAtPosition = globalPosition != null ? getSegmentIdForPosition(globalPosition) : 0;
const { visibleSegmentationLayer, volumeTracing } = props;
const hasNoFallbackLayer =
visibleSegmentationLayer != null &&
"fallbackLayer" in visibleSegmentationLayer &&
visibleSegmentationLayer.fallbackLayer == null;
const [segmentVolume, boundingBoxInfo] = useFetch(
async () => {
if (contextMenuPosition == null || volumeTracing == null || !hasNoFallbackLayer) {
if (
contextMenuPosition == null ||
volumeTracing == null ||
!hasNoFallbackLayer ||
!volumeTracing.hasSegmentIndex
) {
return [];
} else {
const tracingId = volumeTracing.tracingId;
Expand Down Expand Up @@ -1158,6 +1164,12 @@ function ContextMenuInner(propsWithInputRef: Props) {
return <></>;
}

// Currently either segmentIdAtPosition or maybeClickedMeshId is set, but not both.
// segmentIdAtPosition is only set if a segment is hovered in one of the xy, xz, or yz viewports.
// maybeClickedMeshId is only set, when a mesh is hovered in the 3d viewport.
// Thus the segment id is always unambiguous / clearly defined.
const isHoveredSegmentOrMesh = segmentIdAtPosition > 0 || maybeClickedMeshId != null;

const activeTreeId = skeletonTracing != null ? skeletonTracing.activeTreeId : null;
const activeNodeId = skeletonTracing?.activeNodeId;

Expand Down Expand Up @@ -1246,7 +1258,7 @@ function ContextMenuInner(propsWithInputRef: Props) {
</Tooltip>
);

if (hasNoFallbackLayer) {
if (hasNoFallbackLayer && volumeTracing?.hasSegmentIndex && isHoveredSegmentOrMesh) {
infoRows.push(
getInfoMenuItem(
"volumeInfo",
Expand All @@ -1260,7 +1272,7 @@ function ContextMenuInner(propsWithInputRef: Props) {
);
}

if (hasNoFallbackLayer) {
if (hasNoFallbackLayer && volumeTracing?.hasSegmentIndex && isHoveredSegmentOrMesh) {
infoRows.push(
getInfoMenuItem(
"boundingBoxPositionInfo",
Expand Down Expand Up @@ -1292,11 +1304,7 @@ function ContextMenuInner(propsWithInputRef: Props) {
);
}

// Currently either segmentIdAtPosition or maybeClickedMeshId is set, but not both.
// segmentIdAtPosition is only set if a segment is hovered in one of the xy, xz, or yz viewports.
// maybeClickedMeshId is only set, when a mesh is hovered in the 3d viewport.
// Thus the segment id is always unambiguous / clearly defined.
if (segmentIdAtPosition > 0 || maybeClickedMeshId != null) {
if (isHoveredSegmentOrMesh) {
const segmentId = maybeClickedMeshId ? maybeClickedMeshId : segmentIdAtPosition;
infoRows.push(
getInfoMenuItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import type {
Segment,
SegmentGroup,
SegmentMap,
VolumeTracing,
} from "oxalis/store";
import Store from "oxalis/store";
import DomVisibilityObserver from "oxalis/view/components/dom_visibility_observer";
Expand Down Expand Up @@ -136,6 +137,7 @@ type StateProps = {
segments: SegmentMap | null | undefined;
segmentGroups: Array<SegmentGroup>;
visibleSegmentationLayer: APISegmentationLayer | null | undefined;
activeVolumeTracing: VolumeTracing | null | undefined;
allowUpdate: boolean;
organization: string;
datasetName: string;
Expand Down Expand Up @@ -177,6 +179,7 @@ const mapStateToProps = (state: OxalisState): StateProps => {
segments,
segmentGroups,
visibleSegmentationLayer,
activeVolumeTracing,
allowUpdate:
state.tracing.restrictions.allowUpdate && !isVisibleButUneditableSegmentationLayerActive,
organization: state.dataset.owningOrganization,
Expand Down Expand Up @@ -1061,7 +1064,8 @@ class SegmentsView extends React.Component<Props, State> {
if (
visibleSegmentationLayer == null ||
!("fallbackLayer" in visibleSegmentationLayer) ||
visibleSegmentationLayer.fallbackLayer != null
visibleSegmentationLayer.fallbackLayer != null ||
!this.props.activeVolumeTracing?.hasSegmentIndex
) {
//in this case there is a fallback layer
return null;
Expand Down Expand Up @@ -1501,8 +1505,7 @@ class SegmentsView extends React.Component<Props, State> {
segments.length > 0
) {
const state = Store.getState();
const volumeTracing = getActiveSegmentationTracing(state);
const tracingId = volumeTracing?.tracingId;
const tracingId = this.props.activeVolumeTracing?.tracingId;
if (tracingId == null) return null;
const tracingStoreUrl = state.tracing.tracingStore.url;
return this.state.activeStatisticsModalGroupId === groupId ? (
Expand Down
1 change: 1 addition & 0 deletions frontend/stylesheets/dark.less
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ a:hover {

.cell-context-icon {
background-image: url("/assets/images/cell-bright.svg");
opacity: 0.5;
}

.hide-tree-edges-icon {
Expand Down
1 change: 1 addition & 0 deletions frontend/stylesheets/trace_view/_tracing_view.less
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ img.keyboard-mouse-icon:first-child {
display: inline-block;
background-image: url("/assets/images/cell.svg");
background-size: contain;
opacity: 0.65;
}

.hide-tree-edges-icon {
Expand Down