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
- Executive Overview
- System Architecture
- Module 1: Biosignal Processing (VCG & EEG Sleep Staging)
- Module 2: Analog Front-End (AFE) Biopotential Circuits
- Module 3: Real-Time Hardware ECG Acquisition & HRV Telemetry
- Clinical Findings & Empirical Benchmarks
- Repository Organization
- How to Run & Reproduce
- Technical Reports
- Citation
- Author & License
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:
- 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.
- 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.
- 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).
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)
Located in 01-biosignal-processing-vcg-eeg/.
The electrical activity of the myocardium can be approximated as a time-varying 3D equivalent cardiac dipole:
| VCG Orthogonal Leads (Time Domain) | 3D Cardiac Spatial Vector Loop |
|---|---|
![]() |
![]() |
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) |
|---|---|
![]() |
![]() |
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.
-
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.
Figure: Complete multi-stage ECG instrumentation amplifier schematic in Multisim.
Figure: AC Frequency response (Bode magnitude and phase) demonstrating flat passband between 0.1 Hz and 100 Hz.
Rejects severe
-
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}$ .
Figure: Symmetrical active Twin-T 50 Hz notch filter circuit.
EEG signals measured at the scalp have amplitudes of merely
- 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) |
|---|---|
![]() |
![]() |
Located in 03-hardware-ecg-acquisition-hrv/.
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 ( |
| 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 |
|---|---|
![]() |
![]() |
-
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.
-
Baseline Wander Removal: 2nd-order zero-phase Butterworth bandpass filter (
$0.5 - 40.0 ext{ Hz}$ ) viafiltfiltto 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) |
|---|---|
![]() |
![]() |
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 | Normal resting sinus rhythm | ||
| Mean R-R Interval | Stable cardiac pacing | ||
| SDNN (Total Variability) |
|
Healthy autonomic neurocardiac regulation | |
| RMSSD (Parasympathetic) | Robust vagal tone and parasympathetic activation | ||
| pNN50 | High beat-to-beat variability and vagal responsiveness | ||
| LF/HF Ratio | Balanced sympathovagal autonomic homeostasis |
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
% 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');- Open NI Multisim (v14.0 or higher).
- Open
02-analog-front-end-multisim/ECG.ms14. - Run AC Analysis / Bode Plotter to inspect passband gain (
$0.1 - 100 ext{ Hz}$ ). - Open
Notch_filter.ms14to verify$> -40 ext{ dB}$ attenuation at$50 ext{ Hz}$ .
- Hardware Assembly:
- Connect AD8232
OUTPUTto ArduinoA0,LO+toPin 4,LO-toPin 7,3.3Vto3.3V, andGNDtoGND. - Affix three Ag/AgCl electrodes in Einthoven Lead-I orientation (RA, LA, RL).
- Connect AD8232
- Flash Microcontroller:
- Open
ad8232_ecg_sampler.inoin Arduino IDE. - Select your target board and upload.
- Open
- 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');
The comprehensive documentation is compiled into academic reports located in reports/:
- Report 1: Biosignal Processing, VCG Modeling & EEG Sleep Staging (13 Pages)
- Report 2: Analog Front-End Biopotential Circuit Synthesis (10 Pages)
- Report 3: Real-Time Hardware ECG Telemetry & Heart Rate Variability (3 Pages)
- Complete Unified IBME Technical Report (26 Pages)
- IEEEtran Two-Column LaTeX Source
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: 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.









