pyheartlib.data

Module Contents

Classes

Data

Parent of other data classes.

DataSeq

Parent of other data classes.

class pyheartlib.data.Data(base_path=None, remove_bl=False, lowpass=False, cutoff=45, order=15, **kwargs)

Parent of other data classes.

Parameters:
  • base_path (str, optional) – Path of the main directory for storing the original and processed data, by default None

  • remove_bl (bool, optional) – If True, the baseline wander is removed from the original signals prior to extracting excerpts, by default False

  • lowpass (bool, optional) – Whether or not to apply low-pass filter to the original signals, by default False

  • cutoff (int, optional) – Parameter of the low pass-filter, by default 45

  • order (int, optional) – Parameter of the low pass-filter, by default 15

  • processors (list, optional) – Ordered list of functions’ names for preprocessing the raw signals. Each function takes a one-dimensional NumPy array as its input and returns an array of the same length.

config

Dataset config. It is loaded from the config.yaml file.

Type:

dict

data_path

Path of the data directory.

Type:

str

sampling_rate

Sampling rate of the signals, by default 360

Type:

int

config
data_path = ''
sampling_rate = 360
get_ecg_record(record_id=106)

Returns a record as a dictionary.

Parameters:

record_id (str) – Record id.

Returns:

A dictionary with keys: signal, r_locations, r_labels, rhythms, rhythms_locations.

Return type:

dict

class pyheartlib.data.DataSeq

Bases: abc.ABC

Parent of other data classes.

progress_bar = True
abstract full_annotate()
get_all_records(rec_list)

Returns all the records.

Parameters:

rec_list (list) – List of records IDs.

Returns:

A list containing a dictionary for each record. [rec1,rec2,….]. Each record is a dictionary with keys: signal, r_locations, r_labels, rhythms, rhythms_locations, full_ann.

Return type:

list

abstract gen_samples_info()
save_dataset(rec_list, file_name, win_size, stride, **kwargs)

Saves a dataset holding ECG records along with metadata about signal excerpts.

Parameters:
  • rec_list (list) – List of records IDs.

  • file_name (str, optional) – Name of the file that will be saved, by default None

  • win_size (int, optional) – Sliding window length (excerpt length).

  • stride (int, optional) – Stride of the sliding window, by default 36

Returns:

Two items: (records, metadata)

The first item is a list of records ([rec1_dict, …]). Each record is a dictionary with keys: signal, r_locations, r_labels, rhythms, rhythms_locations, full_ann.

The second item is a nested list. Each inner list contains the metadata for an excerpt structured as: [record_id, onset, offset, annotation]. E.g. : [[10,500,800,’AFIB’], …].

Return type:

tuple

save_samples(*args, **kwargs)