def concatenate_events(events, first_samps, last_samps):
 if (not isinstance(events, list)):
  raise ValueError('events must be a list of arrays')
 if (not ((len(events) == len(last_samps)) and (len(events) == len(first_samps)))):
  raise ValueError('events, first_samps, and last_samps must all have the same lengths')
 first_samps = np.array(first_samps)
 last_samps = np.array(last_samps)
 n_samps = np.cumsum(((last_samps - first_samps) + 1))
 events_out = events[0]
 for (e, f, n) in zip(events[1:], first_samps[1:], n_samps[:(-1)]):
  e2 = e.copy()
  e2[:, 0] -= f
  e2[:, 0] += (n + first_samps[0])
  events_out = np.concatenate((events_out, e2), axis=0)
 return events_out

def concatenate_events ( events , first_samps , last_samps ) : if ( not isinstance ( events , list ) ) : raise ValueError ( 'events must be a list of arrays' ) if ( not ( ( len ( events ) == len ( last_samps ) ) and ( len ( events ) == len ( first_samps ) ) ) ) : raise ValueError ( 'events, first_samps, and last_samps must all have the same lengths' ) first_samps = np . array ( first_samps ) last_samps = np . array ( last_samps ) n_samps = np . cumsum ( ( ( last_samps - first_samps ) + 1 ) ) events_out = events [ 0 ] for ( e , f , n ) in zip ( events [ 1 : ] , first_samps [ 1 : ] , n_samps [ : ( - 1 ) ] ) : e2 = e . copy ( ) e2 [ : , 0 ] -= f e2 [ : , 0 ] += ( n + first_samps [ 0 ] ) events_out = np . concatenate ( ( events_out , e2 ) , axis = 0 ) return events_out
concatenate event lists to be compatible with concatenate_raws .