function [average_psth, std_psth] = psth(spike_times, max_time, sample_rate, kernel_width)

binary_spikes = zeros(size(spike_times,2), round(max_time*sample_rate));
responses = zeros(size(binary_spikes));
window = hann(kernel_width*sample_rate,'symmetric');
window = window/sum(window);

for i = 1:size(spike_times,2)
    t = spike_times{i};
    temp = round(t*sample_rate);
    if temp(1) <= 0 
      temp(1) = 1;
    end
    binary_spikes(i, temp) = 1;
    responses(i,:) = conv(binary_spikes(i,:), window, 'same')*sample_rate;
end

average_psth = mean(responses,1);
std_psth = std(responses, [], 1);