Lab 08_Signal Processing

.docx

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

1110

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

5

Uploaded by SargentGoldfinchMaster1038

Report
BIOMEDE 3702 LAB PROCEDURE: Signal Processing Learning Objectives: Students will be able to… Learn how to implement different types of simple filters. Build their own functions while keeping awareness of function/variable scoping. Analyze and relate EMG signal characteristics with motor unit activation. Materials: Matlab Software Laptop A. Analyzing Data In lab you will work through guided example analysis to become familiar with common signal processing techniques. First, we will construct and integrated EMG signal. Second, we will experiment with Fourier Transform to look at the frequency content of the EMG signal. Work these tasks in a script, rather than the command window. It is highly recommended that each of the coming sections you build as independent functions. You can create functions by writing a script file as seen in Figure 1. A function allows to run complex lines of code by simply integrating them into a single named structure (called a function ). These processes can then be simply repeated by invoking the function rather than the entire lines of code. Considerations: 1. To call functions, these files must be saved on the same folder as any other codes being run. 2. The name of the function of the script should match the file name (to avoid errors). 3. Functions need an output, and can have more than one. Use the brackets [] to include more than one output. 4. To get multiple outputs from a function, you must include the brackets (example the max function can be called as [M,I] = max(X). M will give you the value, I will give you the index. Figure 1: Function Definition Code Structure 1. Function 1: Implementing simple filters:
BIOMEDE 3702 a. Download the EMG Back Up Data ( Carmen > Lab Documents and Links > Backup data > Lab 1 EMG ) b. Select a signal from recording 2 or 4 (fatigue exercise trial). c. The first simple filter you will apply is a highpass [y = highpass(x,fpass,fs)]. This MatLab filter will remove any baseline drifts from your signal. The function has three parameters: x indexed fatigue signal, fpass – cutoff frequency of the filter in Hz ( pick 5 Hz ), and fs sampling frequency of the signal. Note: Consider the frequency ranges of an EMG signal! i. You can experiment with the highpass by calling the function without an output in the command window. d. Rectify the output of the highpass filter [abs()]. e. Apply a moving average filter to the rectified highpass signal using movmean(). This MatLab function has two parameters: A – input signal, and [kb, kf] – which are the edges of the averaging bin. Make both kb and kf half the sampling frequency, which would result in a 1- second bin. f. Plot the moving average filtered signal overtop of the rectified high pass filtered signal (but in a different color). Make sure to save this figure to include in the post lab. 2. Function 2: Transforming into the frequency domain: a. Revert back to using the unfiltered fatigue exercise signal from step 1a. b. Compute the Fourier transform using Y = fft(X), where X is the raw signal. c. Write Y(100) in your function and run it. You will notice that is complex (a + jb) which encode both for magnitude and phase of your complex exponential. d. To remove the complex value, take the absolute value of Y. e. You will also note that this output is symmetrical. Plot the absolute value of Y. You will be removing half of this spectrum. f. To split the signal index by half your absolute value signal [signal(1:end/2+1)], then multiply this resulting vector by 2 to conserve total power. g. This resulting signal is your power (P|X|) values (or y in the frequency domain), but we have yet to calculate the frequency axis.
BIOMEDE 3702 h. You can calculate the frequency axis by creating a vector from 0 to the half-length of your raw signal [0:L/2]. Multiply these values by fs (sampling frequency), and then divide by the total length of the raw signal. i. Plot the resulting spectrum using the frequency axis as x, and power as y. Save this figure for the post lab. 3. Function 3: Removing 60 Hz power line noise: a. If your spectrum (in section 2) shows a strong peak around 60 Hz, this is due power line or electromagnetic field noise caused by the AC power supply. b. Apply a bandstop filter to the raw fatigue exercise signal from step 1a. The function is similar to the high pass ( y = bandstop(x,fpass,fs) ) where fpass will be the vector of frequencies to attenuate [59,61]. c. Plot the frequency spectrum of the bandstop signal (run the output of this function through Function 2). Notice any changes from your unprocessed signal in the previous section? Save this figure for the postlab. 4. Function 4: Calculating the median frequency: a. The median frequency is a great indicator to slow/fast twitch muscle activation. As to what it calculates, you will need to look that up online ( as part of your post lab ). b. Use freq = medfreq(x,fs) where x is the bandstop (or notched) filtered signal (in the time domain) to obtain the median frequency. Plot this value as vertical line overtop of the frequency power spectrum plot of the bandstop signal. Save these figures for the postlab . THE POINT In this lab, we were able to use MATLAB to create multiple functions to perform various EMG signal processing operations. We learned how to implement simple filters (highpass and bandstop) for the analysis of provided data. We saw how signals change when transformed into the frequency domain. We also learned about identifying and filtering electromagnetic field noise, as well as the importance of the median frequency in EMG signals.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help