- MATLAB 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| alg | ||
| README.md | ||
TransferLearning_AF_Explanations
Code to reproduce the exemplary ECG explanation plots, statistical anlysis and boxplots of ECG interval relevance from the paper:
"Cross-Domain Transfer Learning Strategy Enhances Interpretability of
Deep Learning Model Explanations"
M. Zannini, A. Hammer, H. Malberg, M. Schmidt
Institute of Biomedical Engineering, TU Dresden
Requirements
- MATLAB R2021b or later
- Statistics and Machine Learning Toolbox
Data
The relevance data required to run this code is publicly available on Zenodo:
doi:10.5281/zenodo.19555343
Download the af_test.json test subset file, the json relevance files and the 12 .mat files and place them in the same folder as the scripts.
The dataset includes the test ECGs contained in the file af_test.json and 4 files per model (MSTN, MLTN, RSTN, RLTN):
| File | Contents |
|---|---|
| _norm_relevance.json` | Per-ECG relevance |
rhythmAnalysis_<model>.mat |
Per-ECG relevance statistics aggregated over beat intervals, predictions, labels |
results_<model>.mat |
ANOVA results, Tukey-Kramer post-hoc comparisons, effect sizes |
templateVals_<model>.mat |
Average beat template relevance per model configuration and class |
Usage
- Clone or download this repository
- Download the
.matfiles from Zenodo and place them in the same folder
Performing ANOVA and creating boxplots
Open createRelevanceBoxplots.m in MATLAB
Set the model name at the top of the script:
in_fn = "MSTN"; % one of: "MSTN", "MLTN", "RSTN", "RLTN"
Run the script. It will:
- Load the corresponding
.matfiles automatically - Run the ANOVA and Tukey-Kramer post-hoc analysis
- Generate the boxplot figure
- Export it as
<model>_boxplots.pdfin the current folder
Plotting ECG explanation examples
To visualize DTD relevance heatmaps overlaid on ECG signals, open
plot_explanation_examples.m and set the parameters at the top of the script:
model_name = "RSTN"; % "MSTN" | "MLTN" | "RSTN" | "RLTN"
model_ids = [0 3 4 5 6 7 8]; % model configuration indices
ids = [207 208]; % indices of the two ECG samples to plot
segment_start = 0; % start sample (signal length: 5000 samples)
segment_end = 5000; % end sample
base_path = "path\to\relevance\files\"; % folder containing the JSON relevance files
Then run the script. It will generate a 2×2 figure where:
- Each row corresponds to one model configuration
- Each column corresponds to one of the two selected ECG samples
- The ECG signal is plotted as a colored line, where the color encodes the DTD relevance of each sample (black indicates low relevance and white indicates high relevance)
- A colorbar is shown on the right column
The figure is exported as <model_name>_examples.pdf in the current folder.