I would like help setting up my code
1 view (last 30 days)
Show older comments
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 Comments
Jan
on 3 Nov 2022
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?
Answers (1)
Jan
on 3 Nov 2022
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 Comments
See Also
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!