CINC2021Dataset

class torch_ecg.databases.datasets.CINC2021Dataset(config: CFG | None = None, training: bool = True, lazy: bool = True, **reader_kwargs: Any)[source]

Bases: ReprMixin, Dataset

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

Parameters:
  • config (dict) –

    configurations for the Dataset, ref. CINC2021TrainCfg. A simple example is as follows:

    >>> config = deepcopy(CINC2021TrainCfg)
    >>> config.db_dir = "some/path/to/db"
    >>> dataset = CINC2021Dataset(config, 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.

empty(leads: Sequence[str] | None = None) None[source]

Empty the loaded data, and keep the leads.

Parameters:

leads (Sequence[str], optional) – The leads to be kept, by default the current leads.

Return type:

None

extra_repr_keys() List[str][source]

Extra keys for __repr__() and __str__().

classmethod from_extern(ext_ds: CINC2021Dataset, config: CFG) CINC2021Dataset[source]

Create a new dataset from an existing one.

The existing dataset must have all data loaded into memory, and its leads must be a superset of the new dataset.

Parameters:
  • ext_ds (CINC2021Dataset) – The existing dataset.

  • config (CFG) – The configuration of the new dataset.

Returns:

A new instance of the dataset.

Return type:

CINC2021Dataset

property labels: ndarray

Cached labels, only available when lazy=False or preloading is performed manually.

persistence() None[source]

Save the processed dataset to disk.

reload_from_extern(ext_ds: CINC2021Dataset) None[source]

Reload the data from an existing dataset.

The existing dataset must have all data loaded into memory, and its leads must be a superset of the current dataset.

Parameters:

ext_ds (CINC2021Dataset) – The existing dataset.

Return type:

None

property signals: ndarray

Cached signals, only available when lazy=False or preloading is performed manually.

to(leads: Sequence[str]) None[source]

Reduce the leads to a subset of the current leads.

Parameters:

leads (Sequence[str]) – The subset of leads to be kept.

Return type:

None