1
1
#!/usr/bin/env python3
2
2
# -*- coding: UTF-8 -*-
3
3
4
- import importlib
5
4
import multiprocessing
6
5
import time
7
6
from typing import Dict
@@ -439,13 +438,13 @@ def __init__(self, parent, auto_segment=False):
439
438
class SubpartSegmenterDialog (DeepLearningSegmenterDialog ):
440
439
def __init__ (self , parent , auto_segment = False ):
441
440
self .mask_types = {
442
- "Cortical " : _ ("Cortical" ),
443
- "Subcortical " : _ ("Subcortical" ),
444
- "White_matter " : _ ("White Matter" ),
445
- "Cerebellum " : _ ("Cerebellum" ),
446
- "Ventricles " : _ ("Ventricles" ),
447
- "Brain_stem " : _ ("Brain Stem" ),
448
- "Choroid_Plexus " : _ ("Choroid Plexus" ),
441
+ "cortical " : _ ("Cortical" ),
442
+ "subcortical " : _ ("Subcortical" ),
443
+ "white_matter " : _ ("White Matter" ),
444
+ "cerebellum " : _ ("Cerebellum" ),
445
+ "ventricles " : _ ("Ventricles" ),
446
+ "brain_stem " : _ ("Brain Stem" ),
447
+ "choroid_plexus " : _ ("Choroid Plexus" ),
449
448
}
450
449
451
450
self .selected_mask_types = []
@@ -455,7 +454,7 @@ def __init__(self, parent, auto_segment=False):
455
454
title = _ ("Subpart Segmentation" ),
456
455
has_torch = True ,
457
456
has_tinygrad = True ,
458
- segmenter = segment .SubpartSegementProcess ,
457
+ segmenter = segment .SubpartSegmentProcess ,
459
458
auto_segment = auto_segment ,
460
459
)
461
460
@@ -477,28 +476,6 @@ def _init_gui(self):
477
476
self .mask_checkboxes [mask_id ] = wx .CheckBox (self , wx .ID_ANY , mask_label )
478
477
self .mask_checkboxes [mask_id ].SetValue (False )
479
478
480
- self ._check_model_availability ()
481
-
482
- def _check_model_availability (self ):
483
- """Check if required models and dependencies are available"""
484
- try :
485
- # Try to create a dummy process to check model availability
486
- # This is safer than calling slc.Slice().matrix which might not be ready
487
- self .models_missing = False
488
- self .missing_reason = ""
489
-
490
- # We could add specific checks here, but for now we'll do it lazily
491
- # during segmentation start to avoid initialization issues
492
-
493
- except Exception as e :
494
- self .models_missing = True
495
- self .missing_reason = str (e )
496
-
497
- if self .models_missing :
498
- self .lbl_models_missing = wx .StaticText (
499
- self , - 1 , _ ("FastSurfer models not found. Please check installation." )
500
- )
501
-
502
479
def _do_layout (self ):
503
480
"""Override _do_layout to arrange FastSurferCNN specific UI elements"""
504
481
super ()._do_layout ()
@@ -545,15 +522,6 @@ def _do_layout(self):
545
522
# Fallback - just add to the main sizer
546
523
self .main_sizer .Add (self .mask_types_sizer , 0 , wx .ALL | wx .EXPAND , 5 )
547
524
548
- if self .models_missing :
549
- error_sizer = wx .BoxSizer (wx .VERTICAL )
550
- error_sizer .Add (self .lbl_models_missing , 0 , wx .ALL , 5 )
551
-
552
- index = self .main_sizer .GetItemCount () - 1
553
- self .main_sizer .Insert (index , error_sizer , 0 , wx .EXPAND | wx .ALL , 5 )
554
-
555
- self .btn_segment .Enable (False )
556
-
557
525
self .main_sizer .Fit (self )
558
526
self .Layout ()
559
527
@@ -575,7 +543,7 @@ def OnSegment(self, evt):
575
543
device_id = self .torch_devices [self .cb_devices .GetValue ()]
576
544
except (KeyError , AttributeError ):
577
545
device_id = "cpu"
578
- use_gpu = True if not "cpu" in device_id .lower () else False
546
+ use_gpu = True if "cpu" not in device_id .lower () else False
579
547
elif backend .lower () == "tinygrad" :
580
548
try :
581
549
device_id = self .tinygrad_devices [self .cb_devices .GetValue ()]
@@ -637,18 +605,10 @@ def AfterSegment(self):
637
605
checkbox .Enable ()
638
606
639
607
def apply_segment_threshold (self ):
640
- print ("apply_segment_threshold: Starting..." )
641
608
threshold = self .sld_threshold .GetValue () / 100.0
642
- print (f"apply_segment_threshold: Threshold value: { threshold } " )
643
-
644
- print ("apply_segment_threshold: Calling apply_segment_threshold..." )
645
609
self .ps .apply_segment_threshold (threshold )
646
- print ("apply_segment_threshold: apply_segment_threshold completed" )
647
-
648
- print ("apply_segment_threshold: Discarding buffers and reloading slice..." )
649
610
slc .Slice ().discard_all_buffers ()
650
611
Publisher .sendMessage ("Reload actual slice" )
651
- print ("apply_segment_threshold: Completed successfully" )
652
612
653
613
def OnStop (self , evt ):
654
614
super ().OnStop (evt )
@@ -811,6 +771,10 @@ def _init_gui(self):
811
771
812
772
self .patch_cmb = wx .ComboBox (self , choices = patch_size , value = "480" )
813
773
774
+ self .path_sizer = wx .BoxSizer (wx .HORIZONTAL )
775
+ self .path_sizer .Add (self .patch_txt , 0 , wx .EXPAND | wx .ALL , 5 )
776
+ self .path_sizer .Add (self .patch_cmb , 2 , wx .EXPAND | wx .ALL , 5 )
777
+
814
778
self .method = wx .RadioBox (
815
779
self ,
816
780
- 1 ,
@@ -849,7 +813,7 @@ def OnSegment(self, evt):
849
813
apply_wwwl = self .chk_apply_wwwl .GetValue ()
850
814
create_new_mask = self .chk_new_mask .GetValue ()
851
815
use_gpu = self .chk_use_gpu .GetValue ()
852
- prob_threshold = self .sld_threshold .GetValue () / 100.0
816
+ # prob_threshold = self.sld_threshold.GetValue() / 100.0
853
817
method = self .method .GetSelection ()
854
818
855
819
self .btn_close .Disable ()
0 commit comments