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

Combine custom names of merged agglomerates & transfer custom name to split-off segments #7877

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -11,6 +11,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
[Commits](https://github.com/scalableminds/webknossos/compare/24.06.0...HEAD)

### Added
- Added that proofreading actions no longer drop custom names. A merge action now combines the potenial existing custom names of both segments and a split-action transfers the custom name to the split-off segment. [#7877](https://github.com/scalableminds/webknossos/pull/7877)
MichaelBuessemeyer marked this conversation as resolved.
Show resolved Hide resolved
- Added the option for the owner to lock explorative annotations. Locked annotations cannot be modified by any user. An annotation can be locked in the annotations table and when viewing the annotation via the navbar dropdown menu. [#7801](https://github.com/scalableminds/webknossos/pull/7801)
- Uploading an annotation into a dataset that it was not created for now also works if the dataset is in a different organization. [#7816](https://github.com/scalableminds/webknossos/pull/7816)
- When downloading + reuploading an annotation that is based on a segmentation layer with active mapping, that mapping is now still be selected after the reupload. [#7822](https://github.com/scalableminds/webknossos/pull/7822)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
HybridTracing,
LabelAction,
OxalisState,
Segment,
SegmentGroup,
SegmentMap,
Tracing,
Expand Down Expand Up @@ -621,6 +622,11 @@ export function getLabelActionFromPreviousSlice(
);
}

export function getSegmentName(segment: Segment, fallbackToId: boolean = false): string {
const fallback = fallbackToId ? `${segment.id}` : `Segment ${segment.id}`;
return segment.name || fallback;
}

// Output is in [0,1] for R, G, B, and A
export function getSegmentColorAsRGBA(
state: OxalisState,
Expand Down
52 changes: 52 additions & 0 deletions frontend/javascripts/oxalis/model/sagas/proofread_saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
initializeEditableMappingAction,
removeSegmentAction,
setMappingIsEditableAction,
updateSegmentAction,
} from "oxalis/model/actions/volumetracing_actions";
import type { ProofreadAtPositionAction } from "oxalis/model/actions/proofread_actions";
import {
Expand All @@ -39,6 +40,7 @@ import {
getSegmentsForLayer,
getMeshInfoForSegment,
getEditableMappingForVolumeTracingId,
getSegmentName,
} from "oxalis/model/accessors/volumetracing_accessor";
import {
getLayerByName,
Expand Down Expand Up @@ -711,6 +713,8 @@ function* handleProofreadMergeOrMinCut(action: Action) {
const [sourceInfo, targetInfo] = idInfos;
const sourceAgglomerateId = sourceInfo.agglomerateId;
const targetAgglomerateId = targetInfo.agglomerateId;
const sourceAgglomerate = volumeTracing.segments.getNullable(sourceAgglomerateId);
const targetAgglomerate = volumeTracing.segments.getNullable(targetAgglomerateId);

/* Send the respective split/merge update action to the backend (by pushing to the save queue
and saving immediately) */
Expand Down Expand Up @@ -786,6 +790,36 @@ function* handleProofreadMergeOrMinCut(action: Action) {
volumeTracing.tracingId,
targetInfo.unmappedId,
);
// Preserving custom names across merges & splits.
if (
action.type === "PROOFREAD_MERGE" &&
sourceAgglomerate &&
targetAgglomerate &&
(sourceAgglomerate.name || targetAgglomerate.name)
) {
const mergedName = _.uniq([sourceAgglomerate.name, targetAgglomerate.name])
.filter((name) => name != null)
.join(",");
if (mergedName !== sourceAgglomerate.name) {
yield* put(updateSegmentAction(sourceAgglomerateId, { name: mergedName }, volumeTracingId));
Toast.info(`Renamed segment "${getSegmentName(sourceAgglomerate)}" to "${mergedName}."`);
}
} else if (
action.type === "MIN_CUT_AGGLOMERATE_WITH_POSITION" &&
sourceAgglomerate &&
sourceAgglomerate.name != null
) {
// Assign custom name to split-off target.
yield* put(
updateSegmentAction(
newTargetAgglomerateId,
{ name: sourceAgglomerate.name },
volumeTracingId,
),
);

Toast.info(`Assigned name "${sourceAgglomerate.name}" to new split-off segment.`);
}

yield* spawn(refreshAffectedMeshes, volumeTracingId, [
{
Expand Down Expand Up @@ -847,6 +881,8 @@ function* handleProofreadCutNeighbors(action: Action) {

const editableMappingId = volumeTracing.mappingName;

const targetAgglomerate = volumeTracing.segments.getNullable(targetAgglomerateId);

/* Send the respective split/merge update action to the backend (by pushing to the save queue
and saving immediately) */

Expand Down Expand Up @@ -884,6 +920,22 @@ function* handleProofreadCutNeighbors(action: Action) {
...neighborInfo.neighbors.map((neighbor) => call(getDataValue, neighbor.position)),
]);

if (targetAgglomerate != null && targetAgglomerate.name != null) {
// Assign custom name to split-off target.
const updateNeighborNamesActions = newNeighborAgglomerateIds.map((newNeighborAgglomerateId) =>
put(
updateSegmentAction(
newNeighborAgglomerateId,
{ name: targetAgglomerate.name },
volumeTracingId,
),
),
);
yield* all(updateNeighborNamesActions);

Toast.info(`Assigned name "${targetAgglomerate.name}" to all new split-off segments.`);
}

/* Reload meshes */
yield* spawn(refreshAffectedMeshes, volumeTracingId, [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import type {
VolumeTracing,
} from "oxalis/store";
import Store from "oxalis/store";
import { getSegmentColorAsHSLA } from "oxalis/model/accessors/volumetracing_accessor";
import {
getSegmentColorAsHSLA,
getSegmentName,
} from "oxalis/model/accessors/volumetracing_accessor";
import Toast from "libs/toast";
import { hslaToCSS } from "oxalis/shaders/utils.glsl";
import { V4 } from "libs/mjs";
Expand Down Expand Up @@ -747,9 +750,4 @@ function getComputeMeshAdHocTooltipInfo(
};
}

function getSegmentName(segment: Segment, fallbackToId: boolean = false): string {
const fallback = fallbackToId ? `${segment.id}` : `Segment ${segment.id}`;
return segment.name || fallback;
}

export default SegmentListItem;