PhysioNetDataBase

class torch_ecg.databases.PhysioNetDataBase(db_name: str, db_dir: str | bytes | PathLike | None = None, working_dir: str | bytes | PathLike | None = None, verbose: int = 1, **kwargs: Any)[source]

Bases: _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 (path-like, optional) – Storage path of the database. If is None, wfdb will fetch data from PhysioNet.

  • working_dir (path-like, 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

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

Download the database from PhysioNet.

get_file_download_url(file_name: str | bytes | PathLike) str[source]

Get the download url of the file.

Parameters:

file_name (path-like) – 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: 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: str | List[str] | None = 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

load_data(rec: str | int, leads: str | int | Sequence[int | str] | None = None, sampfrom: int | None = None, sampto: int | None = None, data_format: str = 'channel_first', units: str | None = 'mV', fs: Real | None = None, return_fs: bool = False) ndarray | Tuple[ndarray, 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_: str | None

URL of the compressed database file for downloading.

property version: str

Version of the database.

property webpage: str

URL of the database webpage