How to orthogonalize time series

489 views Asked by At

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
1

There are 1 answers

0
bogatron On BEST ANSWER

The problem is that sig1 is just a scalar multiple of sig 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:

sig1 = sig + 200 * np.cos(2*np.pi*50*t)

The result is shown below and the two signals are orthogonal:

In [4]: np.dot(ortho[0], ortho[1])
Out[4]: 1.9263943063278366e-16

ortho_image