MITDB¶
- class torch_ecg.databases.MITDB(db_dir: str | bytes | PathLike | None = None, working_dir: str | bytes | PathLike | None = None, verbose: int = 1, **kwargs: Any)[source]¶
Bases:
PhysioNetDataBase
MIT-BIH Arrhythmia Database
ABOUT
contains 48 half-hour excerpts of two-channel ambulatory ECG recordings, obtained from 47 subjects.
recordings were digitized at 360 samples per second per channel with 11-bit resolution over a 10 mV range.
annotations contains:
beat-wise or finer (e.g. annotations of flutter wave) annotations, accessed via the symbol attribute of an Annotation.
rhythm annotations, accessed via the aux_note attribute of an Annotation.
Webpage of the database on PhysioNet [1].
Usage
Beat classification
Rhythm classification (segmentation)
R peaks detection
References
Citation
10.1109/51.932724 10.13026/C2F305
- 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.
- property df_stats: DataFrame¶
DataFrame of the statistics of the dataset.
- property df_stats_expanded: DataFrame¶
Expanded DataFrame of the statistics of the dataset.
- property df_stats_expanded_boolean: DataFrame¶
Expanded DataFrame of the statistics of the dataset, with boolean values.
- load_ann(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, rhythm_format: str = 'intervals', rhythm_types: Sequence[str] | None = None, beat_format: str = 'beat', beat_types: Sequence[str] | None = None, keep_original: bool = False) dict [source]¶
Load rhythm and beat annotations of the record.
Rhythm and beat annotations are stored in the aux_note, symbol attributes of corresponding annotation files. NOTE that qrs annotations (.qrs files) do NOT contain any rhythm annotations.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the annotations to be loaded.
sampto (int, optional) – End index of the annotations to be loaded.
rhythm_format ({"interval", "mask"}, optional) – Format of returned annotation, by default “interval”, case insensitive.
rhythm_types (list of str, optional) – Defaults to self.rhythm_types. If is not None, only the rhythm annotations with the specified types will be returned.
beat_format ({"beat", "dict"}, optional) – Format of returned annotation, by default “beat”, case insensitive.
beat_types (List[str], optional) – Beat types to be loaded, by default self.beat_types. If is not None, only the beat annotations with the specified types will be returned.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
ann – The annotations of
rhythm
andbeat
, withrhythm
annotatoins in the format of intervals, or mask;beat
annotations in the format of dict orBeatAnn
.- Return type:
- load_beat_ann(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, beat_format: str = 'beat', beat_types: Sequence[str] | None = None, keep_original: bool = False) Dict[str, ndarray] | List[BeatAnn] [source]¶
Load beat annotations of the record.
Beat annotations are stored in the symbol attribute of corresponding annotation files.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the annotations to be loaded.
sampto (int, optional) – End index of the annotations to be loaded.
beat_format ({"beat", "dict"}, optional) – Format of returned annotation, by default “beat”, case insensitive.
beat_types (List[str], optional) – Beat types to be loaded, by default self.beat_types. If is not None, only the beat annotations with the specified types will be returned.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
ann – Locations (indices) of the all the beat types (“A”, “N”, “Q”, “V”,).
- Return type:
- load_rhythm_ann(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, rhythm_format: str = 'intervals', rhythm_types: Sequence[str] | None = None, keep_original: bool = False) Dict[str, list] | ndarray [source]¶
Load rhythm annotations of the record.
Rhythm annotations are stored in the aux_note attribute of corresponding annotation files.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the annotations to be loaded.
sampto (int, optional) – End index of the annotations to be loaded.
rhythm_format ({"interval", "mask"}, optional) – Format of returned annotation, by default “interval”, case insensitive.
rhythm_types (list of str, optional) – Defaults to self.rhythm_types. If is not None, only the rhythm annotations with the specified types will be returned.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
ann – Annotations in the format of intervals or mask.
- Return type:
- load_rpeak_indices(rec: str | int, sampfrom: int | None = None, sampto: int | None = None, keep_original: bool = False) ndarray [source]¶
Load rpeak indices of the record.
Rpeak indices, or equivalently qrs complex locations, are stored in the symbol attribute of corresponding annotation files, regardless of their beat types.
- Parameters:
rec (str or int) – Record name or index of the record in
all_records
.sampfrom (int, optional) – Start index of the annotations to be loaded.
sampto (int, optional) – End index of the annotations to be loaded.
keep_original (bool, default False) – If True, indices will keep the same with the annotation file, otherwise subtract sampfrom if specified.
- Returns:
rpeak_inds – Locations (indices) of the all the rpeaks (qrs complexes).
- Return type:
- plot(rec: str | int, data: ndarray | None = None, ann: Dict[str, ndarray] | None = None, beat_ann: Dict[str, ndarray] | None = None, rpeak_inds: Sequence[int] | ndarray | None = None, ticks_granularity: int = 0, leads: int | List[int] | None = None, sampfrom: int | None = None, sampto: int | None = None, same_range: bool = False, **kwargs: Any) None [source]¶
Not implemented.