Skip to content

Commit 420f648

Browse files
WIP: address review
1 parent 3f4bcaf commit 420f648

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export function TrainAiModelFromAnnotationTab({ onClose }: { onClose: () => void
158158
);
159159
}
160160

161-
type MagInfoPerAnnotation = { annotationId: string; magInfo: MagInfo };
161+
type MagInfoWithAnnotationId = { annotationId: string; magInfo: MagInfo };
162162

163163
export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | HybridTracing>({
164164
getMagsForSegmentationLayer,
@@ -175,7 +175,7 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
175175
}) {
176176
const [form] = Form.useForm();
177177
const [useCustomWorkflow, setUseCustomWorkflow] = React.useState(false);
178-
const [mags, setMags] = useState<MagInfoPerAnnotation[]>();
178+
const [mags, setMags] = useState<MagInfoWithAnnotationId[]>();
179179

180180
const getIntersectingMagList = (
181181
annotationId: string,
@@ -358,6 +358,16 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
358358
: [];
359359
const initialMagInfo = new MagInfo(initialMags);
360360

361+
const onChangeLayer = () => {
362+
setIntersectingMags(
363+
annotationId,
364+
dataset,
365+
form.getFieldValue(["trainingAnnotations", idx, "layerName"]),
366+
form.getFieldValue(["trainingAnnotations", idx, "imageDataLayer"]),
367+
);
368+
form.setFieldValue(["trainingAnnotations", idx, "mag"], undefined);
369+
};
370+
361371
return (
362372
<Row key={annotationId} gutter={8}>
363373
<Col span={6}>
@@ -388,15 +398,7 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
388398
getReadableNameForLayer={(layer) => layer.name}
389399
fixedLayerName={fixedSelectedColorLayer?.name || undefined}
390400
style={{ width: "100%" }}
391-
onChange={() => {
392-
setIntersectingMags(
393-
annotationId,
394-
dataset,
395-
form.getFieldValue(["trainingAnnotations", idx, "layerName"]),
396-
form.getFieldValue(["trainingAnnotations", idx, "imageDataLayer"]),
397-
);
398-
form.setFieldValue(["trainingAnnotations", idx, "mag"], undefined);
399-
}}
401+
onChange={onChangeLayer}
400402
/>
401403
</FormItem>
402404
</Col>
@@ -412,23 +414,15 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
412414
}}
413415
fixedLayerName={fixedSelectedSegmentationLayer?.name || undefined}
414416
label="Ground Truth Layer"
415-
onChange={() => {
416-
setIntersectingMags(
417-
annotationId,
418-
dataset,
419-
form.getFieldValue(["trainingAnnotations", idx, "layerName"]),
420-
form.getFieldValue(["trainingAnnotations", idx, "imageDataLayer"]),
421-
);
422-
form.setFieldValue(["trainingAnnotations", idx, "mag"], undefined);
423-
}}
417+
onChange={onChangeLayer}
424418
/>
425419
</Col>
426420
<Col span={6}>
427421
<MagSelectionFormItem
428422
name={["trainingAnnotations", idx, "mag"]}
429423
magInfo={
430424
mags != null
431-
? mags.find((magInfoPerAnno) => magInfoPerAnno.annotationId === annotationId)
425+
? mags.find((magInfoForAnno) => magInfoForAnno.annotationId === annotationId)
432426
?.magInfo
433427
: initialMagInfo
434428
}

0 commit comments

Comments
 (0)