From e90eaf252ee1255ccd93a74942b91228e492f912 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Tue, 31 Jan 2023 18:49:36 +0100 Subject: [PATCH] Fix proofreading when mag 1 doesn't exist for segmentation layer (#6795) * fix that getRawDataCuboid could request data from non-existent mag by default * update changelog --- CHANGELOG.unreleased.md | 1 + frontend/javascripts/oxalis/api/api_latest.ts | 9 ++++++--- .../oxalis/model/accessors/dataset_accessor.ts | 12 ++++++++++-- .../javascripts/oxalis/model/sagas/proofread_saga.ts | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index e4cbe1baca9..f1a8892d92c 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -40,6 +40,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - Fixed a bug where the dataset folders view would not list public datasets if the requesting user could not also access the dataset for other reasons, like being admin. [#6759](https://github.com/scalableminds/webknossos/pull/6759) - Fixed a bug where zarr-streamed datasets would produce (very rare) rendering errors. [#6782](https://github.com/scalableminds/webknossos/pull/6782) - Fixed a bug where publicly shared annotations were not viewable by users without an account. [#6784](https://github.com/scalableminds/webknossos/pull/6784) +- Fixed proofreading when mag 1 doesn't exist for segmentation layer [#6795](https://github.com/scalableminds/webknossos/pull/6795) - Fixed that the proofreading tool allowed to split/merge with segment 0 which led to an inconsistent state. [#6793](https://github.com/scalableminds/webknossos/pull/6793) ### Removed diff --git a/frontend/javascripts/oxalis/api/api_latest.ts b/frontend/javascripts/oxalis/api/api_latest.ts index e38de96daf6..a4750a85078 100644 --- a/frontend/javascripts/oxalis/api/api_latest.ts +++ b/frontend/javascripts/oxalis/api/api_latest.ts @@ -66,7 +66,6 @@ import { } from "oxalis/model/accessors/volumetracing_accessor"; import { getHalfViewportExtentsFromState } from "oxalis/model/sagas/saga_selectors"; import { - getDatasetResolutionInfo, getLayerBoundaries, getLayerByName, getResolutionInfo, @@ -1549,10 +1548,12 @@ class DataApi { topLeft: Vector3, bottomRight: Vector3, token: string, + resolution?: Vector3, ): string { const { dataset } = Store.getState(); - const resolutionInfo = getDatasetResolutionInfo(dataset); - const resolution = resolutionInfo.getLowestResolution(); + const resolutionInfo = getResolutionInfo(getLayerByName(dataset, layerName, true).resolutions); + resolution = resolution || resolutionInfo.getLowestResolution(); + const magString = resolution.join("-"); return ( `${dataset.dataStore.url}/data/datasets/${dataset.owningOrganization}/${dataset.name}/layers/${layerName}/data?mag=${magString}&` + @@ -1591,6 +1592,7 @@ class DataApi { layerName: string, topLeft: Vector3, bottomRight: Vector3, + resolution?: Vector3, ): Promise { return doWithToken((token) => { const downloadUrl = this._getDownloadUrlForRawDataCuboid( @@ -1598,6 +1600,7 @@ class DataApi { topLeft, bottomRight, token, + resolution, ); return Request.receiveArraybuffer(downloadUrl); }); diff --git a/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts b/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts index 16a65d1c433..f4a4d5c8ce5 100644 --- a/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts +++ b/frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts @@ -368,11 +368,19 @@ function _getResolutionInfoOfVisibleSegmentationLayer(state: OxalisState): Resol export const getResolutionInfoOfVisibleSegmentationLayer = memoizeOne( _getResolutionInfoOfVisibleSegmentationLayer, ); -export function getLayerByName(dataset: APIDataset, layerName: string): DataLayerType { +export function getLayerByName( + dataset: APIDataset, + layerName: string, + alsoMatchFallbackLayer: boolean = false, +): DataLayerType { const dataLayers = getDataLayers(dataset); const hasUniqueNames = _.uniqBy(dataLayers, "name").length === dataLayers.length; ErrorHandling.assert(hasUniqueNames, messages["dataset.unique_layer_names"]); - const layer = dataLayers.find((l) => l.name === layerName); + const layer = dataLayers.find( + (l) => + l.name === layerName || + (alsoMatchFallbackLayer && "fallbackLayer" in l && l.fallbackLayer === layerName), + ); if (!layer) { throw new Error(`Layer "${layerName}" not found`); diff --git a/frontend/javascripts/oxalis/model/sagas/proofread_saga.ts b/frontend/javascripts/oxalis/model/sagas/proofread_saga.ts index a8e9837bcbd..e5a44245a1d 100644 --- a/frontend/javascripts/oxalis/model/sagas/proofread_saga.ts +++ b/frontend/javascripts/oxalis/model/sagas/proofread_saga.ts @@ -699,6 +699,7 @@ function* createGetUnmappedDataValueFn( fallbackLayerName, nodePosition, V3.add(nodePosition, mag), + mag, ); return Number(new TypedArrayClass(buffer)[0]);