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

Implement option to export proofreading as segmentation #8286

Merged
merged 16 commits into from
Jan 20, 2025
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 @@ -13,6 +13,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
### Added
- Added the total volume of a dataset to a tooltip in the dataset info tab. [#8229](https://github.com/scalableminds/webknossos/pull/8229)
- Optimized performance of data loading with “fill value“ chunks. [#8271](https://github.com/scalableminds/webknossos/pull/8271)
- Added the option to export a segmentation that was corrected with the proofreading tool to a new segmentation. [#8286](https://github.com/scalableminds/webknossos/pull/8286)
- The fill tool can now be adapted so that it only acts within a specified bounding box. Use the new "Restrict Floodfill" mode for that in the toolbar. [#8267](https://github.com/scalableminds/webknossos/pull/8267)
- Added the option for "Selective Segment Visibility" for segmentation layers. Select this option in the left sidebar to only show segments that are currently active or hovered. [#8281](https://github.com/scalableminds/webknossos/pull/8281)
- A segment can be activated with doubleclick now. [#8281](https://github.com/scalableminds/webknossos/pull/8281)
Expand Down
11 changes: 9 additions & 2 deletions app/controllers/JobController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ class JobController @Inject()(
newDatasetName: String,
outputSegmentationLayerName: String,
mergeSegments: Boolean,
volumeLayerName: Option[String]): Action[AnyContent] =
volumeLayerName: Option[String],
includesEditableMapping: Boolean,
boundingBox: Option[String]): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
log(Some(slackNotificationService.noticeFailedJobRequest)) {
for {
Expand All @@ -393,6 +395,9 @@ class JobController @Inject()(
command = JobCommand.materialize_volume_annotation
_ <- datasetService.assertValidDatasetName(newDatasetName)
_ <- datasetService.assertValidLayerNameLax(outputSegmentationLayerName)
multiUser <- multiUserDAO.findOne(request.identity._multiUser)
_ <- Fox.runIf(!multiUser.isSuperUser && includesEditableMapping)(Fox.runOptional(boundingBox)(bbox =>
jobService.assertBoundingBoxLimits(bbox, None)))
commandArgs = Json.obj(
"organization_id" -> organization._id,
"dataset_name" -> dataset.name,
Expand All @@ -403,7 +408,9 @@ class JobController @Inject()(
"annotation_type" -> annotationType,
"new_dataset_name" -> newDatasetName,
"merge_segments" -> mergeSegments,
"volume_layer_name" -> volumeLayerName
"volume_layer_name" -> volumeLayerName,
"use_zarr_streaming" -> includesEditableMapping,
"bounding_box" -> boundingBox
)
job <- jobService.submitJob(command, commandArgs, request.identity, dataset._dataStore) ?~> "job.couldNotRunApplyMergerMode"
js <- jobService.publicWrites(job)
Expand Down
2 changes: 1 addition & 1 deletion conf/webknossos.latest.routes
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ POST /jobs/run/inferNuclei/:datasetId
POST /jobs/run/inferNeurons/:datasetId controllers.JobController.runInferNeuronsJob(datasetId: String, layerName: String, bbox: String, newDatasetName: String)
POST /jobs/run/inferMitochondria/:datasetId controllers.JobController.runInferMitochondriaJob(datasetId: String, layerName: String, bbox: String, newDatasetName: String)
POST /jobs/run/alignSections/:datasetId controllers.JobController.runAlignSectionsJob(datasetId: String, layerName: String, newDatasetName: String, annotationId: Option[String])
POST /jobs/run/materializeVolumeAnnotation/:datasetId controllers.JobController.runMaterializeVolumeAnnotationJob(datasetId: String, fallbackLayerName: String, annotationId: String, annotationType: String, newDatasetName: String, outputSegmentationLayerName: String, mergeSegments: Boolean, volumeLayerName: Option[String])
POST /jobs/run/materializeVolumeAnnotation/:datasetId controllers.JobController.runMaterializeVolumeAnnotationJob(datasetId: String, fallbackLayerName: String, annotationId: String, annotationType: String, newDatasetName: String, outputSegmentationLayerName: String, mergeSegments: Boolean, volumeLayerName: Option[String], includesEditableMapping: Boolean, boundingBox: Option[String])
POST /jobs/run/findLargestSegmentId/:datasetId controllers.JobController.runFindLargestSegmentIdJob(datasetId: String, layerName: String)
POST /jobs/run/renderAnimation/:datasetId controllers.JobController.runRenderAnimationJob(datasetId: String)
GET /jobs/:id controllers.JobController.get(id: String)
Expand Down
12 changes: 12 additions & 0 deletions frontend/javascripts/admin/api/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ function startSegmentationAnnotationDependentJob(
annotationId: string,
annotationType: APIAnnotationType,
mergeSegments?: boolean,
includesEditableMapping?: boolean,
boundingBox?: Vector6,
): Promise<APIJob> {
const requestURL = new URL(`/api/jobs/run/${jobURLPath}/${datasetId}`, location.origin);
if (volumeLayerName != null) {
Expand All @@ -222,6 +224,12 @@ function startSegmentationAnnotationDependentJob(
if (mergeSegments != null) {
requestURL.searchParams.append("mergeSegments", mergeSegments.toString());
}
if (includesEditableMapping != null) {
requestURL.searchParams.append("includesEditableMapping", includesEditableMapping.toString());
}
if (boundingBox) {
requestURL.searchParams.append("boundingBox", boundingBox.join(","));
}
return Request.receiveJSON(requestURL.href, {
method: "POST",
});
Expand All @@ -235,6 +243,8 @@ export function startMaterializingVolumeAnnotationJob(
annotationId: string,
annotationType: APIAnnotationType,
mergeSegments: boolean,
includesEditableMapping: boolean,
boundingBox?: Vector6,
): Promise<APIJob> {
return startSegmentationAnnotationDependentJob(
"materializeVolumeAnnotation",
Expand All @@ -245,6 +255,8 @@ export function startMaterializingVolumeAnnotationJob(
annotationId,
annotationType,
mergeSegments,
includesEditableMapping,
boundingBox,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ export function MaterializeVolumeAnnotationModal({
}: MaterializeVolumeAnnotationModalProps) {
const dataset = useSelector((state: OxalisState) => state.dataset);
const tracing = useSelector((state: OxalisState) => state.tracing);
let includesEditableMapping = false;
const activeSegmentationTracingLayer = useSelector(getActiveSegmentationTracingLayer);
const fixedSelectedLayer = selectedVolumeLayer || activeSegmentationTracingLayer;
const readableVolumeLayerName =
Expand Down Expand Up @@ -925,6 +926,10 @@ export function MaterializeVolumeAnnotationModal({
output dataset and the output segmentation layer.
</p>
);
} else if (fixedSelectedLayer && "tracingId" in fixedSelectedLayer) {
includesEditableMapping =
tracing.volumes.find((volume) => volume.tracingId === fixedSelectedLayer.tracingId)
?.hasEditableMapping === true;
}
const jobImage =
jobNameToImagePath[jobName] != null ? (
Expand Down Expand Up @@ -954,8 +959,13 @@ export function MaterializeVolumeAnnotationModal({
jobName={"materialize_volume_annotation"}
suggestedDatasetSuffix="with_merged_segmentation"
chooseSegmentationLayer
isBoundingBoxConfigurable={includesEditableMapping}
fixedSelectedLayer={fixedSelectedLayer}
jobApiCall={async ({ newDatasetName, selectedLayer: segmentationLayer }) => {
jobApiCall={async ({
newDatasetName,
selectedLayer: segmentationLayer,
selectedBoundingBox,
}) => {
// There are 3 cases for the value assignments to volumeLayerName and baseSegmentationName for the job:
// 1. There is a volume annotation with a fallback layer. volumeLayerName will reference the volume layer
// and baseSegmentationName will reference the fallback layer. The job will merge those layers.
Expand All @@ -968,6 +978,9 @@ export function MaterializeVolumeAnnotationModal({
? getReadableNameOfVolumeLayer(segmentationLayer, tracing)
: null;
const baseSegmentationName = getBaseSegmentationName(segmentationLayer);
const bbox = selectedBoundingBox?.boundingBox
? computeArrayFromBoundingBox(selectedBoundingBox.boundingBox)
: undefined;
return startMaterializingVolumeAnnotationJob(
dataset.id,
baseSegmentationName,
Expand All @@ -976,6 +989,8 @@ export function MaterializeVolumeAnnotationModal({
tracing.annotationId,
tracing.annotationType,
isMergerModeEnabled,
includesEditableMapping,
bbox,
);
}}
description={
Expand Down