MITDBDataset

class torch_ecg.databases.datasets.MITDBDataset(config: CFG, task: str, training: bool = True, lazy: bool = True, **reader_kwargs: Any)[source]

Bases: ReprMixin, Dataset

Data generator for feeding data into pytorch models using the MITDB database.

Parameters:
  • config (dict) –

    Configurations for the dataset, ref. MITDBDataset. A simple example is as follows:

    >>> config = deepcopy(MITDBDataset)
    >>> config.db_dir = "some/path/to/db"
    >>> dataset = MITDBDataset(config, task="qrs_detection", training=True, lazy=False)
    

  • training (bool, default True) – If True, the training set will be loaded, otherwise the test (val) set will be loaded.

  • lazy (bool, default True) – If True, the data will not be loaded immediately, instead, it will be loaded on demand.

  • **reader_kwargs (dict, optional) – Keyword arguments for the database reader class.

extra_repr_keys() List[str][source]

Extra keys for __repr__() and __str__().

persistence(force_recompute: bool = False, verbose: int = 0) None[source]

Save the preprocessed data to disk.

Parameters:
  • force_recompute (bool, default False) – Whether to force recompute the preprocessed data.

  • verbose (int, default 0) – Verbosity level for printing the progress.

Return type:

None

plot_seg(seg: str, ticks_granularity: int = 0) None[source]

Plot the segment.

Parameters:
  • seg (str) – Name of the segment, of pattern like “S_1_1_0000193”.

  • ticks_granularity (int, default 0) – Granularity to plot axis ticks, the higher the more ticks. 0 (no ticks) –> 1 (major ticks) –> 2 (major + minor ticks)

Return type:

None

reset_task(task: str, lazy: bool = True) None[source]

Reset the task of the data generator.

Parameters:
  • task (str) – The task to be set.

  • lazy (bool, optional) – Whether to load the data lazily, by default True.

Return type:

None