def get_double_clicks(data,ch0_start=0, ch0_stop=700, ch1_start=0, ch1_stop=700): clicks=hht3.get_allclicks(data) clicks=hht3.filter_timewindow(clicks,0,ch0_start,ch0_stop) clicks=hht3.filter_timewindow(clicks,1,ch1_start,ch1_stop) clicks=np.vstack((clicks,np.zeros(4,dtype=np.uint32))) clicks=np.vstack((np.zeros(4,dtype=np.uint32),clicks)) delta_marker=clicks[1:,0]-clicks[:-1,0] double_click_idx=np.ravel(np.where(delta_marker==1)) triple_click_idx=np.ravel(np.where(delta_marker==0)) bad_idx=np.append(triple_click_idx,\ [triple_click_idx-np.ones(len(triple_click_idx),dtype=np.uint),\ triple_click_idx+np.ones(len(triple_click_idx),dtype=np.uint)]) valid_double_click_idx=np.setdiff1d(double_click_idx,bad_idx) valid_double_click_idx=np.sort(np.append(valid_double_click_idx,valid_double_click_idx+np.ones(len(valid_double_click_idx),dtype=np.uint))) return clicks[valid_double_click_idx]
def get_double_clicks_slow(hhdata, ch0_start=0, ch0_stop=700, ch1_start=0, ch1_stop=700): noof_double = 0 double_clicks = np.zeros(4,dtype=np.uint32) hhdata=hht3.get_allclicks(hhdata) hhdata=hht3.filter_timewindow(hhdata,0,ch0_start,ch0_stop) hhdata=hht3.filter_timewindow(hhdata,1,ch1_start,ch1_stop) for i in np.arange(len(hhdata)): try: if (hhdata[i,0]+1==(hhdata[i+1,0])): if (len(hhdata[np.where(hhdata[:,0]==hhdata[i,0])])==1 and\ len(hhdata[np.where(hhdata[:,0]==hhdata[i+1,0])])==1): double_clicks=np.vstack((double_clicks,hhdata[i])) double_clicks=np.vstack((double_clicks,hhdata[i+1])) except IndexError: pass if (len(np.shape(double_clicks))>1): double_clicks=double_clicks[1:] return double_clicks