PickLabel#
- class dpeeg.transforms.PickLabel(pick: ndarray, keys: list[str] | None = None, order: bool = True, shuffle: bool = True, seed: int = 42)[source]#
Pick a subset of data.
Pick the required labels and data from the dataset and re-label them.
- Parameters:
pick (ndarray) – Label to include.
keys (list of str, optional) – The key of the eegdata value to be transformed, if required. Applies to all eegdata by default.
order (bool) – If True, relabel the selected labels.
shuffle (bool) – Whether or not to shuffle the data after picking.
seed (int) – Controls the shuffling applied to the data after picking.
- Returns:
data – Transformed eegdata.
- Return type:
eegdata or dataset
Examples
>>> eegdata = dpeeg.EEGData(edata=np.random.randn(16, 3, 10), ... label=np.random.randint(0, 3, 16)) array([1, 2, 0, 2, 1, 2, 0, 1, 0, 0, 0, 1, 2, 1, 0, 0])
>>> transforms.PickLabel(np.array([1, 2]))(eegdata, verbose=False) array([1, 0, 1, 0, 1, 0, 0, 0, 1])
If some values do not need to be transformed, they can be excluded by the keys parameter:
>>> eegdata = dpeeg.EEGData( ... edata=np.random.randn(16, 3, 10), ... label=np.random.randint(0, 3, 16), ... adj=np.random.randn(16, 3, 3), ... pcc=np.random.randn(16, 3, 3), ... ) >>> transforms.PickLabel( ... np.array([0, 1]), keys=["edata", "adj"] ... )(eegdata, verbose=False) [edata=(12, 3, 10), label=(12,), adj=(12, 3, 3), pcc=(16, 3, 3)]