ApneaECG¶
- class torch_ecg.databases.ApneaECG(db_dir: str | bytes | PathLike | None = None, working_dir: str | bytes | PathLike | None = None, verbose: int = 1, **kwargs: Any)[source]¶
Bases:
PhysioNetDataBase
Apnea-ECG Database - The PhysioNet Computing in Cardiology Challenge 2000
ABOUT
consist of 70 single lead ECG records, divided into a learning set of 35 records (a01 through a20, b01 through b05, and c01 through c10), and a test set of 35 records (x01 through x35)
recordings vary in length from slightly less than 7 hours to nearly 10 hours (401 - 578 min) each
control group (c01 through c10): records having fewer than 5 min of disorder breathing
borderline group (b01 through b05): records having 10-96 min of disorder breathing
apnea group (a01 through a20): records having 100 min or more of disorder breathing
.dat files contain the digitized ECGs, and respiration signals, all with frequency 100 Hz
.apn files are (binary) annotation files (only for the learning set), containing an annotation for each minute of each recording indicating the presence or absence of apnea at that time. labels are in the member “symbol”, “N” for normal, “A” for apnea
.qrs files are machine-generated (binary) annotation files, unaudited and containing errors, provided for the convenience of those who do not wish to use their own QRS detectors
c05 and c06 come from the same original recording (c05 begins 80 seconds later than c06). c06 may have been a corrected version of c05
eight records (a01 through a04, b01, and c01 through c03) that include respiration signals have several additional files each:
*r.dat files contains respiration signals correspondingly, with 4 channels: “Resp C”, “Resp A”, “Resp N”, “SpO2”
*er.* files only contain annotations
annotations for the respiration signals are identical to the corresponding ECG signals
Webpage of the database on PhysioNet [1]. Paper describing the database [2].
Usage
Sleep apnea analysis
References
Citation
10.1109/cic.2000.898505 10.13026/C23W2R
- Parameters:
db_dir (path-like, optional) – Storage path of the database. If not specified, data will be fetched from Physionet.
working_dir (path-like, optional) – Working directory, to store intermediate files and log files.
verbose (int, default 1) – Level of logging verbosity.
kwargs (dict, optional) – Auxilliary key word arguments.
- property database_info: DataBaseInfo¶
The
DataBaseInfo
object of the database.
- load_ann(rec: str | int, ann_path: str | bytes | PathLike | None = None, **kwargs) list [source]¶
Load annotations of the record.
- load_apnea_event(rec: str | int, ann_path: str | None = None) DataFrame [source]¶
Load annotations of apnea events of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.ann_path (str or pathlib.Path, optional) – Path of the file which contains the annotations. If is None, default path will be used.
- Returns:
df_apnea_ann – Apnea annotations with columns “event_start”, “event_end”, “event_name”, “event_duration” (ref. self.sleep_event_keys).
- Return type:
pandas.DataFrame
- 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 or respiration 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 or respiration 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 or respiration 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 or respiration 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.
- load_ecg_data(rec: str | int, 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.
- load_rsp_data(rec: str, channels: 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 [source]¶
Load physical (converted from digital) respiration 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 respiration 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 respiration 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 respiration 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.
- plot_ann(rec: str | int, ann_path: str | None = None) None [source]¶
Plot annotations of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.ann_path (str or pathlib.Path, optional) – Path of the file which contains the annotations. If is None, default path will be used.
- Return type:
None