示例#1
0
import os

from tqdm import tqdm
from wfdb import io, plot
import pandas as pd
# https://mc.ai/diagnosing-myocardial-infarction-using-long-short-term-memory-networks-lstms/
# The folder where you want to store your data
data_folder = '../data/'
# First get the list of available records and then download
# those records and store them in data_folder.
record_names = io.get_record_list('sddb')
#io.dl_database('sddb', data_folder, record_names)

# Read the first record
record_name = record_names[0]
print(record_name)
record = io.rdrecord(record_name="../data/" + record_name)

records = []
for record_name in tqdm(record_names):
    record = io.rdrecord(record_name=os.path.join('../data/', record_name))
    print(record.sig_name)
    print(record.comments)
    # label = comments_to_dict(record.comments)['Reason for admission'][1:]
    label = record.comments
    patient = record_name.split('/')[0]
    signal_length = record.sig_len
    records.append({
        'name': record_name,
        'label': label,
        'patient': patient,
示例#2
0
import keras
from keras.layers import Conv1D, MaxPooling1D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K
import os



def comments_to_dict(comments):
    key_value_pairs = [comment.split(':') for comment in comments]
    return {pair[0]: pair[1] for pair in key_value_pairs}    


data_folder = 'data'
db = 'ptbdb'
record_names = io.get_record_list(db)
record_names


def record_to_row(record, patient_id):
    row = {}
    row['patient'] = patient_id
    row['name'] = record.record_name
    row['label'] = comments_to_dict(record.comments)['Reason for admission'][1:]
    row['signals'] = record.p_signal
    row['signal_length'] = record.sig_len
    channels = record.sig_name
    signals = record.p_signal.transpose()
    
    row['channels'] = channels
    
示例#3
0
import os

from tqdm import tqdm
from wfdb import io, plot
import pandas as pd
# https://mc.ai/diagnosing-myocardial-infarction-using-long-short-term-memory-networks-lstms/
# The folder where you want to store your data
data_folder = '../data/'
# First get the list of available records and then download
# those records and store them in data_folder.
record_names = io.get_record_list('ptbdb')
#io.dl_database('ptbdb', data_folder, record_names)

# Read the first record
record_name = record_names[0]
print(record_name)
record = io.rdrecord(record_name="../data/ptdb/" + record_name)

records = []
for record_name in tqdm(record_names):
    record = io.rdrecord(
        record_name=os.path.join('../data/ptdb/', record_name))
    print(record.sig_name)
    # label = comments_to_dict(record.comments)['Reason for admission'][1:]
    label = record.comments[4].split(": ")[-1]
    patient = record_name.split('/')[0]
    signal_length = record.sig_len
    records.append({
        'name': record_name,
        'label': label,
        'patient': patient,