# What are the most suitable methods for correcting sudden DC offsets or baseline offset? and Why? See the image for the use-case or example

The signal values should not get affected by the correction. Most methods I found were related to baseline drift or exponential baseline shift/decay. I am unable to find a method suitable for my use case. In the image it is visible that after sudden dc offset the baseline got shifted. After correction it should stay same.

I'd do this nonlinearily, in two steps:

1. Detect the jump
2. Correct the jump

Detection sounds rather easy: a short (linear-phase) high-pass filtered version of your signal is compared to a threshold. From that, we know exactly the position of your jump; it's where the threshold was crossed, minus the group delay of the filter (which happens to be half the filter length).

Take the value of the original signal right after the jump. Shift the right-hand side of the original signal such that it ends up at the same amplitude as the sample before the jump. (A more elegant way would be definining a signal model, and then modeling the most likely signal progression, but you don't seem to have an overly useful signal, as you don't mention it.)

• Thanks for the answer. But this is just an example, I was wondering if there already exists a standard algorithm or function specifically for these kind of corrections.I am not a person who has worked with signal processing at all. This is my first time. If you can elaborate on your method that would also be helpful. – user55240 Jan 20 at 11:21
• what I described is an algorithm for these kind of corrections? It exists now? I'd like to elaborate, but I'd need you to ask a specific question! – Marcus Müller Jan 20 at 11:22
• Okay, I'll try explain my case as best as I can. We are getting these signals from a device now I want an algorithm to remove the sudden DC offset caused due to motion/ external disturbance such that the DC component does not get removed entirely as happens in all the baseline correction methods. The reason being that hemodynamic information will get lost. In simple words, what I want to do is that this data be manipulated such that there is no information loss and offset gets removed. As u can see the signal after offset is same just shifted upwards in y axis. I want it to recover. Help! – user55240 Jan 21 at 11:10
• my algorithm does exactly that. – Marcus Müller Jan 21 at 12:01