def _combine_annotations(annotations, last_samps, first_samps, sfreq):
 if (not any(annotations)):
  return None
 elif (annotations[1] is None):
  return annotations[0]
 elif (annotations[0] is None):
  old_onset = list()
  old_duration = list()
  old_description = list()
  old_orig_time = None
 else:
  old_onset = annotations[0].onset
  old_duration = annotations[0].duration
  old_description = annotations[0].description
  old_orig_time = annotations[0].orig_time
 extra_samps = (len(first_samps) - 1)
 onset = (annotations[1].onset + (((sum(last_samps[:(-1)]) + extra_samps) - sum(first_samps[:(-1)])) / sfreq))
 onset = np.concatenate([old_onset, onset])
 duration = np.concatenate([old_duration, annotations[1].duration])
 description = np.concatenate([old_description, annotations[1].description])
 return Annotations(onset, duration, description, old_orig_time)

def _combine_annotations ( annotations , last_samps , first_samps , sfreq ) : if ( not any ( annotations ) ) : return None elif ( annotations [ 1 ] is None ) : return annotations [ 0 ] elif ( annotations [ 0 ] is None ) : old_onset = list ( ) old_duration = list ( ) old_description = list ( ) old_orig_time = None else : old_onset = annotations [ 0 ] . onset old_duration = annotations [ 0 ] . duration old_description = annotations [ 0 ] . description old_orig_time = annotations [ 0 ] . orig_time extra_samps = ( len ( first_samps ) - 1 ) onset = ( annotations [ 1 ] . onset + ( ( ( sum ( last_samps [ : ( - 1 ) ] ) + extra_samps ) - sum ( first_samps [ : ( - 1 ) ] ) ) / sfreq ) ) onset = np . concatenate ( [ old_onset , onset ] ) duration = np . concatenate ( [ old_duration , annotations [ 1 ] . duration ] ) description = np . concatenate ( [ old_description , annotations [ 1 ] . description ] ) return Annotations ( onset , duration , description , old_orig_time )
helper for combining a tuple of annotations .