20 lines
632 B
Matlab
20 lines
632 B
Matlab
function s_est = reconstructStimulus(spike_times, sta, stim_duration, dt)
|
|
% Function estimates the stimulus from the Spike-Triggered-Average
|
|
% (sta).
|
|
% Arguments:
|
|
% spike_times, a vector containing the spike times in seconds.
|
|
% sta, a vector containing the spike-triggered-average.
|
|
% stim_duration, the total duration of the stimulus.
|
|
% dt, the sampling interval given in seconds.
|
|
%
|
|
% Returns:
|
|
% the estimated stimulus.
|
|
|
|
s_est = zeros(round(stim_duration / dt), 1);
|
|
|
|
binary_spikes = zeros(size(s_est));
|
|
binary_spikes(round(spike_times ./ dt)) = 1;
|
|
|
|
s_est = conv(binary_spikes, sta, 'same');
|
|
|