Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update transposition to latest torch convention #446

Merged
merged 3 commits into from Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions braindecode/augmentation/functional.py
Expand Up @@ -501,8 +501,9 @@ def _frequency_shift(X, fs, f_shift):
analytical = _analytic_transform(padded)
if isinstance(f_shift, (float, int, np.ndarray, list)):
f_shift = torch.as_tensor(f_shift).float()
reshaped_f_shift = f_shift.repeat(
N_padded, n_channels, 1).T
f_shift_stack = f_shift.repeat(N_padded, n_channels, 1)
reshaped_f_shift = f_shift_stack.permute(
*torch.arange(f_shift_stack.ndim - 1, -1, -1))
shifted = analytical * torch.exp(2j * np.pi * reshaped_f_shift * t)
return shifted[..., :N_orig].real.float()

Expand Down
2 changes: 2 additions & 0 deletions docs/whats_new.rst
Expand Up @@ -43,6 +43,7 @@ Enhancements

Bugs
~~~~
- Removing deprecation warning due to torch transposition in :func:`braindecode.augmentation.functional._frequency_shift` (:gh:`446` by `Matthieu Terris`_)


API changes
Expand Down Expand Up @@ -186,3 +187,4 @@ Authors
.. _Ghaith Bouallegue: https://github.com/GhBlg
.. _Denis A. Engemann: https://github.com/dengemann
.. _Oskar Størmer: https://github.com/ostormer
.. _Matthieu Terris: https://github.com/matthieutrs