Shortcuts

after_hook_linear_dynamical_system

class torcheeg.transforms.after_hook_linear_dynamical_system(data: List[ndarray | Tensor], V0: float = 0.01, A: float = 1, T: float = 0.0001, C: float = 1, sigma: float = 1)[source][source]

A common hook function used to normalize the signal of the whole trial/session/subject after dividing it into chunks and transforming the divided chunks.

It is used as follows:

from torcheeg.datasets import DEAPDataset
from torcheeg.transforms import after_hook_linear_dynamical_system

dataset = DEAPDataset(root_path='./data_preprocessed_python',
                      offline_transform=transforms.Compose([
                          transforms.BandDifferentialEntropy(),
                          transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT)
                      ]),
                      online_transform=transforms.ToTensor(),
                      after_trial=after_hook_linear_dynamical_system,
                      label_transform=transforms.Compose([
                          transforms.Select('valence'),
                          transforms.Binary(5.0),
                      ]))

If you want to pass in parameters, use partial to generate a new function:

from functools import partial
from torcheeg.datasets import DEAPDataset
from torcheeg.transforms import after_hook_linear_dynamical_system

dataset = DEAPDataset(root_path='./data_preprocessed_python',
                      offline_transform=transforms.Compose([
                          transforms.BandDifferentialEntropy(),
                          transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT)
                      ]),
                      online_transform=transforms.ToTensor(),
                      after_trial=partial(after_hook_linear_dynamical_system, V0=0.01, A=1, T=0.0001, C=1, sigma=1),
                      label_transform=transforms.Compose([
                          transforms.Select('valence'),
                          transforms.Binary(5.0),
                      ]))
Parameters:
  • data (list) – A list of np.ndarray or torch.Tensor, one of which corresponds to an EEG signal in trial.

  • V0 (float) – The initial variance of the linear dynamical system (default: 0.01)

  • A (float) – The coefficient of the linear dynamical system (default: 1)

  • T (float) – The term added to the diagonal of the covariance matrix (default: 0.0001)

  • C (float) – The coefficient of the linear dynamical system (default: 1)

  • sigma (float) – The variance of the linear dynamical system (default: 1)

Returns:

The normalized results of a trial. It is a list of np.ndarray or torch.Tensor, one of which corresponds to an EEG signal in trial.

Return type:

list

Read the Docs v: latest
Versions
latest
stable
v1.1.1
v1.1.0
v1.0.11
v1.0.10
v1.0.9
v1.0.8.post1
v1.0.8
v1.0.7
v1.0.6
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

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