Esempio n. 1
0
    np.savez(base_folder + 'behavioral_traces.npz', **res_bt)
    #%%
    with np.load(base_folder + 'behavioral_traces.npz') as ld:
        res_bt = dict(**ld)
    #%%
    pl.close()
    tm = res_bt['time']
    f_rate_bh = old_div(1, np.median(np.diff(tm)))
    ISI = res_bt['trial_info'][0][3] - res_bt['trial_info'][0][2]
    eye_traces = np.array(res_bt['eyelid'])
    idx_CS_US = res_bt['idx_CS_US']
    idx_US = res_bt['idx_US']
    idx_CS = res_bt['idx_CS']

    idx_ALL = np.sort(np.hstack([idx_CS_US, idx_US, idx_CS]))
    eye_traces, amplitudes_at_US, trig_CRs = gc.process_eyelid_traces(
        eye_traces, tm, idx_CS_US, idx_US, idx_CS, thresh_CR=.15, time_CR_on=-.1, time_US_on=.05)

    idxCSUSCR = trig_CRs['idxCSUSCR']
    idxCSUSNOCR = trig_CRs['idxCSUSNOCR']
    idxCSCR = trig_CRs['idxCSCR']
    idxCSNOCR = trig_CRs['idxCSNOCR']
    idxNOCR = trig_CRs['idxNOCR']
    idxCR = trig_CRs['idxCR']
    idxUS = trig_CRs['idxUS']
    idxCSCSUS = np.concatenate([idx_CS, idx_CS_US])

    pl.plot(tm, np.mean(eye_traces[idxCSUSCR], 0))
    pl.plot(tm, np.mean(eye_traces[idxCSUSNOCR], 0))
    pl.plot(tm, np.mean(eye_traces[idxCSCR], 0))
    pl.plot(tm, np.mean(eye_traces[idxCSNOCR], 0))
    pl.plot(tm, np.mean(eye_traces[idx_US], 0))
Esempio n. 2
0
with np.load(base_folder+'all_triggers.npz') as at:
    triggers_img=at['triggers']
    trigger_names_img=at['trigger_names'] 
    
with np.load(base_folder+'behavioral_traces.npz') as ld: 
    res_bt = dict(**ld)
    tm=res_bt['time']
    f_rate_bh=1/np.median(np.diff(tm))
    ISI=res_bt['trial_info'][0][3]-res_bt['trial_info'][0][2]
    eye_traces=np.array(res_bt['eyelid'])
    idx_CS_US=res_bt['idx_CS_US']
    idx_US=res_bt['idx_US']
    idx_CS=res_bt['idx_CS']
    
    idx_ALL=np.sort(np.hstack([idx_CS_US,idx_US,idx_CS]))
    eye_traces,amplitudes_at_US, trig_CRs=gc.process_eyelid_traces(eye_traces,tm,idx_CS_US,idx_US,idx_CS,thresh_CR=.15,time_CR_on=-.1,time_US_on=.05)
    
    idxCSUSCR = trig_CRs['idxCSUSCR']
    idxCSUSNOCR = trig_CRs['idxCSUSNOCR']
    idxCSCR = trig_CRs['idxCSCR']
    idxCSNOCR = trig_CRs['idxCSNOCR']
    idxNOCR = trig_CRs['idxNOCR']
    idxCR = trig_CRs['idxCR']
    idxUS = trig_CRs['idxUS']
    idxCSCSUS=np.concatenate([idx_CS,idx_CS_US]) 

with open(base_folder+'traces.pk','r') as f:    
            locals().update(pickle.load(f))  

triggers_img=np.array(triggers_img)    
idx_expected_US=  np.repeat( np.nanmedian(triggers_img[:,1]),len(triggers_img[:,1]))     
     learning_phase=0
     print 'early'
 else:
     if day != session_now:
         session_id += 1
         session_now=day
     
         
     
 chunk=re.search('_00[0-9][0-9][0-9]_',nm.split('/')[9]).group(0)[3:-1]
 
 idx_CS_US=np.where(tr_bh[:,-2]==2)[0]
 idx_US=np.where(tr_bh[:,-2]==1)[0]
 idx_CS=np.where(tr_bh[:,-2]==0)[0]
 idx_ALL=np.sort(np.hstack([idx_CS_US,idx_US,idx_CS]))
 eye_traces,amplitudes_at_US, trig_CRs=process_eyelid_traces(eye,tm,idx_CS_US,idx_US,idx_CS,thresh_CR=thresh_CR,time_CR_on=time_CR_on,time_US_on=time_US_on)        
 idxCSUSCR = trig_CRs['idxCSUSCR']
 idxCSUSNOCR = trig_CRs['idxCSUSNOCR']
 idxCSCR = trig_CRs['idxCSCR']
 idxCSNOCR = trig_CRs['idxCSNOCR']
 idxNOCR = trig_CRs['idxNOCR']
 idxCR = trig_CRs['idxCR']
 idxUS = trig_CRs['idxUS']
 idxCSCSUS=np.concatenate([idx_CS,idx_CS_US]) 
 
 
 
 wheel_traces, movement_at_CS, trigs_mov = process_wheel_traces(np.array(whe),tm,thresh_MOV_iqr=thresh_MOV_iqr,time_CS_on=time_CS_on_MOV,time_US_on=time_US_on_MOV)    
 print 'fraction with movement:'    + str(len(trigs_mov['idxMOV'])*1./len(trigs_mov['idxNO_MOV']))
 
 mn_idx_CS_US =np.intersect1d(idx_CS_US,trigs_mov['idxNO_MOV'])