我有一个尖峰时间向量(来自神经元的动作电位)和一个刺激事件时间戳向量。我想创建一个 PSTH 来查看刺激是否会影响神经元的尖峰率。我可以通过循环遍历每个刺激事件来做到这一点(参见下面的简单示例),但是对于有超过 30,000 个刺激事件并且正在记录许多神经元的长时间实验来说,这非常慢。
如果没有 for 循环,如何做到这一点?
慢速方式示例:
% set variables
spikeTimes = [0.9 1.1 1.2 2.5 2.8 3.1];
stimTimes = [1 2 3 4 5];
preStimTime = 0.2;
postStimTime = 0.3;
for iStim = 1:length(stimTimes)
% find spikes within time window
inds = find((spikeTimes > (stimTimes(iStim) - preStimTime)) & (spikeTimes < (stimTimes(iStim) + postStimTime)));
% align spike times to stimulus onset
stimONtimes = spikeTimes(inds) - stimTimes(iStim);
% store times in array for plotting
PSTH_array(iStim,1:length(stimONtimes)) = stimONtimes;
end