# Is it correct to subtract two signals acquired over different times and trials to remove the common signal in them?

I have two signals that represent the response of a neuron under two different conditions.

• Signal 1 (S1): response to Stimulus A
• Signal 2 (S2): response to Stimulus A+B

The response to stimulus A is common in both signals but I am interested in the response to stimulus B only. Because the signals are noisy, they have been acquired multiple times. S1 is acquired 60 times and S2 is acquired only 4 times.

Will averaging S1 over these 60 acquisitions and S2 over 4 (Figure 1) and then subtracting the averaged signals (S2_avg - S1_avg) give me a better representation of response to Stimulus B or should both the signals be averaged across equal acquisitions (Figure 2)?

Averaging S1 60 times really smooths the response to Stimulus A but compared to this, response to Stimulus A is not smooth in S2 as it is only averaged 4 times. So in this way, what I understand is by averaging S1 many times might actually be a disadvantage.

Additional info following answers: my underlying assumption is that the neuron behaves like an LTI system. My concern is that averaging S1 many times smoothes it as compared to response to stimulus A in S2. As such, subtracting them would not really remove the common signal in them.

• Whether the approach that you suggest is a good idea is really domain-specific. I don't think anyone can answer authoritatively unless they are an expert on processing the specific types of signals that you're looking at. – Jason R Sep 15 '16 at 16:06
• In addition, note that if the neuron is non-linear, then S2-S1 is not the response to B. – MBaz Sep 15 '16 at 16:38
• Your subtraction might be appropriate if the system is LTI (linear time invariant). However, this is likely false for neurons (which have a very non-linear activation function, and which also can "learn", thus vary, over time). – hotpaw2 Sep 15 '16 at 18:27
• To the valid comments about time invariance and the brain, I would just like to note that this type of averaging is common place in evoked potential research, where consistent signals emerge after averaging. For an example of such a signal, please see the P300 – A_A Sep 16 '16 at 15:56
• The answer probably depends on what you are looking for: a threshold, some frequency content, the total variation, etc. – anderstood Sep 17 '16 at 1:41

Will averaging S1 over these 60 acquisitions and S2 over 4 (Figure 1) and then subtracting the averaged signals (S2_avg - S1_avg) give me a better representation of response to Stimulus B or should both the signals be averaged across equal acquisitions (Figure 2).

Ideally, both signals should be averaged over the same amount of repetitions and the ideal here would be the biggest of the two (60). This is for each individual point estimate to "suffer" from approximately the same (and as low as possible) variance.

Potentially, you might gain some more insight if you were to use bootstraping, where you would be forming point estimates of each time instant of your time series and then examine these smaller subsets (potentially through a boxplot) to try and "guess" what is the most likely time series to be formed, give these two datasets. But the fact that averaging is suggested in the first place anyway, means that an assumption is already made for the time instance differences to be coming from a gaussian distribution.

You can treat this problem as an estimation problem that follows a linear model:

You have the following equations: \begin{align} y_1=h_1+n \\ y_2=h_1+h_2+n \end{align}

where $h_1$, $h_2$ are the unknown answers to A and B and n is a noise variable (supposedly Gaussian, maybe). $y_1$ and $y_2$ are your observations as answers to A and A+B. Then, you have 60 measurements of $y_1$: $\{y_{1,i}\}_{i=1...60}$ and 4 measurements of $y_2$: $\{y_{2,i}\}_{i=1...4}$. You can form a linear model involving all measurements:

$$\begin{pmatrix}y_{1,1}\\\vdots\\y_{1,60}\\y_{2,1}\\\vdots\\y_{2,4}\end{pmatrix}= \begin{pmatrix}I & 0\\ \vdots\\ I & 0\\I&I\\\vdots\\I & I\end{pmatrix}\begin{pmatrix}h_1\\h_2\end{pmatrix}+n\\ Y=Sh+n$$

Here, n is the unknown noise realization among all measurements. Now, the LMMSE estimator for h1,h2 is given by $$\hat{h}=R_hS^H(SR_hS^H+R_n)^{-1}(Y-E(Y)) + E(h).$$

Here, $\hat{h}$ contains estimates of $h_1$ and $h_2$, and $R_h$ contain a-priori knowledge of h. If you have no information, you can let $R_h=I$ of appropriate size. Further, $R_n$ is the noise covariance matrix. Assuming it's Gaussian uncorrelated noise, you can estimate its variance from the 60 measurements of $y_1$. Finally, E(h) is again a-priori knowledge on h, i.e. if you have some idea what values it might have. If not, put E(h)=0. Finally, E(Y)=SE(h).

Then, you have an optimal (under some assumptions, like h is Gaussian) estimate on both h1 and h2.

Complexity-wise, you can resort to the alternate form of the LMMSE estimator. Additionally, use some sparse linear algebra system, as your system matrix is very sparse.