@@ -158,7 +158,7 @@ export function TrainAiModelFromAnnotationTab({ onClose }: { onClose: () => void
158
158
) ;
159
159
}
160
160
161
- type MagInfoPerAnnotation = { annotationId : string ; magInfo : MagInfo } ;
161
+ type MagInfoWithAnnotationId = { annotationId : string ; magInfo : MagInfo } ;
162
162
163
163
export function TrainAiModelTab < GenericAnnotation extends APIAnnotation | HybridTracing > ( {
164
164
getMagsForSegmentationLayer,
@@ -175,7 +175,7 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
175
175
} ) {
176
176
const [ form ] = Form . useForm ( ) ;
177
177
const [ useCustomWorkflow , setUseCustomWorkflow ] = React . useState ( false ) ;
178
- const [ mags , setMags ] = useState < MagInfoPerAnnotation [ ] > ( ) ;
178
+ const [ mags , setMags ] = useState < MagInfoWithAnnotationId [ ] > ( ) ;
179
179
180
180
const getIntersectingMagList = (
181
181
annotationId : string ,
@@ -358,6 +358,16 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
358
358
: [ ] ;
359
359
const initialMagInfo = new MagInfo ( initialMags ) ;
360
360
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
+
361
371
return (
362
372
< Row key = { annotationId } gutter = { 8 } >
363
373
< Col span = { 6 } >
@@ -388,15 +398,7 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
388
398
getReadableNameForLayer = { ( layer ) => layer . name }
389
399
fixedLayerName = { fixedSelectedColorLayer ?. name || undefined }
390
400
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 }
400
402
/>
401
403
</ FormItem >
402
404
</ Col >
@@ -412,23 +414,15 @@ export function TrainAiModelTab<GenericAnnotation extends APIAnnotation | Hybrid
412
414
} }
413
415
fixedLayerName = { fixedSelectedSegmentationLayer ?. name || undefined }
414
416
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 }
424
418
/>
425
419
</ Col >
426
420
< Col span = { 6 } >
427
421
< MagSelectionFormItem
428
422
name = { [ "trainingAnnotations" , idx , "mag" ] }
429
423
magInfo = {
430
424
mags != null
431
- ? mags . find ( ( magInfoPerAnno ) => magInfoPerAnno . annotationId === annotationId )
425
+ ? mags . find ( ( magInfoForAnno ) => magInfoForAnno . annotationId === annotationId )
432
426
?. magInfo
433
427
: initialMagInfo
434
428
}
0 commit comments