- Project Overview
- System Architecture
- Medical Signals (ECG/EEG)
- Acoustic Signals
- Trading Signals
- Microbiome Signals
- Installation & Setup
- Usage Guide
- Technical Implementation
- Demo Video
BioSignal AI is a comprehensive multi-modal signal analysis platform that implements all requirements of Task 1: Signal Viewer with basic processing. The system handles four distinct signal types with specialized visualization and AI-powered analysis.
| Signal Type | Key Capabilities | AI Models Used |
|---|---|---|
| Medical | Multi-channel ECG/EEG, 4+ viewer types, abnormality detection | HuBERT + MLP Classifier |
| Acoustic | Doppler simulation, vehicle velocity estimation, drone detection | Classic algorithms (non-AI) |
| Trading | Stock/currency/mineral analysis, LSTM prediction | Global LSTM (3-layer) |
| Microbiome | Disease profiling, diversity metrics, clinical reports | Random Forest |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Flask Backend (app.py) โ
โ Routes, File Handling, Model Loading, API โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โ Medical API โ โ Acoustic API โ โ Trading API โ
โ /upload โ โ/upload_sound โ โ /api/upload โ
โ/analyze_signalโ โ /detect_drone โ โ /api/predict โ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โ Models/ โ โ Audio โ โ Models/ โ
โ Medical/ โ โ Processing โ โ Trading/ โ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
SIGNAL_VIEWER/
โ
โโโ Data/ # Raw signal data
โ โโโ Acoustic Signals/ # Vehicle and drone audio
โ โโโ Medical Signals/ # ECG/EEG recordings
โ โโโ Microbiome Signals/ # Microbial abundance data
โ โโโ Trading Signals/ # Stock/currency/mineral CSVs
โ
โโโ Models/ # Pre-trained AI models
โ โโโ Medical/ # ECG classification models
โ โโโ Microbiome/ # Random Forest models
โ โโโ Trading/ # LSTM models
โ
โโโ static/ # Frontend assets
โ โโโ CSS/ # Styling files
โ โโโ JS/ # JavaScript logic
โ
โโโ Templates/ # HTML pages
โ โโโ index.html # Main entry
โ โโโ viewer.html # Medical viewer
โ โโโ sound.html # Acoustic analyzer
โ โโโ stock.html # Trading dashboard
โ โโโ micro.html # Microbiome analysis
โ
โโโ docs/ # Documentation
โ โโโ images/ # Screenshots
โ โโโ Video/ # Demo video
โ
โโโ app.py # Main Flask application
The medical signal viewer supports multi-channel ECG (heart) and EEG (brain) signals with multiple visualization modes and AI-based abnormality detection.
Main medical dashboard with sidebar controls and chart grid
.hea+.dat(WFDB format).edf(European Data Format).csv(custom format)
Choose between ECG and EEG signals
Alternative signal type selector
Standard time-domain visualization with amplitude vs time
Features:
- Viewport of fixed time-length
- Speed control (1x to 20x)
- Window size adjustment (100-5000 samples)
- Play/Stop controls
- Zoom in/out capability
Polar representation where r = magnitude, ฮธ = time
Advanced Polar Modes:
- Standard Overlay - Multiple channels overlaid
- Ratio Mode (V1/V2) - Channel ratio visualization
- Ratio Mode (V2/V1) - Inverse ratio visualization
Two-channel polar overlay with ratio analysis
Multiple channels overlaid in polar coordinates
Enhanced polar overlay with multiple channels
Signal divided into time chunks and XOR-ed
How it works:
- Signal divided into chunks (window size)
- Each chunk plotted on top of previous
- Identical chunks cancel out (XOR effect)
- Highlights differences between periods
XOR visualization with adjustable chunk size
XOR view with multiple channels overlaid
2D Scatter plot betwee X[n] and X[n+1]
Customization:
- X-axis channel selection
- Y-axis channel selection
- Color map selection (Hot, Viridis, Plasma, Jet)
- Shows signal dynamics and patterns
Enhanced recurrence plot with density contours
Standard overlay view with multiple channels
Multi-select channels with Ctrl+Click
- Color picker - Custom color per channel
- Line thickness - Adjustable width (0.5-5.0)
- Animation toggle - Enable/disable per channel
- Show/Hide - Toggle visibility in overlay mode
Side-by-side comparison of Deep Learning and Classic ML
- Feature Extractor: HuBERT Transformer model
- Classifier: 3-layer MLP (256โ128โ64 neurons)
- Classes: 5 ECG abnormality types
- Normal (N)
- Supraventricular ectopic beat (S)
- Ventricular ectopic beat (V)
- Fusion beat (F)
- Unknown beat (Q)
- Multi-channel analysis: Analyzes up to 3 channels
- R-peak detection using
scipy.signal.find_peaks - Heart rate calculation (BPM)
- Statistical features: SDNN, RMSSD
- Rule-based classification:
- SDNN > 0.12 โ Arrhythmia suspected
- BPM > 100 โ Tachycardia
- BPM < 50 โ Bradycardia
- Otherwise โ Normal rhythm
Adjust playback speed and viewing window
- Speed Slider: 1x to 20x
- Window Size: 100 to 5000 samples
- Real-time animation across all viewers
- Synchronized playback in multi-view mode
Complete set of viewer types in single mode
Choose from multiple analysis modes
The acoustic module provides Doppler effect simulation and real-world vehicle/drone analysis using classic signal processing algorithms.
Main acoustic analysis dashboard
Velocity and frequency sliders with play/pause controls
Physics Model:
f_approach = f * (v_sound + v) / (v_sound - v)
f_recede = f * (v_sound - v) / (v_sound + v)
Parameters:
- Velocity: 1-300 m/s
- Frequency: 100-2000 Hz
- Duration: 5 seconds
- Envelope: Triangular amplitude envelope
Features:
- Real-time slider updates
- Play/Pause generated sound
- Download as WAV file
Upload real vehicle sounds for analysis
Algorithm Steps:
- Band-pass filtering (100-800 Hz) - removes noise
- Autocorrelation - finds dominant frequency
- Sliding windows - analyzes approach and recede phases
- Doppler formula - calculates velocity
Results Display:
- Velocity in m/s and km/h
- Approach frequency
- Receding frequency
- Noise filter toggle
Frequency-based drone detection algorithm
Detection Method:
- Frequency range: 150-800 Hz (typical drone range)
- Window size: 200ms sliding windows
- Autocorrelation frequency estimation
- Average frequency across all windows
Output:
โ ๏ธ DRONE DETECTED! (if frequency in range)- โ No Drone Detected (if frequency outside range)
- Average frequency display
The trading module supports stocks, currencies, and minerals with multiple chart types and LSTM-based prediction.
Main trading dashboard with category selection
| Category | Chart Types | Example Assets |
|---|---|---|
| Stock Market | Candlestick + Volume, MA Overlay, % Comparison, Line Chart | AAPL, MSFT, GOOGL |
| Currency | Line Chart, Bollinger Bands, Rolling Volatility, MA Overlay | EUR/USD, GBP/USD, USD/JPY |
| Mineral | Candlestick, MA 50/200 Cross, Seasonality, Line Chart | Gold, Silver, Copper |
CSV upload with automatic format detection
Intelligent Parser Features:
- Detects Yahoo Finance format (skips first 2 rows)
- Handles standard CSV with headers
- Works with files without headers
- Automatic date column detection
- Extracts price data from various formats
OHLC candlesticks with volume bars
Moving averages (20/50) overlaid on price
Volatility bands with MA20 and ยฑ2ฯ
Average price by month for minerals
Forecast days selection and prediction button
Model Architecture:
- Input: 60-day sequences
- Features: open, high, low, close returns, volume change
- LSTM layers: 128 โ 64 โ 32 units
- Dropout: 0.2 after each LSTM layer
- Output: Next day's price
Smart Prediction Taming:
- Calculate historical volatility
- Apply realistic drift
- Clip extreme predictions
- Generate 95% confidence bands
Historical data + forecast with confidence intervals
Full historical data displayed
Animated window view with playback
Four chart types displayed simultaneously
Over time view of all currency charts
Static view of all currency charts
Over time view of all mineral charts
Static view of all mineral charts
The microbiome module analyzes microbial abundance data to predict disease states and calculate diversity metrics.
Main microbiome analysis dashboard
TSV/CSV upload with sample selection
Supported Format:
- Rows: Samples/patients
- Columns: Bacterial taxa
- Last column: Diagnosis (CD, UC, Healthy, nonIBD)
AI-predicted disease with confidence score
Model Details:
- Algorithm: Random Forest (100 trees)
- Training data: iHMP dataset
- Classes: Crohn's Disease, Ulcerative Colitis, Healthy, nonIBD
- Features: 200+ bacterial taxa
Bar chart and radar visualization
Shannon Index (Alpha diversity):
H = -โ(p_i * ln(p_i))
where p_i = relative abundance of taxon i
F/B Ratio (Phyla balance):
- Firmicutes / Bacteroidetes
- Balanced range: 0.5 - 1.5
- Low (<0.5): Bacteroidetes dominance
- High (>1.5): Firmicutes dominance
Beneficial bacteria:
- Faecalibacterium
- Bifidobacterium
- Lactobacillus
Pathogen load:
- Escherichia
- Shigella
- Enterobacteriaceae
AI-generated clinical report with color-coded advice
Report Components:
- Diagnosis - Disease classification
- Phyla Balance - F/B ratio interpretation
- Summary - Personalized advice
- Diversity - Shannon index value
Python 3.8+
pip (Python package manager)
FFmpeg (for audio processing)
Git (optional)git clone <repository-url>
cd SIGNAL_VIEWERpip install -r requirements.txtrequirements.txt:
flask==2.3.3
tensorflow==2.13.0
torch==2.0.1
transformers==4.35.0
wfdb==4.1.2
mne==1.5.1
librosa==0.10.1
scikit-learn==1.3.0
pandas==2.0.3
numpy==1.24.3
plotly==5.17.0
joblib==1.3.2
scipy==1.11.2
# Create data directories
mkdir -p Data/Acoustic\ Signals/{car,Drones}
mkdir -p Data/Medical\ Signals/{ECG\ Data,EEG}
mkdir -p Data/Microbiome\ Signals
mkdir -p Data/Trading\ Signals/{currencies,minerals,Stock}
# Create temp upload directories
mkdir -p temp_uploads_{ecg,micro,sound,eeg,acoustic}Medical Models (Models/Medical/):
hubert_ecg.py- Custom HuBERT implementationecg_classifier.pkl- Trained MLP classifiermodel.safetensors- HuBERT weightsconfig.json- Model configuration
Microbiome Models (Models/Microbiome/):
microbiome_model.pkl- Random Forest classifiermodel_features.pkl- Feature names
Trading Models (Models/Trading/saved/):
global_lstm_model.h5- Trained LSTM weightsglobal_lstm_model_scaler_X.pkl- Feature scalerglobal_lstm_model_scaler_y.pkl- Target scalerasset_mapping.json- Asset ID mapping
Medical Data:
- Download MIT-BIH Arrhythmia Database samples
- Place in
Data/Medical Signals/ECG Data/
Acoustic Data:
- Add vehicle pass-by recordings to
Data/Acoustic Signals/car/ - Add drone recordings to
Data/Acoustic Signals/Drones/
Trading Data:
- Download CSV files from Yahoo Finance
- Place in respective category folders
Microbiome Data:
- Download iHMP dataset
- Save as
Data/Microbiome Signals/iHMP_data.csv
python app.pyOpen browser and navigate to:
http://127.0.0.1:5000
-
Select Signal Type
- Choose ECG or EEG from dropdown
-
Upload Data
- Click "Choose Files"
- Select .hea/.edf/.csv files
- Wait for processing
-
Select Channels
- Ctrl+Click to select multiple
- Customize colors/thickness
-
Choose Viewer Type
- Signal (time-domain)
- Polar (magnitude vs time)
- XOR (difference detection)
- Recurrence (2D scatter)
-
Run AI Analysis
- Click "Run AI Prediction"
- Compare DL vs Classic results
-
Control Playback
- Adjust speed slider
- Adjust window size
- Click Play/Stop
For Simulation:
- Adjust velocity and frequency
- Click "Generate Sound"
- Use Play/Pause to listen
- Click "Download" to save
For Vehicle Analysis:
- Upload vehicle audio file
- Toggle noise filter if needed
- Click "Analyze Velocity"
- View estimated speed and frequencies
For Drone Detection:
- Upload test audio file
- Click "Run Detection"
- View detection result
-
Select Category
- Stock Market / Currency / Mineral
-
Load Data
- Upload CSV or use pre-loaded
- View file info panel
-
Choose View Mode
- Single (one large chart)
- Multi (four charts)
-
Select Chart Type
- Based on category selection
-
Set Display Mode
- Static (full history)
- Over Time (animated window)
-
Run Prediction
- Set forecast days
- Click "Predict Future Behavior"
- View forecast with confidence bands
-
Upload File
- Select TSV/CSV file
- Wait for sample extraction
-
Select Sample
- Choose from dropdown
- Click "Run AI Analysis"
-
Review Results
- AI Diagnosis with confidence
- Shannon diversity index
- F/B ratio
- Beneficial/pathogen percentages
-
Examine Visualizations
- Top taxa bar chart
- Microbial radar plot
- Clinical interpretation report
# Key routes and their functions
@app.route('/upload') # Medical signal upload
@app.route('/analyze_signal_ai') # AI analysis for medical
@app.route('/upload_sound') # Acoustic file upload
@app.route('/micro_upload') # Microbiome data upload
@app.route('/analyze_micro_sample') # Microbiome analysis
@app.route('/api/upload') # Trading data upload
@app.route('/api/predict') # LSTM prediction# Feature extraction with HuBERT
with torch.no_grad():
outputs = ECG_AI_MODEL(sig_tensor)
features = outputs.last_hidden_state.mean(dim=1)
# Classic ML detection
peaks, _ = scipy.signal.find_peaks(work_sig_norm,
distance=int(0.4 * fs))
rr_intervals = np.diff(peaks) / fs
sdnn = np.std(rr_intervals)
rmssd = np.sqrt(np.mean(np.diff(rr_intervals) ** 2))# Band-pass filter implementation
def bandPassFilter(segment, sampleRate, lowHz, highHz):
RC_low = 1 / (2 * np.pi * lowHz)
RC_high = 1 / (2 * np.pi * highHz)
dt = 1 / sampleRate
# Filter logic...
# Autocorrelation frequency estimation
def estimateFrequency(segment, sampleRate):
for lag in range(minLag, maxLag):
corr = np.sum(segment[:-lag] * segment[lag:])
if corr > maxCorr:
maxCorr = corr
bestLag = lagclass GlobalLSTM:
def build_model(self):
model = Sequential([
Input(shape=(sequence_length, n_features)),
LSTM(128, return_sequences=True),
Dropout(0.2),
LSTM(64, return_sequences=True),
Dropout(0.2),
LSTM(32),
Dropout(0.2),
Dense(16, activation='relu'),
Dense(1)
])// Dynamic chart creation
function renderChart(divId, type, data, predictionData) {
let traces = [];
if (type === 'candlestick') {
traces.push({
x: dates,
open: data.prices.open,
high: data.prices.high,
low: data.prices.low,
close: data.prices.close,
type: 'candlestick'
});
}
Plotly.newPlot(divId, traces, layout);
}A comprehensive demonstration video is available:
BioSignal AI successfully implements all requirements of Task 1 with:
| Category | Requirements Met | Key Achievement |
|---|---|---|
| โ Medical | 14/14 | Multi-channel ECG/EEG with 4 viewer types + AI comparison |
| โ Acoustic | 7/7 | Doppler simulation + real vehicle/drone analysis |
| โ Trading | 7/7 | Multi-category charts + LSTM prediction |
| โ Microbiome | 6/6 | Disease profiling + diversity metrics + clinical reports |
- Unified interface for four distinct signal types
- Real-time visualization with playback controls
- AI-powered analysis (HuBERT, LSTM, Random Forest)
- Classic algorithms for comparison
- Comprehensive customization options
- Professional documentation with 40+ screenshots
- Demo video showcasing all features
TThis project is created for educational purposes as part of the Digital Signal Processing Course - Task 01: Signal Viewer with Basic Processing.
Course: Digital Signal Processing Task1: Signal Viewer with Basic Processing Semester: Spring 2026 Team: 08

