Student Information
Experiment 1: Analysis of Biomedical Signals in Time, Frequency, and Time-Frequency Domains
1. Objectives
Upon completion of this lab, you will be able to:
- Visualize and interpret biomedical signals in the time domain.
- Apply the Discrete Fourier Transform (DFT) to analyze the frequency content of signals.
- Utilize the Short-Time Fourier Transform (STFT) and power spectral density estimation (pwelch) to understand how a signal's frequency content changes over time.
- Investigate the effects of sampling and filtering on signal integrity.
- Identify and characterize key features, artifacts, and clinical abnormalities within these signals.
2. Required Materials and Software
- Software: MATLAB (with the Signal Processing Toolbox).
- Datasets:
- EEG_Seizure.mat: A multi-channel EEG recording of a patient experiencing an epileptic seizure.
- EOG_Movement.mat: A two-channel EOG recording capturing horizontal eye movements.
- ECG_Arrhythmia.mat: A two-channel ECG recording containing normal heartbeats and various arrhythmias.
- EMG_Disorders.mat: Three separate EMG recordings from a healthy subject, a patient with myopathy, and a patient with neuropathy.
Experiment 2: EEG Artifact Identification and Removal using ICA
1. Objectives
Upon completion of this lab, you will be able to:
- Visually identify common artifacts in EEG signals (EMG, EOG, ECG).
- Understand and apply the Independent Component Analysis (ICA) algorithm to separate signal sources.
- Analyze ICA components using their time course, power spectrum, and scalp topography.
- Make an informed decision on which components to remove.
- Reconstruct a clean EEG signal and evaluate the denoising performance.
2. Background
Electroencephalography (EEG) measures the brain's electrical activity but is often contaminated by non-brain signals called artifacts. Independent Component Analysis (ICA) is a computational method that separates a set of mixed signals (like the EEG channels) into their underlying, statistically independent sources. By identifying which sources correspond to artifacts, we can remove them and reconstruct a cleaner signal, improving the quality of any subsequent analysis.
Experiment Procedures
Background
EEG signals measure the brain's electrical activity. They are characterized by low amplitude and specific frequency bands (Delta, Theta, Alpha, Beta, Gamma) associated with different brain states. During an epileptic seizure, brain activity becomes highly synchronized and abnormal, which is clearly visible in the EEG.
Procedure
-
Data Loading and Initial Visualization:
- Load the EEG_Seizure.mat file into your MATLAB workspace. This file should contain the EEG data matrix (eeg_data), the sampling frequency (fs), and channel labels (channel_labels).
- Select a single channel (e.g., Channel 5) and plot its entire duration in the time domain. Label your axes appropriately (Amplitude vs. Time in seconds).
Plot Output Area: Channel 5 Signal vs. Time
Analysis Task: Observe the signal's overall morphology. Identify distinct periods of activity. Does the amplitude or frequency appear to change over time? Note your initial observations. -
Comparative Channel Analysis:
- Select a different channel (e.g., Channel 23) and plot it below the first one for comparison.
Plot Output Area: Channel 5 vs. Channel 23 Comparison
Analysis Task: Compare the two channels. Note similarities and differences in amplitude, frequency, and the presence of artifacts like eye blinks (sharp, high-amplitude spikes). - Select a different channel (e.g., Channel 23) and plot it below the first one for comparison.
-
Multi-Channel Visualization:
- Plot all EEG channels on a single figure. To prevent overlap, apply a vertical offset to each channel's data before plotting. A common technique is to add i * offset_value to the i-th channel's data.
Plot Output Area: All EEG Channels with Offsets
Analysis Task: Observe the global brain activity. Can you identify the approximate time when the seizure begins? Which channels appear to be most affected? Note how the seizure activity propagates across different brain regions (channels). - Plot all EEG channels on a single figure. To prevent overlap, apply a vertical offset to each channel's data before plotting. A common technique is to add i * offset_value to the i-th channel's data.
-
Time-Frequency Analysis of Seizure Evolution:
- From a single channel (e.g., Channel 5), extract four distinct 5-second epochs representing different states:
- Baseline/Normal: 2s to 7s
- Pre-Ictal (Before Seizure): 30s to 35s
- Ictal (During Seizure): 42s to 47s
- Post-Ictal/Late Seizure: 50s to 55s
- For each epoch, perform the following analyses:
- Time Domain Plot: Plot the 5-second segment.
- Frequency Domain (DFT): Compute the FFT of the epoch. Use fftshift to center the spectrum at 0 Hz. Plot the magnitude spectrum against frequency (Hz).
- Power Spectral Density (PSD): Use the pwelch function to estimate the PSD of the epoch.
- Time-Frequency (STFT): Use the spectrogram function to visualize how the frequency content changes within the 5-second epoch.
Plot Output Area: Baseline EpochPlot Output Area: Pre-Ictal EpochPlot Output Area: Ictal EpochPlot Output Area: Post-Ictal Epoch
Analysis Task: For each state (Baseline, Pre-Ictal, etc.), compare the four plots. How does the frequency content change from normal brain activity to seizure activity? Look for dominant frequencies, the emergence of rhythmic patterns (like the 10 Hz spikes in the pre-ictal phase), and the broadening of the frequency spectrum during the seizure. - From a single channel (e.g., Channel 5), extract four distinct 5-second epochs representing different states:
-
Downsampling and Filtering:
- Take the pre-ictal epoch (30s-35s). Note its primary frequency content from the FFT plot.
- Design a low-pass Butterworth filter (e.g., 6th order) with a cutoff frequency just above the highest significant frequency (e.g., 60 Hz).
- Apply this filter to the epoch.
- Downsample the filtered signal by a factor of 2 using the downsample command.
- Plot the time, frequency, and spectrogram representations of this new, downsampled signal.
Plot Output Area: Time DomainPlot Output Area: Frequency DomainPlot Output Area: Spectrogram
Analysis Task: Compare these plots to the originals. Has any significant information been lost? Discuss the trade-offs between a lower sampling rate (less data) and signal fidelity. This demonstrates the Nyquist theorem in a practical context.
Background
EOG measures the electrical potential difference between the front and back of the eye. This potential changes as the eye moves, allowing us to track eye movements.
Procedure
-
Data Loading and Time-Domain Visualization:
- Load the EOG_Movement.mat file. It contains two channels, one for the left eye and one for the right.
- Plot both channels on the same axes.
Plot Output Area: Left vs. Right EOG Channels
Analysis Task: Describe the relationship between the two signals. Are they correlated? Inverted? What does this tell you about the electrode placement and the nature of the eye movements being recorded? -
Frequency and Time-Frequency Analysis:
- Compute and plot the FFT for each EOG channel.
- Compute and plot the spectrogram for each channel.
Plot Output Area: Left EOG FFTPlot Output Area: Right EOG FFTPlot Output Area: Left EOG SpectrogramPlot Output Area: Right EOG Spectrogram
Analysis Task: What is the dominant frequency range for eye movements? Is this what you would expect? Correlate high-frequency activity in the spectrogram with high-amplitude, rapid movements in the time-domain plot.
Background
ECG records the heart's electrical activity. A normal heartbeat has a characteristic P-QRS-T waveform. Arrhythmias are irregularities in the heart's rhythm, which manifest as deviations from this normal pattern.
Procedure
-
Data Loading and Waveform Identification:
- Load the ECG_Arrhythmia.mat file. It contains two channels (lead II and lead V1), sampling frequency, and arrhythmia annotations.
- Plot a short segment (e.g., 5 seconds) of a "normal" period of the ECG.
Plot Output Area: Normal ECG Segment
- Zoom in on a single, clear heartbeat. Identify and label the P wave, QRS complex, and T wave.
Plot Output Area: Single Heartbeat with Labels
Analysis Task: Compare the morphology of the same beat in both channels. Explain why they might look different (due to different lead perspectives). -
Arrhythmia Visualization and Labeling:
- Plot a 10-second segment of the ECG known to contain arrhythmias (e.g., starting at 530s).
- Use the provided annotation data to overlay text labels (e.g., 'PVC', 'NAPC') on the plot at the correct time points for each abnormal beat.
Plot Output Area: Arrhythmia Segment with Labels
Analysis Task: For each labeled arrhythmia type (PVC, NAPC, RHYTHM, etc.), visually compare it to a normal beat. Describe the key differences in terms of:- Timing: Is the beat premature or late?
- Morphology: Is the QRS complex wider? Is the P wave absent?
- Rhythm: Is the interval to the next beat regular or irregular?
-
Time-Frequency Analysis of Normal vs. Abnormal Beats:
- Extract two 2-second segments from Channel 1:
- A segment containing only normal beats.
- A segment containing an abnormal beat (e.g., the PVC/Rhythm beat around 477s).
- For both segments, compute and plot the FFT and the spectrogram. For the spectrogram, use two different window sizes (e.g., 128 and 64 samples).
Plot Output Area: Normal Beat FFTPlot Output Area: Abnormal Beat FFTPlot Output Area: Normal Beat Spectrogram (128)Plot Output Area: Abnormal Beat Spectrogram (128)Plot Output Area: Normal Beat Spectrogram (64)Plot Output Area: Abnormal Beat Spectrogram (64)
Analysis Task: Compare the frequency content of the normal and abnormal beats. Does the arrhythmia introduce new frequency components? How does the energy distribution in the spectrogram differ? Explain how a shorter window in the STFT provides better temporal localization of the beat's components. - Extract two 2-second segments from Channel 1:
Background
EMG measures the electrical signals produced by muscles. The signal's characteristics (amplitude, frequency, firing pattern) can reveal the health of the muscle and its controlling nerves.
Procedure
-
Data Loading and Comparative Visualization:
- Load the EMG_Disorders.mat file. It contains three separate signals: emg_healthy, emg_myopathy, and emg_neuropathy.
- Plot the entire duration of all three signals in separate subplots.
Plot Output Area: Healthy EMGPlot Output Area: Myopathy EMGPlot Output Area: Neuropathy EMG
Analysis Task: Make general observations. Which signal has the largest amplitude? Which appears most "random" or "spiky"? -
Zoomed-in Morphological Analysis:
- Zoom in on short, representative segments of each of the three signals.
Plot Output Area: Healthy EMG ZoomPlot Output Area: Myopathy EMG ZoomPlot Output Area: Neuropathy EMG Zoom
Analysis Task: Describe the detailed morphology.- Healthy: Note the pattern of motor unit recruitment during contraction.
- Myopathy (muscle disease): Look for lower-amplitude, shorter-duration motor unit action potentials (MUAPs).
- Neuropathy (nerve disease): Look for high-amplitude, long-duration, "giant" MUAPs, which result from nerve regeneration and reinnervation.
- Zoom in on short, representative segments of each of the three signals.
-
Frequency and Time-Frequency Analysis:
- For each of the three EMG signals, compute and plot the FFT and the spectrogram.
Plot Output Area: Healthy FFTPlot Output Area: Myopathy FFTPlot Output Area: Neuropathy FFTPlot Output Area: Healthy SpectrogramPlot Output Area: Myopathy SpectrogramPlot Output Area: Neuropathy Spectrogram
Analysis Task: Compare the frequency spectra. How does the frequency content shift with each disorder?- Healthy: Should have a broad spectrum.
- Myopathy: Tends to shift power to higher frequencies.
- Neuropathy: Tends to shift power to lower frequencies.
Correlate the features in the spectrograms with the time-domain signals. For example, do the "giant" spikes in the neuropathy signal correspond to bursts of low-frequency power in its spectrogram?
- For each of the three EMG signals, compute and plot the FFT and the spectrogram.