mne-tools / mne-tools/mne-python
Function for creating toy data
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
I often find myself generating toy data (e.g. for educational or testing purposes), so I thought a dedicated function might be useful.
It should be as simple as possible, for example:
from numpy.random import default_rng
from mne import create_info
from mne.io import RawArray
def create_toy_data(n_channels=3, duration=25, sfreq=250, seed=None):
rng = default_rng(seed)
data = rng.standard_normal(size=(n_channels, int(duration * sfreq))) * 5e-6
info = create_info(n_channels, sfreq, "eeg")
return RawArray(data, info)
It is important that there are sensible defaults for all parameters, which makes it possible to generate toy data very quickly:
raw = create_toy_data()
If people think this would be useful, I can go ahead and submit a PR.
Of course, this function could have a lot of additional parameters, such as
- the kind of generated data (raw, epochs, evoked),
- the probability distribution to sample from,
- the channel type,
- the data scaling,
- ...
However, I'd say YAGNI until someone really needs a particular feature.
If there is interest, I have two questions:
- Where should this function live? I'd put it in
mne.miscand export it tomne, but there might be a better place. - The recommended method for generating random numbers is
numpy.random.default_rng(seed), but the seed is not compatible with how we are dealing with random state (check_random_state()). If the function gets aseedorrandom_stateparameter, how should we handle this?
So – yay or nay?
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 reviewing the proposed create_toy_data entry point in mne.misc, its export to mne, and the existing create_info and RawArray APIs. Compare the suggested numpy.random.default_rng(seed) approach with the project's check_random_state() handling. Done means the API location, random-state behavior, defaults, and supported output are agreed and implemented with appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100