Shortcuts

MapChunk

class torcheeg.transforms.MapChunk(transform: EEGTransform, chunk_size: int = 250, overlap: int = 0, apply_to_baseline: bool = False)[source][source]

Divide the input EEG signal into multiple chunks according to chunk_size and overlap, and then apply a transofrm to each chunk, and combine the calculation results of a transofrm on all chunks. It is used when feature fusion is required.

from torcheeg import transforms

t = transforms.MapChunk(
    transforms.BandDifferentialEntropy(),
    chunk_size=250,
    overlap=0
)
t(eeg=np.random.randn(64, 1000))['eeg'].shape
>>> (64, 16)

TorchEEG allows feature fusion at multiple scales:

from torcheeg import transforms

t = transforms.Concatenate([
    transforms.MapChunk(
        transforms.BandDifferentialEntropy()
        chunk_size=250,
        overlap=0),  # 4 chunk * 4-dim feature
    transforms.MapChunk(
        transforms.BandDifferentialEntropy()
        chunk_size=500,
        overlap=0),  # 2 chunk * 4-dim feature
    transforms.BandDifferentialEntropy()  # 1 chunk * 4-dim feature
])
t(eeg=np.random.randn(64, 1000))['eeg'].shape
>>> (64, 28) # 4 * 4 + 2 * 4 + 1 * 4
Parameters:
  • transform (EEGTransform) – a transform

  • apply_to_baseline – (bool): Whether to act on the baseline signal at the same time, if the baseline is passed in when calling. (default: False)

__call__(*args, **kwargs) Dict[str, ndarray][source][source]
Parameters:
  • eeg (np.ndarray) – The input EEG signals in shape of [number of electrodes, number of data points].

  • baseline (np.ndarray, optional) – The corresponding baseline signal, if apply_to_baseline is set to True and baseline is passed, the baseline signal will be transformed with the same way as the experimental signal.

Returns:

The combined results of a transform from multiple chunks.

Return type:

np.ndarray

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources