Looking for ideas to solve a trivial problem. One must calculate each Period individually

조회 수: 2 (최근 30일)
This is a sketch to receive feedback from other sources, as the task is not easy.
We have the following interval, in which the maximum values (showned here as X=3000,81 Y=730 ; X =3005,16 Y=740 ; etc. ) should be saved independently; and at the same time measure its mean value. The data showned has been plot as plot(RR_location , RR), in which both RR_location and RR have a length of 14583x1 double.
There are 2 goals, which both of them are complementary from each other.
The first one is to measure each maximum peak for as long as to reach the next following one (this will be measure as a whole period, which will save in the parameter arrayMax the new maximum peaks (keeping the length of RR_location).
The second goal is the mean breathing rate {as an example for the first period: meanHF = (730 + 715 + 725 + 725 + 720 + 735 + 740) / 7 = 727,14}. This will then be save in finalHF{i} = meanHF / 60 (units: Beats per Minute).
My actual guess, which is wrong (no need to test it, its just a first sketch with some random parameters and comments floating around jeje), as I simply need some fresh air. :)
%array for only maximum values (this would be the output of the function
arrayMax = [];
%constant value for the actual Max value (or at least a guess)
newMax = 0;
firstMax= 0;
secondMax=0;
%Mean value Breathing Rate
MeanHF = 0;
%second output final HF
%actual HF
actualHF = 0;
%step Counter to do the mean value afterwards
counter = 0;
for i=1:length(RR_location) %this is for the whole database
%The maximas showned in the graph are as follow:
%Sample RR_location(i= 4429) => X=3000,81 ; Y=730
%Sample RR_location(i= 4435) => X=3005,16 ; Y=740
%Sample RR_location(i= 4440) => X=3008,8 ; Y= 740
%Sample RR_location(i= 4444) => X=3011,74 ; Y= 750
%Sample RR_location(i= 4453) => X=3018,15 ; Y= 745
%This would be associated to a motion artifact, aka a false value to be remove
if(RR(i+1) > 1000) || (RR(i+1) < 500)
newMax = 0;
else
firstMax = RR(i+1);
end
%And here is where my struggles arise (aka PROBLEM)
if (RR(i+1) > firstMax)
newMax = RR(i);
counter = 0;
elseif (RR(i+1) < firstMax)
newMax = 0; %if it wasnt a Max peak, the arrayMax = 0;
counter = counter + 1; %we increase the step counter;
end
arrayMax{i} = newMax;
firstMax = RR(i);
%if we find a maxPeak, we enter a new for-loop
for j=1:10
actualHF = RR(i);
%count the number of samples taken
if(RR(i+j+1)>RR(i+j))||(RR(i+j+1)>firstMax)
counter = counter + 1;
else
secondMax = RR(i+j);
break;
end
end
meanHF = ( ) / 60;
secondMax = firstMax;
end
If it helps, I can upload the X and Y values for the whole interval showned above. Just ask for it.
Any suggestion are welcome.
Thank you, David
  댓글 수: 1
Image Analyst
Image Analyst 2022년 6월 22일
편집: Image Analyst 2022년 6월 22일
Is it "trivial" or "not easy"? Explain the contradiction.
Did you try findpeaks?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by