Beispiel #1
0
 def pushBtn_savePlot_Clicked(self):
     QtGui.QApplication.processEvents()
     QtGui.QApplication.processEvents()
     file_path = self._workingDataBase['file_path'][0]
     if not (os.path.isdir(file_path)):
         file_path = os.getcwd()
     file_fullPath, _ = QFileDialog.\
         getSaveFileName(self, "Save plot", file_path,
                         filter="PNG (*.png)")
     if file_fullPath == '':
         return 0
     _, file_path, _, file_ext, _ = lib.get_fullPath_components(
         file_fullPath)
     if not (file_ext == '.png'):
         file_fullPath = file_fullPath + '.png'
     if os.path.isdir(file_path):
         # create an exporter instance, as an argument give it
         # the item you wish to export
         ex_png = pg.exporters.ImageExporter(self.graphWin.scene())
         ex_png.export(file_fullPath)
         file_fullPath_svg = file_fullPath[0:-4]
         file_fullPath_svg = file_fullPath_svg + '.svg'
         ex_svg = pg.exporters.SVGExporter(self.graphWin.scene())
         ex_svg.export(file_fullPath_svg)
     return 0
Beispiel #2
0
    def load_dataBase(self,
                      file_fullPath,
                      ch_data=None,
                      ch_time=None,
                      sample_rate=None,
                      grandDataBase=None,
                      isCommonAverage=False):
        _, _, _, file_ext, _ = lib.get_fullPath_components(file_fullPath)
        if file_ext == '.psort':
            self._grandDataBase = grandDataBase
            # Backward compatibility for PSORT_VERSION 0_3 and PSORT_VERSION 0_4_10
            if not ('PSORT_VERSION' in self._grandDataBase[-1].keys()):
                self.backward_compatibility_for_Psort_03()
            elif (self._grandDataBase[-1]['PSORT_VERSION'][1] == 4) and \
                (self._grandDataBase[-1]['PSORT_VERSION'][2] < 10):
                self.backward_compatibility_for_Psort_03()
            # Backward compatibility for newly added variables
            for key in dictionaries._singleSlotDataBase.keys():
                if not (key in self._grandDataBase[-2].keys()):
                    for counter_slot in range(len(self._grandDataBase) - 1):
                        self._grandDataBase[counter_slot][key] = \
                            deepcopy(dictionaries._singleSlotDataBase[key])
            for key in dictionaries._topLevelDataBase.keys():
                if not (key in self._grandDataBase[-1].keys()):
                    self._grandDataBase[-1][key] = deepcopy(
                        dictionaries._topLevelDataBase[key])
            self._currentSlotDataBase = self._grandDataBase[-2]
            self._topLevelDataBase = self._grandDataBase[-1]
            self.set_file_fullPath(file_fullPath)
            return 0

        if not (isCommonAverage):
            _ch_data = deepcopy(ch_data)
            _ch_time = deepcopy(ch_time)
            _sample_rate = deepcopy(sample_rate)
            self.init_slotsDataBase_hard(_ch_data, _ch_time, _sample_rate)
            self.set_file_fullPath(file_fullPath)
            self._topLevelDataBase['file_fullPathOriginal'] = \
                np.array([file_fullPath], dtype=np.unicode)
            return 0

        if isCommonAverage:
            _ch_data_cmn = deepcopy(ch_data)
            # check _ch_data_cmn size
            if _ch_data_cmn.size == self._topLevelDataBase['ch_data'].size:
                self._topLevelDataBase['file_fullPathCommonAvg'] = \
                    np.array([file_fullPath], dtype=np.unicode)
                self._topLevelDataBase['ch_data'] = \
                    self._topLevelDataBase['ch_data'] - _ch_data_cmn
            else:
                print('Error: <database.load_dataBase: ' \
                    + 'size of common average data does not match main data.>')
        return 0
Beispiel #3
0
 def set_file_fullPath(self, file_fullPath):
     file_fullPath, file_path, file_name, file_ext, file_name_without_ext = \
         lib.get_fullPath_components(file_fullPath)
     self._topLevelDataBase['file_fullPath'] = np.array([file_fullPath],
                                                        dtype=np.unicode)
     self._topLevelDataBase['file_path'] = np.array([file_path],
                                                    dtype=np.unicode)
     self._topLevelDataBase['file_name'] = np.array([file_name],
                                                    dtype=np.unicode)
     self._topLevelDataBase['file_ext'] = np.array([file_ext],
                                                   dtype=np.unicode)
     self._topLevelDataBase['file_name_without_ext'] = \
         np.array([file_name_without_ext], dtype=np.unicode)
     return 0
Beispiel #4
0
 def add_file_fullPath_array_to_table(self, file_fullPath_array):
     rowCount = self.widget_table.rowCount()
     num_files = len(file_fullPath_array)
     for counter_file in range(num_files):
         self.widget_table.insertRow(rowCount + counter_file)
         fullPath_components = lib.get_fullPath_components(\
             file_fullPath_array[counter_file])
         for counter_key in range(len(_file_keys)):
             self._workingDataBase[_file_keys[counter_key]] = \
                 np.append(self._workingDataBase[_file_keys[counter_key]],
                             fullPath_components[counter_key])
         self.widget_table.setItem(
             rowCount + counter_file, 0,
             QTableWidgetItem(
                 self._workingDataBase['file_name'][rowCount +
                                                    counter_file]))
     self.lastUsedPath = deepcopy(self._workingDataBase['file_path'][-1])
     return 0
Beispiel #5
0
 def onSave_pressed(self):
     file_path = self._workingDataBase['file_path'][-1]
     if not (os.path.isdir(file_path)):
         file_path = os.getcwd()
     file_fullPath, _ = QFileDialog.\
         getSaveFileName(self, "Save DataBase", file_path,
                         filter="h5 Data (*.h5)")
     if file_fullPath == '':
         self.pushBtn_save.setEnabled(False)
         self.pushBtn_save.setEnabled(True)
         return 0
     _, file_path, _, file_ext, _ = lib.get_fullPath_components(
         file_fullPath)
     if not (file_ext == '.h5'):
         file_fullPath = file_fullPath + '.h5'
     if os.path.isdir(file_path):
         self.save_process_start(file_fullPath)
     return 0