0
$\begingroup$

I have signal as seen in the picture. It has high frequency noise and drifting baseline. I am able to remove the noise in MATLAB but I am not sure what can I do about the drift.

enter image description here

I would like the signal to have a stable baseline. Any help or hints on how I can do that would be most helpful.

Thanks

$\endgroup$
2
  • 1
    $\begingroup$ Have you tried detrend yet? $\endgroup$
    – jojeck
    Commented May 28, 2015 at 15:44
  • $\begingroup$ Plus, you can detrend with wavelets. $\endgroup$
    – Sektor
    Commented May 28, 2015 at 15:52

2 Answers 2

2
$\begingroup$

Like I already mentioned in the comment, you might find MATLAB's detrend function useful. Generally it is useful for removal of linear (or piecewise linear) trend:

y = detrend(x);

Another solution, that should work in your case, is to use the polynomial fitting. This will remove the non-linear trend (providing you want that). A minimal code example:

% vectors t,x are given (time and the signal)
degree = 5; % to be adjusted
[p, S, mu] = polyfit(t, x, degree);
xp = polyval(p, t, [], mu);
y = x - xp;

Personally I do not recommend any Moving Average filtering, since it is introducing delay and can distort your signal.

$\endgroup$
2
  • $\begingroup$ I apologize I am quite new to signal processing. I might have stated my question incorrectly. The data comes from a sensor and i expect it to be stable. As you can see the signal is gradually decreasing, whereas it is supposed to maintain somewhat similar amplitude (i.e. around 4, 4.1 for the signal shown). Using detrend or high pass filtering centers the baseline at 0. I am looking for a method which will center the base line at its proper amplitude. I understand there may not be a straightforward command that will do this. Is there any algorithm that can be used? Thanks $\endgroup$ Commented May 29, 2015 at 14:17
  • $\begingroup$ Then I would suggest you to check the reasons of that drift nevertheless I have no idea what is the outcome you do expect so I am unable to give you fully working answer. You can do try both methods. $\endgroup$
    – jojeck
    Commented May 29, 2015 at 14:19
1
$\begingroup$

A drifting baseline to me looks like a displacement from zero by the mean amplitude.

  • From a stats point of view, you will want compute the rolling mean and subtract.
  • From a signals point of view, this problem is a DC offset, and can be corrected with a high pass filter, with a very low cutoff, that essentially removes this low frequency amplitude modulation. There are a number of prior discussion here, and implementations. If you're in MATLAB, detrend can be useful as already mentioned.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.