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 statistics bug and rename resolution methods to coarsest and finest #7355

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -15,6 +15,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
### Changed

### Fixed
- Fixed that segment statistics were requested in the wrong resolution within the statistics modal. [#7355](https://github.com/scalableminds/webknossos/pull/7355)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ export function RestrictResolutionSlider({
resolutionIndices,
setResolutionIndices,
}: RestrictResolutionSliderProps) {
let highestResolutionIndex = resolutionInfo.getHighestResolutionIndex();
let lowestResolutionIndex = resolutionInfo.getLowestResolutionIndex();
let highestResolutionIndex = resolutionInfo.getCoarsestResolutionIndex();
let lowestResolutionIndex = resolutionInfo.getFinestResolutionIndex();

if (selectedSegmentationLayer != null) {
const datasetFallbackLayerResolutionInfo = getResolutionInfo(
selectedSegmentationLayer.resolutions,
);
highestResolutionIndex = datasetFallbackLayerResolutionInfo.getHighestResolutionIndex();
lowestResolutionIndex = datasetFallbackLayerResolutionInfo.getLowestResolutionIndex();
highestResolutionIndex = datasetFallbackLayerResolutionInfo.getCoarsestResolutionIndex();
lowestResolutionIndex = datasetFallbackLayerResolutionInfo.getFinestResolutionIndex();
}

const highResolutionIndex = Math.min(highestResolutionIndex, resolutionIndices[1]);
Expand Down Expand Up @@ -197,8 +197,8 @@ function CreateExplorativeModal({ datasetId, onClose }: Props) {
selectedSegmentationLayer == null
? getSomeResolutionInfoForDataset(dataset)
: getResolutionInfo(selectedSegmentationLayer.resolutions);
const highestResolutionIndex = resolutionInfo.getHighestResolutionIndex();
const lowestResolutionIndex = resolutionInfo.getLowestResolutionIndex();
const highestResolutionIndex = resolutionInfo.getCoarsestResolutionIndex();
const lowestResolutionIndex = resolutionInfo.getFinestResolutionIndex();

const highResolutionIndex = Math.min(highestResolutionIndex, userDefinedResolutionIndices[1]);
const lowResolutionIndex = Math.max(lowestResolutionIndex, userDefinedResolutionIndices[0]);
Expand Down
6 changes: 3 additions & 3 deletions frontend/javascripts/oxalis/api/api_latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ class DataApi {
} else {
const layer = getLayerByName(Store.getState().dataset, layerName);
const resolutionInfo = getResolutionInfo(layer.resolutions);
zoomStep = resolutionInfo.getLowestResolutionIndex();
zoomStep = resolutionInfo.getFinestResolutionIndex();
}

const cube = this.model.getCubeByLayerName(layerName);
Expand Down Expand Up @@ -1694,7 +1694,7 @@ class DataApi {
if (_zoomStep != null) {
zoomStep = _zoomStep;
} else {
zoomStep = resolutionInfo.getLowestResolutionIndex();
zoomStep = resolutionInfo.getFinestResolutionIndex();
}

const resolutions = resolutionInfo.getDenseResolutions();
Expand Down Expand Up @@ -1896,7 +1896,7 @@ class DataApi {
): string {
const { dataset } = Store.getState();
const resolutionInfo = getResolutionInfo(getLayerByName(dataset, layerName, true).resolutions);
resolution = resolution || resolutionInfo.getLowestResolution();
resolution = resolution || resolutionInfo.getFinestResolution();

const magString = resolution.join("-");
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function isVolumeAnnotationDisallowedForZoom(tool: AnnotationTool, state:
}

const volumeResolutions = getResolutionInfoOfActiveSegmentationTracingLayer(state);
const lowestExistingResolutionIndex = volumeResolutions.getLowestResolutionIndex();
const lowestExistingResolutionIndex = volumeResolutions.getFinestResolutionIndex();
// The current resolution is too high for the tool
// because too many voxels could be annotated at the same time.
const isZoomStepTooHigh =
Expand All @@ -221,7 +221,7 @@ export function getMaximumBrushSize(state: OxalisState) {
return MAX_BRUSH_SIZE_FOR_MAG1;
}

const lowestExistingResolutionIndex = volumeResolutions.getLowestResolutionIndex();
const lowestExistingResolutionIndex = volumeResolutions.getFinestResolutionIndex();
// For each leading magnification which does not exist,
// we double the maximum brush size.
return MAX_BRUSH_SIZE_FOR_MAG1 * 2 ** lowestExistingResolutionIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class LayerRenderingManager {
const { dataset, datasetConfiguration } = state;
const layer = getLayerByName(dataset, this.name);
const resolutionInfo = getResolutionInfo(layer.resolutions);
const maximumResolutionIndex = resolutionInfo.getHighestResolutionIndex();
const maximumResolutionIndex = resolutionInfo.getCoarsestResolutionIndex();

if (logZoomStep > maximumResolutionIndex) {
// Don't render anything if the zoomStep is too high
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class PrefetchStrategy extends AbstractPrefetchStrategy {
return [];
}

const maxZoomStep = resolutionInfo.getHighestResolutionIndex();
const maxZoomStep = resolutionInfo.getCoarsestResolutionIndex();
const zoomStepDiff = currentZoomStep - zoomStep;
const queueItemsForCurrentZoomStep = this.prefetchImpl(
cube,
Expand Down
20 changes: 10 additions & 10 deletions frontend/javascripts/oxalis/model/helpers/resolution_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,30 @@ export class ResolutionInfo {
return this.resolutionMap.get(powerOfTwo);
}

getHighestResolutionPowerOf2(): number {
getCoarsestResolutionPowerOf2(): number {
return maxValue(Array.from(this.resolutionMap.keys()));
}

getLowestResolutionPowerOf2(): number {
getFinestResolutionPowerOf2(): number {
return minValue(Array.from(this.resolutionMap.keys()));
}

getHighestResolutionIndex(): number {
return Math.log2(this.getHighestResolutionPowerOf2());
getCoarsestResolutionIndex(): number {
return Math.log2(this.getCoarsestResolutionPowerOf2());
}

getLowestResolutionIndex(): number {
return Math.log2(this.getLowestResolutionPowerOf2());
getFinestResolutionIndex(): number {
return Math.log2(this.getFinestResolutionPowerOf2());
}

getHighestResolution(): Vector3 {
getCoarsestResolution(): Vector3 {
// @ts-ignore
return this.getResolutionByPowerOf2(this.getHighestResolutionPowerOf2());
return this.getResolutionByPowerOf2(this.getCoarsestResolutionPowerOf2());
}

getLowestResolution(): Vector3 {
getFinestResolution(): Vector3 {
// @ts-ignore
return this.getResolutionByPowerOf2(this.getLowestResolutionPowerOf2());
return this.getResolutionByPowerOf2(this.getFinestResolutionPowerOf2());
}

getAllIndices(): Array<number> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/javascripts/oxalis/model/sagas/dataset_saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function* watchZ1Downsampling(): Saga<void> {
break;
}
const resolutionInfo = getResolutionInfo(dataLayer.resolutions);
const bestExistingIndex = resolutionInfo.getLowestResolutionIndex();
const bestExistingIndex = resolutionInfo.getFinestResolutionIndex();
const currentIndex = resolutionInfo.getIndexByResolution(currentRes);
if (currentIndex <= bestExistingIndex) {
// There's no better mag to render the current layer in.
Expand Down
6 changes: 3 additions & 3 deletions frontend/javascripts/oxalis/model/sagas/proofread_saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,8 @@ function* prepareSplitOrMerge(

const resolutionInfo = getResolutionInfo(volumeTracingLayer.resolutions);
// The mag the agglomerate skeleton corresponds to should be the finest available mag of the volume tracing layer
const agglomerateFileMag = resolutionInfo.getLowestResolution();
const agglomerateFileZoomstep = resolutionInfo.getLowestResolutionIndex();
const agglomerateFileMag = resolutionInfo.getFinestResolution();
const agglomerateFileZoomstep = resolutionInfo.getFinestResolutionIndex();

const getDataValue = (position: Vector3) => {
const { additionalCoordinates } = Store.getState().flycam;
Expand Down Expand Up @@ -765,7 +765,7 @@ function* createGetUnmappedDataValueFn(
const layerName = volumeTracingLayer.tracingId;

const resolutionInfo = getResolutionInfo(volumeTracingLayer.resolutions);
const mag = resolutionInfo.getLowestResolution();
const mag = resolutionInfo.getFinestResolution();

const fallbackLayerName = volumeTracingLayer.fallbackLayer;
if (fallbackLayerName == null) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function _DownloadModalView({
const [selectedBoundingBoxId, setSelectedBoundingBoxId] = useState(
initialBoundingBoxId ?? userBoundingBoxes[0].id,
);
const [rawMag, setMag] = useState<Vector3>(selectedLayerResolutionInfo.getLowestResolution());
const [rawMag, setMag] = useState<Vector3>(selectedLayerResolutionInfo.getFinestResolution());
const mag = selectedLayerResolutionInfo.getClosestExistingResolution(rawMag);
const [exportFormat, setExportFormat] = useState<ExportFormat>(ExportFormat.OME_TIFF);

Expand Down
6 changes: 3 additions & 3 deletions frontend/javascripts/oxalis/view/context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,17 +1118,17 @@ function ContextMenuInner(propsWithInputRef: Props) {
} else {
const tracingId = volumeTracing.tracingId;
const tracingStoreUrl = Store.getState().tracing.tracingStore.url;
const mag = getResolutionInfo(visibleSegmentationLayer.resolutions);
const magInfo = getResolutionInfo(visibleSegmentationLayer.resolutions);
const [segmentSize] = await getSegmentVolumes(
tracingStoreUrl,
tracingId,
mag.getLowestResolution(),
magInfo.getFinestResolution(),
[segmentIdAtPosition],
);
const [boundingBox] = await getSegmentBoundingBoxes(
tracingStoreUrl,
tracingId,
mag.getLowestResolution(),
magInfo.getFinestResolution(),
[segmentIdAtPosition],
);
const boundingBoxTopLeftString = `(${boundingBox.topLeft[0]}, ${boundingBox.topLeft[1]}, ${boundingBox.topLeft[2]})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export function SegmentStatisticsModal({
getSegmentVolumes(
tracingStoreUrl,
tracingId,
mag.getHighestResolution(),
mag.getFinestResolution(),
segments.map((segment) => segment.id),
),
getSegmentBoundingBoxes(
tracingStoreUrl,
tracingId,
mag.getHighestResolution(),
mag.getFinestResolution(),
segments.map((segment) => segment.id),
),
]).then((response) => {
Expand Down