How do I create a sliding window and/or bin that records the number of elements over a given time period
9 ビュー (過去 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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!