Esempio n. 1
0
def main( parsed_args, workflow_cmdline_args=[] ):
    this_path = os.path.dirname(__file__)
    ilastik_dir = os.path.abspath(os.path.join(this_path, "..%s.." % os.path.sep))
    
    # If necessary, redirect stdout BEFORE logging is initialized
    _redirect_output( parsed_args )
    _init_logging( parsed_args ) # Initialize logging before anything else

    _init_configfile( parsed_args )
    
    _clean_paths( parsed_args, ilastik_dir )
    _update_debug_mode( parsed_args )
    _init_threading_monkeypatch()
    _validate_arg_compatibility( parsed_args )

    # Extra initialization functions.
    # Called during app startup.
    init_funcs = []
    lazyflow_config_fn = _prepare_lazyflow_config( parsed_args )
    if lazyflow_config_fn:
        init_funcs.append( lazyflow_config_fn )    

    load_fn = _prepare_auto_open_project( parsed_args )
    if load_fn:
        init_funcs.append( load_fn )    
    
    create_fn = _prepare_auto_create_new_project( parsed_args )
    if create_fn:
        init_funcs.append( create_fn )

    _enable_faulthandler()
    _init_excepthooks( parsed_args )
    eventcapture_mode, playback_args = _prepare_test_recording_and_playback( parsed_args )    

    if ilastik_config.getboolean("ilastik", "debug"):
        message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    else:
        message = 'Starting ilastik from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    
    # Headless launch
    if parsed_args.headless:
        from ilastik.shell.headless.headlessShell import HeadlessShell
        shell = HeadlessShell( workflow_cmdline_args )
        for f in init_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui
        sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, *init_funcs))
Esempio n. 2
0
def main( parsed_args, workflow_cmdline_args=[] ):
    _update_debug_mode( parsed_args )
    _init_logging( parsed_args ) # Initialize logging before anything else
    _init_threading_monkeypatch()
    _validate_arg_compatibility( parsed_args )

    # Extra initialization functions.
    # Called during app startup.
    init_funcs = []
    load_fn = _prepare_auto_open_project( parsed_args )
    if load_fn:
        init_funcs.append( load_fn )    
    
    create_fn = _prepare_auto_create_new_project( parsed_args )
    if create_fn:
        init_funcs.append( create_fn )

    _enable_faulthandler()
    _init_excepthooks( parsed_args )
    eventcapture_mode, playback_args = _prepare_test_recording_and_playback( parsed_args )    

    if ilastik_config.getboolean("ilastik", "debug"):
        logger.info("Starting ilastik in debug mode.")
    else:
        logger.info("Starting ilastik.")
    
    # Headless launch
    if parsed_args.headless:
        from ilastik.shell.headless.headlessShell import HeadlessShell
        shell = HeadlessShell( workflow_cmdline_args )
        for f in init_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui
        sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, *init_funcs))
Esempio n. 3
0
def main( parsed_args, workflow_cmdline_args=[] ):
    this_path = os.path.dirname(__file__)
    ilastik_dir = os.path.abspath(os.path.join(this_path, "..%s.." % os.path.sep))
    
    # If necessary, redirect stdout BEFORE logging is initialized
    _redirect_output( parsed_args )
    _init_logging( parsed_args ) # Initialize logging before anything else

    _init_configfile( parsed_args )
    
    _update_debug_mode( parsed_args )
    _init_threading_logging_monkeypatch()
    _init_threading_h5py_monkeypatch()
    _validate_arg_compatibility( parsed_args )

    # Extra initialization functions.
    # These are called during app startup, but before the shell is created.
    preinit_funcs = []
    preinit_funcs.append( _import_opengm ) # Must be first (or at least before vigra).
    
    lazyflow_config_fn = _prepare_lazyflow_config( parsed_args )
    if lazyflow_config_fn:
        preinit_funcs.append( lazyflow_config_fn )

    # More initialization functions.
    # These will be called AFTER the shell is created.
    # The shell is provided as a parameter to the function.
    postinit_funcs = []
    load_fn = _prepare_auto_open_project( parsed_args )
    if load_fn:
        postinit_funcs.append( load_fn )
    
    create_fn = _prepare_auto_create_new_project( parsed_args )
    if create_fn:
        postinit_funcs.append( create_fn )

    _enable_faulthandler()
    _init_excepthooks( parsed_args )
    eventcapture_mode, playback_args = _prepare_test_recording_and_playback( parsed_args )    

    if ilastik_config.getboolean("ilastik", "debug"):
        message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    else:
        message = 'Starting ilastik from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    
    # Headless launch
    if parsed_args.headless:
        # If any applet imports the GUI in headless mode, that's a mistake.
        # To help developers catch such mistakes, we replace PyQt with a dummy module, so we'll see import errors.
        import ilastik
        dummy_module_dir = os.path.join( os.path.split(ilastik.__file__)[0], "headless_dummy_modules" )
        sys.path.insert(0, dummy_module_dir)

        # Run pre-init
        for f in preinit_funcs:
            f()
        
        from ilastik.shell.headless.headlessShell import HeadlessShell
        shell = HeadlessShell( workflow_cmdline_args )

        # Run post-init
        for f in postinit_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui
        sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, preinit_funcs, postinit_funcs))
from ilastik.shell.gui.startShellGui import startShellGui
from predictionViewerWorkflow import PredictionViewerWorkflow

if __name__ == "__main__":
    startShellGui( PredictionViewerWorkflow )
Esempio n. 5
0
def main( parsed_args, workflow_cmdline_args=[] ):
    this_path = os.path.dirname(__file__)
    ilastik_dir = os.path.abspath(os.path.join(this_path, "..%s.." % os.path.sep))
    _update_debug_mode( parsed_args )
    
    # If necessary, redirect stdout BEFORE logging is initialized
    _redirect_output( parsed_args )
    _init_logging( parsed_args ) # Initialize logging before anything else

    _init_configfile( parsed_args )
    
    _init_threading_logging_monkeypatch()
    _init_threading_h5py_monkeypatch()
    _validate_arg_compatibility( parsed_args )

    # Extra initialization functions.
    # These are called during app startup, but before the shell is created.
    preinit_funcs = []
    preinit_funcs.append( _import_opengm ) # Must be first (or at least before vigra).
    
    lazyflow_config_fn = _prepare_lazyflow_config( parsed_args )
    if lazyflow_config_fn:
        preinit_funcs.append( lazyflow_config_fn )

    # More initialization functions.
    # These will be called AFTER the shell is created.
    # The shell is provided as a parameter to the function.
    postinit_funcs = []
    load_fn = _prepare_auto_open_project( parsed_args )
    if load_fn:
        postinit_funcs.append( load_fn )
    
    create_fn = _prepare_auto_create_new_project( parsed_args )
    if create_fn:
        postinit_funcs.append( create_fn )

    _enable_faulthandler()
    _init_excepthooks( parsed_args )
    eventcapture_mode, playback_args = _prepare_test_recording_and_playback( parsed_args )    

    if ilastik_config.getboolean("ilastik", "debug"):
        message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    else:
        message = 'Starting ilastik from "%s".' % ilastik_dir
        logger.info(message)
        print message     # always print the startup message
    
    # Headless launch
    if parsed_args.headless:
        # If any applet imports the GUI in headless mode, that's a mistake.
        # To help developers catch such mistakes, we replace PyQt with a dummy module, so we'll see import errors.
        import ilastik
        dummy_module_dir = os.path.join( os.path.split(ilastik.__file__)[0], "headless_dummy_modules" )
        sys.path.insert(0, dummy_module_dir)

        # Run pre-init
        for f in preinit_funcs:
            f()
        
        from ilastik.shell.headless.headlessShell import HeadlessShell
        shell = HeadlessShell( workflow_cmdline_args )

        # Run post-init
        for f in postinit_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui
        sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, preinit_funcs, postinit_funcs))
from ilastik.shell.gui.startShellGui import startShellGui
from layerViewerWorkflow import LayerViewerWorkflow

def debug_with_new(shell, workflow):
    """
    (Function for debug and testing.)
    """
    projFilePath = "/magnetic/test_project.ilp"

    # New project
    shell.createAndLoadNewProject(projFilePath)

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
    info = DatasetInfo()
    #info.filePath = '/magnetic/gigacube.h5'
    info.filePath = '/magnetic/5d.npy'
    #info.filePath = '/magnetic/synapse_small.npy'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)
    
    # Save the project
    shell.onSaveProjectActionTriggered()

if __name__ == "__main__":    
    startShellGui( LayerViewerWorkflow )
    #startShellGui( LayerViewerWorkflow, debug_with_new )
Esempio n. 7
0
                  help="specify a file which adds a hint overlay")
     
    parser.add_option("--pmapoverlay",
                  dest="pmapoverlayFile", default=None,
                  help="specify a file which adds a pmap overlay")

    options, args = parser.parse_args()
    
    if len(args)==0:
        workflowKwargs={'hintoverlayFile' : options.hintoverlayFile,
                        'pmapoverlayFile' : options.pmapoverlayFile }
        
        def loadProject(shell):
            pass
        
        startShellGui(functools.partial(CarvingWorkflow, **workflowKwargs),loadProject)
        
    elif len(args)==1:
        projectFilename = args[0]
        
        def loadProject(shell):
            shell.openProjectFile(projectFilename)
        
        workflowKwargs={'hintoverlayFile' : options.hintoverlayFile,
                        'pmapoverlayFile' : options.pmapoverlayFile }
        startShellGui( functools.partial(CarvingWorkflow, **workflowKwargs), loadProject)
        
    elif len(args) == 2:
        
        carvingGraphFilename = os.path.abspath(args[0]).replace("\\","/")
        projectFilename = args[1]
Esempio n. 8
0
    from optparse import OptionParser
    usage = "%prog [options] <carving graph filename> <project filename to be created>"
    parser = OptionParser(usage)

#    import sys
#    sys.argv.append("/magnetic/denk.h5")
#    sys.argv.append("/magnetic/carving_test.ilp")

    (options, args) = parser.parse_args()
    
    if len(args) == 2:
        carvingGraphFilename = args[0]
        projectFilename = args[1]
        def loadProject(shell, workflow):
            if not os.path.exists(projectFilename):
                shell.createAndLoadNewProject(projectFilename)
            else:
                shell.openProjectFile(projectFilename)
            workflow.setCarvingGraphFile(carvingGraphFilename)
            # Add a file
            from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
            info = DatasetInfo()
            info.filePath = carvingGraphFilename + "/graph/raw"
            opDataSelection = workflow.dataSelectionApplet.topLevelOperator
            opDataSelection.Dataset.resize(1)
            opDataSelection.Dataset[0].setValue(info)
            shell.setSelectedAppletDrawer(2)
        startShellGui( CarvingWorkflow, loadProject, windowTitle="Carving %s" % carvingGraphFilename,
                       workflowKwargs={'carvingGraphFile': carvingGraphFilename} )
    else:
        parser.error("incorrect number of arguments")
from ilastik.shell.gui.startShellGui import startShellGui
from labelImageViewerWorkflow import LabelImageViewerWorkflow

if __name__ == "__main__":
    startShellGui( LabelImageViewerWorkflow )
        init_funcs.append( loadProject )

    if parsed_args.playback_script is not None:
        from ilastik.utility.gui.eventRecorder import EventPlayer
        def play_recording(shell):
            player = EventPlayer(parsed_args.playback_speed)
            player.play_script(parsed_args.playback_script)
        init_funcs.append( partial(play_recording) )

    if parsed_args.exit_on_failure:
        old_excepthook = sys.excepthook
        def print_exc_and_exit(*args):
            old_excepthook(*args)
            sys.stderr.write("Exiting early due to an unhandled exception.  See error output above.\n")
            from PyQt4.QtGui import QApplication
            QApplication.exit(1)
        sys.excepthook = print_exc_and_exit

    from ilastik.shell.gui.startShellGui import startShellGui
    from pixelClassificationWorkflow import PixelClassificationWorkflow
    startShellGui( PixelClassificationWorkflow, *init_funcs )

    # Start the GUI with a debug project    

    #startShellGui( PixelClassificationWorkflow )    
    #startShellGui( PixelClassificationWorkflow, debug_with_existing )
    #startShellGui( PixelClassificationWorkflow, debug_with_new )

    # Test special transpose-on-import feature
    #startShellGui( PixelClassificationWorkflow, debug_with_imported )
Esempio n. 11
0
def main(parsed_args, workflow_cmdline_args=[], init_logging=True):
    """
    init_logging: Skip logging config initialization by setting this to False.
                  (Useful when opening multiple projects in a Python script.)
    """
    if parsed_args.headless:
        # If any applet imports the GUI in headless mode, that's a mistake.
        # To help developers catch such mistakes, we replace PyQt with a dummy
        #  module, so we'll see import errors.
        import ilastik
        dummy_module_dir = os.path.join(
            os.path.split(ilastik.__file__)[0], "headless_dummy_modules")
        sys.path.insert(0, dummy_module_dir)

    this_path = os.path.dirname(__file__)
    ilastik_dir = os.path.abspath(
        os.path.join(this_path, "..%s.." % os.path.sep))
    _import_h5py_with_utf8_encoding()
    _update_debug_mode(parsed_args)
    _update_hbp_mode(parsed_args)

    # If necessary, redirect stdout BEFORE logging is initialized
    _redirect_output(parsed_args)

    if init_logging:
        _init_logging(parsed_args)  # Initialize logging before anything else

    _init_configfile(parsed_args)

    _init_threading_logging_monkeypatch()

    # Extra initialization functions.
    # These are called during app startup, but before the shell is created.
    preinit_funcs = []
    # Must be first (or at least before vigra).
    preinit_funcs.append(_import_opengm)

    lazyflow_config_fn = _prepare_lazyflow_config(parsed_args)
    if lazyflow_config_fn:
        preinit_funcs.append(lazyflow_config_fn)

    # More initialization functions.
    # These will be called AFTER the shell is created.
    # The shell is provided as a parameter to the function.
    postinit_funcs = []
    load_fn = _prepare_auto_open_project(parsed_args)
    if load_fn:
        postinit_funcs.append(load_fn)

    create_fn = _prepare_auto_create_new_project(parsed_args)
    if create_fn:
        postinit_funcs.append(create_fn)

    faulthandler.enable()
    _init_excepthooks(parsed_args)

    if ilastik_config.getboolean("ilastik", "debug"):
        message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir
        logging.basicConfig(level=logging.DEBUG)
        logger.info(message)
        print(message)     # always print the startup message
    else:
        message = 'Starting ilastik from "%s".' % ilastik_dir
        logger.info(message)
        print(message)     # always print the startup message

    # Headless launch
    if parsed_args.headless:
        # Run pre-init
        for f in preinit_funcs:
            f()

        from ilastik.shell.headless.headlessShell import HeadlessShell
        shell = HeadlessShell(workflow_cmdline_args)

        # Run post-init
        for f in postinit_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui
        sys.exit(startShellGui(workflow_cmdline_args, preinit_funcs, postinit_funcs))
    # Set some features
    import numpy
    featApplet = workflow.applets[2]
    featureGui = featApplet.gui
    opFeatures = featApplet.topLevelOperator
    #                    sigma:   0.3    0.7    1.0    1.6    3.5    5.0   10.0
    selections = numpy.array([
        [True, False, False, False, False, False, False],
        [False, False, False, False, False, False, False],
        [False, False, False, False, False, False, False],  # ST EVs
        [False, False, False, False, False, False, False],
        [False, False, False, False, False, False, False],  # GGM
        [False, False, False, False, False, False, False]
    ])
    opFeatures.SelectionMatrix.setValue(selections)
    opFeatures.Scales.setValue(featureGui.ScalesList)
    opFeatures.FeatureIds.setValue(featureGui.FeatureIds)

    # Select the labeling drawer
    shell.setSelectedAppletDrawer(3)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui(PixelClassificationWithVigraWatershedWorkflow)
    #startShellGui( PixelClassificationWithVigraWatershedWorkflow, debug_with_new )
    #startShellGui( PixelClassificationWithVigraWatershedWorkflow, debug_with_existing )
from ilastik.shell.gui.startShellGui import startShellGui
from chaingraphTrackingWorkflow import ChaingraphTrackingWorkflow


debug_testing = False

if debug_testing:
    def test(shell, workflow):
        #projFilePath = '/home/bergs/Downloads/synapse_detection_training1.ilp'
        #projFilePath = '/home/bkausler/withLabelImageAndRegionCenters.ilp'
        #projFilePath = '/home/mschiegg/hufnagel2012-08-03/375-386_classification.ilp'        
        projFilePath = '/home/mschiegg/hufnagel2012-08-03/segmentation/375-386_tracking.ilp'
        
        #shell.createAndLoadNewProject(projFilePath)
        shell.openProjectFile(projFilePath)        
        #from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
        #info = DatasetInfo()
        #info.filePath = '/magnetic/gigacube.h5'
        #info.filePath = '/home/mschiegg/hufnagel2012-08-03/375-386diff_results_rgb.h5'
        #info.filePath = '/magnetic/synapse_small.npy'
        #info.filePath = '/magnetic/singleslice.h5'
        #opDataSelection = workflow.dataSelectionApplet.topLevelOperator
        #opDataSelection.Dataset.resize(1)
        #opDataSelection.Dataset[0].setValue(info)
        shell.setSelectedAppletDrawer(2)
    
    startShellGui( ChaingraphTrackingWorkflow, test )
    
else:
    startShellGui( ChaingraphTrackingWorkflow )
    # Import the project    
    shell.importProject(importedFilePath, newProjectFilePath)

    # Select the labeling drawer
    shell.setSelectedAppletDrawer(3)

if __name__ == "__main__":
    from optparse import OptionParser
    usage = "%prog [options] filename"
    parser = OptionParser(usage)

    (options, args) = parser.parse_args()

    # Start the GUI
    if len(args) == 1:
        def loadProject(shell, workflow):
            shell.openProjectFile(args[0])
        startShellGui( PixelClassificationWorkflow, loadProject )
    elif len(args) == 0:
        startShellGui( PixelClassificationWorkflow )
    else:
        parser.error("incorrect number of arguments")

    # Start the GUI with a debug project    
    #startShellGui( PixelClassificationWorkflow )    
    #startShellGui( PixelClassificationWorkflow, debug_with_existing )
    #startShellGui( PixelClassificationWorkflow, debug_with_new )

    # Test special transpose-on-import feature
    #startShellGui( PixelClassificationWorkflow, debug_with_imported )
 
Esempio n. 15
0
    #predictionInfo.filePath = '/magnetic/synapse_debug_data/block256_spots_predictions.h5/cube'
    #predictionInfo.filePath = '/magnetic/synapse_small_4d_synapse_predictions.h5/volume/data'
    predictionInfo.filePath = '/magnetic/validation_slices_20_40_3200_4000_1200_2000_pred.h5/volume/data'
    opPredDataSelection = workflow.predictionSelectionApplet.topLevelOperator
    opPredDataSelection.Dataset.resize(1)
    opPredDataSelection.Dataset[0].setValue(predictionInfo)

    # Select the feature drawer
    shell.setSelectedAppletDrawer(2)

def debug_with_existing(shell):
    """
    (Function for debug and testing.)
    """
    # Open an existing project
    #projFilePath = "/magnetic/objectLabels_good.ilp"
    #projFilePath = "/magnetic/object_prediction.ilp"
    projFilePath = "/magnetic/stuart_object_predictions.ilp"
    
    shell.openProjectFile(projFilePath)

    # Select a default drawer
    shell.setSelectedAppletDrawer(2)
    
    
if __name__ == '__main__':
    startShellGui( SynapseBlockwiseWorkflow )
    #startShellGui( SynapseBlockwiseWorkflow, debug_with_new )
    #startShellGui( SynapseBlockwiseWorkflow, debug_with_existing )

from ilastik.shell.gui.startShellGui import startShellGui
from synapsePixelClassificationWorkflow import SynapsePixelClassificationWorkflow

if __name__ == '__main__':
    startShellGui( SynapsePixelClassificationWorkflow )

Esempio n. 17
0
    sys.excepthook = print_exc_and_exit
    install_thread_excepthook()
# Show uncaught exceptions to the user (default behavior)
elif not ilastik_config.getboolean('ilastik', 'debug') and not parsed_args.headless:
    old_excepthook = sys.excepthook
    def exception_dialog(*exc_info):
        old_excepthook(*exc_info)
        try:
            from ilastik.shell.gui.startShellGui import shell
            shell.postErrorMessage( exc_info[0].__name__, str(exc_info[1]) )
        except:
            pass
    sys.excepthook = exception_dialog
    install_thread_excepthook()

if ilastik_config.getboolean("ilastik", "debug"):
    logger.info("Starting ilastik in debug mode.")

# Headless launch
if parsed_args.headless:
    from ilastik.shell.headless.headlessShell import HeadlessShell
    shell = HeadlessShell( workflow_cmdline_args )
    for f in init_funcs:
        f(shell)
# Normal launch
else:
    from ilastik.shell.gui.startShellGui import startShellGui
    sys.exit(startShellGui(workflow_cmdline_args, parsed_args.start_recording, *init_funcs))


    featureGui = workflow.featureSelectionApplet.gui
    opFeatures = workflow.featureSelectionApplet.topLevelOperator
    #                    sigma:   0.3    0.7    1.0    1.6    3.5    5.0   10.0
    selections = numpy.array( [[False, False, False,  True, False, False, False],
                               [False, False, False, False, False, False, False],
                               [False, False, False, False, False, False, False], # ST EVs
                               [False, False, False, False, False, False, False],
                               [False, False, False, False, False, False, False],  # GGM
                               [False, False, False, False, False, False, False]] )
    opFeatures.SelectionMatrix.setValue(selections)
    opFeatures.Scales.setValue( featureGui.ScalesList )
    opFeatures.FeatureIds.setValue( featureGui.FeatureIds )

    # Select the labeling drawer
    shell.setSelectedAppletDrawer(3)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    # Start the GUI
    #import os
    #os.execl('/home/akreshuk/voluminave/bin/activate')
    startShellGui( AutocontextClassificationWorkflow )

    # Start the GUI with a debug project    
    #startShellGui( AutocontextClassificationWorkflow, debug_with_existing )    
#    startShellGui( AutocontextClassificationWorkflow, debug_with_new )

Esempio n. 19
0
def main(parsed_args, workflow_cmdline_args=[], init_logging=True):
    """
    init_logging: Skip logging config initialization by setting this to False.
                  (Useful when opening multiple projects in a Python script.)
    """
    this_path = os.path.dirname(__file__)
    ilastik_dir = os.path.abspath(
        os.path.join(this_path, "..%s.." % os.path.sep))
    _import_h5py_with_utf8_encoding()
    _update_debug_mode(parsed_args)
    _update_hbp_mode(parsed_args)

    # If necessary, redirect stdout BEFORE logging is initialized
    _redirect_output(parsed_args)

    if init_logging:
        _init_logging(parsed_args)  # Initialize logging before anything else

    _init_configfile(parsed_args)

    _init_threading_logging_monkeypatch()

    _init_preferences()

    # Extra initialization functions.
    # These are called during app startup, but before the shell is created.
    preinit_funcs = []
    # Must be first (or at least before vigra).
    preinit_funcs.append(_import_opengm)

    lazyflow_config_fn = _prepare_lazyflow_config(parsed_args)
    if lazyflow_config_fn:
        preinit_funcs.append(lazyflow_config_fn)

    # More initialization functions.
    # These will be called AFTER the shell is created.
    # The shell is provided as a parameter to the function.
    postinit_funcs = []
    load_fn = _prepare_auto_open_project(parsed_args)
    if load_fn:
        postinit_funcs.append(load_fn)

    create_fn = _prepare_auto_create_new_project(parsed_args)
    if create_fn:
        postinit_funcs.append(create_fn)

    faulthandler.enable()
    _init_excepthooks(parsed_args)

    if ilastik_config.getboolean("ilastik", "debug"):
        message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir
        logging.basicConfig(level=logging.DEBUG)
        logger.info(message)
        print(message)  # always print the startup message
    else:
        message = 'Starting ilastik from "%s".' % ilastik_dir
        logger.info(message)
        print(message)  # always print the startup message

    # Headless launch
    if parsed_args.headless:
        # Run pre-init
        for f in preinit_funcs:
            f()

        from ilastik.shell.headless.headlessShell import HeadlessShell

        shell = HeadlessShell(workflow_cmdline_args)

        # Run post-init
        for f in postinit_funcs:
            f(shell)
        return shell
    # Normal launch
    else:
        from ilastik.shell.gui.startShellGui import startShellGui

        sys.exit(
            startShellGui(workflow_cmdline_args, preinit_funcs,
                          postinit_funcs))
from layerViewerWorkflow import LayerViewerWorkflow


def debug_with_new(shell, workflow):
    """
    (Function for debug and testing.)
    """
    projFilePath = "/magnetic/test_project.ilp"

    # New project
    shell.createAndLoadNewProject(projFilePath)

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
    info = DatasetInfo()
    #info.filePath = '/magnetic/gigacube.h5'
    info.filePath = '/magnetic/5d.npy'
    #info.filePath = '/magnetic/synapse_small.npy'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui(LayerViewerWorkflow)
    #startShellGui( LayerViewerWorkflow, debug_with_new )
Esempio n. 21
0
#!/usr/bin/env python

from ilastik.shell.gui.startShellGui import startShellGui
from optparse import OptionParser
import ilastik.workflows
from ilastik.workflow import getWorkflowFromName

usage = "%prog [options] <project file>"
parser = OptionParser(usage)
parser.add_option("--workflow",
              dest="workflow", default=None,
              help="specify a workflow that should be loaded")
options, args = parser.parse_args()

if len(args)==0:
    startShellGui(workflowClass=options.workflow)

elif len(args)==1:
    def loadProject(shell):
        shell.openProjectFile(args[0])
    workflowClass = getWorkflowFromName(options.workflow)
    startShellGui(workflowClass,loadProject)
from ilastik.shell.gui.startShellGui import startShellGui
from ilastik.shell.gui.eventRecorder import EventRecorder
from thresholdMaskingWorkflow import ThresholdMaskingWorkflow

debug_testing = False
if debug_testing:
    
    def test(shell):
        projFilePath = '/Users/bergs/MyProject.ilp'
        shell.openProjectFile(projFilePath)
        eventRecorder = EventRecorder( parent=shell )
        eventRecorder.start()
    
    startShellGui( ThresholdMaskingWorkflow, test )
else:
    startShellGui( ThresholdMaskingWorkflow )

    featApplet = workflow.applets[2]
    featureGui = featApplet.gui
    opFeatures = featApplet.topLevelOperator
    #                    sigma:   0.3    0.7    1.0    1.6    3.5    5.0   10.0
    selections = numpy.array( [[True, False, False,  False, False, False, False],
                               [False, False, False, False, False, False, False],
                               [False, False, False, False, False, False, False], # ST EVs
                               [False, False, False, False, False, False, False],
                               [False, False, False, False, False, False, False],  # GGM
                               [False, False, False, False, False, False, False]] )
    opFeatures.SelectionMatrix.setValue(selections)
    opFeatures.Scales.setValue( featureGui.ScalesList )
    opFeatures.FeatureIds.setValue( featureGui.FeatureIds )

    # Select the labeling drawer
    shell.setSelectedAppletDrawer(3)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui( PixelClassificationWithVigraWatershedWorkflow )
    #startShellGui( PixelClassificationWithVigraWatershedWorkflow, debug_with_new )
    #startShellGui( PixelClassificationWithVigraWatershedWorkflow, debug_with_existing )





from ilastik.shell.gui.startShellGui import startShellGui
from featureSelectionWorkflow import FeatureSelectionWorkflow

debug_testing = False
if debug_testing:
    def test(shell, workflow):
        #projFilePath = '/home/bergs/Downloads/synapse_detection_training1.ilp'
        projFilePath = '/magnetic/MyProject.ilp'

        shell.openProjectFile(projFilePath)
    
    startShellGui( FeatureSelectionWorkflow, test )

else:
    startShellGui( FeatureSelectionWorkflow )
Esempio n. 25
0
                  help="specify a file which adds a hint overlay")
     
    parser.add_option("--pmapoverlay",
                  dest="pmapoverlayFile", default=None,
                  help="specify a file which adds a pmap overlay")

    options, args = parser.parse_args()
    
    if len(args)==0:
        workflowKwargs={'hintoverlayFile' : options.hintoverlayFile,
                        'pmapoverlayFile' : options.pmapoverlayFile }
        
        def loadProject(shell):
            pass
        
        startShellGui(functools.partial(CarvingWorkflow, **workflowKwargs),loadProject)
        
    elif len(args)==1:
        projectFilename = args[0]
        
        def loadProject(shell):
            shell.openProjectFile(projectFilename)
        
        workflowKwargs={'hintoverlayFile' : options.hintoverlayFile,
                        'pmapoverlayFile' : options.pmapoverlayFile }
        startShellGui( functools.partial(CarvingWorkflow, **workflowKwargs), loadProject)
        
    elif len(args) == 2:
        
        carvingGraphFilename = os.path.abspath(args[0]).replace("\\","/")
        projectFilename = args[1]
from ilastik.shell.gui.startShellGui import startShellGui
from deviationFromMeanWorkflow import DeviationFromMeanWorkflow

debug_testing = False
if debug_testing:
    def test(shell):
        #projFilePath = '/home/bergs/Downloads/synapse_detection_training1.ilp'
        projFilePath = '/home/bergs/MyProject.ilp'

        shell.openProjectFile(projFilePath)
    
    startShellGui( DeviationFromMeanWorkflow, test )

else:
    startShellGui( DeviationFromMeanWorkflow )
from ilastik.shell.gui.startShellGui import startShellGui
from thresholdMaskingWorkflow import ThresholdMaskingWorkflow

debug_testing = True
if debug_testing:

    def test(shell):
        import h5py

        #projFilePath = '/home/bergs/Downloads/synapse_detection_training1.ilp'
        projFilePath = '/home/bergs/gigacube.ilp'

        shell.openProjectFile(projFilePath)

    startShellGui(ThresholdMaskingWorkflow, test)

else:
    startShellGui(ThresholdMaskingWorkflow)
def debug_with_new(shell, workflow):
    """
    (Function for debug and testing.)
    """
    projFilePath = "/magnetic/test_watershed_project.ilp"

    # New project
    shell.createAndLoadNewProject(projFilePath)

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
    info = DatasetInfo()
    #info.filePath = '/magnetic/gigacube.h5'
    #info.filePath = '/magnetic/synapse_small.npy'
    info.filePath = '/magnetic/synapse_small.npy_results.h5'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)

    # Select the watershed drawer
    shell.setSelectedAppletDrawer(1)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui(VigraWatershedWorkflow)
    #startShellGui( VigraWatershedWorkflow, debug_with_new )
Esempio n. 29
0
    sys.excepthook = print_exc_and_exit
    install_thread_excepthook()
# Show uncaught exceptions to the user (default behavior)
elif not ilastik_config.getboolean('ilastik', 'debug') and not parsed_args.headless:
    old_excepthook = sys.excepthook
    def exception_dialog(*exc_info):
        old_excepthook(*exc_info)
        try:
            from ilastik.shell.gui.startShellGui import shell
            shell.postErrorMessage( exc_info[0].__name__, str(exc_info[1]) )
        except:
            pass
    sys.excepthook = exception_dialog
    install_thread_excepthook()

if ilastik_config.getboolean("ilastik", "debug"):
    logger.info("Starting ilastik in debug mode.")

# Headless launch
if parsed_args.headless:
    from ilastik.shell.headless.headlessShell import HeadlessShell
    shell = HeadlessShell( workflow_cmdline_args )
    for f in init_funcs:
        f(shell)
# Normal launch
else:
    from ilastik.shell.gui.startShellGui import startShellGui
    sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, *init_funcs))


Esempio n. 30
0
        sys.stderr.write("Exiting early due to an unhandled exception.  See error output above.\n")
        QApplication.exit(1)
    sys.excepthook = print_exc_and_exit
    install_thread_excepthook()
# Show uncaught exceptions to the user (default behavior)
elif not ilastik_config.getboolean('ilastik', 'debug') and not parsed_args.headless:
    old_excepthook = sys.excepthook
    def exception_dialog(*args):
        old_excepthook(*args)
        try:
            from ilastik.shell.gui.startShellGui import shell
            shell.postErrorMessage(args[0].__name__, args[1].message)
        except:
            pass
    sys.excepthook = exception_dialog
    install_thread_excepthook()

if ilastik_config.getboolean("ilastik", "debug"):
    logger.info("Starting ilastik in debug mode.")

# Headless launch
if parsed_args.headless:
    from ilastik.shell.headless.headlessShell import HeadlessShell
    shell = HeadlessShell( workflow_cmdline_args )
    for f in init_funcs:
        f(shell)
# Normal launch
else:
    from ilastik.shell.gui.startShellGui import startShellGui
    sys.exit(startShellGui(workflow_cmdline_args, parsed_args.start_recording, *init_funcs))
from ilastik.shell.gui.startShellGui import startShellGui
from fillMissingSlicesWorkflow import FillMissingSlicesWorkflow

debug_testing = False
if debug_testing:
    def test(shell, workflow):
        #projFilePath = '/home/bergs/Downloads/synapse_detection_training1.ilp'
        projFilePath = '/magnetic/MyProject.ilp'

        shell.openProjectFile(projFilePath)
    
    startShellGui( FillMissingSlicesWorkflow, test )

else:
    startShellGui( FillMissingSlicesWorkflow )
Esempio n. 32
0
from ilastik.shell.gui.startShellGui import startShellGui
from stopWatchWorkflow import StopWatchWorkflow

startShellGui( StopWatchWorkflow )
    #info.filePath = '/magnetic/synapse_small.npy'
    info.filePath = '/magnetic/synapse_small.npy_results.h5'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)

    # Select the watershed drawer
    shell.setSelectedAppletDrawer(1)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    from optparse import OptionParser
    usage = "%prog [options] filename"
    parser = OptionParser(usage)

    (options, args) = parser.parse_args()

    # Start the GUI
    if len(args) == 1:
        def loadProject(shell):
            shell.openProjectFile(args[0])
        startShellGui( VigraWatershedWorkflow, loadProject )
    elif len(args) == 0:
        startShellGui( VigraWatershedWorkflow )
    else:
        parser.error("incorrect number of arguments")
    shell.setSelectedAppletDrawer(1)


def debug_with_new(shell, workflow):
    """
    (Function for debug and testing.)
    """
    projFilePath = "/magnetic/test_project.ilp"

    # New project
    shell.createAndLoadNewProject(projFilePath)

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
    info = DatasetInfo()
    info.filePath = '/magnetic/gigacube.h5'
    #info.filePath = '/magnetic/synapse_small.npy'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui(LabelingWorkflow)
    #startShellGui( LabelingWorkflow, debug_with_new )
    #startShellGui( LabelingWorkflow, debug_with_existing )
Esempio n. 35
0
    # Select the labeling drawer
    shell.setSelectedAppletDrawer(3)


if __name__ == "__main__":
    from optparse import OptionParser
    usage = "%prog [options] filename"
    parser = OptionParser(usage)

    (options, args) = parser.parse_args()

    # Start the GUI
    if len(args) == 1:

        def loadProject(shell, workflow):
            shell.openProjectFile(args[0])

        startShellGui(PixelClassificationWorkflow, loadProject)
    elif len(args) == 0:
        startShellGui(PixelClassificationWorkflow)
    else:
        parser.error("incorrect number of arguments")

    # Start the GUI with a debug project
    #startShellGui( PixelClassificationWorkflow )
    #startShellGui( PixelClassificationWorkflow, debug_with_existing )
    #startShellGui( PixelClassificationWorkflow, debug_with_new )

    # Test special transpose-on-import feature
    #startShellGui( PixelClassificationWorkflow, debug_with_imported )
    """
    (Function for debug and testing.)
    """
    projFilePath = "/magnetic/test_watershed_project.ilp"

    # New project
    shell.createAndLoadNewProject(projFilePath)

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
    info = DatasetInfo()
    #info.filePath = '/magnetic/gigacube.h5'
    #info.filePath = '/magnetic/synapse_small.npy'
    info.filePath = '/magnetic/synapse_small.npy_results.h5'
    #info.filePath = '/magnetic/singleslice.h5'
    opDataSelection = workflow.dataSelectionApplet.topLevelOperator
    opDataSelection.Dataset.resize(1)
    opDataSelection.Dataset[0].setValue(info)

    # Select the watershed drawer
    shell.setSelectedAppletDrawer(1)

    # Save the project
    shell.onSaveProjectActionTriggered()


if __name__ == "__main__":
    startShellGui( VigraWatershedWorkflow )
    #startShellGui( VigraWatershedWorkflow, debug_with_new )

Esempio n. 37
0
onfinish = None
if parsed_args.exit_on_success:
    onfinish = QApplication.quit

if parsed_args.playback_script is not None:
    from ilastik.utility.gui.eventRecorder import EventPlayer
    def play_recording(shell):
        player = EventPlayer(parsed_args.playback_speed)
        player.play_script(parsed_args.playback_script, onfinish)
    init_funcs.append( partial(play_recording) )

if parsed_args.exit_on_failure:
    old_excepthook = sys.excepthook
    def print_exc_and_exit(*args):
        old_excepthook(*args)
        sys.stderr.write("Exiting early due to an unhandled exception.  See error output above.\n")
        QApplication.exit(1)
    sys.excepthook = print_exc_and_exit
    install_thread_excepthook()

# Import all possible workflows so they are registered with the base class
import ilastik.workflows

# Ask the base class to give us the workflow type
from ilastik.workflow import Workflow
workflowClass = Workflow.getSubclass(parsed_args.workflow)

# Launch the GUI
from ilastik.shell.gui.startShellGui import startShellGui
sys.exit( startShellGui( workflowClass, *init_funcs ) )
    from optparse import OptionParser
    usage = "%prog [options] filename"
    parser = OptionParser(usage)
    parser.add_option("-b", "--binary",
                      action="store_true",
                      dest="binary",
                      default=False,
                      help="use binary workflow")

    (options, args) = parser.parse_args()

    #options.binary = True

    if options.binary:
        workflow = binary_workflow
    else:
        workflow = pixel_workflow

    # Start the GUI
    if len(args) == 1:
        def loadProject(shell):
            shell.openProjectFile(args[0])
        startShellGui(workflow, loadProject)
    elif len(args) == 0:
        startShellGui(workflow)
        #startShellGui(workflow, debug_with_new)
        #startShellGui(workflow, debug_with_existing)
    else:
        parser.error("incorrect number of arguments")
Esempio n. 39
0
    init_funcs.append(loadProject)

onfinish = None
if parsed_args.exit_on_success:
    onfinish = QApplication.quit

if parsed_args.playback_script is not None:
    def play_recording(shell):
        player = EventPlayer(parsed_args.playback_speed)
        player.play_script(parsed_args.playback_script, onfinish)
    init_funcs.append( partial(play_recording) )

if parsed_args.exit_on_failure:
    old_excepthook = sys.excepthook
    def print_exc_and_exit(*args):
        old_excepthook(*args)
        sys.stderr.write("Exiting early due to an unhandled exception.  See error output above.\n")
        QApplication.exit(1)
    sys.excepthook = print_exc_and_exit
    install_thread_excepthook()

if parsed_args.debug:
    ilastik_config.set('ilastik', 'debug', 'true')
    
if ilastik_config.getboolean("ilastik", "debug"):
    logger.info("Starting ilastik in debug mode.")

sys.exit(startShellGui(None,*init_funcs))

    
    shell.createAndLoadNewProject(projFilePath)
    workflow = shell.projectManager.workflow

    # Add a file
    from ilastik.applets.dataSelection.opDataSelection import DatasetInfo

    rawInfo = DatasetInfo()
    #rawInfo.filePath = '/magnetic/synapse_debug_data/block256.h5/cube'
    #rawInfo.filePath = '/magnetic/synapse_small_4d.h5/volume/data'
    rawInfo.filePath = '/magnetic/validation_slices_20_40_3200_4000_1200_2000.h5/volume/data'
    opRawDataSelection = workflow.rawDataSelectionApplet.topLevelOperator
    opRawDataSelection.Dataset.resize(1)
    opRawDataSelection.Dataset[0].setValue(rawInfo)

    predictionInfo = DatasetInfo()
    #predictionInfo.filePath = '/magnetic/synapse_debug_data/block256_spots_predictions.h5/cube'
    #predictionInfo.filePath = '/magnetic/synapse_small_4d_synapse_predictions.h5/volume/data'
    predictionInfo.filePath = '/magnetic/validation_slices_20_40_3200_4000_1200_2000_pred.h5/volume/data'
    opPredDataSelection = workflow.predictionSelectionApplet.topLevelOperator
    opPredDataSelection.Dataset.resize(1)
    opPredDataSelection.Dataset[0].setValue(predictionInfo)

    # Select the feature drawer
    shell.setSelectedAppletDrawer(2)
    
if __name__ == '__main__':
    startShellGui( SynapseObjectClassificationWorkflow )
    #startShellGui( SynapseObjectClassificationWorkflow, debug_with_new )
    #startShellGui( SynapseObjectClassificationWorkflow, debug_with_existing )