|
Algorithm 1: SVD Adaptive Filtering |
Initialize a variable X as the input signal.
Generate a set of circularly shifted versions of the input signal by looping through a range of 1 to 40, and for each iteration:
Circularly shift the elements of X by the current iteration number of positions.
Append the shifted signal to a new variable Xshifted.
Concatenate the original signal X and the shifted versions in Xshifted to form the signal matrix Xconcat.
Perform SVD on the concatenated signal matrix Xconcat to obtain the matrices U, S, V.
Extract the diagonal matrix S from the SVD results.
Zero out the largest singular values in the S matrix, which are determined by values greater than 90% of the maximum singular value.
Use the modified S matrix, along with the U and V matrices from the SVD, to reconstruct the signal matrix Xrecon.
Compute a reference signal using the moving average of the corresponding values with a window size of 20.
Starting from DBS time to the end of the array, replace the values of Xrecon with the reference signal.
Implement an adaptive filtering algorithm using the least mean squares (LMS) method to extract a high frequency component and suppress the sharp DBS peaks:
Apply a moving average filter to the input signal X with a window size of 100.
Initialize an LMS filter object with filter length of 7 and step size of a small value.
Apply the LMS filter to the Xrecon signal to obtain the filter weights and error signal.
Locate two change points in the error signal, assuming them to correspond to the period including sharp DBS peaks.
Locate the peaks in the error signal within these two change points and reduce their amplitudes by a factor of 10.
Repeat the process twice more to further reduce the amplitudes of these peaks.
|