# How to Subtract One Signal from Another?

I am capturing some body internal signals.

I am using 2 identical mics. One captures the in body signal and one open air.

I want to remove/delete/subtract the open air signal (noise for me) from the main signal.

Under the assumption that your background noise is statistically independent of the signal you want to recover and that your second microphone picks up virtually nothing from the body noise, you have the following model for your measurements: $$\begin{eqnarray} M_1(t) &=& L\{N(t)\} + B(t) \\ M_2(t) &=& N(t) \end{eqnarray}$$

Here, $M_1,M_2$ are the signals picked up by the microphone, $B(t)$ is the signal you want to recover, $N(t)$ is the environmental noise signal and $L$ is a linear time invariant system that maps the recorded environmental noise to what is picked up by the second microphone.

With $\langle\langle \cdot, \cdot \rangle\rangle$ as cross correlation, we also have the non-correlation constraint $\langle\langle N,B \rangle\rangle=0$ and $\langle\langle L\{N\},B \rangle\rangle=0$ as a consequence of statistical independence of $N$ and $B$.

These prerequisites guarantee a cross correlation matching pursuit to converge against $B(t)$:

1. Normalise $M_2$ with the standard inner product: $M_2(t)\leftarrow \frac{M_2}{\sqrt{\langle M_2(t),M_2(t) \rangle}}$
2. Find $c(t):=\langle\langle M_2,M_1\rangle\rangle$
3. Find the time associated with the maximum of the squared cross correlation: $\tau=\mathrm{argmax}\left( c^2(t) \right)$
4. Update $M_1$ to remove the contribution of the environmental noise: $M_1(t)\leftarrow M_1(t)-\langle M_2(t-\tau),M_2 \rangle\cdot M_2(t-\tau)$
5. If result not good enough, go back to 2.

In step 4 you may also use $c(\tau)$ instead of the inner product if the cross correlation uses the same inner product. Stopping the matching pursuit is a question of experience. Some of the assumptions you need for this algorithm are only approximately true, like the perfect uncorrelatedness of the environmental noise and the body signal. A good way to check if your matching pursuit runs into a non-productive state of signal modifications is to observe the natural square-norm of $M_1$. If it stops decreasing in step 4, terminate the loop.

After the algorithm ran, $M_1(t)$ will contain only your body signal $B(t)$.

• Waw!!! Thanks for so detailed explanation! Will try to perform this algorithm. Thanks! – Anna Feb 4 '16 at 13:31
• Nice, but works with the assumption that N(t) is the same for both microphones. That's very unlikely to be the case, so you have some how estimate $N_1(t)$ from $N_2(t)$. Depending on the setup there may be only limited correlation between the two noise signals which would make the estimation difficult. Rooms are very effective decorrleators – Hilmar Feb 4 '16 at 18:03
• @Hilmar, that assumption is made in the question. And It does not make the strict assumption that you are making. It assumes that the noise at the body microphone is related by a linear time invariant system to the noise at the other microphone. If that is not the case, there is nothing you can do with the information from the second system anyway. – Jazzmaniac Feb 4 '16 at 19:39
• Of course, if you fear that long term correlation is compromised by changes in the microphone/room geometry, just apply the procedure frame-wise so that the correlation is locally given. – Jazzmaniac Feb 4 '16 at 19:44

You can use adaptive filters for this kind of application.

as you mentioned in question "One captures the in body signal and one open air", so what you can do is use open air signal as reference and body signal as input to the adaptive filter, by doing this we will get the estimation of the open air signal in main body signal. if we subtract this estimate from original main body signal we will get noise(open air) free signal.

• Thanks!I a little bit confused what is the meaning "get the estimation" and subtract it but I will learn it and the adaptive filters . Thanks – Anna Feb 4 '16 at 13:36
• Anna, what i mean by "get the estimation and subtract it" is that once we give the noise as reference and main signal(which contains same noise but in some transformed form) as input to adaptive filter, the output of adaptive filter converges(or atleast with good replication) to the transformed noise that is present in main body signal. once we get this transformed noise, we subtract it from the original main body signal. Important : operations needs to be done frame wise, and we should be careful in selecting adaptation regions for filter adaptation. – Arpit Jain Feb 5 '16 at 4:43