mne-tools / mne-tools/mne-python
Opportunity for code improvement in get_annotations_per_epoch
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
Finding the overlap of two collections of intervals is a very common issue for people working with time series data. In MNE, this is encountered in the get_annotations_per_epoch method. I couldn't help but notice that in its implementation, there are three cases which are identified and treated separately, each with two comparisons: start within bounds, stop within bounds, or both within bounds.
In truth, only two comparisons need to hold at the same time: start is before stop of the other interval, and stop is after start of the other interval.
I apologize in advance for making this into an issue, but I didn't really know where else to post it. The performance improvement is likely not huge for modest amounts of data, but it is an improvement nonetheless.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the get_annotations_per_epoch method and reading its current interval-overlap handling. Verify how the three existing cases behave, then confirm that the two stated comparisons preserve the same results and improve the implementation. Done means the overlap logic is simplified without changing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100