def test_file_notfound(hea_path): with pytest.raises(FileNotFoundError): ECGRecord.from_wfdb(hea_path)
def test_select_annotation(hea_path): record = ECGRecord.from_wfdb(hea_path) assert len(record.annotations.select_label("N")) == 2239
def test_unique_labels(hea_path): record = ECGRecord.from_wfdb(hea_path) assert record.annotations.unique_labels == ['+', 'A', 'N', 'V']
def test_signal_content(hea_path, lead_name, signal): record = ECGRecord.from_wfdb(hea_path) assert record.get_lead(lead_name)[:10] == signal
def test_annotation(hea_path): record = ECGRecord.from_wfdb(hea_path) assert len(record.annotations) == 2274
def test_signal_name(hea_path): record = ECGRecord.from_wfdb(hea_path) assert record.lead_names == ['MLII', 'V5']
def test_record_name(hea_path): record = ECGRecord.from_wfdb(hea_path) assert record.record_name == "100"
def test_signal(hea_path): record = ECGRecord.from_wfdb(hea_path) assert record.n_sig == 2
def test_length(hea_path): record = ECGRecord.from_wfdb(hea_path) assert len(record) == 650000
with zipfile.ZipFile("MIT_Noise.zip", "r") as zip_ref: zip_ref.extractall() hea_path_1 = "mit-bih-arrhythmia-database-1.0.0/mit-bih-arrhythmia-database-1.0.0/" hea_path = "mit-bih-noise-stress-test-database-1.0.0/mit-bih-noise-stress-test-database-1.0.0/bw.hea" # To load a wfdb formatted ECG record hea_path_1 = "D:/Research_Impl/Noise_Removal_Autoencoder/Dataset/mit-bih-arrhythmia-database-1.0.0/mit-bih-arrhythmia-database-1.0.0/" hea_path = "D:/Research_Impl/Noise_Removal_Autoencoder/Dataset/mit-bih-noise-stress-test-database-1.0.0 (1)/mit-bih-noise-stress-test-database-1.0.0/bw.hea" ####################################################################################################### # EXTRACTING THE NOISE SIGNALS FROM HEA ####################################################################################################### record = ECGRecord.from_wfdb(hea_path) signal_noise = record.get_lead("noise1") ####################################################################################################### # EXTRACTING THE ORIGINAL SIGNALS FROM HEA ####################################################################################################### signal_original = [] for i in range(100, 125): if i == 110 or i == 120: continue record_1 = ECGRecord.from_wfdb(hea_path_1 + str(i) + ".hea") signal_orig = record_1.get_lead("MLII") if signal_orig == None: print(i) continue signal_original.append(signal_orig)