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

Add MaskEncoding augmentation #631

Merged
merged 6 commits into from
Jun 19, 2024

Conversation

gustavohenriquesr
Copy link
Collaborator

Hi, I've implemented another data augmentation class called MaskEncoding.

The idea is similar to SmoothTimeMask but there is no smoothing of the masking. In addition, the masking can be divided into parts and spread across the signal (these parts can overlap, and I chose to leave it this way). This implementation was initially based on this article, and I modified it as I saw appropriate.

Adresses #628

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.34%. Comparing base (726ee1a) to head (52a1d66).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #631      +/-   ##
==========================================
+ Coverage   87.29%   87.34%   +0.04%     
==========================================
  Files          67       67              
  Lines        6055     6083      +28     
==========================================
+ Hits         5286     5313      +27     
- Misses        769      770       +1     

@bruAristimunha
Copy link
Collaborator

Hey @gustavohenriquesr,

The code is already good, so I will ask something else: can you measure the impact of augmentation using the ShallowNet and BCNI datasets? To integrate something, we need to have some interesting results!

The idea would be to do a cross-subject approach with 5-fold, very similar to Cedric's tutorial, but with a splitter for cross-validation with the augmentation. You can decide whether to validate the augmentation parameters or the probability. Use the same parameters from https://github.com/eeg-augmentation-benchmark/eeg-augmentation-benchmark-2022/blob/1df778f7359581b1297d18dbdabf2b2fd4fcfa2f/eeg_augmentation_benchmark/models.py#L64C1-L78C57

Small inspiration to build the cross-validation object:

If you need an extension for the deadline, ping me on Discord ;)

@gustavohenriquesr
Copy link
Collaborator Author

Hello, @bruAristimunha

Thank you for the patience.

I did the tests you requested using a simplified strategy of what @cedricrommel proposed earlier for some other augmentations. The results show that using more than one segment benefits the model, while very high masking ratios when n_segments = 1 worsen performance. When we increase the number of segments, as in this case I tested with 5 segments, the model responds well up to a certain masking ratio.

Leave it to you to decide whether it's worth adding this method to Braindecode.

Later, with more time, I can do more tests with a wider range of values if you like.

splits

mask_ratio

mask_ratio_5

@bruAristimunha
Copy link
Collaborator

Amazing work @gustavohenriquesr ;)

@agramfort, the green button is your!

@agramfort agramfort merged commit 946e333 into braindecode:master Jun 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants