code: def mark_stages(self, start_time, length, stage_name):
          
          y_pos = BARS['stage']['pos0']
          current_stage = STAGES.get(stage_name, STAGES['Unknown'])
  
          # the -1 is really important, otherwise we stay on the edge of the rect
          old_score = self.scene.itemAt(start_time + length / 2,
                                        y_pos +
                                        current_stage['pos0'] +
                                        current_stage['pos1'] - 1,
                                        self.transform())
  
          # check we are not removing the black border
          if old_score is not None and old_score.pen() == NoPen:
              lg.debug('Removing old score at {}'.format(start_time))
              self.scene.removeItem(old_score)
              self.idx_annot.remove(old_score)
  
          rect = QGraphicsRectItem(start_time,
                                   y_pos + current_stage['pos0'],
                                   length,
                                   current_stage['pos1'])
          rect.setPen(NoPen)
          rect.setBrush(current_stage['color'])
          self.scene.addItem(rect)
          self.idx_annot.append(rect)
docs: Mark stages, only add the new ones.
  
          Parameters
          ----------
          start_time : int
              start time in s of the epoch being scored.
          length : int
             duration in s of the epoch being scored.
          stage_name : str
              one of the stages defined in global stages.