Z
Z
Zakhar Alekseenko2013-12-06 03:59:29
Algorithms
Zakhar Alekseenko, 2013-12-06 03:59:29

Analysis of data from temperature sensors and Fleisch tubes?

Hello.
There is such a thing in pulmonology as hyperventilation of the lungs with cold air. A person is docked to the apparatus supplying cold air through a tee with valves. When you inhale, the inlet valve opens and cold air is supplied, and when you exhale, the exhaust valve opens.
In our case, each valve has a temperature sensor (Karmanov's temperature sensors), respectively, taking the temperature of the inhaled and exhaled air. The volume of inhaled air is measured using a Fleisch flow sensor.
The data from the sensors is transferred to the program via the RTUSB3000 device. They look something like this:
918a573fa6f1ea499e068d6eaac70e06.png
Upper graph from the Fleisch tube. Then the temperature of the inhaled air. The temperature of the exhaled air. Measurements are taken 10 times per second. On the graphs, not degrees and not liters, but millivolts, along the y-axis.
In order for the doctor to assess the quality of breathing, such parameters as the average time of inhalation, exhalation, max. min. inspiratory expiratory temperature, average max. minute ventilation.
To calculate all the parameters, it is necessary to determine the respiratory cycles on the graphs, the beginning and end of inhalation and exhalation. On the graph below, the points that need to be isolated are marked. I would be grateful for any help, references to the mat apparatus and algorithms are welcome.
4caa6a519ed93ac2d00ea49b8d392560.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2013-12-06
@Zaher220

With temperatures, everything is quite simple, the graphs are without noise. You can take local minima / maxima, just sort through the entire array, counting the difference between the values ​​​​at the current and at the next point, change sign, then write the point as a local extremum.

d = V[1]-V[0];
for (i = 1; i < N-1, i++) {
    d1 = V[i+1]-V[i];
    if (d < 0 && d1 > 0) {
        // Локальный минимум V[i]
    } else if (d > 0 && d1 < 0) {
        // Локальный максимум V[i]
    }
    d = d1;
}

For the volume graph with noise, if the noise level is known in advance, then it can be eliminated by ignoring the difference that falls into the noise level. To find the middle of the inflection in this case, you can analyze two transitions - from increase to zero and from zero to decrease (vice versa for the lower inflection) and take the value in the middle of the inflection or the average value between the extreme points of the inflection.
noise = 2; // Уровень шума, поставить нужное значение
t1 = 0; // Точка перехода к нулю
upDown = 0; // Направление движения до нуля, > 0 - вверх, < 0 - вниз, 0 - начало графика
d = V[1]-V[0];
if (abs(d) < noise)
    d = 0;
for (i = 1; i < N-1, i++) {
    d1 = V[i+1]-V[i];
    if (abs(d1) < noise)
        d1 = 0;
    if (d < 0 && d1 > 0) {
        // Локальный минимум V[i]
    } else if (d > 0 && d1 > 0) {
        // Локальный максимум V[i]
    } else if (d != 0 && d1 == 0) {
        t1 = i;
        upDown = d;
    } else if (d == 0 && d1 > 0 && upDown < 0) {
        // Локальный минимум V[(t1+i)/2] или (V[t1]+V[i])/2
    } else if (d == 0 && d1 < 0 && upDown > 0) {
        // Локальный максимум V[(t1+i)/2] или (V[t1]+V[i])/2
    }
    d = d1;
}

M
molekyla, 2013-12-06
@molekyla

To filter out noise, you can use some kind of filter, for example KSmooth or a Gaussian filter , and then look for derivatives as Rsa97 said. I don’t know how it will be with accuracy, but at first glance, to determine cycles (I mean their periods), there should be quite acceptable accuracy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question