def _read_annot(annot, annotmap, sfreq, data_length):
 pat = '([+/-]\\d+.\\d+),(\\w+)'
 annot = open(annot).read()
 triggers = re.findall(pat, annot)
 (times, values) = zip(*triggers)
 times = [(float(time) * sfreq) for time in times]
 pat = '(\\w+):(\\d+)'
 annotmap = open(annotmap).read()
 mappings = re.findall(pat, annotmap)
 maps = {}
 for mapping in mappings:
  maps[mapping[0]] = mapping[1]
 triggers = [int(maps[value]) for value in values]
 stim_channel = np.zeros(data_length)
 for (time, trigger) in zip(times, triggers):
  stim_channel[time] = trigger
 return stim_channel

def _read_annot ( annot , annotmap , sfreq , data_length ) : pat = '([+/-]\\d+.\\d+),(\\w+)' annot = open ( annot ) . read ( ) triggers = re . findall ( pat , annot ) ( times , values ) = zip ( * triggers ) times = [ ( float ( time ) * sfreq ) for time in times ] pat = '(\\w+):(\\d+)' annotmap = open ( annotmap ) . read ( ) mappings = re . findall ( pat , annotmap ) maps = { } for mapping in mappings : maps [ mapping [ 0 ] ] = mapping [ 1 ] triggers = [ int ( maps [ value ] ) for value in values ] stim_channel = np . zeros ( data_length ) for ( time , trigger ) in zip ( times , triggers ) : stim_channel [ time ] = trigger return stim_channel
annotation file reader .