This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/pointprocesses/code/reconstructStimulus.m
2015-11-26 23:40:12 +01:00

20 lines
698 B
Matlab

function s_est = reconstructStimulus(spikes, sta, duration, deltat)
% Estimate the stimulus from the spike-triggered-average (STA).
%
% s_est = reconstructStimulus(spikes, sta, duration, deltat)
%
% Arguments:
% spikes : a vector containing the spike times in seconds.
% sta : a vector containing the spike-triggered-average.
% duration: the total duration of the stimulus.
% deltat : the time step of the stimulus in seconds.
%
% Returns:
% s_est: vector with the estimated stimulus.
s_est = zeros(round(duration / deltat), 1);
binary_spikes = zeros(size(s_est));
binary_spikes(round(spikes ./ deltat)) = 1;
s_est = conv(binary_spikes, sta, 'same');
end