braindecode.augmentation.SensorsRotation#

class braindecode.augmentation.SensorsRotation(probability, sensors_positions_matrix, axis='z', max_degrees=15, spherical_splines=True, random_state=None)[source]#

Interpolates EEG signals over sensors rotated around the desired axis with an angle sampled uniformly between -max_degree and max_degree.

Suggested in [1]

Parameters
  • probability (float) – Float setting the probability of applying the operation.

  • sensors_positions_matrix (numpy.ndarray) –

    Matrix giving the positions of each sensor in a 3D cartesian coordinate system. Should have shape (3, n_channels), where n_channels is the number of channels. Standard 10-20 positions can be obtained from mne through:

    >>> ten_twenty_montage = mne.channels.make_standard_montage(
    ...    'standard_1020'
    ... ).get_positions()['ch_pos']
    

  • axis ('x' | 'y' | 'z', optional) – Axis around which to rotate. Defaults to ‘z’.

  • max_degree (float, optional) – Maximum rotation. Rotation angles will be sampled between -max_degree and max_degree. Defaults to 15 degrees.

  • spherical_splines (bool, optional) – Whether to use spherical splines for the interpolation or not. When False, standard scipy.interpolate.Rbf (with quadratic kernel) will be used (as in the original paper). Defaults to True.

  • random_state (int | numpy.random.Generator, optional) – Seed to be used to instantiate numpy random number generator instance. Defaults to None.

References

1

Krell, M. M., & Kim, S. K. (2017). Rotational data augmentation for electroencephalographic data. In 2017 39th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC) (pp. 471-474).

Methods

get_augmentation_params(*batch)[source]#

Return transform parameters.

Parameters
  • X (tensor.Tensor) – The data.

  • y (tensor.Tensor) – The labels.

Returns

params – Contains four elements:

  • sensors_positions_matrixnumpy.ndarray

    Matrix giving the positions of each sensor in a 3D cartesian coordinate system. Should have shape (3, n_channels), where n_channels is the number of channels.

  • axis’x’ | ‘y’ | ‘z’

    Axis around which to rotate.

  • anglesarray-like

    Array of float of shape (batch_size,) containing the rotation angles (in degrees) for each element of the input batch, sampled uniformly between -max_degrees``and ``max_degrees.

  • spherical_splinesbool

    Whether to use spherical splines for the interpolation or not. When False, standard scipy.interpolate.Rbf (with quadratic kernel) will be used (as in the original paper).

Return type

dict

static operation(X, y, sensors_positions_matrix, axis, angles, spherical_splines)#

Interpolates EEG signals over sensors rotated around the desired axis with the desired angle.

Suggested in [1]

Parameters
  • X (torch.Tensor) – EEG input example or batch.

  • y (torch.Tensor) – EEG labels for the example or batch.

  • sensors_positions_matrix (numpy.ndarray) –

    Matrix giving the positions of each sensor in a 3D cartesian coordinate system. Should have shape (3, n_channels), where n_channels is the number of channels. Standard 10-20 positions can be obtained from mne through:

    >>> ten_twenty_montage = mne.channels.make_standard_montage(
    ...    'standard_1020'
    ... ).get_positions()['ch_pos']
    

  • axis ('x' | 'y' | 'z') – Axis around which to rotate.

  • angles (array-like) – Array of float of shape (batch_size,) containing the rotation angles (in degrees) for each element of the input batch.

  • spherical_splines (bool) – Whether to use spherical splines for the interpolation or not. When False, standard scipy.interpolate.Rbf (with quadratic kernel) will be used (as in the original paper).

References

1

Krell, M. M., & Kim, S. K. (2017). Rotational data augmentation for electroencephalographic data. In 2017 39th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC) (pp. 471-474).