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

Fix #9383, removing delta in set_annotations with corresponding tests. #10351

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jevenzh
Copy link

@jevenzh jevenzh commented Feb 16, 2022

Thanks for contributing a pull request! Please make sure you have read the
contribution guidelines
before submitting.

Please be aware that we are a loose team of volunteers so patience is
necessary. Assistance handling other issues is very welcome. We value
all user contributions, no matter how minor they are. If we are slow to
review, either the pull request needs some benchmarking, tinkering,
convincing, etc. or more likely the reviewers are simply busy. In either
case, we ask for your understanding during the review process.

Again, thanks for contributing!

Reference issue

Example: Fixes #1234.

What does this implement/fix?

Explain your changes.

Additional information

Any additional information you think is important.

@jevenzh jevenzh mentioned this pull request Feb 16, 2022
@jevenzh
Copy link
Author

jevenzh commented Feb 16, 2022

Previous discussions .can be found in #10160. @drammock please have a look when you have time.

Comment on lines 1587 to 1594
n_channels = 1
sampling_freq = 100
length_seconds = 20

info = mne.create_info(n_channels, sfreq=sampling_freq,
ch_types=['eeg'])
data = np.random.randn(n_channels, sampling_freq * length_seconds)
raw = mne.io.RawArray(data, info)
Copy link
Member

Choose a reason for hiding this comment

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

@jevenzh you could use a pytest fixture to avoid recomputing such a raw toy data for each test. Tell us if you need help

Copy link
Author

Choose a reason for hiding this comment

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

Oops, I indeed violated the DRY principle, thanks for the hint! I will learn about the pytest fixture and apply it here.

@@ -687,17 +687,15 @@ def set_annotations(self, annotations, emit_warning=True,
' which case the annotation onsets would be'
' taken in reference to the first sample of'
' the raw object.')

delta = 1. / self.info['sfreq']
Copy link
Author

Choose a reason for hiding this comment

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

According to the CI test results, it seems that removing this delta will affect the annotation filtering behavior. For example:

data = np.ones((1, 1000))
info = create_info(1, 1000., 'eeg')
raw = RawArray(data, info)

this will result in data duration of 0.999 instead of 1 second.

Copy link
Member

Choose a reason for hiding this comment

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

So it seems like maybe we do need to keep delta in there for deciding which annotation durations to crop, but adjust which annotations get removed based on onset ...? Like in the case of 1 sec of data at 1000 Hz, if an annotation has onset=0 and duration = 1 it shouldn't be cropped, but one with an onset >= 1 should be removed because it actually starts (rather than ends) at the next time point?

@larsoner
Copy link
Member

@jevenzh do you think we should continue here? One way forward would be to keep the new tests, but revert the change about delta and see if everything passes?

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.

3 participants