braindecode.augmentation.SensorsRotation

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

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
probabilityfloat

Float setting the probability of applying the operation.

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. 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_degreefloat, optional

Maximum rotation. Rotation angles will be sampled between -max_degree and max_degree. Defaults to 15 degrees.

spherical_splinesbool, 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_params(*batch)

Return transform parameters.

Parameters
Xtensor.Tensor

The data.

ytensor.Tensor

The labels.

Returns
paramsdict

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).

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
Xtorch.Tensor

EEG input example or batch.

ytorch.Tensor

EEG labels for the example or batch.

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. 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.

anglesarray-like

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

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).

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).