def make_WTA_filters(con, nfilt, nang, npha, freq, scale, tot, fdist, R, npts=32): grats = np.array([[[ test.GRATC(0, a, freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1) + test.GRATC(c, a + (np.pi / 2), freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1), test.GRATC(1, a, freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1) + test.GRATC(c, a + (np.pi / 2), freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1) ] for a in [i * math.pi / npts for i in range(npts)]] for c in con]) filt = np.array([[[ proc.get_phased_filter_coefficients(x, nang, npha, freq, scale, tot, R) for x in g ] for g in C] for C in grats]) filt = np.array([[[ proc.sample_coef(x, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt, fdist) for x in I ] for I in C] for C in filt]) return filt #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_att_COS_filters(con, p2, nfilt, nang, npha, freq, scale, tot, fdist): if p2 == 0: grats = np.array([ test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1) + test.GRATC(c, np.pi / 2, freq, 2 * (tot + 2 * fdist + 1), tot + 2 * fdist + 1) for c in con ]) elif p2 == 1: grats = np.array([ test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1) for c in con ]) else: grats = np.array([ test.GRATC(c, np.pi / 2, freq, fdist / 2, tot + 2 * fdist + 1) for c in con ]) filt = np.array([ proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot) for g in grats ]) filt = np.array([ proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt, fdist) for I in filt ]) return filt #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_BSS_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,nda): grats = np.array([[[ test.GRATC(c,0.,freq,fdist,tot + 2*fdist + 1), test.GRATC(c,0.,freq,fdist,tot + 2*fdist + 1,surr = 0) + test.s_GRATC(1,da,freq,fdist,tot+2*fdist + 1,surr = 0.) ] for c in con] for da in [i * math.pi/(2 * ((nda - 1) if nda > 1 else 1)) for i in range(nda)]]) filt = np.array([[[proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in C] for C in A] for A in grats]) filt = np.array([[[proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in C] for C in A] for A in filt]) return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_SS_filters(con, nfilt, nang, npha, freq, scale, tot, fdist, get_grat=False): sizes = range(0, int(1 * (fdist + freq)), 1) # sizes = [10,20] grats = np.array( [test.GRATC(1, 0, freq, s, tot + 2 * fdist + 1) for s in sizes]) if get_grat: return grats filt = np.array([ proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot) for g in grats ]) filt = np.array([ proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt, fdist) for I in filt ]) return np.array([c * filt for c in con ]) #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_TI_filters(con, nfilt, nang, npha, freq, scale, tot, fdist, R, npts=20): grats = np.array([[ test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1, surr=0) + test.s_GRATC(c, a, freq, fdist / 2, tot + 2 * fdist + 1, surr=0) for a in [i * math.pi / npts for i in range(npts)] ] for c in con]) filt = np.array([[ proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot, R) for g in C ] for C in grats]) filt = np.array([[ proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt, fdist) for I in C ] for C in filt]) return filt #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_full_field_COS_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,nda,R): grats = np.array([test.GRATC(c1,0,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) + test.GRATC(c2,d,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) for k in range(nda) for c1 in con for c2 in con for d in [k*np.pi/(2*(nda - 1))]]) filt = np.array([proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in grats]) filt = np.array([proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in filt]) return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_full_field_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,R): grats = np.array([test.GRATC(c,0,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) for c in con]) filt = np.array([proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in grats]) filt = np.array([proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in filt]) return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def make_OTUNE_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,R): grats = np.array([[test.GRATC(c,a,freq,freq,tot + 2*fdist + 1) for a in np.linspace(0,2*np.pi,32)] for c in [.05,.1,.25,.5]]) filt = np.array([[proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in C] for C in grats]) filt = np.array([[proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in C] for C in filt]) return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
def gaborC(a,k,s,t): v1 = np.sin(a) v2 = np.cos(a) t2 = float(t-1)/2 sin = np.array([[np.cos(2*math.pi*((v1*(float(x)-t2)) + (v2*(float(y)-t2)))/k) for x in range(t)] for y in range(t)]) exp = np.exp(-np.array([[(float(x) - t2)**2 + (float(y) - t2)**2 for x in range(t)] for y in range(t)])/(2.*(s**2))) out = norm*sin*exp/np.sqrt(k*k*np.sum((sin*exp)**2)) base = (test.GRATC(1,0,1,0,t)*out).sum() return out - base
def gaborS(a,k,s,t): v1 = np.sin(a) v2 = np.cos(a) t2 = float(t-1)/2 sin = np.array([[np.sin(2*math.pi*((v1*(float(x)-t2)) + (v2*(float(y)-t2)))/k) for x in range(t)] for y in range(t)]) exp = np.exp(-np.array([[(float(x) - t2)**2 + (float(y) - t2)**2 for x in range(t)] for y in range(t)])/(2.*(s**2))) out = norm*sin*exp/np.sqrt(k*k*np.sum((sin*exp)**2)) base = (test.GRATC(1,0,1,0,t)*out).sum() # this is here because really these things should integrate a constant stimulus to zero but the gabors are messed up in that they don't! I should be using DOG. return out - base
def make_grating(con,angle,freq,rad,tot,phase = "c",A = lambda c:1): if phase == "c": return test.GRATC(con,angle,freq,rad,tot,A = A) elif phase == "s": return test.GRATS(con,angle,freq,rad,tot,A = A)
def make_grating(con, angle, freq, rad, tot, phase="c"): if phase == "c": return test.GRATC(con, angle, freq, rad, tot) elif phase == "s": return test.GRATS(con, angle, freq, rad, tot)