code: def update_annotation_version(xml_file):
      
      with open(xml_file, 'r') as f:
          s = f.read()
  
      m = search('<annotations version="([0-9]*)">', s)
      current = int(m.groups()[0])
  
      if current < 4:
          s = sub('<marker><name>(.*?)</name><time>(.*?)</time></marker>',
                   '<marker><marker_name>\g<1></marker_name><marker_start>\g<2></marker_start><marker_end>\g<2></marker_end><marker_chan/></marker>',
                   s)
  
      if current < 5:
          s = s.replace('marker', 'bookmark')
  
          # note indentation
          s = sub('<annotations version="[0-9]*">',
                  '<annotations version="5">', s)
          with open(xml_file, 'w') as f:
              f.write(s)
docs: Update the fields that have changed over different versions.
  
      Parameters
      ----------
      xml_file : path to file
          xml file with the sleep scoring
  
      Notes
      -----
      new in version 4: use 'marker_name' instead of simply 'name' etc
  
      new in version 5: use 'bookmark' instead of 'marker'