challenge, convert ECG to IBI
in
Programming Questions
•
2 years ago
I got elektrocardiogram data of a heartbeats of serveral persons, i also got files with just the IBI data (inter beat interval).
The ECG data looks like this, where the first is time after start end the second the raw measurement value
There is a part where the persons where running, in the IBI data it often skipped a heartbeat which makes the interval looks longer. I need the IBI data, not the ECG.
I was thinking maybe it's possible to convert the ECG data to IBI data.
Here i visualized a small part of the ECG, so messuring the time between each peak would give the IBI (or start of each peak)
Only above version is quite clean, take the next one for example, i can judge with my eye where a new heartbeat starts, only how do i figure this out just in numbers?
Here's another one:
I can use the data with the interval errors in it but if i could get a cleaner version out of the ECG then that would be really great. Atm you can see in my data visualization really good that some data is corrupt.
So if your bored to death and want to help someone, go ahead.
This code shows the ecg line:
- String[] lines;
- int index = 1508500;
- int minData = MAX_INT;
- int maxData = MIN_INT;
- void setup() {
- size(1000, 600);
- lines = loadStrings("../data/2351/00000004_ECG.csv");
- //find min and max data
- for(int i = 0; i < lines.length; i++) {
- String[] tokens = splitTokens(lines[i], ",");
- int data = int(tokens[1]);
- if(data > maxData) maxData = data;
- if(data < minData) minData = data;
- }
- println("minData: "+minData);
- println("maxData: "+maxData);
- smooth();
- frameRate(100);
- }
- void draw() {
- background(255);
- beginShape();
- float x = 0;
- for(int i = index; i < index+width; i++) {
- if(i > lines.length) {
- noLoop();
- break;
- }
- String[] tokens = splitTokens(lines[i], ",");
- int data = int(tokens[1]);
- float y = map(data, minData, maxData, height-100, 100);
- vertex(x, y);
- x++;
- }
- endShape();
- index += 15;
- }
The ibi files look like this, where the first value is the time after the start, and the second value is the interval time seen from the previous heartbeat.
- 2.13977, 1.09662
- 3.15959, 1.01982
- 4.10357, 0.94399
- 5.05534, 0.95176
- 5.94002, 0.88468
- 6.80332, 0.86330
- 7.84549, 1.04218
- 8.91003, 1.06454
- 9.86471, 0.95468
- 10.66093, 0.79622
- 0.11569,2730927.00000
- 0.11666,2731308.00000
- 0.11763,2730875.00000
- 0.11861,2730994.00000
- 0.11958,2731251.00000
- 0.12055,2730974.00000
- 0.12152,2731937.00000
- 0.12249,2732202.00000
- 0.12347,2732325.00000
- 0.12444,2732526.00000
- 0.12541,2732250.00000
- 0.12638,2732206.00000
- 0.12736,2732474.00000
- 0.12833,2732447.00000
- 0.12930,2732922.00000
- 0.13027,2733368.00000
- 0.13124,2733755.00000
- 0.13222,2734092.00000
- 0.13319,2733881.00000
- 0.13416,2733937.00000
- 0.13513,2733918.00000
- 0.13611,2733412.00000
- 0.13708,2733740.00000
- 0.13805,2733629.00000
- 0.13902,2733879.00000
- 0.13999,2734173.00000
- 0.14097,2735096.00000
- 0.14194,2735119.00000
the raw value can really be different for each person, like the more neutral line (horizontal line in image) is here 27##### by someone else it can be 40#####.
1