Why is PPG signal not periodic? - filtering

I'm new to signal processing. I'm currently trying to convert the data retrieved from PPG to heart rate. I have a question about my PPG signal. So This is the typical PPG signal.
At the same time, my signal looks like this.
This is the signal after applying moving average filter.
This is the signal after applying Savitzky-Golay filter.
My signal is obtained from myself sitting still and putting my finger on a reflective PPG sensor with red light and infrared light. I didn't move my finger at all, so there should be no motion artifact, and there are around 53-55 samples in each second. I also extracted DC component from it, meaning extracting the mean from each data point. But why does my signal look so noisy? I tried moving average filter and savitzky-golay filter, but overall the shape is still not even close to the typical periodic PPG signal above. How can I make the shape of the signal more periodic? Are there any better filters I can try?

Related

Implementing Fixed-Width Sliding Windowing technique on sensor signal

I am trying to replicate the signal pre processing done on this Data Set: http://archive.ics.uci.edu/ml/datasets/Human+Activity+Recognition+Using+Smartphones#
"The sensor signals (accelerometer and gyroscope) were pre-processed by applying noise filters and then sampled in fixed-width sliding windows of 2.56 sec and 50% overlap (128 readings/window)"
I am trying to perform all my functionalities on Matlab and am stuck in trying to create a fixed width sliding window on my acceleration signals.
My main area is AI classification and have no background knowledge on signal preprocessing etc.. I've been trying to research etc for a long time but I cannot understand what I need to do to my signal.
I have signals which are produced at a 51.2 Sampling Frequency. Any help please on how I can generate a sampling window like the one done on the linked data set?
You should calculate window length in number of samples and step=window-overlap and use this:
https://stackoverflow.com/a/44190634/3344428 (you can clear unnecessary code for std, skewness etc.)
You should clarify window length, because you mentioned "128 readings/window", BUT if you use 2.56 sec window on 51.2 Hz signal, then window = 2.56*51.2 = 131 samples.

Low pass filter with clipped data

I have a set of data that basically consist of one low frequency component and one high frequency component, where the low frequency is what I would like to recover. This to me seems like a perfect use case for a low pass filter, however, a problem arises since the data is clipped.
As the clipped points basically are constants for short intervals, they will add some low frequency junk which disturbs the signal of interest. I have tried getting around the problem by simply omitting the points subject to clipping, but this method seems slightly naive, is there a better way?
I have included a few figures which shows simulated data to illustrate what I am working with.
Typical signal, starts with values close to zero and then both the low frequency as well as high frequency signal kicks in simultaniously.
Running the high frequency signal through a low pass filter yields the following results. Note the difference between having clipping in the data and without.
The signal after lowpass filtering. Note the difference between when no clipping is present and when there is.
When filtering the data, I use Matlabs built in function fir1, using the following call:
Signal_lowpass = filter(fir1(100, fc, 'low'), 1, Signal);
All the plots that you have shown are time-domain representation of your signals. Here it would help if you show the frequency response (magnitude response from fft should suffice) of your clipped signal and also the frequency response of low pass filtered signal. From frequency response of your signal one can design a filter which would eliminate clipping effects as well as the high pass signal. If your low pass signal is a single tone (which it looks like from time domain graphs) a bandpass filter around its frequency would help to extract it.

Calculate SNR of drifting signal in MATLAB

I have a signal that is both noisy and drifts. I want to calculate the noise of the signal, but I think for this drift should not be taken into account as "noise". using the snr() funciontion in matlab will give me a really high noise value, I think because it takes into account the drift, right?
How can I calculate it? is there any function available for this?
In this picture, for instance, the noise should be around 2% right? ((22.45-22.36)/2)/22.38. (although what I really want is the SNR value)
Thank you!
Filtered signal with low pass filter with a really low frequency:
I would approach this by identifying the drift of the signal with a low pass filter. Just subtract the filtered signal from the original signal. This will lead to noise signal with low drift.
Filtering the signal might be the most difficult task, but by playing around with the filter parameters this will work

Trying to filter (tons of) noise from accelerometers and gyroscopes

My project:
I'm developing a slot car with 3-axis accelerometer and gyroscope, trying to estimate the car pose (x, y, z, yaw, pitch) but I have a big problem with my vibration noise (while the car is running, the gears induce vibration and the track also gets it worse) because the noise takes values between ±4[g] (where g = 9.81 [m/s^2]) for the accelerometers, for example.
I know (because I observe it), the noise is correlated for all of my sensors
In my first attempt, I tried to work it out with a Kalman filter, but it didn't work because values of my state vectors had a really big noise.
EDIT2: In my second attempt I tried a low pass filter before the Kalman filter, but it only slowed down my system and didn't filter the low components of the noise. At this point I realized this noise might be composed of low and high frecuency components.
I was learning about adaptive filters (LMS and RLS) but I realized I don't have a noise signal and if I use one accelerometer signal to filter other axis' accelerometer, I don't get absolute values, so It doesn't work.
EDIT: I'm having problems trying to find some example code for adaptive filters. If anyone knows about something similar, I will be very thankful.
Here is my question:
Does anyone know about a filter or have any idea about how I could fix it and filter my signals correctly?
Thank you so much in advance,
XNor
PD: I apologize for any mistake I could have, english is not my mother tongue
The first thing i would do, would be to run a DFT on the sensor signal and see if there is actually a high and low frequency component of your accelerometer signals.
With a DFT you should be able to determine an optimum cutoff frequency of your lowpass/bandpass filter.
If you have a constant component on the Z axis, there is a chance that you haven't filtered out gravity. Note that if there is a significant pitch or roll this constant can be seen on your X and Y axes as well
Generally pose estimation with an accelerometer is not a good idea as you need to integrate the acceleration signals twice to get a pose. If the signal is noisy you are going to be in trouble already after a couple of seconds if the noise is not 100% evenly distributed between + and -.
If we assume that there is no noise coming from your gears, even the conversion accuracy of the Accelerometer might start to mess up your pose after a couple of minutes.
I would definately use a second sensor, eg a compass/encoder in combination with your mathematical model and combine all your sensor data in a kalmann filter(Sensor fusion).
You might also be able to derive a black box model of your noise by assuming that it is correlated with your motors RPM. (Box-jenkins/Arma/Arima).
I had similar problems with noise with low and high frequencies and I managed to decently remove it without removing good signal too by using an universal microphone shock mount. It does a good job with gyroscope too especially if you find one which fits it (or you can put it in a small case then mount it)
It basically uses elastic strings to remove shocks and vibration.
Have you tried a simple low-pass filter on the data? I'd guess that the vibration frequency is much higher than the frequencies in normal car acceleration data. At least in normal driving. Crashes might be another story...

Removing noise from wave audio file in MATLAB

I have two wave files, one is normal version, another one is distorted version. In distorted version, I hear a long beep like sound. Here are the frequency domain plots of normal and distorted version sounds. First one is normal, second one is distorted. notice the scales.
How do I go about this?
It's a bit hard to tell without using a marker or zooming in, but it seems you have a sinusoid inserted to your signal, which would explain the continuous beep you hear and the delta like function you have in the spectrum. Try to locate the noise frequency using the marker and filtering it using the filter design tool (type "fdatool" in the command line). I would go for a notch filter at the frequency of the noise, and if this doesn't work a high (~1000) order high pass FIR filter.
Good luck
Since you have the signal in frequency domain, you can also remove the noise there (with a simple threshold) and then you take inverse Fourier transform and you get the noise free signal in time domain.