How do I create a sliding window and/or bin that records the number of elements over a given time period
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have neural data collected across 16 different channels (2d matrix = 756909 x 16). This data was recorded over a 30 second period (2d matrix 1 x 756909).
For each channel, I have calculated an amplitude threshold (2d matrix 1 x 16).
Over a 10s period (from 20 - 30s), I want to record the number of neural data points that are greater than or equal to the corresponding threshold for each channel. I would like to do this in windows (or bins) of 0.001s.
My code so far is still very deficient but looks like this:
t1 = 20; %start time, seconds
t2 = 30; %end time, seconds
time = tim_trl(tim_trl>=t1 & tim_trl<=t2); %10s window
for ii = 1:16
for jj = t1:0.001:size(time,2)
end
end
I would appreciate any help or advice.
2 comentarios
dpb
el 25 de Jul. de 2020
Is this fixed sample time and if so, what is the actual sampling rate?
IF the data are in fact collected over exactly 30 sec, we can compute what the sampling rate is but if the 30 sec is just an approximation of how long 756909 samples is as the sampling rate is 40 usec instead of 39.6349... usec, that's a different story.
Or, if it's just polled sampling and the the sampling rate is just about 40 usec, that's something different yet.
Need the groundrules strictly defined first, then it'll be straightforward to answer the questions wanted.
Respuesta aceptada
Matt J
el 25 de Jul. de 2020
Editada: Matt J
el 25 de Jul. de 2020
t1 = 20; %start time, seconds
t2 = 30; %end time, seconds
win=tim_trl>=t1 & tim_trl<=t2;
time = tim_trl(win); %10s window
edges=time(1):0.001:time(end)+0.001;
bins=discretize(time,edges);
result=splitapply(@(z)sum(z,1), neuralData(win,:) >= thresholds ,findgroups(bins(:)))
3 comentarios
Matt J
el 26 de Jul. de 2020
You're welcome, but please Accept-click the answer to indicate that it solved your problem.
Más respuestas (0)
Ver también
Categorías
Más información sobre Pulsed Waveforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!