Shortcuts

RandomFrequencyShift

class torcheeg.transforms.RandomFrequencyShift(p: float = 0.5, sampling_rate: int = 128, shift_min: float | int = -2.0, shift_max: float | int = 2.0, series_dim: int = 0, apply_to_baseline: bool = False)[source][source]

Apply a frequency shift with a specified probability, after which the EEG signals of all channels are equally shifted in the frequency domain.

transform = RandomFrequencyShift()
transform(eeg=torch.randn(32, 128))['eeg'].shape
>>> (32, 128)

transform = RandomFrequencyShift(sampling_rate=128, shift_min=4.0)
transform(eeg=torch.randn(1, 32, 128))['eeg'].shape
>>> (1, 32, 128)

transform = RandomFrequencyShift(p=1.0, series_dim=0)
transform(eeg=torch.randn(128, 9, 9))['eeg'].shape
>>> (128, 9, 9)
Parameters:
  • sampling_rate (int) – The original sampling rate in Hz (default: 128)

  • shift_min (float or int) – The minimum shift in the random transformation. (default: -2.0)

  • shift_max (float or int) – The maximum shift in random transformation. (default: 2.0)

  • series_dim (int) – Dimension of the time series in the input tensor. (default: -1)

  • p (float) – Probability of applying random mask on EEG signal samples. Should be between 0.0 and 1.0, where 0.0 means no mask is applied to every sample and 1.0 means that masks are applied to every sample. (default: 0.5)

  • 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, eeg: Tensor, baseline: Tensor | None = None, **kwargs) Dict[str, Tensor][source][source]
Parameters:
  • eeg (torch.Tensor) – The input EEG signal.

  • baseline (torch.Tensor, 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 output EEG signal after applying a random sampling_rate shift.

Return type:

torch.Tensor

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