mne-tools / mne-realtime

Realtime data analysis with MNE-Python
https://mne.tools/mne-realtime/
BSD 3-Clause "New" or "Revised" License
52 stars 23 forks source link

Make `.get_data_as_epoch` timeout a configurable parameter #49

Closed charlesbmi closed 1 year ago

charlesbmi commented 1 year ago

As someone creating a real-time application, I sometimes want to limit the amount of time the application is waiting on data. This change makes wait_time (now called timeout) a configurable parameter.

In the situation that data is not ready before the timeout, .get_data_as_epoch now returns None because EpochsArray(data,...) errors out when data is an empty array. Note: it was possible for data to be empty even before the change, although a shorter timeout now makes this more likely.

larsoner commented 1 year ago

In the situation that data is not ready before the timeout, .get_data_as_epoch now returns None because EpochsArray(data,...) errors out when data is an empty array.

Should we change MNE-Python to allow EpochsArray to be an empty array of shape (0, n_channels, n_times)? We do allow instances of empty Epochs so I don't see why we couldn't do it for EpochsArray...

charlesbmi commented 1 year ago

Should we change MNE-Python to allow EpochsArray to be an empty array of shape (0, n_channels, n_times)? We do allow instances of empty Epochs so I don't see why we couldn't do it for EpochsArray...

Seems reasonable to me! The specific error raised here is because the array is empty with shape (1, n_channels, n_times=0), but EpochsArray initialization also errors out if the passed in data is shape (0, n_channels, n_times) as you mention.

Separately, looks like the jobs are failing due to https://community.codecov.com/t/codecov-yanked-from-pypi-all-versions/4259/9

larsoner commented 1 year ago

The update I pushed should fix the codecov problem

Feel free to make a PR to allow 0 length EpochsArray. Maybe not for no time points, but it seems reasonable for zero epochs

larsoner commented 1 year ago

Marking for merge when green @charlesincharge , thanks in advance!