How to identify the beginning of another hour and choose 3 rows per hour depending on the value of another metric in another column?

1 view (last 30 days)
Hey everybody!
I want to analyse 24h ECG recordings (that are divided in several files) from several patients and I already have the metrics in struct files. The metrics are analysed each 5 minutes but I need to analyse statistically 10 min in each hour with an overlap of 50% (3 rows per hour). The rows need to be consecutive and depend on a threshold in column 3 (minimum of 50% in each row) so they don't always get chosen every N rows (attached picture). I need to find the mean, maximum and minimum of those 3 rows.
I also have a char event time with the time and date of the beginning of the file, the beginning and end of the intervals I am interested in (attached picture).
Could anyone help me with the easiest/efficient way to analyse all the data?
  2 Comments
Rishabh Mishra
Rishabh Mishra on 2 Sep 2020
Hi,
Kindly attach the ECG readings file, it would enable me to come up with an efficient solution and help you in the best way possible.
Márcia Nunes
Márcia Nunes on 2 Sep 2020
Hi Rishabh, I am afraid I can't attach the file you are are requesting since the data is confidential. If there is some way to help me it would be great, if not I understand it is complicated to help without all the information

Sign in to comment.

Answers (1)

Rishabh Mishra
Rishabh Mishra on 3 Sep 2020
Hi,
Consider the code given below. Few assumptions that I have made while writing this code are:
  1. The readings are taken starting 12 at Midnight.
  2. The ECG readings & it’s columns are stored in ‘M’ matrix.
  3. The readings consist of 24 x 12 rows.
  4. The number of readings taken every hour is 12 (as readings are taken every 5 minutes on average)
The code:
% assuming that ECG rreadings are taken starting 12 Midnight
start = datetime(2020,1,1,0,0,0)
% assuming that data is stored in 'M' matrix
% time of reading
time = M(:,1)
% reading value
reading = M(:,2)
% threshold value
threshold = M(:,3)
% traverse each row of the data
for k = 1:numel(time)
i = 0
if (time(k) >= start & threshold(k) >= 50.0)
i = i+1
else
i = 0
end
% if 3 consecutive rows with given requirements are found
if (i == 3)
disp(mean(reading(k-2:k))
disp(min(reading(k-2:k))
disp(max(reading(k-2:k))
start = start + duration(1,0,0)
i = 0
end
end
Hope this helps.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!