ltbio.ml.datasets.BiosignalDataset#

Overview#

Classes#

BiosignalDataset

An abstract class representing a dataset of Biosignals.

BiosignalSubset

Subset of a dataset at specified indices.

CohortDataset

Dataset as a concatenation of multiple datasets.

Contents#

class ltbio.ml.datasets.BiosignalDataset.BiosignalDataset(name: str = None)#

Bases: torch.utils.data.dataset.Dataset, abc.ABC

digraph inheritancec9d2c607eb { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "BiosignalDataset" [URL="#ltbio.ml.datasets.BiosignalDataset.BiosignalDataset",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An abstract class representing a dataset of Biosignals."]; "Dataset" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Dataset" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="An abstract class representing a :class:`Dataset`."]; "Generic" -> "Dataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Generic" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Abstract base class for generic types."]; }

An abstract class representing a dataset of Biosignals. All subclasses should store the ordered list of objects and targets, respectively, in __objects and __targets. Also, subclasses have to overwrite __getitem__, supporting fetching an example for a given key. An example is a pair (object, target).

property all_examples: list[tuple[numpy.ndarray, numpy.ndarray]]#

All examples in the dataset.

property all_objects: numpy.ndarray#

All objects in the dataset.

property all_targets: numpy.ndarray#

All targets in the dataset.

property biosignals: dict[str, ltbio.biosignals.modalities.Biosignal.Biosignal]#

The Biosignals from which the dataset was populated.

property object_timeseries_names#
property target_timeseries_names#
augment(techniques: Collection[ltbio.ml.datasets.augmentation.DatasetAugmentationTechnique], how_many_times=1, show_example=False)#
plot_example_object(number: int = None)#
redimension_to(dimensions: int)#
split(subsetA_size: int, subsetB_size: int, randomly: bool)#
to_tensor()#
transfer_to_device(device)#
class ltbio.ml.datasets.BiosignalDataset.BiosignalSubset(dataset: BiosignalDataset, indices: Sequence[int])#

Bases: torch.utils.data.dataset.Subset, BiosignalDataset

digraph inheritance1b7bbe21c8 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "BiosignalDataset" [URL="#ltbio.ml.datasets.BiosignalDataset.BiosignalDataset",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An abstract class representing a dataset of Biosignals."]; "Dataset" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BiosignalSubset" [URL="#ltbio.ml.datasets.BiosignalDataset.BiosignalSubset",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Subset" -> "BiosignalSubset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BiosignalDataset" -> "BiosignalSubset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Dataset" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="An abstract class representing a :class:`Dataset`."]; "Generic" -> "Dataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Generic" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Abstract base class for generic types."]; "Subset" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Subset of a dataset at specified indices."]; "Dataset" -> "Subset" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Subset of a dataset at specified indices.

Args:

dataset (Dataset): The whole Dataset indices (sequence): Indices in the whole set selected for subset

property all_examples#

All examples in the dataset.

property all_objects#

All objects in the dataset.

property all_targets#

All targets in the dataset.

property object_timeseries_names#
property target_timeseries_names#
class ltbio.ml.datasets.BiosignalDataset.CohortDataset(datasets: Iterable[BiosignalDataset])#

Bases: torch.utils.data.dataset.ConcatDataset, BiosignalDataset

digraph inheritance9e2254967d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "BiosignalDataset" [URL="#ltbio.ml.datasets.BiosignalDataset.BiosignalDataset",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An abstract class representing a dataset of Biosignals."]; "Dataset" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "BiosignalDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CohortDataset" [URL="#ltbio.ml.datasets.BiosignalDataset.CohortDataset",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ConcatDataset" -> "CohortDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BiosignalDataset" -> "CohortDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ConcatDataset" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Dataset as a concatenation of multiple datasets."]; "Dataset" -> "ConcatDataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Dataset" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="An abstract class representing a :class:`Dataset`."]; "Generic" -> "Dataset" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Generic" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Abstract base class for generic types."]; }

Dataset as a concatenation of multiple datasets.

This class is useful to assemble different existing datasets.

Args:

datasets (sequence): List of datasets to be concatenated

property all_examples#

All examples in the dataset.

property all_objects#

All objects in the dataset.

property all_targets#

All targets in the dataset.

property object_timeseries_names#
property target_timeseries_names#