MATLAB Answers

Setting time intervals in a cell array all to the same 0 to 5 second time interval

1 view (last 30 days)
Krispy Scripts
Krispy Scripts on 13 Jun 2016
Commented: Krispy Scripts on 16 Jun 2016
I am trying to find the spiking rates over 5 second intervals of time. I have the spike times of intervals in a cell array(spk). I am wondering if it is possible or if any of you clever coders might know of a way to set all of the intervals and spike times contained within those intervals to 0 to 5 second interval. For example, the spike time of the first interval in the cell is 59.031, so put that as 0.031. The next 59.0599 to 0.0599. Is this possible?

  3 Comments

John BG
John BG on 13 Jun 2016
I need some background.
Firstly please clarify the following points:
1.- when you say the 'rates' of those spikes, to me, I read you are after the frequencies, is my assumption correct?
If so you may try the FFT, I already have, but bare without options, not of much help, at least not over the interval of 5 seconds.
s1=spk{1}
s2=spk{2}
s3=spk{3}
S1=fft(s1);S2=fft(s2);S3=fft(s3);
stem(abs(S1)) % just one significant sample
2.- I have the impression that if you reveal a bit of the application, the readers of your question may be able to aim the answers on the right direction.
3.- Frequency analysis requires repetition, let me explain: When a certain event happens every time within the time window of observation (what you mention 5 seconds) such event has a frequency f1=1 cycle = 1 Hz = once per observation window. If another event happens twice as often within same time windowing, this second event has f2=2*f1.
Having it clear, your recording is a one-off, there is no repetition.
4.- Are all spikes the same, or can you tag them, with amplitude, phase, frame position?
5.= The '59.031 .. as 0.031' and '59.0599 to 0.0599', this rounding, you probably mean inversion f1=1/T1, right? to go from time domain to frequency domain?
6.- checking the 1st derivative is always useful:
Because the variations you want to study rates of are comparatively really small
ds1=diff(s1)
max(ds1)
=
1.581700000000005
min(ds1)
=
6.750000000010914e-04
mean(ds1)
=
0.058685843373494
so the widest variations away from a regular constant cycle interval occur between spikes 13 to 25 (within the 84 registered spikes of s1)
I don't think this comment qualifies as answer, but in the interest of answering something to be accepted, please shed some light, enough to develop an answer.
Regards
John BG
Krispy Scripts
Krispy Scripts on 13 Jun 2016
My apologies on lack of clarity. These spike times are times when recorded neurons are firing, so it is just the time stamp. I have this five second window of time during which a behavior is occurring that I would like to see the spiking rate or amount of spikes happening per time over this five seconds. I attached an image that I hope will show exactly what I am trying to do once I have what I am asking here. I can calculate for this, but I need two things. First I need all of the spike times in those intervals in cell arrays, like I have in the spks.mat attached. The second is that I need all of the spike times in the five second window relative to each other, so when all the intervals start, no matter what time that becomes time 0. The time of these stamps is continually happening so I need a way to take these five second intervals and set all of the first. My apologies again because I did not attach the interval matrix, but I attached it here. So the spike times from the intervals are in the spks.mat, but I need to set the beginning of the interval as time 0 for all of these interval's spike times? Does this make it more clear? My apologies again for the lack of clarity from my first post and in advance if this does not help.
Image is not supported, but here is a google link to peri-stimulus histograms and raster plots of spiking rates over time periods.
https://www.google.com/search?q=peristimulus+time+histogram&espv=2&biw=1440&bih=799&tbm=isch&imgil=6hjVLtLAq8dHMM%253A%253BZ9MK_7n9kWdEtM%253Bhttp%25253A%25252F%25252Fsifter.org%25252F~simon%25252Fjournal%25252F20070705.html&source=iu&pf=m&fir=6hjVLtLAq8dHMM%253A%252CZ9MK_7n9kWdEtM%252C_&usg=__iwWPyv19x2QpzDl_1OZ4qQxlw_Y%3D&ved=0ahUKEwjp1tTlkabNAhXCRSYKHQN0BOsQyjcINA&ei=Xj9fV-mvNMKLmQGD6JHYDg#imgrc=6hjVLtLAq8dHMM%3A

Sign in to comment.

Answers (1)

Andrew Bliss
Andrew Bliss on 13 Jun 2016
Not quite sure what you're trying to do, but wouldn't mod help? E.g.
mod(59.031,1)

  0 Comments

Sign in to comment.

Sign in to answer this question.