function y = spike_filter_binned(ts,fromto,bins,krn,varargin) % this function uses qcount_binned to normalize trial time length and % calculate "squeezed" psth. binsz=5e-4 ; normalize_krn= 1 ; utils.overridedefaults(who, varargin) if normalize_krn krn = krn/sum(abs(krn))/binsz; % normalize end offset = ceil(length(krn)/2); buffer=offset*binsz; fromto = [fromto(:,1) - buffer,fromto]; bins = [offset,bins]; y = stats.qcount_binned(ts,fromto,bins); y = [y,zeros(size(y,1),offset)]; y = filter(krn, 1, y, [], 2); y = y(:, 2*offset:end-1); % trim extra columns end