Help with PSTH (Peristimulus Time Histogram)
24 views (last 30 days)
Show older comments
Hi all,
I am trying to write a function that computes a PSTH (peristimulus time histogram). I have data from electrophisiology experiment, composed by the timestamps in seconds of spiking of 60 channels of recording and timestamps of 2 indexes of stimulation. I am trying to create this function that would select one channel and compute the PSTH. I am having problems with it, nonetheless.
I set the variables:
end
stimArrayx = timeStim{1, 2};
timeStampsx = timeStamps{1, 1}; %This is channel 1. It has 15 timestamps for the whole experiment.
preStim = 2; % time before stimulation in seconds
posStim = 6; % time after stimulation in seconds.
Then, I am trying to understand the coding for creating a PSTH proposed by one of the questions posted before here (this Loop: https://stackoverflow.com/questions/38941771/vectorized-approach-to-compute-psth-peristimulus-time-histogram-in-matlab). Using the same loop I am also plotting something, but it is not right yet.
for iStim = 1:length(stimArrayx)
% find spikes within time window
inds = find((timeStampsx > (stimArrayx(iStim) - preStim)) & (timeStampsx < (stimArrayx(iStim) + posStim)));
% align spike times to stimulus onset
stimONtimes = timeStampsx(inds) - stimArrayx(iStim);
% store times in array for plotting
PSTH_array(iStim,1:length(stimONtimes)) = stimONtimes;
end
histogram(PSTH_array)
Any help in constructing this function would be appreciated.
Thank you very much
0 Comments
Answers (0)
See Also
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!