code: def get_sleepstage(self, stage_idx=None):
          
          if self.annot is None:  # remove if buttons are disabled
              error_dialog = QErrorMessage()
              error_dialog.setWindowTitle('Error getting sleep stage')
              error_dialog.showMessage('No score file loaded')
              error_dialog.exec()
              return
  
          window_start = self.parent.value('window_start')
          window_length = self.parent.value('window_length')
  
          if window_length != self.epoch_length:
              msg = ('Zoom to ' + str(self.epoch_length) + ' (epoch length) ' +
                     'for sleep scoring.')
              error_dialog = QErrorMessage()
              error_dialog.setWindowTitle('Error getting sleep stage')
              error_dialog.showMessage(msg)
              error_dialog.exec()
              lg.debug(msg)
              return
  
          try:
              self.annot.set_stage_for_epoch(window_start,
                                             STAGE_NAME[stage_idx])
  
          except KeyError:
              msg = ('The start of the window does not correspond to any epoch ' +
                     'in sleep scoring file.\n\n'
                     'Switch to the appropriate window length in View, then use '
                     'Navigation --> Line Up with Epoch to line up the window.')
              error_dialog = QErrorMessage()
              error_dialog.setWindowTitle('Error getting sleep stage')
              error_dialog.showMessage(msg)
              error_dialog.exec()
              lg.debug(msg)
  
          else:
              lg.debug('User staged ' + str(window_start) + ' as ' +
                       STAGE_NAME[stage_idx])
  
              self.set_stage_index()
              self.parent.overview.mark_stages(window_start, window_length,
                                               STAGE_NAME[stage_idx])
              self.display_stats()
              self.parent.traces.page_next()
docs: Score the sleep stage, using shortcuts or combobox.