%This function displays flicker-free animations of spike activity function Spk_animate(spk_vec,time_vec,disp_time,ms_per_frame,fps), %Variables spk_vec; %Matrix of spikes time_vec; %vector of times asscoiated with the spike train disp_time; %vector of [start_time stop_time] for display (ms) ms_per_frame; %amount of each frame advance (skips frames in between) fps; %approximate # of frames per second to display %Find number of vector slots to skip for given ms/frame tmp = find(time_vec < ms_per_frame); frame_skip = length(tmp); %Find indexes of frames to be displayed tmp = find((time_vec >= disp_time(1)) & (time_vec <= disp_time(2))); start_frm = tmp(1); stop_frm = tmp(length(tmp)); %Find total time in data tot_time = size(spk_vec,1); %Transpose spike vector spk_vec = spk_vec'; %Find max and min values in vector clow=min(min(spk_vec)); chigh=max(max(spk_vec)); %Set up diplay colormap colormap('default'); caxis([clow chigh]); %Reshape spike data for display spk_vec=reshape(spk_vec,[8 8 tot_time]); %For flash free animation! h = figure(1); set(h,'DoubleBuffer','on'); %Start animation for frame = start_frm:frame_skip:stop_frm, %Display frame and update title imagesc(spk_vec(:,:,frame)',[clow chigh]); colorbar('horiz'); axis image off; title(sprintf('Time = %dms',time_vec(frame))); pause(1/fps); drawnow; end; return