I would like help setting up my code

조회 수: 2 (최근 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에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by