Exemple #1
0
        private static void PlotMaxim(System.Windows.Window owner, HRContext ctx)
        {
            List <DataPoint> dx;
            List <DataPoint> dxBeforeHamming;

            LogParser.Maxim(ctx.iredsRaw, ctx.redsRaw, out dx, out dxBeforeHamming);
            var maximWnd = new LogPlotWnd();

            maximWnd.MyModel.Title = "maxim";
            maximWnd.MyModel.Series.Clear();
            var s5 = new OxyPlot.Series.LineSeries();
            int hr = HRCLib.HRCLib.GetHeartRate();

            s5.Title = $"dx-{hr}";
            s5.Points.AddRange(dx);
            maximWnd.MyModel.Series.Add(s5);

            var s6 = new OxyPlot.Series.LineSeries();

            s6.Title = "dx-b-hamming";
            s6.Points.AddRange(dxBeforeHamming);
            maximWnd.MyModel.Series.Add(s6);
            maximWnd.Owner = owner;
            maximWnd.Show();
        }
Exemple #2
0
        private static void PlotFFT(System.Windows.Window owner, HRContext ctx)
        {
            List <DataPoint> fft1;
            List <DataPoint> fft2;

            LogParser.FFT(ctx.redsOSC, out fft1);
            LogParser.FFT(ctx.iredsOSC, out fft2);

            var fftWnd = new LogPlotWnd();

            fftWnd.MyModel.Title = "fft";
            fftWnd.MyModel.Series.Clear();
            var   s3    = new OxyPlot.Series.LineSeries();
            float freq1 = LogParser.FFTMaxAmplitude(fft1);

            s3.Title = $"red-{(int)(freq1 * 60)}";
            s3.Points.AddRange(fft1);
            fftWnd.MyModel.Series.Add(s3);

            var   s4    = new OxyPlot.Series.LineSeries();
            float freq2 = LogParser.FFTMaxAmplitude(fft2);

            s4.Title = $"ired-{(int)(freq2 * 60)}";
            s4.Points.AddRange(fft2);
            fftWnd.MyModel.Series.Add(s4);

            fftWnd.Owner = owner;
            fftWnd.Show();
        }
Exemple #3
0
        public static bool Parse(string text, HRContext ctx)
        {
            var reds  = new List <DataPoint>();
            var ireds = new List <DataPoint>();

            ctx.redsRaw  = reds;
            ctx.iredsRaw = ireds;

            var index = 0;

            using (var ss = new StringReader(text))
            {
                while (true)
                {
                    var line1 = ss.ReadLine();
                    if (line1 == null)
                    {
                        break;
                    }

                    if (!line1.StartsWith("r:"))
                    {
                        continue;
                    }

                    var line2 = ss.ReadLine();
                    if (line2 == null)
                    {
                        break;
                    }

                    if (!line2.StartsWith("ir:"))
                    {
                        continue;
                    }

                    int intValue1;
                    if (!int.TryParse(line1.Substring(2), out intValue1))
                    {
                        continue;
                    }


                    int intValue2;
                    if (!int.TryParse(line2.Substring(3), out intValue2))
                    {
                        continue;
                    }

                    reds.Add(new DataPoint(index, intValue1));
                    ireds.Add(new DataPoint(index, intValue2));

                    index++;
                }
            }

            return(reds.Count > 0 || ireds.Count > 0);
        }
Exemple #4
0
        public static float Spo2Calc(HRContext ctx, out float r)
        {
            List <int> redPeakLocs;
            List <int> iredPeakLocs;

            FindPositivePeak(ctx.redsIFFTOSC, out redPeakLocs);
            FindPositivePeak(ctx.iredsIFFTOSC, out iredPeakLocs);

            List <float> redACDC = new List <float>();

            foreach (var rpl in redPeakLocs)
            {
                var redAC = ctx.redsIFFTOSC[rpl].Y;
                var redDC = ctx.redsMV2[rpl].Y;

                var ratio = redAC / redDC;
                redACDC.Add((float)ratio);
            }

            List <float> iredACDC = new List <float>();

            foreach (var irpl in iredPeakLocs)
            {
                var iredAC = ctx.iredsIFFTOSC[irpl].Y;
                var iredDC = ctx.iredsMV2[irpl].Y;

                var ratio = iredAC / iredDC;
                iredACDC.Add((float)ratio);
            }

            List <float> ratios = new List <float>();
            var          i      = 0;

            foreach (var rr in redACDC)
            {
                ratios.Add(rr / iredACDC[i++]);

                if (i >= iredACDC.Count)
                {
                    break;
                }
            }

            var ratioFinal = Average(ratios);

            r = ratioFinal;
            double spO2 = -45.060 * ratioFinal * ratioFinal + 30.354 * ratioFinal + 94.845;   // for comparison with table

            return((float)spO2);
        }
Exemple #5
0
        private static void PlotRawMV(System.Windows.Window owner, HRContext ctx)
        {
            var wnd   = new LogPlotWnd();
            var model = wnd.MyModel;

            model.Title = "R-IR";
            model.Series.Clear();

            var s1 = new OxyPlot.Series.LineSeries();

            s1.Title = $"R:{ctx.HeartRate}";
            s1.Points.AddRange(ctx.redsRaw);
            model.Series.Add(s1);

            var s11 = new OxyPlot.Series.LineSeries();

            s11.Title = "R-MV";
            s11.Points.AddRange(ctx.redsMV1);
            model.Series.Add(s11);
            var s12 = new OxyPlot.Series.LineSeries();

            s12.Title = "R-MV2";
            s12.Points.AddRange(ctx.redsMV2);
            model.Series.Add(s12);

            var s2   = new OxyPlot.Series.LineSeries();
            var sp02 = ctx.SpO2.ToString("0.00");

            s2.Title = $"IR:{sp02}%";
            s2.Points.AddRange(ctx.iredsRaw);
            model.Series.Add(s2);

            var s21 = new OxyPlot.Series.LineSeries();
            var r   = ctx.R.ToString("0.00");

            s21.Title = $"iR-MV:{r}";
            s21.Points.AddRange(ctx.iredsMV1);
            model.Series.Add(s21);
            var s22 = new OxyPlot.Series.LineSeries();

            s22.Title = "iR-MV2";
            s22.Points.AddRange(ctx.iredsMV2);
            model.Series.Add(s22);

            wnd.Owner = owner;
            wnd.Show();
        }
Exemple #6
0
        public static void plotRedIRed(string text, System.Windows.Window owner)
        {
            var ctx = new HRContext();

            if (!LogParser.Parse(text, ctx))
            {
                return;
            }

            ctx.Refine();

            PlotRawMV(owner, ctx);

            //PlotOSC(ctx.redsOSC, ctx.redsIFFTOSC, "red", owner);

            //PlotOSC(ctx.redsOSC, ctx.iredsIFFTOSC, "ired", owner);

            //PlotFFT(owner, ctx);

            PlotMaxim(owner, ctx);
        }