FIX: Keep extras when combining Annotations#14028
Open
sametSeckiiin wants to merge 3 commits into
Open
Conversation
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14022 What does this implement/fix?
When combining annotations using
_combine_annotations(e.g., during raw concatenations or appending), theextraslist associated with the annotations was being dropped. Whileonset,duration, anddescriptionarrays were properly concatenated, the newAnnotationsobject was constructed without passing the combinedextraskeyword argument.This PR fixes the issue by:
extraslists from the input annotation objects (list(one.extras) + list(two.extras)).extraslist to the returnedAnnotationsconstructor so that metadata like response times or stimulus details are preserved after concatenation.Additional information
Here is a minimal script to verify the fix:
`import mne
a1 = mne.Annotations([1], [1], ['stim'], extras=[{'res': 1}])
a2 = mne.Annotations([2], [2], ['stim'], extras=[{'res': 2}])
print((a1 + a2).extras)
Output is now correctly: [{'res': 1}, {'res': 2}] instead of [{}]