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 displayed segment #4480

Merged
merged 6 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ class DataCube {
}
}

hasDataAtPositionAndZoomStep(voxel: Vector3, zoomStep: number = 0) {
return this.getBucket(this.positionToZoomedAddress(voxel, zoomStep)).hasData();
}

getDataValue(voxel: Vector3, mapping: ?Mapping, zoomStep: number = 0): number {
const bucket = this.getBucket(this.positionToZoomedAddress(voxel, zoomStep));
const voxelIndex = this.getVoxelIndex(voxel, zoomStep);
Expand Down
81 changes: 68 additions & 13 deletions frontend/javascripts/oxalis/view/right-menu/mapping_info_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { OxalisState, Mapping } from "oxalis/store";
import { calculateGlobalPos } from "oxalis/controller/viewmodes/plane_controller";
import { getMappingsForDatasetLayer } from "admin/admin_rest_api";
import { getPosition, getRequestLogZoomStep } from "oxalis/model/accessors/flycam_accessor";
import { getSegmentationLayer } from "oxalis/model/accessors/dataset_accessor";
import { getSegmentationLayer, getResolutions } from "oxalis/model/accessors/dataset_accessor";
import { getVolumeTracing } from "oxalis/model/accessors/volumetracing_accessor";
import { setLayerMappingsAction } from "oxalis/model/actions/dataset_actions";
import { setMappingEnabledAction } from "oxalis/model/actions/settings_actions";
Expand Down Expand Up @@ -45,6 +45,7 @@ type StateProps = {|
activeViewport: OrthoView,
activeCellId: number,
isMergerModeEnabled: boolean,
renderMissingDataBlack: boolean,
|};
type Props = {| ...OwnProps, ...StateProps |};

Expand Down Expand Up @@ -126,24 +127,57 @@ class MappingInfoView extends React.Component<Props, State> {
}

renderIdTable() {
const {
mapping,
isMappingEnabled,
mappingColors,
activeViewport,
mousePosition,
zoomStep,
position,
dataset,
segmentationLayer,
renderMissingDataBlack,
} = this.props;
const cube = this.getSegmentationCube();
const hasMapping = this.props.mapping != null;
const customColors = this.props.isMappingEnabled ? this.props.mappingColors : null;
const hasMapping = mapping != null;
const customColors = isMappingEnabled ? mappingColors : null;

let globalMousePosition;
if (this.props.mousePosition && this.props.activeViewport !== OrthoViews.TDView) {
const [x, y] = this.props.mousePosition;
if (mousePosition && activeViewport !== OrthoViews.TDView) {
const [x, y] = mousePosition;
globalMousePosition = calculateGlobalPos({ x, y });
}

const getIdForPos = pos => pos && cube.getDataValue(pos, null, this.props.zoomStep);
let usableZoomStep = zoomStep;
const flycamPosition = position;
const resolutions = getResolutions(dataset);
// While render missing data black is not active and there is no segmentation for the current zoom step,
// the segmentation of a higher zoom step is shown.
// Here we determine the the next zoom step of the displayed segmentation data to get the correct segment ids.
while (
!renderMissingDataBlack &&
usableZoomStep < resolutions.length - 1 &&
!cube.hasDataAtPositionAndZoomStep(flycamPosition, usableZoomStep)
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
) {
usableZoomStep++;
}
let usedResolutionAsString = null;
if (segmentationLayer) {
const usedResolution = segmentationLayer.resolutions[usableZoomStep];
usedResolutionAsString = `(${usedResolution[0]}-${usedResolution[1]}-${usedResolution[2]})`;
}
const getIdForPos = pos => pos && cube.getDataValue(pos, null, usableZoomStep);

const tableData = [
{ name: "Active ID", key: "active", unmapped: this.props.activeCellId },
{
name: "ID at current position",
name: "Active ID",
key: "active",
unmapped: this.props.activeCellId,
},
{
name: "ID at the center",
key: "current",
unmapped: getIdForPos(this.props.position),
unmapped: getIdForPos(flycamPosition),
},
{
name: (
Expand All @@ -170,16 +204,36 @@ class MappingInfoView extends React.Component<Props, State> {
.map(idInfo => ({
...idInfo,
unmapped: (
<span style={{ background: convertCellIdToCSS(idInfo.unmapped) }}>{idInfo.unmapped}</span>
<span
style={{
background: convertCellIdToCSS(idInfo.unmapped),
}}
>
{idInfo.unmapped}
</span>
),
mapped: (
<span style={{ background: convertCellIdToCSS(idInfo.mapped, customColors) }}>
<span
style={{
background: convertCellIdToCSS(idInfo.mapped, customColors),
}}
>
{idInfo.mapped}
</span>
),
}));
// Add entry to show currently used resolution.
tableData.push({
name: "Segmentation resolution",
key: "resolution",
unmapped: usedResolutionAsString,
mapped: usedResolutionAsString,
});

const columnHelper = (title, dataIndex) => ({ title, dataIndex });
const columnHelper = (title, dataIndex) => ({
title,
dataIndex,
});
const idColumns =
hasMapping && this.props.isMappingEnabled
? // Show an unmapped and mapped id column if there's a mapping
Expand Down Expand Up @@ -328,6 +382,7 @@ function mapStateToProps(state: OxalisState) {
.map(tracing => tracing.activeCellId)
.getOrElse(0),
isMergerModeEnabled: state.temporaryConfiguration.isMergerModeEnabled,
renderMissingDataBlack: state.datasetConfiguration.renderMissingDataBlack,
};
}

Expand Down