How do I create a sliding window and/or bin that records the number of elements over a given time period
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2020-7-25
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.
采纳的回答
Matt J
2020-7-25
编辑:Matt J
2020-7-25
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 个评论
Matt J
2020-7-26
You're welcome, but please Accept-click the answer to indicate that it solved your problem.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pulsed Waveforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!