mne-tools / mne-tools/mne-python
No bounds checks for `{raw,epochs}.get_data()` with `tmin` or `tmax`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
I was a bit surprised to find out that .get_data() in combination with tmin or tmax arguments does not perform any bounds checks, but instead just returns the (entire) data array. I expected an error, a warning, or at least an info message stating that a given tmin or tmax argument exceeded the available data range.
Is this an intentional decision? If so, it should at least be documented. I think the current behavior is very dangerous, because it can lead to bugs that are really hard to find.
n_channels = 32
sfreq = 256
data = np.ones((n_channels, 100 * sfreq))
info = mne.create_info(n_channels, sfreq)
raw = mne.io.RawArray(data, info)
onsets = np.arange(1 * sfreq, 91 * sfreq, sfreq, dtype=int)
events = np.column_stack(
(onsets, np.zeros(len(onsets), dtype=int), np.ones(len(onsets), dtype=int))
)
epochs = mne.Epochs(raw, events, tmin=-0.2, tmax=0.5)
epochs.get_data(tmin=-0.6, tmax=1.8) # both tmin and tmax exceed data range!
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 reproducing the supplied example and inspecting the get_data() entry points for Raw and Epochs. Determine whether out-of-range tmin or tmax should raise, warn, report information, or be documented as intentional; completion should make the behavior explicit and cover both objects consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100