Esempio n. 1
0
    def on_loadImagesPushButton_clicked(self):
        ''' Load the current batch of images into the list
        '''

        selmodel = self.ui.imageListView.selectionModel()
        self.disconnect(
            selmodel,
            QtCore.SIGNAL(
                "selectionChanged(const QItemSelection &, const QItemSelection &)"
            ), self.onSelectionChanged)
        ImageViewerWindow.on_loadImagesPushButton_clicked(self)
        selmodel = self.ui.imageListView.selectionModel()
        self.connect(
            selmodel,
            QtCore.SIGNAL(
                "selectionChanged(const QItemSelection &, const QItemSelection &)"
            ), self.onSelectionChanged)
Esempio n. 2
0
    def registerPage(self, wizardPage):
        '''
        '''

        wizardPage.registerField(
            wizardPage.wizard().param("raw_reference_file*"),
            self.ui.referenceLineEdit)
        wizardPage.registerField(wizardPage.wizard().param("curr_apix*"),
                                 self.ui.referencePixelSizeDoubleSpinBox,
                                 "value",
                                 QtCore.SIGNAL('valueChanged(double)'))
Esempio n. 3
0
    def setup(self):
        ''' Display specific setup
        '''

        selmodel = self.ui.imageListView.selectionModel()
        self.connect(
            selmodel,
            QtCore.SIGNAL(
                "selectionChanged(const QItemSelection &, const QItemSelection &)"
            ), self.onSelectionChanged)
        self.ui.imageListView.setStyleSheet(
            'QListView::item:selected{ color: #008000; border: 3px solid #6FFF00; }'
        )
Esempio n. 4
0
    def registerPage(self, wizardPage):
        '''
        '''

        wizardPage.registerField("sessions*", self, "selected",
                                 QtCore.SIGNAL('selectionChanged()'))
Esempio n. 5
0
    def __init__(self, parent=None):
        "Initialize a image display window"

        QtGui.QMainWindow.__init__(self, parent)

        # Setup logging
        root = logging.getLogger()
        while len(root.handlers) > 0:
            root.removeHandler(root.handlers[0])
        h = logging.StreamHandler()
        h.setFormatter(logging.Formatter('%(message)s'))
        root.addHandler(h)

        # Build window
        _logger.info("\rBuilding main window ...")
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Setup variables
        self.lastpath = str(QtCore.QDir.currentPath())
        self.coordinates_files = []
        self.stack_file = ""
        self.inifile = ""  #'ara_view.ini'
        self.data = None
        self.header = None
        self.group_indices = None
        self.label_cols = []
        self.rtsq_cols = []
        self.select_col = -1
        self.markers = ['s', 'o', '^', '>', 'v', 'd', 'p', 'h', '8', '+', 'x']
        self.selectedImage = None

        # Setup Plotting View
        self.fig = Figure((6.0, 4.0))  #, dpi=self.ui.dpiSpinBox.value())
        self.ui.canvas = FigureCanvas(self.fig)
        self.ui.canvas.setParent(self.ui.centralwidget)
        self.axes = self.fig.add_subplot(111)
        self.ui.centralHLayout.addWidget(self.ui.canvas)
        self.ui.centralHLayout.setStretchFactor(self.ui.canvas, 4)

        #self.ui.canvas.mpl_connect('motion_notify_event', self.onHover)
        self.ui.canvas.mpl_connect('pick_event', self.displayLabel)
        self.annotation = None

        # Setup Navigation Tool Bar
        self.ui.mpl_toolbar = NavigationToolbar(self.ui.canvas, self)
        self.ui.mpl_toolbar.hide()
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.ui.mpl_toolbar)
        if not hasattr(self.ui.mpl_toolbar, 'edit_parameters'):
            self.ui.toolBar.removeAction(self.ui.actionShow_Options)

        # Custom Actions
        self.ui.toggleImageDockAction = self.ui.imageDockWidget.toggleViewAction(
        )
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/mini/mini/image.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.toggleImageDockAction.setIcon(icon8)
        self.ui.toolBar.insertAction(self.ui.actionShow_Options,
                                     self.ui.toggleImageDockAction)
        self.ui.imageDockWidget.hide()
        self.ui.toggleImageDockAction.setEnabled(False)

        action = self.ui.plotDockWidget.toggleViewAction()
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/mini/mini/chart_line.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        action.setIcon(icon8)
        self.ui.toolBar.insertAction(self.ui.actionShow_Options, action)

        self.ui.toggleAdvancedDockAction = self.ui.advancedDockWidget.toggleViewAction(
        )
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/mini/mini/cog_edit.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.toggleAdvancedDockAction.setIcon(icon8)
        self.ui.toolBar.insertAction(self.ui.actionShow_Options,
                                     self.ui.toggleAdvancedDockAction)
        self.ui.advancedDockWidget.hide()

        action = self.ui.fileDockWidget.toggleViewAction()
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/mini/mini/folder_explore.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        action.setIcon(icon8)
        self.ui.toolBar.insertAction(self.ui.actionShow_Options, action)

        # Create advanced settings

        property.setView(self.ui.advancedSettingsTreeView)
        self.advanced_settings, self.advanced_names = self.ui.advancedSettingsTreeView.model(
        ).addOptionList(self.advancedSettings())
        self.ui.advancedSettingsTreeView.setStyleSheet(
            'QTreeView::item[readOnly="true"]{ color: #000000; }')

        for i in xrange(
                self.ui.advancedSettingsTreeView.model().rowCount() - 1, 0,
                -1):
            if self.ui.advancedSettingsTreeView.model().index(
                    i, 0).internalPointer().isReadOnly(
                    ):  # Hide widget items (read only)
                self.ui.advancedSettingsTreeView.setRowHidden(
                    i, QtCore.QModelIndex(), True)

        # Subset List
        self.subsetListModel = QtGui.QStandardItemModel()
        self.ui.subsetListView.setModel(self.subsetListModel)

        # File List
        self.fileListModel = QtGui.QStandardItemModel()
        self.ui.fileTableView.setModel(self.fileListModel)
        self.fileListModel.setHorizontalHeaderLabels(['file', 'items'])
        self.connect(
            self.ui.fileTableView.selectionModel(),
            QtCore.SIGNAL(
                "selectionChanged(const QItemSelection &, const QItemSelection &)"
            ), self.openSelectedFile)

        # Plot

        # Create advanced settings

        #property.setView(self.ui.advancedSettingsTreeView)
        #self.advanced_settings, self.advanced_names = self.ui.advancedSettingsTreeView.model().addOptionList(self.advancedSettings())
        #self.ui.advancedSettingsTreeView.setStyleSheet('QTreeView::item[readOnly="true"]{ color: #000000; }')

        #for i in xrange(self.ui.advancedSettingsTreeView.model().rowCount()-1, 0, -1):
        #    if self.ui.advancedSettingsTreeView.model().index(i, 0).internalPointer().isReadOnly(): # Hide widget items (read only)
        #        self.ui.advancedSettingsTreeView.setRowHidden(i, QtCore.QModelIndex(), True)

        # Load the settings
        _logger.info("\rLoading settings ...")
        self.loadSettings()
Esempio n. 6
0
    def __init__(self, screen_shot_file=None, parent=None):
        '''
        '''

        QtGui.QWizard.__init__(self, parent)

        self.ui = Ui_ProjectWizard()
        self.ui.setupUi(self)
        #self.subPages={}
        self.lastmicpath = str(QtCore.QDir.currentPath())
        self.lastgainpath = str(QtCore.QDir.currentPath())
        self.micrograph_files = []
        self.gain_files = []
        self.parameters = []
        self.screen_shot_file = screen_shot_file
        self.helpDialog = HelpDialog(self)
        self.default_spider_path = '/guam.raid.cluster.software/spider.21.00/'

        version = arachnid.__version__
        n = version.find('_')
        if n != -1: version = version[:n]
        self.setWindowTitle("Arachnid - Workflow Creation Wizard - v%s" %
                            version)
        self.docs_url = ""

        self.setPixmap(
            QtGui.QWizard.WatermarkPixmap,
            QtGui.QPixmap(':/icons/logo/ArachnidLogoWindow_small.png'
                          ))  #:/icons/icons/icon256x256.png'))
        self.setPixmap(
            QtGui.QWizard.BackgroundPixmap,
            QtGui.QPixmap(':/icons/logo/ArachnidLogoWindow_small.png'
                          ))  #:/icons/icons/icon256x256.png'))

        ########################################################################################################################################
        ###### Introduction Page
        ########################################################################################################################################
        self.ui.introductionPage.setTitle('Welcome to Arachnid - v%s' %
                                          version)
        if screen_shot_file:
            self.ui.screenShotCheckBox.setCheckState(QtCore.Qt.Checked)
            self.ui.screenShotCheckBox.setEnabled(False)

        ########################################################################################################################################
        ###### Question Page
        ########################################################################################################################################
        self.currentIdChanged.connect(self.onCurrentIDChanged)
        self.ui.yesLeginonPushButton.clicked.connect(self.next)
        self.ui.noLeginonPushButton.clicked.connect(self.next)
        self.ui.yesReferencePushButton.clicked.connect(self.next)
        self.ui.noReferencePushButton.clicked.connect(self.next)

        ########################################################################################################################################
        ###### Leginon Page
        ########################################################################################################################################
        self.ui.leginonWidget = LeginonUI(self, self.helpDialog)
        self.ui.leginonDBLayout.addWidget(self.ui.leginonWidget)
        #self.subPages[self.idOf(self.ui.leginonDBPage)]=self.ui.leginonWidget
        self.ui.leginonWidget.registerPage(self.ui.leginonDBPage)
        #self.ui.leginonWidget.loadFinished.connect(self.next)
        self.ui.leginonWidget.loadFinished.connect(self.onLeginonLoadFinished)
        self.ui.leginonWidget.captureScreen.connect(self.captureScreen)

        ########################################################################################################################################
        ###### Reference Page
        ########################################################################################################################################
        self.ui.referenceWidget = ReferenceUI(self, self.helpDialog)
        self.ui.referenceLayout.addWidget(self.ui.referenceWidget)
        #self.subPages[self.idOf(self.ui.referencePage)]=self.ui.referenceWidget
        self.ui.referenceWidget.registerPage(self.ui.referencePage)
        #self.ui.referencePage.registerField("referenceEdit*", self.ui.referenceWidget.ui.referenceLineEdit)
        self.ui.referenceWidget.captureScreen.connect(self.captureScreen)
        self.ui.referenceWidget.updateParticleDiameter.connect(
            self.ui.particleSizeDoubleSpinBox.setValue)

        ########################################################################################################################################
        ###### Monitor Page
        ########################################################################################################################################
        self.ui.monitorWidget = MonitorUI(self, self.helpDialog)
        self.ui.monitorLayout.insertWidget(0, self.ui.monitorWidget)
        self.ui.monitorWidget.programStarted.connect(self.onProgramStarted)
        self.ui.monitorWidget.programCompleted.connect(self.onProgramCompleted)

        ########################################################################################################################################
        ###### Fine Settings Page
        ########################################################################################################################################
        self.ui.settingsTabWidget = SettingsUI(self)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(2)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.ui.settingsTabWidget.sizePolicy().hasHeightForWidth())
        self.ui.settingsTabWidget.setSizePolicy(sizePolicy)
        self.ui.settingsHorizontalLayout.addWidget(self.ui.settingsTabWidget)

        self.ui.workflowListView.setModel(self.ui.monitorWidget.model())
        selmodel = self.ui.workflowListView.selectionModel()
        selmodel.currentChanged.connect(
            self.ui.settingsTabWidget.settingsChanged)

        ########################################################################################################################################
        ###### Manual Settings Page
        ########################################################################################################################################
        self.ui.manualSettingsPage.registerField(
            self.param("apix*"), self.ui.pixelSizeDoubleSpinBox, "value",
            QtCore.SIGNAL('valueChanged(double)'))

        self.ui.manualSettingsPage.registerField(
            self.param("voltage*"), self.ui.voltageDoubleSpinBox, "value",
            QtCore.SIGNAL('valueChanged(double)'))
        self.ui.manualSettingsPage.registerField(
            self.param("cs*"), self.ui.csDoubleSpinBox, "value",
            QtCore.SIGNAL('valueChanged(double)'))
        self.ui.manualSettingsPage.registerField(
            self.param("input_files*"), self, 'micrographFiles',
            QtCore.SIGNAL('micrographFilesUpdated()'))
        self.ui.manualSettingsPage.registerField(
            self.param("gain_files"), self, 'gainFiles',
            QtCore.SIGNAL('gainFilesUpdated()'))
        self.ui.manualSettingsPage.registerField(self.param("gain_file"), self,
                                                 'gainFile')
        self.ui.manualSettingsPage.registerField(self.param("invert"),
                                                 self.ui.invertCheckBox)
        self.ui.imageStatTableView.setModel(
            ListTableModel([], ['Exposure', 'Gain'],
                           ['Width', 'Height', 'Frames', 'Total'], self))
        self.ui.importMessageLabel.setVisible(False)

        ########################################################################################################################################
        ###### Additional Settings Page
        ########################################################################################################################################

        if os.path.exists(self.default_spider_path):
            self.updateSpiderExe(self.default_spider_path, True)

        self.updateParticleSizeSpinBox = lambda x: self.ui.particleSizeSpinBox.setValue(
            int(x / self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0)
        self.updateWindowSizeSpinBox = lambda x: self.ui.windowSizeSpinBox.setValue(
            int(x / self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0)
        self.updateMaskDiameterSpinBox = lambda x: self.ui.maskDiameterSpinBox.setValue(
            int(x / self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0)

        self.updateParticleSizeDoubleSpinBox = lambda x: self.ui.particleSizeDoubleSpinBox.setValue(
            float(x * self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0.0)
        self.updateWindowSizeDoubleSpinBox = lambda x: self.ui.windowSizeDoubleSpinBox.setValue(
            float(x * self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0.0)
        self.updateMaskDiameterDoubleSpinBox = lambda x: self.ui.maskDiameterDoubleSpinBox.setValue(
            float(x * self.ui.pixelSizeDoubleSpinBox.value())
            if self.ui.pixelSizeDoubleSpinBox.value() > 0 else 0.0)

        self.ui.particleSizeDoubleSpinBox.valueChanged.connect(
            self.updateParticleSizeSpinBox)
        self.ui.windowSizeDoubleSpinBox.valueChanged.connect(
            self.updateWindowSizeSpinBox)
        self.ui.maskDiameterDoubleSpinBox.valueChanged.connect(
            self.updateMaskDiameterSpinBox)

        self.ui.particleSizeUnitComboBox.currentIndexChanged.connect(
            self.ui.particleDiameterStackedWidget.setCurrentIndex)
        self.ui.windowSizeUnitComboBox.currentIndexChanged.connect(
            self.ui.windowSizeStackedWidget.setCurrentIndex)
        self.ui.maskDiameterUnitComboBox.currentIndexChanged.connect(
            self.ui.maskDiameterStackedWidget.setCurrentIndex)

        self.ui.particleSizeUnitComboBox.currentIndexChanged.connect(
            functools.partial(
                connect_visible_spin_box,
                signals=(self.ui.particleSizeDoubleSpinBox.valueChanged,
                         self.ui.particleSizeSpinBox.valueChanged),
                slots=(self.updateParticleSizeSpinBox,
                       self.updateParticleSizeDoubleSpinBox)))
        self.ui.windowSizeUnitComboBox.currentIndexChanged.connect(
            functools.partial(
                connect_visible_spin_box,
                signals=(self.ui.windowSizeDoubleSpinBox.valueChanged,
                         self.ui.windowSizeSpinBox.valueChanged),
                slots=(self.updateWindowSizeSpinBox,
                       self.updateWindowSizeDoubleSpinBox)))
        self.ui.maskDiameterUnitComboBox.currentIndexChanged.connect(
            functools.partial(
                connect_visible_spin_box,
                signals=(self.ui.maskDiameterDoubleSpinBox.valueChanged,
                         self.ui.maskDiameterSpinBox.valueChanged),
                slots=(self.updateMaskDiameterSpinBox,
                       self.updateMaskDiameterDoubleSpinBox)))

        self.ui.particleSizeDoubleSpinBox.valueChanged.connect(
            lambda x: self.ui.windowSizeDoubleSpinBox.setValue(
                ensure_even_window(x * 1.4,
                                   self.ui.pixelSizeDoubleSpinBox.value())))
        self.ui.particleSizeDoubleSpinBox.valueChanged.connect(
            lambda x: self.ui.maskDiameterDoubleSpinBox.setValue(x * 1.2))

        self.ui.additionalSettingsPage.registerField(
            self.param("spider_path"), self.ui.spiderExecutableLineEdit)
        self.ui.particleSizeDoubleSpinBox.valueChanged.connect(
            self.diameterChanged)
        self.ui.additionalSettingsPage.registerField(
            self.param("particle_diameter*"),
            self.ui.particleSizeDoubleSpinBox, "value",
            QtCore.SIGNAL('valueChanged(double)'))
        #self.ui.additionalSettingsPage.registerField(self.param("particle_diameter*"), self, "particleDiameter", QtCore.SIGNAL('diameterChanged(double)'))

        self.ui.additionalSettingsPage.registerField(
            self.param("window_actual*"), self.ui.windowSizeDoubleSpinBox,
            "value", QtCore.SIGNAL('valueChanged(double)'))
        self.ui.additionalSettingsPage.registerField(
            self.param("mask_diameter*"), self.ui.maskDiameterDoubleSpinBox,
            "value", QtCore.SIGNAL('valueChanged(double)'))
        self.ui.additionalSettingsPage.registerField(
            self.param('worker_count'), self.ui.workerCountSpinBox)
        self.ui.additionalSettingsPage.registerField(
            self.param('thread_count'), self.ui.threadCountSpinBox)
        self.ui.additionalSettingsPage.registerField(self.param("window"),
                                                     self, "window")
        self.ui.additionalSettingsPage.registerField(
            self.param('enable_stderr'), self.ui.enableStderrCheckBox)
        self.ui.additionalSettingsPage.registerField(self.param("disk_mult"),
                                                     self, 'sampleShape')
        self.ui.additionalSettingsPage.registerField(
            self.param("overlap_mult"), self, 'sampleDensity')
        self.ui.additionalSettingsPage.registerField(
            self.param("threshold_minimum"), self, 'sampleDensityMin')
        self.ui.sampleShapeComboBox.setItemData(0, 0.6)
        self.ui.sampleShapeComboBox.setItemData(1, 0.35)
        self.ui.sampleDensityComboBox.setItemData(0, 1.0)
        self.ui.sampleDensityComboBox.setItemData(1, 1.2)
        self.ui.sampleDensityComboBox.setItemData(2, 0.8)

        thread_count = 1
        if openmp.is_openmp_enabled():
            thread_count = openmp.get_num_procs()
        else:
            try:
                thread_count = multiprocessing.cpu_count()
            except:
                pass
        # Hack to determine whether CPU supports hyperthreading
        frac = 1.0
        if sys.platform == 'darwin':
            try:
                info = dict([
                    line.strip().split(':')
                    for line in os.popen('sysctl hw').readlines()[1:20]
                    if line.find(':') != -1
                ])
                frac = float(info['hw.activecpu'].strip()) / float(
                    info['hw.physicalcpu'].strip())
            except:
                pass
        else:
            if os.path.exists('/proc/cpuinfo'):
                info = dict([
                    (line.strip().split(':')[0].strip(),
                     line.strip().split(':')[1].strip())
                    for line in open('/proc/cpuinfo', 'r').readlines()
                    if line.find(':') != -1
                ])
                frac = float(info['siblings'].strip()) / float(
                    info['cpu cores'].strip())

        thread_count = int(thread_count / frac)
        self.ui.workerCountSpinBox.setValue(thread_count)
        self.ui.selectLeginonInformationLabel.setVisible(False)
        self.ui.selectReferenceInformationLabel.setVisible(False)

        _logger.info("\rLoading project settings ...")
        self.readSettings()
        self.loadProject()