Skip to content

Repository files navigation

Introduction to Biomedical Engineering (IBME)

Biopotential Instrumentation, Analog Front-End Circuits & Real-Time Embedded ECG Telemetry

University of Tehran Β |Β  Faculty of Electrical and Computer Engineering
Course: Introduction to Biomedical Engineering (IBME)  |  Semester: Fall 2023 (پاییز ۱۴۰۲)
Instructor: Dr. Majid Badiee Rostami (Ψ―Ϊ©ΨͺΨ± Ω…Ψ¬ΫŒΨ― بدیعی Ψ±Ψ³ΨͺΩ…ΫŒ)
Author: Alireza Najafi Motiei (ΨΉΩ„ΫŒΨ±ΨΆΨ§ Ω†Ψ¬ΩΫŒ Ω…Ψ·ΫŒΨΉΫŒ) Β |Β  Student ID: 810100224

Course Institution MATLAB Multisim Arduino Report License: MIT


πŸ“‹ Table of Contents


πŸ”¬ Executive Overview

This repository houses the complete, publication-grade engineering curriculum portfolio for Introduction to Biomedical Engineering (IBME) at the University of Tehran (Department of Electrical and Computer Engineering, Fall 2023), instructed by Dr. Majid Badiee Rostami.

The codebase bridges three fundamental pillars of modern biomedical technology:

  1. Theoretical Biosignal Modeling & Decomposition: Derivation of 3D Vectorcardiography (VCG) spatial dipole loops and automated EEG sleep stage classification (NREM 1--3, REM, and Wake) using Fourier spectral power ratios.
  2. Analog Front-End (AFE) Microelectronic Design: SPICE/Multisim design and AC frequency analysis of biopotential amplification circuits, including a variable-gain ECG bandpass amplifier (0.1--100 Hz), a high-Q 50 Hz active Twin-T notch filter for powerline hum suppression, and a high-gain (~75,000) low-noise EEG amplifier.
  3. Physical Embedded Hardware Telemetry & Real-Time HRV: In-vivo Lead-I biopotential acquisition interfacing an Analog Devices AD8232 front-end integrated circuit with an Arduino microcontroller, streaming real-time telemetry to MATLAB for zero-phase Butterworth filtering, Pan-Tompkins style QRS detection, and Heart Rate Variability (HRV) analysis in both time and frequency domains (Welch PSD).

πŸ›οΈ System Architecture

                                  PHYSICAL DOMAIN
+---------------------------------------------------------------------------------+
|                                                                                 |
|   Human Subject          Ag/AgCl Electrodes         AD8232 Analog Front-End     |
|  [ Lead-I: RA, LA ] ---> [ Shielded Leads ] ---> [ INA + High-Pass + RLD Stage ]|
|                                                          |                      |
+----------------------------------------------------------|----------------------+
                                                           v Biopotential (0-3.3V)
                                                 +--------------------+
                                                 | Arduino MCU        |
                                                 | 10-Bit ADC (fs~95Hz)|
                                                 | LO+ / LO- Monitors |
                                                 +--------------------+
                                                           |
                                                           v Serial Telemetry (9600 bps)
                                                 +--------------------+
                                                 | MATLAB Processing  |
                                                 +--------------------+
                                                           |
                    +--------------------------------------+--------------------------------------+
                    v                                      v                                      v
          [ Baseline Wander Removal ]            [ QRS & R-Peak Detection ]             [ Spectral HRV Decomposition ]
          Zero-Phase Butterworth (0.5-40 Hz)     Dynamic Refractory Thresholding        Welch Periodogram PSD (VLF/LF/HF)

🧠 Module 1: Biosignal Processing (VCG & EEG Sleep Staging)

Located in 01-biosignal-processing-vcg-eeg/.

1. Vectorcardiography (VCG) Loop Synthesis

The electrical activity of the myocardium can be approximated as a time-varying 3D equivalent cardiac dipole: $$οΏ½ec{D}(t) = οΏ½egin{bmatrix} V_x(t) & V_y(t) & V_z(t) \end{bmatrix}^T$$ Using the Frank lead network, orthogonal biopotentials $V_x$, $V_y$, and $V_z$ are extracted and integrated to reconstruct the continuous frontal, sagittal, and transverse vector loops. The standard clinical 12-lead ECG is mathematically derived via linear transformation projections.

VCG Orthogonal Leads (Time Domain) 3D Cardiac Spatial Vector Loop
VCG Time VCG 3D

2. Polysomnographic EEG Sleep Stage Classification

Continuous EEG brainwave recordings from central (C3/C4) and occipital (O1/O2) channels are analyzed via Discrete Fourier Transform (DFT). Spectral energy is computed across standard neurophysiological bands:

  • Delta ($\delta$): $0.5 - 4.0 ext{ Hz}$ β€” Characteristic of slow-wave sleep (NREM Stage 3).
  • Theta ($ heta$): $4.0 - 8.0 ext{ Hz}$ β€” Prominent during light sleep transition (NREM Stage 1).
  • Alpha ($οΏ½lpha$): $8.0 - 13.0 ext{ Hz}$ β€” Characteristic of relaxed wakefulness with closed eyes (Stage 0).
  • Beta ($οΏ½eta$): $13.0 - 30.0 ext{ Hz}$ β€” Associated with alertness and Rapid Eye Movement (REM) sleep.
Awake State (Stage 0 Alpha Rhythm) Light Sleep (NREM Stage 1 Theta Dominance)
EEG Awake EEG Stage 1

⚑ Module 2: Analog Front-End (AFE) Biopotential Circuits

Located in 02-analog-front-end-multisim/.

Designed and verified in NI Multisim to evaluate small-signal AC response, gain-bandwidth products, and noise margins for microvolt/millivolt biopotentials.

1. ECG Biopotential Amplifier

  • Topological Structure: Input instrumentation buffer stage, active 2nd-order bandpass filter ($0.1 ext{ Hz} - 100 ext{ Hz}$), and an inverting op-amp summing stage.
  • Gain Staging: Continuously adjustable gain up to $7{,}000$ ($76.9 ext{ dB}$).
  • CMRR: $> 90 ext{ dB}$ to eliminate common-mode noise on the thorax.

ECG Amplifier Schematic Figure: Complete multi-stage ECG instrumentation amplifier schematic in Multisim.

ECG Bode Plot Figure: AC Frequency response (Bode magnitude and phase) demonstrating flat passband between 0.1 Hz and 100 Hz.

2. Active Twin-T 50 Hz Notch Filter

Rejects severe $50 ext{ Hz}$ powerline hum without attenuating adjacent QRS diagnostic energy.

  • Topology: Parallel symmetrical low-pass ($R-R-2C$) and high-pass ($C-C-R/2$) T-networks.
  • Selectivity ($Q$): Active bootstrapped feedback from an operational amplifier buffer sharpens the notch to achieve $> -40 ext{ dB}$ rejection at exactly $50 ext{ Hz}$.

Twin-T Notch Filter Figure: Symmetrical active Twin-T 50 Hz notch filter circuit.

3. High-Gain EEG Biopotential Amplifier

EEG signals measured at the scalp have amplitudes of merely $10 - 100\ \mu ext{V}$.

  • Architecture: Cascaded three-stage low-noise amplifier with AC coupling to prevent DC polarization saturation from the electrode-skin interface.
  • Total Gain: $οΏ½pprox 75{,}000$ ($97.5 ext{ dB}$) with a passband up to $200 ext{ Hz}$.
EEG Amplifier Schematic Frequency Response (Bode Plot)
EEG Schematic EEG Bode

🩺 Module 3: Real-Time Hardware ECG Acquisition & HRV Telemetry

Located in 03-hardware-ecg-acquisition-hrv/.

1. Hardware Interconnection & Telemetry Setup

The experimental hardware platform pairs an Analog Devices AD8232 analog front-end board with an Arduino microcontroller.

AD8232 Pin Arduino Pin Signal Type Description
OUTPUT A0 Analog Input Conditioned biopotential signal ($0 - 3.3 ext{ V}$)
3.3V 3.3V DC Supply Regulated low-noise power rail
GND GND Reference Common system ground
LO+ Pin 4 Digital Input Leads-off comparator output: Positive electrode detached
LO- Pin 7 Digital Input Leads-off comparator output: Negative electrode detached
Hardware Breadboard Interface Einthoven Lead-I Electrode Placement
Hardware Setup Electrode Placement

2. Firmware Implementation

  • ad8232_ecg_sampler.ino: Samples ADC channel A0 at $f_s οΏ½pprox 95 ext{ Hz}$, checks digital lead-off status, and streams data via 9600 bps UART.
  • heart_rate_bpm.ino: Embedded moving-window circular buffer with dynamic thresholding to calculate instantaneous BPM with a $300 ext{ ms}$ physiological refractory blanking period.

3. Digital Signal Processing & HRV Analysis Pipeline

  • Baseline Wander Removal: 2nd-order zero-phase Butterworth bandpass filter ($0.5 - 40.0 ext{ Hz}$) via filtfilt to prevent phase distortion.
  • R-Peak Extraction: Adaptive amplitude thresholding with a $450 ext{ ms}$ blanking window to prevent false triggers on tall T-waves.
  • Time-Domain HRV Metrics: Extraction of Normal-to-Normal ($NN$) intervals: $$ ext{SDNN} = \sqrt{rac{1}{N-1}\sum_{i=1}^N (RR_i - \overline{RR})^2}$$ $$ ext{RMSSD} = \sqrt{rac{1}{N-1}\sum_{i=1}^{N-1} (RR_{i+1} - RR_i)^2}$$
  • Frequency-Domain Spectral HRV: Welch periodogram power spectral density to quantify the Sympathovagal balance index: $$ ext{LF/HF Ratio} = rac{\int_{0.04}^{0.15} S_{RR}(f),df}{\int_{0.15}^{0.40} S_{RR}(f),df}$$
Raw vs. Filtered ECG Waveform Welch PSD of R-R Intervals (HRV)
ECG Filtered HRV PSD

πŸ“Š Clinical Findings & Empirical Benchmarks

The in-vivo 30-second recording session from healthy subject yielded the following physiological metrics:

Metric Measured Value Standard Clinical Reference Diagnostic Interpretation
Mean Heart Rate $78.42 ext{ BPM}$ $60 - 100 ext{ BPM}$ Normal resting sinus rhythm
Mean R-R Interval $765.10 ext{ ms}$ $600 - 1000 ext{ ms}$ Stable cardiac pacing
SDNN (Total Variability) $42.18 ext{ ms}$ $> 30 ext{ ms}$ (at rest) Healthy autonomic neurocardiac regulation
RMSSD (Parasympathetic) $31.45 ext{ ms}$ $20 - 50 ext{ ms}$ Robust vagal tone and parasympathetic activation
pNN50 $18.60%$ $> 3%$ High beat-to-beat variability and vagal responsiveness
LF/HF Ratio $1.42$ $1.0 - 2.0$ Balanced sympathovagal autonomic homeostasis

πŸ“ Repository Organization

Biomedical-Instrumentation-and-Signal-Processing/
β”œβ”€β”€ 01-biosignal-processing-vcg-eeg/        # Biosignal modeling & sleep stage classification
β”‚   β”œβ”€β”€ IBME_CA1_part1.m                   # VCG 3D loops & 12-lead ECG derivation
β”‚   β”œβ”€β”€ IBME_CA1_part2_stage0.m            # EEG Awake State (Stage 0) Alpha rhythm analysis
β”‚   β”œβ”€β”€ IBME_CA1_part2_stage1.m            # EEG NREM Stage 1 Theta band dominance
β”‚   β”œβ”€β”€ IBME_CA1_part2_stage2.m            # EEG NREM Stage 2 Sleep spindles & K-complexes
β”‚   β”œβ”€β”€ IBME_CA1_part2_tofind.m            # Unknown patient sleep phase identification
β”‚   β”œβ”€β”€ IBME_CA1_part2_tofind2.m           # REM vs Deep Sleep slow-wave classification
β”‚   β”œβ”€β”€ matlab.mat                         # Polysomnographic EEG clinical dataset
β”‚   └── v1.mat ... v6.mat                  # Precordial ECG recording vectors
β”‚
β”œβ”€β”€ 02-analog-front-end-multisim/           # SPICE circuit simulations (.ms14)
β”‚   β”œβ”€β”€ ECG.ms14                           # Multi-stage ECG instrumentation amplifier
β”‚   β”œβ”€β”€ EEG.ms14                           # Ultra-high gain (~75,000) low-noise EEG amplifier
β”‚   └── Notch_filter.ms14                  # Active 50 Hz Twin-T notch filter
β”‚
β”œβ”€β”€ 03-hardware-ecg-acquisition-hrv/        # Embedded hardware telemetry & HRV analysis
β”‚   β”œβ”€β”€ firmware/                          # Microcontroller code
β”‚   β”‚   β”œβ”€β”€ ad8232_ecg_sampler.ino         # ADC biopotential telemetry with lead-off detection
β”‚   β”‚   └── heart_rate_bpm.ino             # Real-time QRS thresholding & BPM counter
β”‚   β”œβ”€β”€ matlab/                            # Signal processing scripts
β”‚   β”‚   β”œβ”€β”€ ecg_live_capture.m             # Serial COM port streaming & CSV logger
β”‚   β”‚   β”œβ”€β”€ qrs_detect_and_hrv_metrics.m   # Butterworth filter, QRS detection & HRV stats
β”‚   β”‚   └── hrv_spectral_welch_psd.m       # Frequency-domain FFT & Welch periodogram PSD
β”‚   └── data/                              # Recorded biometric datasets
β”‚       └── ecg_recorded_lead1.csv         # Raw in-vivo Lead-I biopotential recording
β”‚
β”œβ”€β”€ docs/media/                            # High-resolution architectural figures
β”‚   β”œβ”€β”€ circuits/                          # Multisim schematics and Bode plots
β”‚   β”œβ”€β”€ signals/                           # VCG spatial loops & EEG frequency spectra
β”‚   └── hardware/                          # Breadboard wiring, electrode layout & waveforms
β”‚
β”œβ”€β”€ reports/                               # Academic technical reports
β”‚   β”œβ”€β”€ Report1_VCG_EEG_Signal_Processing_AlirezaNajafi.pdf
β”‚   β”œβ”€β”€ Report2_Analog_Biopotential_Circuits_AlirezaNajafi.pdf
β”‚   β”œβ”€β”€ Report3_Hardware_ECG_Acquisition_and_HRV_AlirezaNajafi.pdf
β”‚   β”œβ”€β”€ Complete_IBME_Coursework_Report_AlirezaNajafi.pdf   # Merged 26-page portfolio
β”‚   └── Biomedical_Instrumentation_and_Signal_Processing_Report.tex # IEEEtran LaTeX source
β”‚
β”œβ”€β”€ LICENSE                                # MIT Open-Source License
└── README.md                              # Repository documentation

πŸš€ How to Run & Reproduce

1. MATLAB Biosignal Processing (Module 1)

% Open MATLAB and navigate to Module 1
cd('01-biosignal-processing-vcg-eeg');

% Run VCG dipole reconstruction
run('IBME_CA1_part1.m');

% Run EEG sleep stage spectral analysis
run('IBME_CA1_part2_stage0.m');
run('IBME_CA1_part2_tofind.m');

2. NI Multisim Circuit Simulation (Module 2)

  1. Open NI Multisim (v14.0 or higher).
  2. Open 02-analog-front-end-multisim/ECG.ms14.
  3. Run AC Analysis / Bode Plotter to inspect passband gain ($0.1 - 100 ext{ Hz}$).
  4. Open Notch_filter.ms14 to verify $> -40 ext{ dB}$ attenuation at $50 ext{ Hz}$.

3. Embedded Hardware & Real-Time Telemetry (Module 3)

  1. Hardware Assembly:
    • Connect AD8232 OUTPUT to Arduino A0, LO+ to Pin 4, LO- to Pin 7, 3.3V to 3.3V, and GND to GND.
    • Affix three Ag/AgCl electrodes in Einthoven Lead-I orientation (RA, LA, RL).
  2. Flash Microcontroller:
  3. Run MATLAB Analysis Engine:
    cd('03-hardware-ecg-acquisition-hrv/matlab');
    
    % Process recorded in-vivo dataset:
    run('qrs_detect_and_hrv_metrics.m');
    run('hrv_spectral_welch_psd.m');

πŸ“‘ Technical Reports

The comprehensive documentation is compiled into academic reports located in reports/:


πŸ“š Citation

If you utilize this coursework, circuit designs, or signal processing algorithms in academic research, please cite:

@misc{najafimotiei2023ibme,
  author       = {Alireza Najafi Motiei},
  title        = {Introduction to Biomedical Engineering (IBME): Biopotential Instrumentation, Front-End Circuits and Real-Time Telemetry},
  year         = {2023},
  publisher    = {GitHub},
  howpublished = {\url{https://github.com/alirezanmotiei/Introduction-to-Biomedical-Engineering-IBME}},
  note         = {Coursework Portfolio, Department of Electrical and Computer Engineering, University of Tehran}
}

πŸ‘€ Author & License

  • Author: Alireza Najafi Motiei (Student ID: 810100224)
  • Department: Faculty of Electrical and Computer Engineering, University of Tehran
  • Supervision: Dr. Majid Badiee Rostami
  • Academic Term: Fall 2023 (پاییز Ϋ±Ϋ΄Ϋ°Ϋ²)
  • License: Released under the MIT License.
University of Tehran β€’ Department of Electrical and Computer Engineering

About

University of Tehran Introduction to Biomedical Engineering (IBME, Fall 2023): Analog front-end Multisim circuits, AD8232+Arduino real-time ECG acquisition, and biopotential telemetry.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages