%This function sub-samples the input 'spk_train' and 'time_vec' by a value 'factor' %and stores the results in a new file. function Decimate(file_name,factor), %Load extracted spike file file = sprintf('%s.mat',file_name); load(file); %Allocate temporary storage train_decimated = zeros(size(extracted_spks,1)/factor,size(extracted_spks,2)); time_decimated = zeros(length(time)/factor,1); %Decimate time vector time_slots = [1:factor:size(extracted_spks,1)]; time_decimated = time(time_slots); %Decimate spike vector one pad at a time for i = 1:size(extracted_spks,2), %Find spike locations, and decimate them tmp = find(extracted_spks(:,i)); tmp = floor((tmp-1)/factor) + 1; train_decimated(tmp,i) = 1; end; %Convert decimated spike train into sparse matrix [i,j,s] = find(train_decimated); [m,n] = size(train_decimated); train_decimated = sparse(i,j,s,m,n); %Save decimated spike train file file = sprintf('%s_decim_by_%d.mat',file_name,factor); save(file,'train_decimated','time_decimated'); return;