Downloads · 30 days
5
18% of all-time downloads
riverjiang/lqtsnet
lqtsnet is a machine learning model from riverjiang. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for tf-keras. The card lists the license as gpl-3.0.
Deep Neural Networks in Evaluation of Patients with Congenital Long QT Syndrome from the Surface 12-Lead Electrocardiogram
Downloads · 30 days
5
18% of all-time downloads
All-time downloads
28
Public
Repo size
48.4 MB
Likes
0
Public
Click a slice to open those files.
.data-00000-of-0000146.3 MB · 96%
From the Hugging Face model README
Deep Neural Networks in Evaluation of Patients with Congenital Long QT Syndrome from the Surface 12-Lead Electrocardiogram
Install python packages.
python -m pip install -r requirements.txt
Should be in XML format and the beginning of the files start like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE RestingECG SYSTEM "restecg.dtd">
Run python lqtnet/extract_ecg_xml.py, which converts a folder containing XML ECG files into CSV format, normalizes the voltage data, and resamples all the files (to 2500 samples over the file, 250 Hz over 10 second recording).
Create a metadata folder and in that create a CSV file with the following columns:
file,patient_id,ecg_id,id_site,set,lqts_type,dob,age,sex,ethnicity,date,hr,qt,qt_confirmed,qt_prolonged,qc,qc_reason
Descriptions for the columns:
file: csv file name (without '.csv' file extension)patient_id: unique ID for patient (HiRO ID)ecg_id: unique ID for the ECG fileid_site: HiRO site IDset: split, Derivation, Internal validation, or External validationlqts_type: either Control, Type 1, or Type 2 based on genetic diagnosisdob: date of birth, yyyy-mm-ddage: age (in years)sex: Female or Maleethnicity: used for baseline characteristics and subsequent analysisdate: date of ecg, yyyy-mm-ddhr: heart rate, for baseline characteristics and subsequent analysisqt_manual: correct QT interval (in milliseconds)qt_manual_confirmed: True or False, was the QT interval manually interpreted?qc: True or False, whether ECG passed manual quality controlqc_reason (optional): description of QC issue with ECGUse lqtnet.import_metadata.convert_dtypes() to convert the dtypes for the files for more efficient storage. We also suggest saving the metadata file as pickle or parquet format after importing it as a pandas DataFrame.
Some of the files are missing parts of the leads, excessive noise, wandering leads, are corrupted and don't contain any ECG data, etc. Fill in this data into the above metadata file.
Please see example code below, showing inference for an External validation dataset:
import lqtnet
# directory containing normalized CSV files
ECG_SOURCE_DIR = 'ecgs/csv_normalized_2500/'
MODEL_PATH = 'models/XYZ/'
metadata = pd.read_parquet('metadata/example_YYYYmmdd.parquet')
ext_df = metadata.query('set == "External validation" and qc == "Good"')
x_ext = lqtnet.import_ecgs.df_import_csv_to_numpy(ext_df, from_dir=ECG_SOURCE_DIR)
y_ext = lqtnet.import_ecgs.df_to_np_labels(ext_df)
model = lqtnet.train._load_model(MODEL_PATH)
# make predictions - save this output for further analysis
y_extval_pred = model.predict(x_extval)