% % Solution exercise 2, Assignment 6, part 2 % % CAAM 415, 11/25/08 % %parameters here are k_x, s_x, k_t, s_t, corresponding ... %to the peak spatial (c/deg) and temporal (c/sec) values of the %filter and their spread. %circular frequency corresponding to 4.2 cycles/deg k_x = 2*pi*4.2; %in degrees s_x = 0.1; dx = 0.004; %units are degrees nx = 128; x = ((-nx/2+1)*dx:dx:nx/2*dx); %units are degrees, 128 points %compute the spatial filters r_es = g_es(k_x,s_x,x); r_os = g_os(k_x,s_x,x); %circular frequency corresponding to 8 cycles/sec k_t = 2*pi*8; %in sec s_t = 0.031; %temporal filter dt = 0.002; %units are seconds nt = 128; t = ((-nt/2+1)*dt:dt:nt/2*dt)'; %units are seconds t_es = f_es(k_t,s_t,t); t_os = f_os(k_t,s_t,t); %grating t_gr = (0:dt:2)'; n_tgr =length(t_gr); %grating moving to the right g1 = cos(k_x*repmat(x,[n_tgr 1]) - k_t*repmat(t_gr,[1 nx])); %spatial component g1_s = g1*r_es'; %temporal convolution inter1_st = conv(g1_s,t_es); %correct for time shift using conv g1_st(1:n_tgr) = inter1_st(64:n_tgr+64-1)*dt; %grating moving to the left g2 = cos(k_x*repmat(x,[n_tgr 1]) + k_t*repmat(t_gr,[1 nx])); %spatial component g2_s = g2*r_es'; %temporal convolution inter2_st = conv(g2_s,t_es); %correct for time shift using conv g2_st(1:n_tgr) = inter2_st(64:n_tgr+64-1)*dt; figure; h1 = plot(t_gr,g1_st); hold on; h2 = plot(t_gr,g2_st,'r.'); legend([h1 h2],{'right' 'left'}); title('response of separable Gabor Filter to left/right moving sine waves'); xlabel('time (s)'); ylabel('response (arbitrary units)'); %spatial component odd filter part g3_s = g1*r_os'; %temporal convolution inter3_st = conv(g3_s,t_os); %correct for time shift using conv g3_st(1:n_tgr) = inter3_st(64:n_tgr+64-1)*dt; %spatial component odd filter part g4_s = g2*r_os'; %temporal convolution inter4_st = conv(g4_s,t_os); %correct for time shift using conv g4_st(1:n_tgr) = inter4_st(64:n_tgr+64-1)*dt; figure; h3 = plot(t_gr,g1_st+g3_st); hold on; h4 = plot(t_gr,g1_st+g4_st,'r.'); legend([h3 h4], {'right' 'left'}); title('response of inseparable GF to left/right moving sine waves'); xlabel('time (s)'); ylabel('response (arbitrary units)');