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 SegmentationReconstruction augmentation #608

Merged

Conversation

gustavohenriquesr
Copy link
Collaborator

Hi, I created a new data augmentation class named SegmentationReconstruction to braindecode. This process was originally proposed in this paper, which I implemented and used in my own work.

This technique works on the time domain, and the ideia is to segment each trial into several segments and then generate new artificial trials, as a concatenation of segments coming from different and randomly selected training trials from the same class.

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 92.72727% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 87.25%. Comparing base (a9f744f) to head (6d0b492).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #608      +/-   ##
==========================================
+ Coverage   87.20%   87.25%   +0.05%     
==========================================
  Files          67       67              
  Lines        5925     5980      +55     
==========================================
+ Hits         5167     5218      +51     
- Misses        758      762       +4     

test/unit_tests/augmentation/test_transforms.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
@bruAristimunha
Copy link
Collaborator

Hey @gustavohenriquesr,

Thank you for your first contribution!

I am super happy about this ;)

I made some initial comments and I will try to ask for some extra revision, as I am already familiar with the code.

@bruAristimunha
Copy link
Collaborator

Extra comment, please edit the source doc to include in the documentation page.

braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@cedricrommel cedricrommel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the contribution @gustavohenriquesr ! It's been a while I wanted an augmentation like this to be added to the library and I'm glad you are doing it!

I think the PR is great and have just a few comments. Most of them are small things, except maybe for the location where randomness should be introduced: we made the design choice of only sampling:doing random operations outside functionals.py, to stay close to torchvision design.

braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/functional.py Outdated Show resolved Hide resolved
braindecode/augmentation/transforms.py Outdated Show resolved Hide resolved
braindecode/augmentation/transforms.py Outdated Show resolved Hide resolved
braindecode/augmentation/transforms.py Outdated Show resolved Hide resolved
test/unit_tests/models/test_integration.py Outdated Show resolved Hide resolved
@gustavohenriquesr
Copy link
Collaborator Author

gustavohenriquesr commented May 19, 2024

@bruAristimunha

I have removed some functional tests that no longer apply with the new rearrangement of functions here 882bd61. The cases handled in the functions are now at the class level (transforms.py) and are no longer useful for functional testing. We can add more tests to the transform class, if you think it's necessary.

Copy link
Collaborator

@cedricrommel cedricrommel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

Thanks for the changes and explanations!

@bruAristimunha bruAristimunha enabled auto-merge (squash) May 20, 2024 16:42
@bruAristimunha bruAristimunha merged commit 2ebd568 into braindecode:master May 20, 2024
20 checks passed
@bruAristimunha
Copy link
Collaborator

Thank you so much, @gustavohenriquesr! I hope this makes our script simpler with this augmentation now integrated, and I am hoping for the paper to be accepted! 🤞🏽

Thank you so much, too, for your revision, @cedricrommel; I would love to have more reviews from you here if you have time for open source 🙏🏽

@gustavohenriquesr
Copy link
Collaborator Author

Glad to contribute! I also thank you @bruAristimunha @cedricrommel for helping me improve the code. I hope to be able to make further contributions in the future!

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