PhysioNetDataBase

class torch_ecg.databases.PhysioNetDataBase(db_name: str, db_dir: Optional[Union[str, pathlib.Path]] = None, working_dir: Optional[Union[str, pathlib.Path]] = None, verbose: int = 1, **kwargs: Any)[source]

Bases: torch_ecg.databases.base._DataBase

Base class for readers for PhysioNet database.

PhysioNet is a large repository of freely available biomedical signals, including ECG, EEG, EMG, and other signals. The website is 1.

Parameters
  • db_name (str) – Name of the database.

  • db_dir (str or pathlib.Path, optional) – Storage path of the database. If is None, wfdb will fetch data from PhysioNet.

  • working_dir (str or pathlib.Path, optional) – Working directory, to store intermediate files and log files.

  • verbose (int, default 1) – Verbosity level for logging.

  • kwargs (dict, optional) – Auxilliary key word arguments.

References

1

https://www.physionet.org/

download(compressed: bool = True) None[source]

Download the database from PhysioNet.

get_file_download_url(file_name: Union[str, pathlib.Path]) str[source]

Get the download url of the file.

Parameters

file_name (str or pathlib.Path) – Name of the file, e.g. “data/001a.dat”, “training/tr03-0005/tr03-0005.mat”, etc.

Returns

url – URL of the file to be downloaded.

Return type

str

get_subject_id(rec: Union[str, int]) int[source]

Attach a unique subject ID for the record.

Parameters

rec (str or int) – Record name or index of the record in all_records.

Returns

Subject ID associated with the record.

Return type

int

helper(items: Optional[Union[str, List[str]]] = None) None[source]

Print corr. meanings of symbols belonging to items.

More details can be found in the PhysioNet WFDB annotation manual 2.

Parameters

items (str or List[str], optional) – Items to print. If is None, then a comprehensive printing of meanings of all symbols will be performed.

Return type

None

References

2

https://archive.physionet.org/physiobank/annotations.shtml

load_data(rec: Union[str, int], leads: Optional[Union[str, int, Sequence[Union[int, str]]]] = None, sampfrom: Optional[int] = None, sampto: Optional[int] = None, data_format: str = 'channel_first', units: Optional[str] = 'mV', fs: Optional[numbers.Real] = None, return_fs: bool = False) Union[numpy.ndarray, Tuple[numpy.ndarray, numbers.Real]][source]

Load physical (converted from digital) ECG data, which is more understandable for humans; or load digital signal directly.

Parameters
  • rec (str or int) – Record name or index of the record in all_records.

  • leads (str or int or Sequence[str] or Sequence[int], optional) – The leads of the ECG data to load. None or “all” for all leads.

  • sampfrom (int, optional) – Start index of the data to be loaded.

  • sampto (int, optional) – End index of the data to be loaded.

  • data_format (str, default "channel_first") – Format of the ECG data, “channel_last” (alias “lead_last”), or “channel_first” (alias “lead_first”), or “flat” (alias “plain”) which is valid only when leads is a single lead

  • units (str or None, default "mV") – Units of the output signal, can also be “μV” (aliases “uV”, “muV”). None for digital data, without digital-to-physical conversion.

  • fs (numbers.Real, optional) – Sampling frequency of the output signal. If not None, the loaded data will be resampled to this frequency; if None, self.fs will be used if available and not None; otherwise, the original sampling frequency will be used.

  • return_fs (bool, default False) – Whether to return the sampling frequency of the output signal.

Returns

  • data (numpy.ndarray) – The ECG data loaded from the record, with given units and data_format.

  • data_fs (numbers.Real, optional) – Sampling frequency of the output signal. Returned if return_fs is True.

property url: str

URL of the database index page for downloading.

property url_: Optional[str]

URL of the compressed database file for downloading.

property version: str

Version of the database.

property webpage: str

URL of the database webpage