MATLAB Answers

how can i find and mark indexes on my data?

5 views (last 30 days)
furkan akhan
furkan akhan on 9 May 2021
Commented: Rik on 10 May 2021
I have an ''ses'' file of 1x144000 size. I converted them into 400x720 arrays with 200 overlap with the code "buffer". Based on this information, I calculated a value (feature) called mean crossing irregularity and this is a 1x720 size file. Based on this calculation, I set the threshold as 0.4. I have created a table with the ones larger than 0.4 as "non-wheeze" and the smaller ones as "wheeze". My aim is to find the indexes of these "wheezes" and mark the "wheezes" in the ''ses'' file with vertical lines, but I cannot find the indexes and therefore I cannot mark them. You can see the codes for all of the calculations and the table of marking wheezes and non-wheezes. Can you help me?

Answers (1)

Rik
Rik on 9 May 2021
The answer is already in your question: you should use the find function on your mci array.
For clarity, here are the contents of that m-file:
ses=structWheeze(2,1).SoundData;
piece = 400;
overlap = 200;
frames = buffer(ses, piece, overlap);
mci=zeros(1,size(frames,2)-1); %if you want to do many trials with different segment lengths and overlap amounts, you need to initialize so that a different trial will not be affected by the previous
for segind = 2:size(frames,2)
segment=frames(:,segind);
segment=segment-mean(segment); %since it is "mean" crossing irregularity, we should subtract the mean value if our algorithm finds "zero" crossings
x = 1:length(segment);
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0);
dy = zci(segment);
x0=zeros(1,size(dy,1)-1); %you need to initialize to refresh it for every new segment
for k = 1:size(dy,1)-1
b = [[1;1] [x(dy(k)); x(dy(k)+1)]]\[segment(dy(k)); segment(dy(k)+1)];
x0(k) = -b(1)/b(2);
end
iz=diff(x0);
iz(isnan(iz))=[];
mci(segind)=std(iz)/mean(iz);
end
figure,plot(ses),hold on,plot(resample(mci,144000,length(mci)),'r')
w = strings(size(mci));
w(mci<0.4) = "wheeze";
w(mci>=0.4) = "non-wheeze";
T = table(mci.',w.');
  6 Comments
Rik
Rik on 10 May 2021
Since neither you, nor your classmate attached any data, I can't help you very well.
You can see in the wheeze_ind variable all the indices where there is a wheeze. Those are the indices of wheezes, so I don't understand what your issue is.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!