function [event_start_indices,event_end_indices]=threshold_crossing_start_end(data_that_crosses_threshold,threshold)

above_threshold=data_that_crosses_threshold>threshold; 
beginnings_iftrue=~above_threshold(1:end-1)&above_threshold(2:end);
endings_iftrue=above_threshold(1:end-1)&~above_threshold(2:end);
event_start_indices=1+find(beginnings_iftrue);
event_end_indices=find(endings_iftrue);