CINC2018¶
- class torch_ecg.databases.CINC2018(db_dir: str | bytes | PathLike | None = None, working_dir: str | bytes | PathLike | None = None, verbose: int = 1, **kwargs: Any)[source]¶
Bases:
PhysioNetDataBase
,PSGDataBaseMixin
You Snooze You Win - The PhysioNet Computing in Cardiology Challenge 2018
ABOUT
includes 1,985 subjects, partitioned into balanced training (n = 994), and test sets (n = 989)
signals include
electrocardiogram (ECG), electroencephalography (EEG), electrooculography (EOG), electromyography (EMG), electrocardiology (EKG), oxygen saturation (SaO2), etc.
frequency of all signal channels is 200 Hz
units of signals:
mV for ECG, EEG, EOG, EMG, EKG percentage for SaO2
six sleep stages were annotated in 30 second contiguous intervals:
wakefulness, stage 1, stage 2, stage 3, rapid eye movement (REM), undefined
annotated arousals were classified as either of the following:
spontaneous arousals, respiratory effort related arousals (RERA), bruxisms, hypoventilations, hypopneas, apneas (central, obstructive and mixed), vocalizations, snores, periodic leg movements, Cheyne-Stokes breathing, partial airway obstructions
Webpage of the database on PhysioNet [1].
Usage
sleep stage
sleep apnea
References
Citation
10.22489/CinC.2018.049 10.13026/6phb-r450
- 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, sampfrom: int | None = None, sampto: int | None = None, keep_original: bool = False) Dict[str, Dict[str, List[List[int]]]] [source]¶
Load sleep stage and arousal annotations of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the corresponding PSG data.
sampto (int, optional) – End index of the corresponding PSG data.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
A dictionary with keys “sleep_stages” and “arousals”, each of which is a dictionary with keys of sleep stages and arousals, and values of lists of lists of start and end indices of the sleep stages and arousals.
- Return type:
- load_arousals_ann(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, keep_original: bool = False) Dict[str, List[List[int]]] [source]¶
Load arousal annotations of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the corresponding PSG data.
sampto (int, optional) – End index of the corresponding PSG data.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
A dictionary with keys of arousals and values of lists of lists of start and end indices of the arousals.
- Return type:
- load_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 ECG data of the record.
- 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, 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_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 ECG data of the record.
- 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, 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_psg_data(rec: str | int, channel: str | Sequence[str] | None = None, sampfrom: int | None = None, sampto: int | None = None, data_format: str = 'channel_first', physical: bool = True, fs: Real | None = None, return_fs: bool = False) ndarray | Tuple[ndarray, Real] [source]¶
Load PSG data of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.channel (str, optional) – Nname of the channel of PSG data. If is None, all channels will be returned.
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 only one channel is passed.
physical (bool, default True) – If True, the data will be converted to physical units, otherwise, the data will be in digital units.
fs (numbers.Real, optional) – Sampling frequency of the output signal. If not None, the loaded data will be resampled to this frequency, 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) – PSG data corr. to the given channel of the record.
data_fs (numbers.Real, optional) – Sampling frequency of the output signal.
- load_sleep_stages_ann(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, keep_original: bool = False) Dict[str, List[List[int]]] [source]¶
Load sleep stage annotations of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the corresponding PSG data.
sampto (int, optional) – End index of the corresponding PSG data.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
A dictionary with keys of sleep stages and values of lists of lists of start and end indices of the sleep stages.
- Return type:
- plot_ann(rec: str | int) tuple [source]¶
Plot the sleep stage and arousal annotations of the record.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.- Returns:
fig (matplotlib.figure.Figure) – The figure object.
ax (matplotlib.axes.Axes) – The axes object.
TODO
Plot arousals events.