def convolve_s_with_hrf(S,S_times,hrf,TR_times): X = np.shape(S)[0] Y = np.shape(S)[1] s_conv_hrf = np.zeros((X,Y,len(TR_times))) pb = ProgressBar(X) for x in range(X): pb.animate(x+1) for y in range(Y): s = S[x,y,:] hp = np.convolve(s, hrf)[:(np.shape(s)[0])] hp_interp = np.interp(TR_times,S_times,hp) s_conv_hrf[x,y,:] = hp_interp return s_conv_hrf
def convolve_s_with_hrf(S, S_times, hrf, TR_times): X = np.shape(S)[0] Y = np.shape(S)[1] s_conv_hrf = np.zeros((X, Y, len(TR_times))) pb = ProgressBar(X) for x in range(X): pb.animate(x + 1) for y in range(Y): s = S[x, y, :] hp = np.convolve(s, hrf)[:(np.shape(s)[0])] hp_interp = np.interp(TR_times, S_times, hp) s_conv_hrf[x, y, :] = hp_interp return s_conv_hrf
def get_WA_mask_sequence_ab(n,Research_path): s_path = opj(Research_path,'stimuli/Wedge_annulus/sequence'+str(n),'wedge_annulus_sequence'+str(n)+'_masks5Hz_96by128') mat = scipy.io.loadmat(s_path) s = mat['wedge_annulus_sequence'+str(n)+'_masks5Hz_96by128'] s = s[:,:,(5*6):] # NEED TO DEAL WITH DELETE FRAMES frame_5Hz_times = 0.2 * np.arange(0,np.shape(s)[2]) return s,frame_5Hz_times
def get_WA_mask_sequence_ab(n, Research_path): s_path = opj(Research_path, 'stimuli/Wedge_annulus/sequence' + str(n), 'wedge_annulus_sequence' + str(n) + '_masks5Hz_96by128') mat = scipy.io.loadmat(s_path) s = mat['wedge_annulus_sequence' + str(n) + '_masks5Hz_96by128'] s = s[:, :, (5 * 6):] # NEED TO DEAL WITH DELETE FRAMES frame_5Hz_times = 0.2 * np.arange(0, np.shape(s)[2]) return s, frame_5Hz_times
def rf_peak_xy(s_conv_hrf,a,TR_times,fig,graphics=True): X = np.shape(s_conv_hrf)[0] Y = np.shape(s_conv_hrf)[1] rf = np.zeros((X,Y)) #pb = ProgressBar(X) for x in range(X): #pb.animate(x+1) for y in range(Y): rf[x,y] = np.corrcoef(s_conv_hrf[x,y],a)[0,1] peak = np.unravel_index(rf.argmax(), rf.shape) if graphics: PP[FF]=4,4 plt.figure(fig+': rf') plt.clf() mi(rf,fig+': rf',[1,1,1],img_title=(peak,np.max(rf))) PP[FF]=13,2 x,y = peak hp_interp = s_conv_hrf[x,y,:] plt.figure(fig+': time course') plt.clf() plt.plot(TR_times,z21r(hp_interp),'gx') plt.plot(TR_times,8*z21r(a),'r') return rf,peak
def rf_peak_xy(s_conv_hrf, a, TR_times, fig, graphics=True): X = np.shape(s_conv_hrf)[0] Y = np.shape(s_conv_hrf)[1] rf = np.zeros((X, Y)) #pb = ProgressBar(X) for x in range(X): #pb.animate(x+1) for y in range(Y): rf[x, y] = np.corrcoef(s_conv_hrf[x, y], a)[0, 1] peak = np.unravel_index(rf.argmax(), rf.shape) if graphics: PP[FF] = 4, 4 plt.figure(fig + ': rf') plt.clf() mi(rf, fig + ': rf', [1, 1, 1], img_title=(peak, np.max(rf))) PP[FF] = 13, 2 x, y = peak hp_interp = s_conv_hrf[x, y, :] plt.figure(fig + ': time course') plt.clf() plt.plot(TR_times, z21r(hp_interp), 'gx') plt.plot(TR_times, 8 * z21r(a), 'r') return rf, peak