<s> from ilastik . gui . ribbons . ilastikTabBase import IlastikTabBase , TabButton <EOL> from PyQt4 import QtGui , QtCore <EOL> from ilastik . gui . iconMgr import ilastikIcons <EOL> from ilastik . gui . overlaySelectionDlg import OverlaySelectionDialog <EOL> from ilastik . gui . overlayWidget import OverlayWidget <EOL> import ilastik . gui . volumeeditor as ve <EOL> class AutoSegmentationTab ( IlastikTabBase , QtGui . QWidget ) : <EOL> name = '<STR_LIT>' <EOL> position = <NUM_LIT:2> <EOL> moduleName = "<STR_LIT>" <EOL> def __init__ ( self , parent = None ) : <EOL> IlastikTabBase . __init__ ( self , parent ) <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> self . _initContent ( ) <EOL> self . _initConnects ( ) <EOL> self . weights = None <EOL> def on_activation ( self ) : <EOL> if self . ilastik . project is None : <EOL> return <EOL> ovs = self . ilastik . _activeImage . module [ self . __class__ . moduleName ] . getOverlayRefs ( ) <EOL> if len ( ovs ) == <NUM_LIT:0> : <EOL> raw = self . ilastik . _activeImage . overlayMgr [ "<STR_LIT>" ] <EOL> if raw is not None : <EOL> ovs . append ( raw . getRef ( ) ) <EOL> self . ilastik . labelWidget . _history . volumeEditor = self . ilastik . labelWidget <EOL> overlayWidget = OverlayWidget ( self . ilastik . labelWidget , self . ilastik . project . dataMgr ) <EOL> self . ilastik . labelWidget . setOverlayWidget ( overlayWidget ) <EOL> self . ilastik . labelWidget . setLabelWidget ( ve . DummyLabelWidget ( ) ) <EOL> def on_deActivation ( self ) : <EOL> pass <EOL> def _initContent ( self ) : <EOL> tl = QtGui . QHBoxLayout ( ) <EOL> tl . setMargin ( <NUM_LIT:0> ) <EOL> self . btnChooseWeights = TabButton ( '<STR_LIT>' , ilastikIcons . Select ) <EOL> self . btnSegment = TabButton ( '<STR_LIT>' , ilastikIcons . Play ) <EOL> self . btnChooseWeights . setToolTip ( '<STR_LIT>' ) <EOL> self . btnSegment . setToolTip ( '<STR_LIT>' ) <EOL> tl . addWidget ( self . btnChooseWeights ) <EOL> tl . addWidget ( self . btnSegment ) <EOL> tl . addStretch ( ) <EOL> self . setLayout ( tl ) <EOL> def _initConnects ( self ) : <EOL> self . connect ( self . btnChooseWeights , QtCore . SIGNAL ( '<STR_LIT>' ) , self . on_btnChooseWeights_clicked ) <EOL> self . connect ( self . btnSegment , QtCore . SIGNAL ( '<STR_LIT>' ) , self . on_btnSegment_clicked ) <EOL> def on_btnChooseWeights_clicked ( self ) : <EOL> dlg = OverlaySelectionDialog ( self . ilastik , singleSelection = True ) <EOL> answer = dlg . exec_ ( ) <EOL> if len ( answer ) > <NUM_LIT:0> : <EOL> overlay = answer [ <NUM_LIT:0> ] <EOL> self . parent . labelWidget . overlayWidget . addOverlayRef ( overlay . getRef ( ) ) <EOL> volume = overlay . _data [ <NUM_LIT:0> , : , : , : , <NUM_LIT:0> ] <EOL> borderIndicator = QtGui . QInputDialog . getItem ( self . ilastik , "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" , "<STR_LIT>" ] , editable = False ) <EOL> borderIndicator = str ( borderIndicator [ <NUM_LIT:0> ] ) <EOL> if borderIndicator == "<STR_LIT>" : <EOL> weights = volume [ : , : , : ] <EOL> elif borderIndicator == "<STR_LIT>" : <EOL> weights = self . parent . project . dataMgr . Automatic_Segmentation . invertPotential ( volume ) <EOL> weights = self . parent . project . dataMgr . Automatic_Segmentation . normalizePotential ( weights ) <EOL> self . weights = weights <EOL> def on_btnSegment_clicked ( self ) : <EOL> if self . weights is not None : <EOL> self . parent . project . dataMgr . Automatic_Segmentation . computeResults ( self . weights ) <EOL> self . parent . project . dataMgr . Automatic_Segmentation . finalizeResults ( ) <EOL> self . parent . labelWidget . repaint ( ) <EOL> def on_btnSegmentorsOptions_clicked ( self ) : <EOL> pass </s>
