# How to Extract Breathing rate with motion artifacts ?

2 Ansichten (letzte 30 Tage)
David De Querol am 15 Jun. 2022
Beantwortet: Karan Singh am 3 Okt. 2023
Having the created signal out of each capacitive ECG, my task is to calculate the median breathing rate (in Beats Per Minute) over the whole database. The problem arises as some intervals of the signal(s) should be ignore, as motion artifacts created these false data.
As a starting point, I (cheated) choosed an specific interval (Samples from 2985,145 to 2995,145) from the cECG_2 signal. As far as I am concern, 15 BPM is the standard measure. So my result of 11.9 BPM which although a bit low, I believe it is correct. Right?. The code for this easy step is as follows.
function [totalHF] = extract_HF(RR, RR_location, ECG_Signal, record)
%% Calculate HF
counter = 0;
HF = [];
totalHF = 0;
%% How to extend from 1 period to 3 breathing rate periods?
%for i=1:length(RR_location)
for i=4215:4228 %interval from Samples 2985,145 bis 2995,145
%remove strong artifacts
% if((RR_location > 1000) || (RR_location < 200))
% break;
% end
HF(i) = 1000 * abs((RR_location(i+1)-RR_location(i)) / 60);
totalHF = totalHF + HF(i);
counter = counter +1;
end
totalHF = totalHF / counter;
end
Now, my question is how can I prolong these code for the whole database. Any suggestions?
My first thoughts are to firstly extend the single period to 3, so that the program can already differentiate between a "starting point & end point" of each cycle or period. Also, I should manually remove the strong motion artifacts.
Thanks,
David
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
David De Querol am 20 Jun. 2022
Need some help here. So any idea will be much appreciate it.

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Karan Singh am 3 Okt. 2023
Hi David,
From what I understand, the goal is calculate the median breathing rate over a database of signals obtained from capacitive ECG measurements also excluding intervals with motion artifacts and calculating the breathing rate for each interval.
To extend the code for calculating the median breathing rate over the whole database and handle motion artifacts, you can follow these steps:
1. Iterate over the entire database: Modify the code to loop over each signal in your database, instead of just the specific interval.
2. Extend the period: Instead of calculating the breathing rate for a single interval, you can define a longer interval that covers multiple breathing rate periods. For example, you can select an interval of 3 periods (e.g., 3 cycles of the breathing rate).
3. Handle motion artifacts: To exclude intervals with motion artifacts, you can add a condition to skip or ignore those intervals. You can incorporate this step by including a check within the loop to identify and exclude intervals that contain significant motion artifacts.
Here's an example of how you can modify your code to extend it for the whole database and handle motion artifacts:
function [medianBreathingRate] = calculateMedianBreathingRate(database)
breathingRates = [];
for i = 1:length(database)
ECG_Signal = database{i}; % Get the ECG signal from the database
% Define the interval for calculating the breathing rate
startSample = 2985145;
endSample = 2995145;
% Check for motion artifacts and skip if necessary
if hasMotionArtifact(ECG_Signal(startSample:endSample))
continue;
end
% Calculate the breathing rate for the interval
breathingRate = calculateBreathingRate(ECG_Signal(startSample:endSample));
breathingRates = [breathingRates, breathingRate];
end
% Calculate the median breathing rate over the whole database
medianBreathingRate = median(breathingRates);
end
function hasArtifact = hasMotionArtifact(signal)
% Implement your logic to detect motion artifacts in the signal
% Return true if motion artifacts are present, false otherwise
% You can define specific criteria or thresholds to determine motion artifacts
end
function breathingRate = calculateBreathingRate(signal)
% Implement your logic to calculate the breathing rate for the given signal
% You can use the same calculation approach as in your original code
end
In this example, the calculateMedianBreathingRate function takes the database as input and iterates over each signal. It checks for motion artifacts using the hasMotionArtifact function and skips the current signal if motion artifacts are detected. Otherwise, it calculates the breathing rate using the calculateBreathingRate function and stores it in the breathingRates array. Finally, it calculates the median breathing rate over the whole database using the median function.
Hope this helps!
Karan Singh Khati
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by