I would like help setting up my code
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have an array (31003x1), made up of -1’s, 0’s, and 1’s, that represents neural data. The data was down-sampled from 24.414 KHz to 1 KHz.
I want to see how many times UP initiation takes place.
UP initiation is defined as:
A suppressed state (0), followed by a transition period (random 0’s, +1’s, and -1’s), and then an UP (+1) state. The suppressed state needs to last 90 ms (or 90 data points); the transition period should last 10 ms (or 10 data points); and the UP state needs to last 100 ms (or 100 data points).
OR [defined as]
A DOWN state (-1), followed by a transition period, and then an UP state (+1). Like above, the DOWN state needs to last 90 ms, the transition 10 ms, and the UP state 100 ms.
For the same array, I want to also see how many times UP termination takes place.
UP termination is defined as:
An UP state (+1), followed by a transition phase, and then a suppressed state (-1). The UP state needs to last 100 ms; the transition period 20 ms; and the suppressed state 80 ms.
OR
An UP state (+1), that is followed by a period of transition, and then a DOWN state (-1). Similarly, the UP state needs to last 100 ms; the transition period 20 ms; and the DOWN state 80 ms.
I’m having trouble getting started with this, and would any appreciate your help or guidance.
Thank you.
5 个评论
Jan
2022-11-3
Then the states cannot be uniquely identified. See this example with a shorter pattern
UP = [1,1,1,x,x,x,x,0,0,0] % Pattern: 3*1, 4 transitions, 3*0
signal = [1,1,1,1,0,0,0,0,0,0]
UP 1: ^ ^ ^ x x x ^ ^ ^
UP 2: ^ ^ ^ x x x ^ ^ ^
Which one should be chosen?
回答(1 个)
Jan
2022-11-3
up1 = strfind(con.', ones(1, 100));
up2 = strfind(con.', zeros(1, 80));
up = intersect(up1, up2 - 21);
Cleanup detections with a too short distance:
upc = zeros(size(up));
t = -Inf;
c = 0;
for k = 1:numel(up)
if up(k) - t > 201
c = c + 1;
upc(c) = up(k);
end
end
up = upc(1:c);
There might be a nicer version.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!