I would like help setting up my code

1 次查看(过去 30 天)
NA
NA 2022-11-2
回答: Jan 2022-11-3
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 个评论
NA
NA 2022-11-3
Hi Jan, thanks for getting back to me.
An UP state is: [ones(100, 1); TRANSITION; zeros(80, 1)];
The TRANSITION period is a segment of 20 datapoints that I would like to overlook because it is made up of random 0's, 1's and -1's.
Is there a way of searching through con accounting for this transition period?
Many thanks
Jan
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
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.

类别

Help CenterFile Exchange 中查找有关 Variables 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by