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

Rename resolution to mag in local variables #8168

Merged
merged 27 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb0c732
rename local vars in ai_model_list_view, create_explorative_modal, mo…
knollengewaechs Nov 4, 2024
5f19840
rename to mag up to volume interpolation saga
knollengewaechs Nov 7, 2024
fe89bb4
continue renaming local vars
knollengewaechs Nov 8, 2024
4c46b23
rename more occurences of resolution to mag
knollengewaechs Nov 8, 2024
8eaa932
change ServerNode resolution to mag
knollengewaechs Nov 8, 2024
20e27e1
remove shader code edit
knollengewaechs Nov 8, 2024
a1d7f66
fix test: rename resolution to mag in volumetracing saga spec
knollengewaechs Nov 8, 2024
c3a1ecf
rename resolution in create node action
knollengewaechs Nov 8, 2024
4d01c74
rename resolution to mag in DataLayer type
knollengewaechs Nov 8, 2024
2238c90
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 8, 2024
b7e1cf9
revert shader code edit
knollengewaechs Nov 8, 2024
3b8a272
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 11, 2024
1e93c68
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 11, 2024
4c9c01d
add changelog
knollengewaechs Nov 11, 2024
6bf39dd
merge master
knollengewaechs Nov 14, 2024
1368a81
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 18, 2024
14a0ea1
rename resolution to mag in MutableNode and add type checking file fo…
knollengewaechs Nov 18, 2024
b6227a9
change dummy trees to test compatibility of backend and frontend Crea…
knollengewaechs Nov 22, 2024
3486a7d
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 22, 2024
6db1cbe
fix createnode method
knollengewaechs Nov 22, 2024
67965fa
rename resolution to magnification in shader relevant code
Nov 27, 2024
1ec42ab
address review: revert one change and rename resInfo
knollengewaechs Nov 28, 2024
4088eee
merge master
knollengewaechs Nov 28, 2024
5b5fd41
lint
knollengewaechs Nov 28, 2024
364b02a
refresh annotations e2e snapshot
knollengewaechs Nov 28, 2024
3b75011
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Nov 29, 2024
f0e10b1
Merge branch 'master' into rename-resolution-to-mag-localvars
knollengewaechs Dec 2, 2024
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 @@ -14,6 +14,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- When exploring remote URIs pasted from Neuroglancer, the format prefixes like `precomputed://` are now ignored, so users don’t have to remove them. [#8195](https://github.com/scalableminds/webknossos/pull/8195)

### Changed
- Renamed "resolution" to "magnification" in more places within the codebase, including local variables. [#8168](https://github.com/scalableminds/webknossos/pull/8168)
- Reading image files on datastore filesystem is now done asynchronously. [#8126](https://github.com/scalableminds/webknossos/pull/8126)
- Datasets can now be renamed and can have duplicate names. [#8075](https://github.com/scalableminds/webknossos/pull/8075)
- Improved error messages for starting jobs on datasets from other organizations. [#8181](https://github.com/scalableminds/webknossos/pull/8181)
Expand Down
16 changes: 8 additions & 8 deletions frontend/javascripts/admin/tasktype/task_type_create_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Props = {
};

type FormValues = {
isResolutionRestricted: boolean;
isMagRestricted: boolean;
summary: string;
teamId: string;
description: string;
Expand Down Expand Up @@ -103,7 +103,7 @@ function TaskTypeCreateView({ taskTypeId, history }: Props) {
const taskType = taskTypeId ? await getTaskType(taskTypeId) : null;

const defaultValues = {
isResolutionRestricted: false,
isMagRestricted: false,
settings: {
somaClickingAllowed: true,
branchPointsAllowed: true,
Expand Down Expand Up @@ -131,15 +131,15 @@ function TaskTypeCreateView({ taskTypeId, history }: Props) {
}

if (taskType?.settings.magRestrictions.min || taskType?.settings.magRestrictions.max)
form.setFieldValue(["isResolutionRestricted"], true);
form.setFieldValue(["isMagRestricted"], true);
}

async function onFinish(formValues: FormValues) {
const {
settings,
teamId,
recommendedConfiguration,
isResolutionRestricted: _isResolutionRestricted,
isMagRestricted: _isMagRestricted,
...rest
} = formValues;
const teamName = teams.find((team) => team.id === teamId)!["name"];
Expand Down Expand Up @@ -411,7 +411,7 @@ function TaskTypeCreateView({ taskTypeId, history }: Props) {
</FormItem>

<FormItem
name={["isResolutionRestricted"]}
name={["isMagRestricted"]}
valuePropName="checked"
style={{
marginBottom: 6,
Expand All @@ -431,12 +431,12 @@ function TaskTypeCreateView({ taskTypeId, history }: Props) {
<FormItem
noStyle
shouldUpdate={(prevValues, curValues) =>
!prevValues.isResolutionRestricted ||
prevValues.isResolutionRestricted !== curValues.isResolutionRestricted
!prevValues.isMagRestricted ||
prevValues.isMagRestricted !== curValues.isMagRestricted
}
>
{({ getFieldValue }) =>
getFieldValue(["isResolutionRestricted"]) ? (
getFieldValue(["isMagRestricted"]) ? (
<div
style={{
marginLeft: 24,
Expand Down
4 changes: 2 additions & 2 deletions frontend/javascripts/admin/voxelytics/ai_model_list_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ function TrainNewAiJobModal({ onClose }: { onClose: () => void }) {
const volumeTracingIndex = volumeTracings.findIndex(
(tracing) => tracing.tracingId === annotationLayer.tracingId,
);
const resolutions = volumeTracingMags[volumeTracingIndex] || ([[1, 1, 1]] as Vector3[]);
return getMagInfo(resolutions).getFinestMag();
const mags = volumeTracingMags[volumeTracingIndex] || ([[1, 1, 1]] as Vector3[]);
return getMagInfo(mags).getFinestMag();
} else {
const segmentationLayer = getSegmentationLayerByName(dataset, layerName);
return getMagInfo(segmentationLayer.resolutions).getFinestMag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ export function RestrictMagnificationSlider({
magIndices,
setMagIndices,
}: RestrictMagnificationSliderProps) {
let highestResolutionIndex = magInfo.getCoarsestMagIndex();
let lowestResolutionIndex = magInfo.getFinestMagIndex();
let highestMagIndex = magInfo.getCoarsestMagIndex();
let lowestMagIndex = magInfo.getFinestMagIndex();

if (selectedSegmentationLayer != null) {
const datasetFallbackLayerResolutionInfo = getMagInfo(selectedSegmentationLayer.resolutions);
highestResolutionIndex = datasetFallbackLayerResolutionInfo.getCoarsestMagIndex();
lowestResolutionIndex = datasetFallbackLayerResolutionInfo.getFinestMagIndex();
const datasetFallbackLayerMagInfo = getMagInfo(selectedSegmentationLayer.resolutions);
highestMagIndex = datasetFallbackLayerMagInfo.getCoarsestMagIndex();
lowestMagIndex = datasetFallbackLayerMagInfo.getFinestMagIndex();
}

const highResolutionIndex = Math.min(highestResolutionIndex, magIndices[1]);
const lowResolutionIndex = Math.max(lowestResolutionIndex, magIndices[0]);
const highMagIndex = Math.min(highestMagIndex, magIndices[1]);
const lowMagIndex = Math.max(lowestMagIndex, magIndices[0]);

// biome-ignore lint/correctness/useExhaustiveDependencies: setResolutionIndices should also be added to the dependencies. Consider fixing this.
// biome-ignore lint/correctness/useExhaustiveDependencies: setMagIndices should also be added to the dependencies. Consider fixing this.
useEffect(() => {
setMagIndices([lowestResolutionIndex, highestResolutionIndex]);
}, [lowestResolutionIndex, highestResolutionIndex]);
setMagIndices([lowestMagIndex, highestMagIndex]);
}, [lowestMagIndex, highestMagIndex]);
knollengewaechs marked this conversation as resolved.
Show resolved Hide resolved

return lowestResolutionIndex < highestResolutionIndex ? (
return lowestMagIndex < highestMagIndex ? (
<React.Fragment>
<h5
style={{
Expand Down Expand Up @@ -136,16 +136,16 @@ export function RestrictMagnificationSlider({
marginRight: 20,
}}
>
{magInfo.getMagByIndexOrThrow(lowResolutionIndex).join("-")}
{magInfo.getMagByIndexOrThrow(lowMagIndex).join("-")}
</div>
<Slider
tooltip={{ open: false }}
onChange={(value) => setMagIndices(value)}
range
step={1}
min={lowestResolutionIndex}
max={highestResolutionIndex}
value={[lowResolutionIndex, highResolutionIndex]}
min={lowestMagIndex}
max={highestMagIndex}
value={[lowMagIndex, highMagIndex]}
style={{
flexGrow: 1,
}}
Expand All @@ -157,7 +157,7 @@ export function RestrictMagnificationSlider({
textAlign: "right",
}}
>
{magInfo.getMagByIndexOrThrow(highResolutionIndex).join("-")}
{magInfo.getMagByIndexOrThrow(highMagIndex).join("-")}
</div>
</div>
</React.Fragment>
Expand All @@ -167,7 +167,7 @@ export function RestrictMagnificationSlider({
function CreateExplorativeModal({ datasetId, onClose }: Props) {
const dataset = useFetch(() => getDataset(datasetId), null, [datasetId]);
const [annotationType, setAnnotationType] = useState("hybrid");
const [userDefinedResolutionIndices, setUserDefinedResolutionIndices] = useState([0, 10000]);
const [userDefinedMagIndices, setUserDefinedMagIndices] = useState([0, 10000]);
const [selectedSegmentationLayerName, setSelectedSegmentationLayerName] = useState<
string | undefined
>(undefined);
Expand All @@ -194,22 +194,22 @@ function CreateExplorativeModal({ datasetId, onClose }: Props) {
selectedSegmentationLayer != null
? `&fallbackLayerName=${selectedSegmentationLayer.name}`
: "";
const resolutionInfo =
const magInfo =
selectedSegmentationLayer == null
? getSomeMagInfoForDataset(dataset)
: getMagInfo(selectedSegmentationLayer.resolutions);
const highestResolutionIndex = resolutionInfo.getCoarsestMagIndex();
const lowestResolutionIndex = resolutionInfo.getFinestMagIndex();
const highestMagIndex = magInfo.getCoarsestMagIndex();
const lowestMagIndex = magInfo.getFinestMagIndex();

const highResolutionIndex = Math.min(highestResolutionIndex, userDefinedResolutionIndices[1]);
const lowResolutionIndex = Math.max(lowestResolutionIndex, userDefinedResolutionIndices[0]);
const resolutionSlider =
const highMagIndex = Math.min(highestMagIndex, userDefinedMagIndices[1]);
const lowMagIndex = Math.max(lowestMagIndex, userDefinedMagIndices[0]);
const magSlider =
annotationType !== "skeleton" ? (
<RestrictMagnificationSlider
magInfo={resolutionInfo}
magInfo={magInfo}
selectedSegmentationLayer={selectedSegmentationLayer}
magIndices={userDefinedResolutionIndices}
setMagIndices={setUserDefinedResolutionIndices}
magIndices={userDefinedMagIndices}
setMagIndices={setUserDefinedMagIndices}
/>
) : null;
modalContent = (
Expand All @@ -235,17 +235,17 @@ function CreateExplorativeModal({ datasetId, onClose }: Props) {
/>
) : null}

{resolutionSlider}
{magSlider}
<div
style={{
textAlign: "right",
}}
>
<Link
to={`/datasets/${dataset.id}/createExplorative/${annotationType}/?minMag=${Math.max(
...resolutionInfo.getMagByIndexOrThrow(lowResolutionIndex),
...magInfo.getMagByIndexOrThrow(lowMagIndex),
)}&maxMag=${Math.max(
...resolutionInfo.getMagByIndexOrThrow(highResolutionIndex),
...magInfo.getMagByIndexOrThrow(highMagIndex),
)}${fallbackLayerGetParameter}`}
title="Create new annotation with selected properties"
>
Expand Down
50 changes: 24 additions & 26 deletions frontend/javascripts/oxalis/api/api_latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,15 +670,13 @@ class TracingApi {
);
}

const resolutionInfo = getMagInfo(
getLayerByName(state.dataset, segmentationLayerName).resolutions,
);
const magInfo = getMagInfo(getLayerByName(state.dataset, segmentationLayerName).resolutions);
const theoreticalMagIndex = getActiveMagIndexForLayer(state, segmentationLayerName);
const existingMagIndex = resolutionInfo.getIndexOrClosestHigherIndex(theoreticalMagIndex);
const existingMagIndex = magInfo.getIndexOrClosestHigherIndex(theoreticalMagIndex);
if (existingMagIndex == null) {
throw new Error("The index of the current mag could not be found.");
}
const currentMag = resolutionInfo.getMagByIndex(existingMagIndex);
const currentMag = magInfo.getMagByIndex(existingMagIndex);
if (currentMag == null) {
throw new Error("No mag could be found.");
}
Expand Down Expand Up @@ -1843,8 +1841,8 @@ class DataApi {
zoomStep = _zoomStep;
} else {
const layer = getLayerByName(Store.getState().dataset, layerName);
const resolutionInfo = getMagInfo(layer.resolutions);
zoomStep = resolutionInfo.getFinestMagIndex();
const magInfo = getMagInfo(layer.resolutions);
zoomStep = magInfo.getFinestMagIndex();
}

const cube = this.model.getCubeByLayerName(layerName);
Expand Down Expand Up @@ -1900,19 +1898,19 @@ class DataApi {
additionalCoordinates: AdditionalCoordinate[] | null = null,
) {
const layer = getLayerByName(Store.getState().dataset, layerName);
const resolutionInfo = getMagInfo(layer.resolutions);
const magInfo = getMagInfo(layer.resolutions);
let zoomStep;

if (_zoomStep != null) {
zoomStep = _zoomStep;
} else {
zoomStep = resolutionInfo.getFinestMagIndex();
zoomStep = magInfo.getFinestMagIndex();
}

const resolutions = resolutionInfo.getDenseMags();
const mags = magInfo.getDenseMags();
const bucketAddresses = this.getBucketAddressesInCuboid(
mag1Bbox,
resolutions,
mags,
zoomStep,
additionalCoordinates,
);
Expand All @@ -1927,13 +1925,13 @@ class DataApi {
bucketAddresses.map((addr) => this.getLoadedBucket(layerName, addr)),
);
const { elementClass } = getLayerByName(Store.getState().dataset, layerName);
return this.cutOutCuboid(buckets, mag1Bbox, elementClass, resolutions, zoomStep);
return this.cutOutCuboid(buckets, mag1Bbox, elementClass, mags, zoomStep);
}

async getViewportData(
viewport: OrthoView,
layerName: string,
maybeResolutionIndex: number | null | undefined,
maybeMagIndex: number | null | undefined,
additionalCoordinates: AdditionalCoordinate[] | null,
) {
const state = Store.getState();
Expand All @@ -1946,11 +1944,11 @@ class DataApi {
viewport,
);
const layer = getLayerByName(state.dataset, layerName);
const resolutionInfo = getMagInfo(layer.resolutions);
if (maybeResolutionIndex == null) {
maybeResolutionIndex = getActiveMagIndexForLayer(state, layerName);
const magInfo = getMagInfo(layer.resolutions);
if (maybeMagIndex == null) {
maybeMagIndex = getActiveMagIndexForLayer(state, layerName);
}
const zoomStep = resolutionInfo.getClosestExistingIndex(maybeResolutionIndex);
const zoomStep = magInfo.getClosestExistingIndex(maybeMagIndex);

const min = dimensions.transDim(
V3.sub([curU, curV, curW], [halfViewportExtentU, halfViewportExtentV, 0]),
Expand All @@ -1961,10 +1959,10 @@ class DataApi {
viewport,
);

const resolution = resolutionInfo.getMagByIndexOrThrow(zoomStep);
const resolutionUVX = dimensions.transDim(resolution, viewport);
const widthInVoxel = Math.ceil(halfViewportExtentU / resolutionUVX[0]);
const heightInVoxel = Math.ceil(halfViewportExtentV / resolutionUVX[1]);
const mag = magInfo.getMagByIndexOrThrow(zoomStep);
const magUVX = dimensions.transDim(mag, viewport);
const widthInVoxel = Math.ceil(halfViewportExtentU / magUVX[0]);
const heightInVoxel = Math.ceil(halfViewportExtentV / magUVX[1]);
if (widthInVoxel * heightInVoxel > 1024 ** 2) {
throw new Error(
"Requested data for viewport cannot be loaded, since the amount of data is too large for the available magnification. Please zoom in further or ensure that coarser magnifications are available.",
Expand Down Expand Up @@ -2036,12 +2034,12 @@ class DataApi {
magnifications: Array<Vector3>,
zoomStep: number,
): TypedArray {
const resolution = magnifications[zoomStep];
const mag = magnifications[zoomStep];
// All calculations in this method are in zoomStep-space, so in global coordinates which are divided
// by the mag
const topLeft = scaleGlobalPositionWithMagnification(bbox.min, resolution);
const topLeft = scaleGlobalPositionWithMagnification(bbox.min, mag);
// Ceil the bounding box bottom right instead of flooring, because it is exclusive
const bottomRight = scaleGlobalPositionWithMagnification(bbox.max, resolution, true);
const bottomRight = scaleGlobalPositionWithMagnification(bbox.max, mag, true);
const extent: Vector3 = V3.sub(bottomRight, topLeft);
const [TypedArrayClass, channelCount] = getConstructorForElementClass(elementClass);
const result = new TypedArrayClass(channelCount * extent[0] * extent[1] * extent[2]);
Expand Down Expand Up @@ -2107,8 +2105,8 @@ class DataApi {
magnification?: Vector3,
): string {
const { dataset } = Store.getState();
const resolutionInfo = getMagInfo(getLayerByName(dataset, layerName, true).resolutions);
magnification = magnification || resolutionInfo.getFinestMag();
const magInfo = getMagInfo(getLayerByName(dataset, layerName, true).resolutions);
magnification = magnification || magInfo.getFinestMag();

const magString = magnification.join("-");
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const moveW = (deltaW: number, oneSlide: boolean): void => {
// The following logic might not always make sense when having layers
// that are transformed each. Todo: Rethink / adapt the logic once
// problems occur. Tracked in #6926.
const { representativeResolution } = getActiveMagInfo(Store.getState());
const { representativeMag } = getActiveMagInfo(Store.getState());
const wDim = Dimensions.getIndices(activeViewport)[2];
const wStep = (representativeResolution || [1, 1, 1])[wDim];
const wStep = (representativeMag || [1, 1, 1])[wDim];
Store.dispatch(
moveFlycamOrthoAction(
Dimensions.transDim([0, 0, Math.sign(deltaW) * Math.max(1, wStep)], activeViewport),
Expand Down
Loading