コード例 #1
0
    def add_label(self, name, start, stop):
        """adds label to plot if possible.  Returns the index of the new label in the sorted dataset"""        
        if self.lbl.maxshape != (None,): #if dataset is extensible
            win = self.parentWidget().getViewWidget()        
            reply = QMessageBox.question(win,"", "Label cannot be added because dataset is not extensible. Replace with extensible dataset?", QMessageBox.No | QMessageBox.Yes, QMessageBox.No)
            self.key = None  #because keyReleaseEvent may be ignored during message box display                
            if reply == QMessageBox.Yes:
                lbl = self.file[self.path] 
                self.lbl = replace_dataset(lbl, lbl.parent, data=lbl[:], maxshape=(None,))
            else:
                return 

        elif self.file.mode == 'r':
            win = self.parentWidget().getViewWidget()
            QMessageBox.critical(win,"", "Cannot add label. Make sure you have write permission for this file.", QMessageBox.Ok)
            self.key = None
            return 

        arf.append_data(self.lbl,(name,start,stop))
        self.double_clicked = np.append(self.double_clicked,False)
        sort_idx = self.sort_lbl()
        new_idx = np.argmax(sort_idx==(len(self.lbl)-1))
        self.plot_all_events()

        return new_idx
コード例 #2
0
 def delete_selected_labels(self):
     win = self.parentWidget().getViewWidget()
     if self.file.mode == 'r':
         QMessageBox.critical(win,"", "Cannot delete label. Make sure you have write permission for this file.", QMessageBox.Ok)
     else:
         reply = QMessageBox.question(win,"","Delete selected labels?",
                                      QMessageBox.Yes | QMessageBox.No,
                                      QMessageBox.No)
         if reply == QMessageBox.Yes:
             new_data = self.lbl[np.negative(self.double_clicked)]
             lbl = self.file[self.path] #non-anonymous lbl entry
             replace_dataset(lbl, lbl.parent, data=new_data, maxshape=(None,))
             self.lbl = self.file[self.path]
             self.double_clicked = np.zeros(len(self.lbl),dtype=bool)
             self.plot_all_events()
             self.sigNoLabelSelected.emit()