def on_save_workspace(self, evt):
     p = Properties.getInstance()
     dlg = wx.FileDialog(self, message="Save workspace as...", defaultDir=os.getcwd(),
                         defaultFile='%s_%s.workspace'%(os.path.splitext(os.path.split(p._filename)[1])[0], p.image_table),
                         style=wx.SAVE|wx.FD_OVERWRITE_PROMPT|wx.FD_CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         wx.GetApp().save_workspace(dlg.GetPath())
    def OnInit(self):
        """Initialize CPA
        """

        """List of tables created by the user during this session"""
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(), splashimage.GetHeight(), 255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy()  # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog

            splash.Destroy()
            if not show_load_dialog():
                logging.error("CellProfiler Analyst requires a properties file. Exiting.")
                return False
        self.frame = MainGUI(p, None, size=(860, -1))
        self.frame.Show(True)
        db = cpa.dbconnect.DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=False)
        javabridge.attach()
        javabridge.activate_awt()

        try:
            if __version__ != -1:
                import cellprofiler.utilities.check_for_updates as cfu

                cfu.check_for_updates(
                    "http://cellprofiler.org/CPAupdate.html",
                    max(__version__, cpaprefs.get_skip_version()),
                    new_version_cb,
                    user_agent="CPAnalyst/2.0.%d" % (__version__),
                )
        except ImportError:
            logging.warn(
                "CPA was unable to check for updates. Could not import cellprofiler.utilities.check_for_updates."
            )

        return True
 def on_save_properties(self, evt):
     p = Properties.getInstance()
     dirname, filename = os.path.split(p._filename)
     ext = os.path.splitext(p._filename)[-1]
     dlg = wx.FileDialog(self, message="Save properties as...", defaultDir=dirname,
                         defaultFile=filename, wildcard=ext,
                         style=wx.SAVE|wx.FD_OVERWRITE_PROMPT|wx.FD_CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         p.save_file(dlg.GetPath())
 def clear_link_tables(self, evt=None):
     p = Properties.getInstance()
     dlg = wx.MessageDialog(self, 'This will delete the tables '
                 '"%s" and "%s" from your database. '
                 'CPA will automatically recreate these tables as it '
                 'discovers how your database is linked. Are you sure you '
                 'want to proceed?'
                 %(p.link_tables_table, p.link_columns_table),
                 'Clear table linking information?',
                 wx.YES_NO|wx.NO_DEFAULT|wx.ICON_QUESTION)
     response = dlg.ShowModal()
     if response != wx.ID_YES:
         return
     db = dbconnect.DBConnect.getInstance()
     db.execute('DROP TABLE IF EXISTS %s'%(p.link_tables_table))
     db.execute('DROP TABLE IF EXISTS %s'%(p.link_columns_table))
     db.Commit()
def start():
    # Init
    p = Properties.getInstance()
    p.LoadFile("/vagrant/data/23_classes/az-dnaonly.properties")
    # p.LoadFile('/vagrant/data/5_classes/2010_08_21_Malaria_MartiLab_Test_2011_05_27_DIC+Alexa.properties')
    # p.LoadFile('/vagrant/data/cpa_example/example.properties')

    db = dbconnect.DBConnect.getInstance()
    dm = DataModel.getInstance()

    classifier = Classifier(properties=p)  # Create a classifier with p
    classifier.LoadTrainingSet("/vagrant/data/23_classes/Anne_DNA_66.txt")
    # classifier.LoadTrainingSet('/vagrant/data/5_classes/MyTrainingSet_AllStages_Half.txt')
    # classifier.LoadTrainingSet('/vagrant/data/cpa_example/MyTrainingSet.txt')

    settings["p"] = p
    settings["db"] = db
    settings["dm"] = dm
    settings["classifier"] = classifier
    # send everything to logfile
    sys.stderr = Stderr()
    sys.stdout = sys.stderr

if hasattr(sys, 'frozen') and sys.platform.startswith('win'):
    # on windows, log to a file (Mac goes to console)
    setup_frozen_logging()
logging.basicConfig(level=logging.DEBUG)

# Handles args to MacOS "Apps"
if len(sys.argv) > 1 and sys.argv[1].startswith('-psn'):
    del sys.argv[1]

if len(sys.argv) > 1:
    # Load a properties file if passed in args
    p = Properties.getInstance()
    if sys.argv[1] == '--incell':
        # GE Incell xml wrapper
        # LOOP
        p.LoadIncellFiles(sys.argv[2], sys.argv[3], sys.argv[4:])
    else:
        p.LoadFile(sys.argv[1])

import threading
from cpa.classifier import Classifier
from cpa.tableviewer import TableViewer
from cpa.plateviewer import PlateViewer
from cpa.imageviewer import ImageViewer
from cpa.boxplot import BoxPlot
from cpa.scatter import Scatter
from cpa.histogram import Histogram
    def Start(self):
        '''Initialize CPA
        '''

        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(),
                                          255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy() # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN |
                                wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                splash.Destroy()
                example_link_address = 'cellprofiler.org'
                dlg = wx.MessageDialog(None, 'CellProfiler Analyst requires a properties file. Download an example at %s' % (
                                           example_link_address), 'Properties file required', wx.OK)
                response = dlg.ShowModal()
                logging.error('CellProfiler Analyst requires a properties file. Exiting.')
                return False

        self.frame = MainGUI(p, None, size=(1000,-1))

        db = DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=True)

        # removes the log4j warnings
        javabridge.attach()

        # TODO: check for updates
        try:
            if __version__ != -1:
                import cpa.util.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/updates/CPA.html',
                                      max(__version__, cpa.cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/%s'%(__version__))
        except ImportError:
            logging.warn("CPA was unable to check for updates. Could not import cpa.util.check_for_updates.")

        self.frame.Show() # Show frame
        return True
Example #8
0
    def Start(self):
        '''Initialize CPA
        '''
        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = cpa.icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(), 255, 255,
                                          255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy()  # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(
            splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 2000,
            None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                splash.Destroy()
                example_link_address = 'cellprofiler.org'
                dlg = wx.MessageDialog(
                    None,
                    'CellProfiler Analyst requires a properties file. Download an example at %s'
                    % (example_link_address), 'Properties file required',
                    wx.OK)
                response = dlg.ShowModal()
                logging.error(
                    'CellProfiler Analyst requires a properties file. Exiting.'
                )
                return False

        self.frame = MainGUI(p, None, size=(1000, -1))
        # def show_frame():
        #     import time
        #     res = self.frame.Show()
        # wx.CallAfter(show_frame)
        db = cpa.dbconnect.DBConnect.getInstance()
        # Black magic: Bus errors occur on Mac OS X if we wait until
        # the JVM or the wx event look has started to connect. But it
        # has to be done after we have read the properties file. So we
        # do it here.
        db.connect()
        db.register_gui_parent(self.frame)

        # The JVM has to be started after db.connect(), otherwise bus errors
        # occur on Mac OS X.
        javabridge.start_vm(class_path=bioformats.JARS, run_headless=True)

        # removes the log4j warnings
        from bioformats import log4j
        log4j.basic_config()
        javabridge.attach()
        # javabridge.activate_awt()

        try:
            if __version__ != -1:
                import cpa.util.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/CPAupdate.html',
                                      max(__version__,
                                          cpa.cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/%s' %
                                      (__version__))
        except ImportError:
            logging.warn(
                "CPA was unable to check for updates. Could not import cpa.util.check_for_updates."
            )

        self.frame.Show()  # Show frame
        return True
Example #9
0
    sys.stderr = Stderr()
    sys.stdout = sys.stderr


if hasattr(sys, 'frozen') and sys.platform.startswith('win'):
    # on windows, log to a file (Mac goes to console)
    setup_frozen_logging()
logging.basicConfig(level=logging.DEBUG)

# Handles args to MacOS "Apps"
if len(sys.argv) > 1 and sys.argv[1].startswith('-psn'):
    del sys.argv[1]

if len(sys.argv) > 1:
    # Load a properties file if passed in args
    p = Properties.getInstance()
    if sys.argv[1] == '--incell':
        # GE Incell xml wrapper
        # LOOP
        p.LoadIncellFiles(sys.argv[2], sys.argv[3], sys.argv[4:])
    else:
        p.LoadFile(sys.argv[1])

import threading
from cpa.classifier import Classifier
from cpa.tableviewer import TableViewer
from cpa.plateviewer import PlateViewer
from cpa.imageviewer import ImageViewer
from cpa.imagegallery import ImageGallery
from cpa.boxplot import BoxPlot
from cpa.scatter import Scatter