mne-tools / mne-tools/mne-python
Adding an RSA example not based on decoding in the tutorials
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
Proposed documentation enhancement
Hi everyone!
First, thanks again for the amazing tool, using mne (and its documentation) is always a pleasure and I often recommend tutorials or documentation pages as reading to other members of my lab.
I recently submitted an article which performs a relatively simple RSA analysis of MEG data using cross-validated mahalanobis. It uses rsatoolbox and ends up being relatively concise: for a single subject, it essentially boils down to the following.
e = mne.read_epochs(BIDSpath("...")).as_type("mag").pick_types(meg="mag")
data = TemporalDataset(
e.get_data(copy=False),
descriptors = {"subj": "sub-01"},
obs_descriptors = {"category": e.metadata["category"], "run": e.metadata["run"]},
channel_descriptors = {"channels": e.ch_names},
time_descriptors = {"time": e.times})
rdm = calc_rdm_movie(data, method="crossnobis", descriptor="category", cv_descriptor="run")
# Here I would plot empirical RDMs for a few different timepoints
# Then some code to create models (~15 lines); I would plot the predictors here
# Model the empirical RDM; + refer to articles and `rsatoolbox` for choice of metric
betas = rsatoolbox.model.fitter.fit_regress(models, rdm)
# Some code to plot the output.
plt.plot(e.times, betas)
I know that such example code exists across different packages, including rsatoolbox and mne-rsa, but ultimately what I'm proposing is quite close to the data while benefiting from useful abstractions from both mne and rsatoolbox and I think it might be a useful tutorial, which would also include considerations about how to estimate the empirical RDM, how to measure similarity across RDMs, etc.
If the community thinks that this tutorial would be useful, I am happy to draft and submit a version as a PR. My dataset is public, as is my code, and so I would naturally be inclined to make the tutorial about one subject, one run of my own data. But I could also write this about another dataset if it's easier (although I think that an example with predictors that are not just categorical predictors, like audio versus visual, would make this more appealing). Resources specifically related to my work:
- https://www.biorxiv.org/content/10.1101/2024.03.13.584141v2
- https://openneuro.org/datasets/ds006012/
- https://github.com/mathias-sm/AGeometricShapeRegularityEffectHumanBrain/blob/main/MEG/02_rsa/sensor/01_compute_rdms.py
- https://github.com/mathias-sm/AGeometricShapeRegularityEffectHumanBrain/blob/main/MEG/02_rsa/sensor/02_model_rdms.py
Let me know, and thanks again to everyone behind the mne collection of softwares!
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
Before drafting, confirm that maintainers still want this tutorial, since the issue has had no recent activity. Review the referenced scripts 01_compute_rdms.py and 02_model_rdms.py, then define a tutorial using the linked public dataset that covers empirical RDM estimation, RDM similarity, model construction, and plotting; done means the complete example is integrated into the documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation, machine-learning
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100