Ejemplo n.º 1
0
 def _save_select_detect(self, *args, filename=None):
     """Export selected detection."""
     channel, method = self._get_current_chan_type()
     # Read Table
     row_count = self._DetectLocations.rowCount()
     sta_ind = [channel, '', 'Time index (s)']
     end_ind = [method, '', 'Time index (s)']
     duration = ['', '', 'Duration (s)']
     stage = ['', '', 'Sleep stage']
     for row in np.arange(row_count):
         sta_ind.append(str(self._DetectLocations.item(row, 0).text()))
         end_ind.append(str(self._DetectLocations.item(row, 1).text()))
         duration.append(str(self._DetectLocations.item(row, 2).text()))
         stage.append(str(self._DetectLocations.item(row, 3).text()))
     # Get file name :
     saveas = "locinfo" + '_' + channel + '-' + method
     if filename is None:
         filename = dialog_save(
             self, 'Save ' + method + ' detection', saveas,
             "CSV file (*.csv);;Text file"
             " (*.txt);;All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         file += '_' + channel + '-' + method
         zp = zip(sta_ind, end_ind, duration, stage)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zp)
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zp)
Ejemplo n.º 2
0
 def _save_select_detect(self, *args, filename=None):
     """Export selected detection."""
     channel, method = self._get_current_chan_type()
     # Read Table
     row_count = self._DetectLocations.rowCount()
     sta_ind = [channel, '', 'Time index (s)']
     end_ind = [method, '', 'Time index (s)']
     duration = ['', '', 'Duration (s)']
     stage = ['', '', 'Sleep stage']
     for row in np.arange(row_count):
         sta_ind.append(str(self._DetectLocations.item(row, 0).text()))
         end_ind.append(str(self._DetectLocations.item(row, 1).text()))
         duration.append(str(self._DetectLocations.item(row, 2).text()))
         stage.append(str(self._DetectLocations.item(row, 3).text()))
     # Get file name :
     saveas = "locinfo" + '_' + channel + '-' + method
     if filename is None:
         filename = dialog_save(self, 'Save ' + method + ' detection',
                                saveas, "CSV file (*.csv);;Text file"
                                " (*.txt);;All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         file += '_' + channel + '-' + method
         zp = zip(sta_ind, end_ind, duration, stage)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zp)
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zp)
Ejemplo n.º 3
0
 def _save_info_table(self, *args, filename=None):
     """Export stat info."""
     # Get file name :
     if filename is None:
         filename = dialog_save(self, 'Save file', 'statsinfo',
                                "CSV file (*.csv);;Text file (*.txt);;"
                                "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(self._keysInfo, self._valInfo))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(self._keysInfo, self._valInfo))
Ejemplo n.º 4
0
 def _save_info_table(self, *args, filename=None):
     """Export stat info."""
     # Get file name :
     if filename is None:
         filename = dialog_save(
             self, 'Save file', 'statsinfo',
             "CSV file (*.csv);;Text file (*.txt);;"
             "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(self._keysInfo, self._valInfo))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(self._keysInfo, self._valInfo))
Ejemplo n.º 5
0
 def _save_annotation_table(self, *args, filename=None):
     """Export annotation table."""
     # Read Table
     row_count = self._AnnotateTable.rowCount()
     sta_ind, end_ind, annot = [], [], []
     for row in np.arange(row_count):
         sta_ind.append(str(self._AnnotateTable.item(row, 0).text()))
         end_ind.append(str(self._AnnotateTable.item(row, 1).text()))
         annot.append(str(self._AnnotateTable.item(row, 2).text()))
     # Get file name :
     if filename is None:
         filename = dialog_save(self, 'Save annotations', 'annotations',
                                "CSV file (*.csv);;Text file (*.txt);;"
                                "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(sta_ind, end_ind, annot))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(sta_ind, end_ind, annot))
Ejemplo n.º 6
0
 def _save_scoring_table(self, *args, filename=None):
     """Export score info."""
     # Read Table
     row_count = self._scoreTable.rowCount()
     sta_ind, end_ind, stage = [], [], []
     for row in np.arange(row_count):
         sta_ind.append(str(self._scoreTable.item(row, 0).text()))
         end_ind.append(str(self._scoreTable.item(row, 1).text()))
         stage.append(str(self._scoreTable.item(row, 2).text()))
     # Get file name :
     if filename is None:
         filename = dialog_save(self, 'Save file', 'scoring_info',
                                "CSV file (*.csv);;Text file (*.txt);;"
                                "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(sta_ind, end_ind, stage))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(sta_ind, end_ind, stage))
Ejemplo n.º 7
0
 def _save_annotation_table(self, *args, filename=None):
     """Export annotation table."""
     # Read Table
     row_count = self._AnnotateTable.rowCount()
     sta_ind, end_ind, annot = [], [], []
     for row in np.arange(row_count):
         sta_ind.append(str(self._AnnotateTable.item(row, 0).text()))
         end_ind.append(str(self._AnnotateTable.item(row, 1).text()))
         annot.append(str(self._AnnotateTable.item(row, 2).text()))
     # Get file name :
     if filename is None:
         filename = dialog_save(
             self, 'Save annotations', 'annotations',
             "CSV file (*.csv);;Text file (*.txt);;"
             "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(sta_ind, end_ind, annot))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(sta_ind, end_ind, annot))
Ejemplo n.º 8
0
 def _save_scoring_table(self, *args, filename=None):
     """Export score info."""
     # Read Table
     row_count = self._scoreTable.rowCount()
     sta_ind, end_ind, stage = [], [], []
     for row in np.arange(row_count):
         sta_ind.append(str(self._scoreTable.item(row, 0).text()))
         end_ind.append(str(self._scoreTable.item(row, 1).text()))
         stage.append(str(self._scoreTable.item(row, 2).text()))
     # Get file name :
     if filename is None:
         filename = dialog_save(
             self, 'Save file', 'scoring_info',
             "CSV file (*.csv);;Text file (*.txt);;"
             "All files (*.*)")
     if filename:
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(sta_ind, end_ind, stage))
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(sta_ind, end_ind, stage))
Ejemplo n.º 9
0
 def _fcn_save_annotations(self, *args, filename=None):
     """Save annotations."""
     # Read Table
     row_count = self._annot_table.rowCount()
     time, amp, signal, text = [], [], [], []
     for row in range(row_count):
         time.append(self._annot_table.item(row, 0).text())
         amp.append(self._annot_table.item(row, 1).text())
         signal.append(self._annot_table.item(row, 2).text())
         text.append(self._annot_table.item(row, 3).text())
     # Get file name :
     if filename is None:
         filename = dialog_save(self, 'Save annotations', 'annotations',
                                "CSV file (*.csv);;Text file (*.txt);;"
                                "All files (*.*)")
     if filename:
         kw = {'delimiter': '_'}
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(time, amp, signal, text), **kw)
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(time, amp, signal, text), **kw)
Ejemplo n.º 10
0
 def _fcn_save_annotations(self, *args, filename=None):
     """Save annotations."""
     # Read Table
     row_count = self._annot_table.rowCount()
     time, amp, signal, text = [], [], [], []
     for row in range(row_count):
         time.append(self._annot_table.item(row, 0).text())
         amp.append(self._annot_table.item(row, 1).text())
         signal.append(self._annot_table.item(row, 2).text())
         text.append(self._annot_table.item(row, 3).text())
     # Get file name :
     if filename is None:
         filename = dialog_save(
             self, 'Save annotations', 'annotations',
             "CSV file (*.csv);;Text file (*.txt);;"
             "All files (*.*)")
     if filename:
         kw = {'delimiter': '_'}
         file, ext = os.path.splitext(filename)
         if ext.find('csv') + 1:
             write_csv(file + '.csv', zip(time, amp, signal, text), **kw)
         elif ext.find('txt') + 1:
             write_txt(file + '.txt', zip(time, amp, signal, text), **kw)