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
- 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
- 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
- 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.