Skip to content

Commit

Permalink
Create Annotation From View Mode: Keep Activated Mapping (#6647)
Browse files Browse the repository at this point in the history
* [WIP] Create Annotation From View Mode: Keep Activated Mapping

* fix typing errors

* pass active mapping name when creating explorational from dataset view mode

* clean up

* changelog

* also use potentially active mapping when making a segmentation layer editable (i.e., adding a volume annotation layer)

Co-authored-by: Philipp Otto <[email protected]>
Co-authored-by: Philipp Otto <[email protected]>
  • Loading branch information
3 people authored Nov 23, 2022
1 parent 0b5c1f9 commit a40db75
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- When adding remote Zarr datasets with multiple channels, channels are converted into layers. [#6609](https://github.com/scalableminds/webknossos/pull/6609)
- When adding a remote OME-NGFF dataset with labels, these are added as segmentation layers. [#6638](https://github.com/scalableminds/webknossos/pull/6638)
- The scale bar is now included in screenshots of the viewports made using the `Q` shortcut or the "Screenshot" menu entry. If the scale bar should not be included, disable it using "Settings - Viewport Options - Show Scalebars". [#6644](https://github.com/scalableminds/webknossos/pull/6644)
- When creating an annotation from the dataset view, a previously selected mapping of the segmentation layer is now automatically selected in the volume annotation layer fallback segmentation as well. [#6647](https://github.com/scalableminds/webknossos/pull/6647)

### Changed
- The log viewer in the Voxelytics workflow reporting now uses a virtualized list. [#6579](https://github.com/scalableminds/webknossos/pull/6579)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/AnnotationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import scala.concurrent.duration._

case class AnnotationLayerParameters(typ: AnnotationLayerType,
fallbackLayerName: Option[String],
mappingName: Option[String] = None,
resolutionRestrictions: Option[ResolutionRestrictions],
name: String)
object AnnotationLayerParameters {
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/LegacyApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
Some(
AnnotationLayerParameters(AnnotationLayerType.Skeleton,
request.body.fallbackLayerName,
None,
request.body.resolutionRestrictions,
name = AnnotationLayer.defaultSkeletonLayerName))
val volumeParameters =
Expand All @@ -435,6 +436,7 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
Some(
AnnotationLayerParameters(AnnotationLayerType.Volume,
request.body.fallbackLayerName,
None,
request.body.resolutionRestrictions,
name = AnnotationLayer.defaultVolumeLayerName))
List(skeletonParameters, volumeParameters).flatten
Expand Down
11 changes: 8 additions & 3 deletions app/models/annotation/AnnotationService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class AnnotationService @Inject()(
boundingBox: Option[BoundingBox] = None,
startPosition: Option[Vec3Int] = None,
startRotation: Option[Vec3Double] = None,
resolutionRestrictions: ResolutionRestrictions
resolutionRestrictions: ResolutionRestrictions,
mappingName: Option[String]
): Fox[VolumeTracing] = {
val resolutions = VolumeTracingDownsampling.resolutionsForVolumeTracing(dataSource, fallbackLayer)
val resolutionsRestricted = resolutionRestrictions.filterAllowed(resolutions)
Expand All @@ -160,6 +161,7 @@ class AnnotationService @Inject()(
0,
VolumeTracingDefaults.zoomLevel,
organizationName = Some(datasetOrganizationName),
mappingName = mappingName,
resolutions = resolutionsRestricted.map(vec3IntToProto)
)
}
Expand Down Expand Up @@ -249,7 +251,8 @@ class AnnotationService @Inject()(
datasetOrganizationName,
fallbackLayer,
resolutionRestrictions =
annotationLayerParameters.resolutionRestrictions.getOrElse(ResolutionRestrictions.empty)
annotationLayerParameters.resolutionRestrictions.getOrElse(ResolutionRestrictions.empty),
mappingName = annotationLayerParameters.mappingName
)
volumeTracingAdapted = oldPrecedenceLayerProperties.map { p =>
volumeTracing.copy(
Expand Down Expand Up @@ -361,6 +364,7 @@ class AnnotationService @Inject()(
newAnnotationLayerParameters = AnnotationLayerParameters(
newAnnotationLayerType,
usedFallbackLayerName,
None,
Some(ResolutionRestrictions.empty),
AnnotationLayer.defaultNameForType(newAnnotationLayerType))
_ <- addAnnotationLayer(annotation, organizationName, newAnnotationLayerParameters) ?~> "makeHybrid.createTracings.failed"
Expand Down Expand Up @@ -524,7 +528,8 @@ class AnnotationService @Inject()(
},
startPosition = Some(startPosition),
startRotation = Some(startRotation),
resolutionRestrictions = resolutionRestrictions
resolutionRestrictions = resolutionRestrictions,
mappingName = None
)
} yield volumeTracing

Expand Down
4 changes: 4 additions & 0 deletions frontend/javascripts/admin/admin_rest_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ type AnnotationLayerCreateDescriptor = {
typ: "Skeleton" | "Volume";
name: string;
fallbackLayerName?: string | null | undefined;
mappingName?: string | null | undefined;
resolutionRestrictions?: APIResolutionRestrictions | null | undefined;
};

Expand Down Expand Up @@ -789,6 +790,7 @@ export function createExplorational(
datasetId: APIDatasetId,
typ: TracingType,
fallbackLayerName?: string | null | undefined,
mappingName?: string | null | undefined,
resolutionRestrictions?: APIResolutionRestrictions | null | undefined,
options: RequestOptions = {},
): Promise<APIAnnotation> {
Expand All @@ -808,6 +810,7 @@ export function createExplorational(
typ: "Volume",
name: fallbackLayerName || "Volume",
fallbackLayerName,
mappingName,
resolutionRestrictions,
},
];
Expand All @@ -821,6 +824,7 @@ export function createExplorational(
typ: "Volume",
name: fallbackLayerName || "Volume",
fallbackLayerName,
mappingName,
resolutionRestrictions,
},
];
Expand Down
20 changes: 18 additions & 2 deletions frontend/javascripts/oxalis/view/action_bar_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { trackAction } from "oxalis/model/helpers/analytics";
import AddNewLayoutModal from "oxalis/view/action-bar/add_new_layout_modal";
import { withAuthentication } from "admin/auth/authentication_modal";
import type { ViewMode, ControlMode } from "oxalis/constants";
import { ViewMode, ControlMode, MappingStatusEnum } from "oxalis/constants";
import constants, { ControlModeEnum } from "oxalis/constants";
import DatasetPositionView from "oxalis/view/action-bar/dataset_position_view";
import type { OxalisState } from "oxalis/store";
Expand All @@ -26,6 +26,7 @@ import {
is2dDataset,
doesSupportVolumeWithFallback,
getVisibleSegmentationLayer,
getMappingInfoForSupportedLayer,
} from "oxalis/model/accessors/dataset_accessor";
import { AsyncButton } from "components/async_clickables";

Expand Down Expand Up @@ -96,7 +97,22 @@ class ActionBarView extends React.PureComponent<Props, State> {
maybeSegmentationLayer && doesSupportVolumeWithFallback(dataset, maybeSegmentationLayer)
? maybeSegmentationLayer.name
: null;
const annotation = await createExplorational(dataset, "hybrid", fallbackLayerName);

const mappingInfo = getMappingInfoForSupportedLayer(Store.getState());
let maybeMappingName = null;
if (
mappingInfo.mappingStatus !== MappingStatusEnum.DISABLED &&
mappingInfo.mappingType === "HDF5"
) {
maybeMappingName = mappingInfo.mappingName;
}

const annotation = await createExplorational(
dataset,
"hybrid",
fallbackLayerName,
maybeMappingName,
);
trackAction("Create hybrid tracing (from view mode)");
location.href = `${location.origin}/annotations/${annotation.typ}/${annotation.id}${location.hash}`;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import {
NewVolumeLayerSelection,
RestrictResolutionSlider,
} from "dashboard/advanced_dataset/create_explorative_modal";
import type { Tracing } from "oxalis/store";
import Store, { type Tracing } from "oxalis/store";
import { addAnnotationLayer } from "admin/admin_rest_api";
import {
getDatasetResolutionInfo,
getLayerByName,
getMappingInfo,
getSegmentationLayers,
} from "oxalis/model/accessors/dataset_accessor";
import {
Expand All @@ -23,6 +24,7 @@ import messages from "messages";
import InputComponent from "oxalis/view/components/input_component";
import api from "oxalis/api/internal_api";
import Toast from "libs/toast";
import { MappingStatusEnum } from "oxalis/constants";

export type ValidationResult = { isValid: boolean; message: string };
export function checkForLayerNameDuplication(
Expand Down Expand Up @@ -162,6 +164,19 @@ export default function AddVolumeLayerModal({
} else {
selectedSegmentationLayer = getLayerByName(dataset, selectedSegmentationLayerName);
const fallbackLayerName = selectedSegmentationLayer.name;

const mappingInfo = getMappingInfo(
Store.getState().temporaryConfiguration.activeMappingByLayer,
selectedSegmentationLayerName,
);
let maybeMappingName = null;
if (
mappingInfo.mappingStatus !== MappingStatusEnum.DISABLED &&
mappingInfo.mappingType === "HDF5"
) {
maybeMappingName = mappingInfo.mappingName;
}

await addAnnotationLayer(tracing.annotationId, tracing.annotationType, {
typ: "Volume",
name: newLayerName,
Expand All @@ -170,6 +185,7 @@ export default function AddVolumeLayerModal({
min: minResolutionAllowed,
max: maxResolutionAllowed,
},
mappingName: maybeMappingName,
});
}

Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ class ReactRouter extends React.Component<Props> {
dataset,
type,
fallbackLayerName,
null,
resolutionRestrictions,
);
trackAction(`Create ${type} tracing`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ async function _screenshotAnnotationHelper(
typ,
fallbackLayerName,
null,
null,
options,
);

Expand All @@ -107,6 +108,7 @@ export async function screenshotDatasetWithMapping(
"skeleton",
null,
null,
null,
options,
);
await openTracingView(page, baseUrl, createdExplorational.id);
Expand All @@ -128,6 +130,7 @@ export async function screenshotDatasetWithMappingLink(
"skeleton",
null,
null,
null,
options,
);
await openTracingView(page, baseUrl, createdExplorational.id, optionalViewOverride);
Expand Down

0 comments on commit a40db75

Please sign in to comment.