public LowFirFilterProcess() { var lowCoefficient = FirCoefficients.LowPass(HeartContext.F, 37, 40); LowFirFilter = new OnlineFirFilter(lowCoefficient); }
public double[] Derivative(double[] filteredSignal) { Delay += 2; IList<double> hd_coef = new List<double>(); double[] hd_array = { -1, -2, 0, 2, 1 }; foreach (double num in hd_array) { hd_coef.Add(num); } OnlineFirFilter diffFilter = new OnlineFirFilter(hd_coef); double[] derivativeSignal = diffFilter.ProcessSamples(filteredSignal); return derivativeSignal; }
public BandStopFirFilterProcess() { var bandCoefficient = FirCoefficients.BandStop(HeartContext.F, 45, 50, 40); BandFirFilter = new OnlineFirFilter(bandCoefficient); }
public Vector<double> TransformImf(Vector<double>[] imfs, uint fs) { //result Vector Vector<double> imfSum = Vector<double>.Build.Dense(imfs[0].Count - 2); //integrating window double window = Math.Round(0.1 * fs); Delay += Convert.ToUInt32(window / 2); foreach (Vector<double> imf in imfs) { //nonlinear transform Vector<double> imfTransformed = Vector<double>.Build.Dense(imf.Count); for (int i = 2; i < imfs[0].Count; i++) { if ((imf[i] * imf[i - 1] > 0) && (imf[i - 2] * imf[i] > 0)) { imfTransformed[i] = Math.Abs(imf[i] * imf[i - 1] * imf[i - 2]); } else { imfTransformed[i] = 0; } } imfTransformed = imfTransformed.SubVector(2, imf.Count - 2); //integrating IList<double> hi_coeff = new List<double>(); for (int i = 0; i < window; i++) { hi_coeff.Add(1 / window); } OnlineFirFilter integrationFilter = new OnlineFirFilter(hi_coeff); double[] imfIntegrated = integrationFilter.ProcessSamples(imfTransformed.ToArray()); //sum imfSum = imfSum.Add(Vector<double>.Build.DenseOfArray(imfIntegrated)); } return imfSum; }
public double[] Integration(double[] htSignal, uint fs) { double[] int1Signal = new double[htSignal.Length]; double window = Math.Round(0.37 * fs); Delay += Convert.ToUInt32(Math.Round(window / 2)); IList<double> hi_coeff = new List<double>(); for (int i = 0; i < window; i++) { hi_coeff.Add((1 / window) + 1); } OnlineFirFilter integrationFilter = new OnlineFirFilter(hi_coeff); int1Signal = integrationFilter.ProcessSamples(htSignal); Vector<double> tempSignal = Vector<double>.Build.DenseOfArray(int1Signal); // correcting signal length Vector<double> int2Signal = CutSignal(tempSignal, Convert.ToInt16(Math.Round(window / 2)), htSignal.Length - 1); int sigLength = htSignal.Length - Convert.ToInt16(Math.Round(window / 2)); // normalization double tempMax = int2Signal.Maximum(); double tempMin = int2Signal.Minimum(); double normCoeff = (Math.Abs(tempMin) > tempMax) ? Math.Abs(tempMin) : tempMax; double[] integratedSignal = new double[sigLength]; for (int i = 0; i < sigLength; i++) { integratedSignal[i] = int2Signal[i] / normCoeff; } return integratedSignal; }
public double[] Integrating(double[] squaredSignal, uint fs) { double[] integratedSignal = new double[squaredSignal.Length]; double window = Math.Round(0.15 * fs); Delay += Convert.ToUInt32(Math.Round(window / 2)); IList<double> hi_coeff = new List<double>(); for (int i = 0; i < window; i++) { hi_coeff.Add(1 / window); } OnlineFirFilter integrationFilter = new OnlineFirFilter(hi_coeff); integratedSignal = integrationFilter.ProcessSamples(squaredSignal); //enhancing by put zero below threshold (0.002) for (int i = 0; i < integratedSignal.Length; i++) { if (integratedSignal[i] < 0.002) integratedSignal[i] = 0; } return integratedSignal; }
public double[] HilbertTransform(double[] filteredSignal) { double pi = Math.PI; IList<double> d = new List<double>(); d.Add(1 / (pi * filteredSignal.Length)); OnlineFirFilter transformFilter = new OnlineFirFilter(d); double[] hSignal = transformFilter.ProcessSamples(filteredSignal); double[] htSignal = new double[hSignal.Length]; for (int i = 0; i < htSignal.Length; i++) { htSignal[i] = Math.Abs(filteredSignal[i]) + Math.Abs(hSignal[i]); } return htSignal; }
public double[] Filtering(double samplingFreq, double lowCutOff, double highCutOff, double[] rawSignal) { //TO DO: add cutoffs as constants not param? Delay += 10; IList<double> coef = new List<double>(); double[] hf = FirCoefficients.BandPass(samplingFreq, lowCutOff, highCutOff, 10); foreach (double number in hf) { coef.Add(number); } OnlineFirFilter filter = new OnlineFirFilter(coef); double[] vector_f = filter.ProcessSamples(rawSignal); return vector_f; }
public BandPassFirFilterProcess() { var bandCoefficient = FirCoefficients.BandPass(HeartContext.F, 1, 37, 50); BandFirFilter = new OnlineFirFilter(bandCoefficient); }