Clinician ECG Evaluation
This directory contains tools for the clinician-based analysis of the ECG-QA-based model evaluation. It contains a random subset of 84 samples based on the total templates with suitable predictions (42 in total, 2 random samples from each).
Dataset Structure
clinicianecg/
βββ README.md
βββ REVIEWER_INSTRUCTIONS.md
βββ data/
β βββ template_01/
β β βββ sample1/
β β β βββ ecg_plot.png
β β β βββ evaluation_info.txt
β β β βββ lead_I.csv
β β β βββ lead_II.csv
β β β βββ lead_III.csv
β β β βββ lead_aVF.csv
β β β βββ lead_aVL.csv
β β β βββ lead_aVR.csv
β β β βββ lead_V1.csv
β β β βββ lead_V2.csv
β β β βββ lead_V3.csv
β β β βββ lead_V4.csv
β β β βββ lead_V5.csv
β β β βββ lead_V6.csv
β β βββ sample2/
β β βββ ... (same structure)
β βββ template_02/
β β βββ ... (same structure)
β βββ ... (templates 03-42)
β βββ template_42/
βββ pipeline/
β βββ config.json
β βββ 1_dataset_analyzer.py
β βββ 2_excel_generator.py
β βββ 2.5_demo_responses.py
β βββ 3_response_analyzer.py
β βββ 4_model_performance_analysis.ipynb
β βββ requirements.txt
βββ reviewer_workbooks/
βββ review_assignments_summary.csv
βββ reviewer_assignments.pkl
βββ ECG_Assessment_[Reviewer_Name].xlsx (configurable number)
Configuration
The pipeline uses a simple config.json file in the pipeline/ directory to configure the evaluation setup:
{
"reviewer_count": 6,
"reviews_per_sample": 2
}
reviewer_count: Number of reviewers to generate (default: 6, generates Reviewer_A through Reviewer_F)reviews_per_sample: Number of reviews each sample receives (default: 2 for dual-review reliability)
You can modify these values to scale the evaluation system for different numbers of reviewers or review requirements.
Notes:
- All predictions are CORRECT (model answer matches expected answer)
- ECG data is downsampled to 100Hz for consistency
- Each sample includes clinical context, question, answer options, and model reasoning
- CSV files contain time series data for each of the 12 ECG leads
- Templates 01-42 each contain 2 samples for a total of 84 ECG cases
- All reviewer assignments and generated workbooks are stored in the
reviewer_workbooks/directory
Analysis Pipeline
The pipeline/ directory contains a comprehensive workflow for analyzing ECG model performance through expert clinician review. The pipeline consists of several Python scripts and a Jupyter notebook that work together to facilitate data analysis, review generation, and performance evaluation.
Pipeline Components
1. Dataset Analyzer (1_dataset_analyzer.py)
The initial component that analyzes the ECG dataset and generates reviewer assignments:
- Purpose: Parses ECG evaluation files and creates a configurable review system for 84 ECG samples
- Key Features:
- Extracts metadata from
evaluation_info.txtfiles (template ID, ECG ID, questions, answers) - Assigns samples to reviewers with balanced workload distribution (number configurable via
config.json) - Ensures each sample receives the configured number of reviews for reliability assessment
- Generates reviewer assignment files in the
reviewer_workbooks/folder (reviewer_assignments.pkl,review_assignments_summary.csv)
- Extracts metadata from
- Output: Structured assignment data for downstream processing in
reviewer_workbooks/directory
2. Excel Generator (2_excel_generator.py)
Creates professionally formatted Excel workbooks for clinician review:
- Purpose: Generates individual Excel files for each reviewer containing their assigned ECG samples
- Key Features:
- Embeds large, high-quality ECG plots directly in Excel sheets
- Creates structured assessment forms with dropdown menus for standardized responses
- Includes three assessment categories: ECG Pattern Recognition, Clinical Reasoning, Context Integration
- Applies professional styling and formatting for optimal reviewer experience
- Adapts to configurable number of reviewers
- Output: Individual Excel workbooks in
reviewer_workbooks/directory (filename format:ECG_Assessment_[Reviewer_Name].xlsx)
2.5. [Optional] Demo Response Generator (2.5_demo_responses.py)
Generates mock responses for testing and demonstration purposes:
- Purpose: Creates sample responses in Excel workbooks to test the analysis pipeline
- Key Features:
- Fills assessment questions with realistic mock responses
- Uses the same 3-option response scale as actual reviews
- Enables testing of the response analyzer without requiring completed reviews
- Useful for pipeline validation and demonstration
- Output: Excel workbooks populated with demo responses
3. Response Analyzer (3_response_analyzer.py)
Comprehensive analysis of completed reviewer responses:
- Purpose: Parses completed Excel workbooks and generates statistical analysis of reviewer responses
- Key Features:
- Extracts responses from all reviewer Excel files
- Calculates inter-rater agreement statistics (Cohen's kappa, percentage agreement)
- Generates response distribution visualizations
- Creates completion status reports and summary statistics
- Exports analysis results to CSV and JSON formats
- Output: Statistical summaries, visualizations, and detailed response data
Workflow Usage
Initial Setup
Before running the pipeline, set up the Python environment and install dependencies:
# Navigate to the project directory
cd /path/to/clinicianecg
# Create a virtual environment
python3 -m venv venv
# Activate the virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install required dependencies
pip install -r pipeline/requirements.txt
# Install Jupyter kernel for the virtual environment
python -m ipykernel install --user --name=clinicianecg --display-name="ECG Analysis"
Pipeline Execution
Configuration: (Optional) Modify the number of reviewers and reviews per sample
cd pipeline # Edit config.json to adjust reviewer_count and reviews_per_sample as needed # Default: 6 reviewers, 2 reviews per sampleSetup: Run the dataset analyzer to generate reviewer assignments
python3 1_dataset_analyzer.py- Creates
../reviewer_workbooks/directory - Generates
reviewer_assignments.pklandreview_assignments_summary.csv - Reads ECG data from
../data/directory - Uses configuration from
config.jsonfor reviewer assignment
- Creates
Review Generation: Create Excel workbooks for clinicians
python3 2_excel_generator.py- Generates individual Excel files for each reviewer in
../reviewer_workbooks/ - Files:
Reviewer_A_ECG_Review.xlsx,Reviewer_B_ECG_Review.xlsx, etc.
- Generates individual Excel files for each reviewer in
Testing (Optional): Generate mock responses for pipeline testing
python3 2.5_demo_responses.py- Fills Excel workbooks with sample responses for testing
Analysis: Extract and analyze completed reviewer responses
python3 3_response_analyzer.py- Parses completed Excel workbooks from
../reviewer_workbooks/ - Generates statistical summaries and visualizations in
../analysis_results/
- Parses completed Excel workbooks from
Deep Analysis: Open the Jupyter notebook for comprehensive analysis
# Start Jupyter Lab or Jupyter Notebook (from pipeline directory) jupyter lab 4_model_performance_analysis.ipynb # OR jupyter notebook 4_model_performance_analysis.ipynb- Select the "ECG Analysis" kernel when prompted
- Run cells for statistical analysis and visualization
- Notebook reads from
../analysis_results/directory
Requirements
See pipeline/requirements.txt for Python dependencies.