Skip to content

Commit c37fe7f

Browse files
Michael BüßemeyerMichael Büßemeyer
authored andcommitted
apply pr feedback
- regarding bbox size calculation use bbox adjusted to mag (not just aligned)
1 parent 52a80ef commit c37fe7f

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

frontend/javascripts/oxalis/model/bucket_data_handling/bounding_box.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ class BoundingBox {
206206
return new BoundingBox({ min, max });
207207
}
208208

209+
alignFromMag1ToMag(mag: Vector3, strategy: "shrink" | "grow" | "ceil" | "floor"): BoundingBox {
210+
return this.alignWithMag(mag, strategy).fromMag1ToMag(mag);
211+
}
212+
209213
/*
210214
* Each component of margins is used as
211215
* - a left margin IF the value is negative (the absolute value will be

frontend/javascripts/oxalis/model/helpers/shader_editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import app from "app";
21
// @ts-nocheck
2+
import app from "app";
33
import window, { document } from "libs/window";
44

55
export default {

frontend/javascripts/oxalis/view/jobs/train_ai_model.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const FormItem = Form.Item;
5656
// only the APIAnnotations of the given annotations to train on are loaded from the backend.
5757
// Thus, the code needs to handle both HybridTracing | APIAnnotation where APIAnnotation is missing some information.
5858
// Therefore, volumeTracings with the matching volumeTracingMags are needed to get more details on each volume annotation layer and its magnifications.
59-
// As the userBoundingBoxes should have multiple sizes of the smallest one, a check with a warning should be included.
59+
// As the userBoundingBoxes should have extents that are multiples of the smallest extent, a check with a warning should be included.
6060
// As training on fallback data is supported and an annotation is not required to have VolumeTracings,
6161
// it is necessary to save userBoundingBoxes separately and not load them from volumeTracings entries to support skeleton only annotations.
62-
// Moreover, in case an annotations is a task, its task bounding box should also be used for training.
62+
// Moreover, in case an annotation is a task, its task bounding box should also be used for training.
6363
// Note that a copy of the userBoundingBoxes is included in each volume and skeleton tracing of an annotation. Thus, it doesn't matter from which the userBoundingBoxes are taken.
6464
export type AnnotationInfoForAITrainingJob<GenericAnnotation> = {
6565
annotation: GenericAnnotation;
@@ -560,7 +560,7 @@ function checkBoundingBoxesForErrorsAndWarnings(
560560
(min, { boundingBox: box, trainingMag }) => {
561561
let bbox = new BoundingBox(box);
562562
if (trainingMag) {
563-
bbox = bbox.alignWithMag(trainingMag, "shrink");
563+
bbox = bbox.alignFromMag1ToMag(trainingMag, "shrink");
564564
}
565565
const size = bbox.getSize();
566566
return {
@@ -586,18 +586,20 @@ function checkBoundingBoxesForErrorsAndWarnings(
586586
const nonMultipleBoxes: BoundingBoxWithAnnotationId[] = [];
587587
const notMagAlignedBoundingBoxes: (BoundingBoxWithAnnotationId & {
588588
alignedBoundingBox: Vector6;
589+
trainingMag: Vector3;
589590
})[] = [];
590591
userBoundingBoxes.forEach(({ boundingBox: box, name, annotationId, trainingMag }) => {
591592
const boundingBox = new BoundingBox(box);
592593
let arrayBox = computeArrayFromBoundingBox(box);
593594
if (trainingMag) {
594-
const alignedBoundingBox = boundingBox.alignWithMag(trainingMag, "shrink");
595+
const alignedBoundingBox = boundingBox.alignFromMag1ToMag(trainingMag, "shrink");
595596
if (!alignedBoundingBox.equals(boundingBox)) {
596597
const alignedArrayBox = computeArrayFromBoundingBox(alignedBoundingBox);
597598
notMagAlignedBoundingBoxes.push({
598599
boundingBox: arrayBox,
599600
name,
600601
annotationId,
602+
trainingMag,
601603
alignedBoundingBox: alignedArrayBox,
602604
});
603605
// Update the arrayBox as the aligned version of the bounding box will be used for training.
@@ -625,8 +627,8 @@ function checkBoundingBoxesForErrorsAndWarnings(
625627
if (notMagAlignedBoundingBoxes.length > 0) {
626628
hasBBoxWarnings = true;
627629
const notMagAlignedBoundingBoxesStrings = notMagAlignedBoundingBoxes.map(
628-
({ boundingBox, name, annotationId, alignedBoundingBox }) =>
629-
`'${name}' of annotation ${annotationId}: ${boundingBox.join(", ")} -> ${alignedBoundingBox.join(", ")}`,
630+
({ boundingBox, name, annotationId, alignedBoundingBox, trainingMag }) =>
631+
`'${name}' of annotation ${annotationId}: ${boundingBox.join(", ")} will be ${alignedBoundingBox.join(", ")} in mag ${trainingMag.join(", ")}`,
630632
);
631633
warnings.push(
632634
`The following bounding boxes are not aligned with the selected magnification. They will be automatically shrunk to be aligned with the magnification:\n${notMagAlignedBoundingBoxesStrings.join("\n")}`,

0 commit comments

Comments
 (0)