I'm working with the MEG signal and to address the problem of spatial leakage I wanted to perform orthogonalization of the time series. To have better understanding I started working with a sine signal. I wrote a code in python and to orthogonalize I used a function in [spectral python][1] module. If you run the following code and plot the signal, you will find something like shown in attached picture. I think the orthogonalize signal should also looks like the original signal. It should not change drastically. Please let me know if there are better ways to orthogonalize a signal. [enter image description here][2] Here is my code:
import matplotlib.pyplot as plt
import spectral
from scipy import signal
from scipy.signal import hilbert
#Computing Sine wave#
t = np.linspace(-0.02, 0.05, 1000)
sig = 325 * np.sin(2*np.pi*50*t)
sig1 = 200 * np.sin(2*np.pi*50*t)
signal = np.zeros((2, 1000))
signal[0] = sig
signal[1] = sig1
#Orthogonalisation
ortho = spectral.orthogonalize(signal)
#Plotting
plt.figure()
plt.plot(signal[0], 'Blue')
plt.plot(signal[1], 'Green')
plt.title('Signal')
plt.figure()
plt.plot(ortho[0], 'Red')
plt.plot(ortho[1], 'Black')
plt.title('Ortho')```
[1]: https://www.spectralpython.net/class_func_ref.html#orthogonalize
[2]: https://i.stack.imgur.com/GKVZ9.png
The problem is that
sig1
is just a scalar multiple ofsig
so there is no orthogonal component between the two signals. The black orthogonal component you are plotting is just noise due to machine precision/roundoff. Try this instead:The result is shown below and the two signals are orthogonal: