Epoch exclusion based on timing in to_epochs#136
Open
gongcastro wants to merge 2 commits intoibs-lab:mainfrom
Open
Epoch exclusion based on timing in to_epochs#136gongcastro wants to merge 2 commits intoibs-lab:mainfrom
to_epochs#136gongcastro wants to merge 2 commits intoibs-lab:mainfrom
Conversation
to_epochsto_epochs
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.
Summary
I wrote a small function to exclude certain events from
df_stimwhen runningto_epochs.This would allow the user to exclude certain epochs that, despite their trial type being included in
trial_types, overlap with some other events that make the epoch undesirable. For instance, if triggers were sent online during the task indicating events like noise, external interference, etc., the user may want to exclude epochs overlapping with such events.Below I explain the rationale, happy to clarify or adjust the code to ease integration if the PR is considered.
How it works
df_stim:exclude_trial_typesargument into_epochs.Noneand not empty, the functionexclude_eventsremoves fromdf_stimany events for which:a) Trial type is included in
exclude_trial_typesb) At least one subsequent event with onset between
onset-beforeandonset+afterhas trial type included inexclude_trial_typesIn the example, the resulting intermediate version of
df_stimonly includes the third event, as it is the only that does not satisfy (a) and (b). The functionexclude_eventscan also be called outside ofto_epochsto simply exclude the corresponding events beforehand:Testing
I added additional tests for
exclude_eventsand for the modified version ofto_epochs(testing the behaviour of the new argument). The whole testing suit runs fine locally.Note: not sure which branch to direct this PR, sending it to main until told otherwise.
PS: Thanks for your work! Cedalion is working very well in our lab (dealing with messy newborns data).