Skip to content

Commit 88796b4

Browse files
Add project: MEG_TRF (Wang Chi) – Brainhack School 2025 (#376)
* upload a page for Chi_brainhack_ project * Update content/en/project/MEG-TRF/index.md --------- Co-authored-by: Lune Bellec <[email protected]>
1 parent 619f081 commit 88796b4

File tree

6 files changed

+127
-0
lines changed

6 files changed

+127
-0
lines changed
513 KB
Loading
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
type: "project" # DON'T TOUCH THIS ! :)
3+
date: "2025-06-14" # Date you first upload your project.
4+
# Title of your project (we like creative title)
5+
title: "MEG Meets Stories - TRF Analysis of Continuous Speech in SMN4Lang"
6+
7+
# List the names of the collaborators within the [ ]. If alone, simple put your name within []
8+
names: [Wang Chi]
9+
10+
# Your project GitHub repository URL
11+
github_repo: https://github.com/Chi-WangPsy/Chi_brainhack_project
12+
13+
# If you are working on a project that has website, indicate the full url including "https://" below or leave it empty.
14+
website:
15+
16+
# List +- 4 keywords that best describe your project within []. Note that the project summary also involves a number of key words. Those are listed on top of the [github repository](https://github.com/PSY6983-2021/project_template), click `manage topics`.
17+
# Please only lowercase letters
18+
tags: [meg, trf, speech, language]
19+
20+
# Summarize your project in < ~75 words. This description will appear at the top of your page and on the list page with other projects..
21+
22+
summary: "This project explores how the brain responds to natural stories via TRF modeling on the SMN4Lang dataset, using acoustic envelope and word-aligned features -- and includes an exploratory attempt at word classification using machine learning."
23+
24+
# If you want to add a cover image (listpage and image in the right), add it to your directory and indicate the name
25+
# below with the extension.
26+
image: "cover.png"
27+
---
28+
<!-- This is an html comment and this won't appear in the rendered page. You are now editing the "content" area, the core of your description. Everything that you can do in markdown is allowed below. We added a couple of comments to guide your through documenting your progress. -->
29+
30+
## Project definition
31+
32+
### Background
33+
34+
This project was developed as part of Brainhack School 2025, where students from diverse backgrounds explore neuroscience tools through hands-on, open-science projects. Inspired by this spirit, I set out to investigate how the brain responds to naturalistic language.
35+
36+
Specifically, I used the SMN4Lang dataset, which provides synchronized MEG and audio recordings of Mandarin stories. By extracting time-aligned word-level features and modeling their relationship to brain signals using Temporal Response Functions (TRF), I explored how different linguistic properties -such as the acoustic envelope -shape neural responses.
37+
38+
At first, I couldn't really tell if the signals made any sense. But after much trial and error (and some brave plotting), the curves started to take shape - and although I still wasn't sure how meaningful they were, the instructor at my final presentation said they "mean something." That gave me a surprising sense of accomplishment.
39+
40+
The project also included a bold, exploratory attempt to decode word categories using machine learning... which didn't quite work - but the learning process absolutely did.
41+
42+
### Tools
43+
44+
The "Chi_brainhack_project" project will rely on the following technologies:
45+
* MNE-Python: For preprocessing and analyzing MEG data, including filtering and visualization.
46+
* NumPy: For numerical operations and signal processing.
47+
* Matplotlib: For generating custom plots and visualizations.
48+
* Scikit-learn: For an exploratory (and brave) attempt at machine learning–based word classification.
49+
* Jupyter Notebook: To write, test, and document code in an interactive, reproducible way.
50+
* Git & GitHub: For version control and sharing the project with the Brainhack community.
51+
52+
### Data
53+
54+
This project uses the SMN4Lang dataset(https://openneuro.org/datasets/ds004078), which contains magnetoencephalography (MEG) recordings and time-aligned annotations of Mandarin speech from 60 naturalistic story-listening sessions across 12 participants. The dataset includes synchronized audio, transcripts, and preprocessed MEG signals, enabling analysis of how the brain tracks both linguistic and acoustic features during continuous speech.
55+
This rich, real-world dataset allows researchers to move beyond controlled laboratory stimuli and investigate language processing in more ecologically valid settings.
56+
57+
58+
### Deliverables
59+
60+
At the end of this project, the following deliverables were completed:
61+
- Word-level stimulus .csv tables for each story, including POS, word frequency, and onset time.
62+
- TRF coefficients for acoustic envelope features, with corresponding visualizations.
63+
- Scripts to segment raw MEG data based on the annotated word-level features.
64+
- SVM classification of nouns vs. verbs using LOSO-CV accuracy and feature weight analysis.
65+
66+
## Results
67+
68+
### Progress overview
69+
70+
This project was developed during Brainhack School 2025, where students are encouraged to learn open neuroscience tools through hands-on projects. Initially unfamiliar with MEG data and the TRF framework, I gradually gained confidence by replicating small parts of existing pipelines and troubleshooting errors. The process was at times frustrating, especially when interpreting signal outputs, but became deeply rewarding after discussing the results with instructors who reassured me that "this already means something.
71+
72+
73+
### Tools I learned during this project
74+
75+
* **MNE-Python** for loading, preprocessing, and analyzing MEG data.
76+
* **Scikit-learn** for exploratory machine learning (SVM classification).
77+
* **Matplotlib** for visualization of TRF weights and decoding results.
78+
* **NumPy / SciPy** for signal processing and numerical computations.
79+
* **GitHub & Markdown** for project management and documentation
80+
81+
82+
### Results
83+
84+
#### Deliverable 1: Integrating required annotations into a single CSV file
85+
86+
At first, I had to repeatedly load multiple files, and I was always worried that the timestamps didn't align correctly or that data types were mismatched. Later, I realized it was more efficient to extract all necessary information and consolidate it into a single CSV file. This made subsequent data access much more convenient and allowed me to quickly visualize and verify the alignment.
87+
88+
* a presentation [made in a Jupyter notebook](https://github.com/Chi-WangPsy/Chi_brainhack_project/blob/main/notebook/alignstimuli.ipynb)
89+
90+
#### Deliverable 2: TRF coefficients and visualization
91+
92+
I initially attempted to use Brodbeck's eelbrain, but the data format differences caused repeated failures. Eventually, with help from ChatGPT and a better understanding of TRF principles, I created a custom TRF pipeline. In future work, I'd still like to revisit eelbrain since it might produce cleaner TRF signals.
93+
94+
In my current pipeline, I first save the TRF coefficients, which can later be loaded and plotted as needed. I visualized GRAD channels separately, explored hemispheric differences (left vs. right), and also generated topomaps to observe the dynamic patterns across the brain.
95+
96+
**TRF GRAD Waveform**
97+
![TRF GRAD WAVE](results/AE_TRF_GRAD_WAVE.png)
98+
**TRF MAG Waveform**
99+
![TRF MAG WAVE](results/AE_TRF_MAG_WAVE.png)
100+
**TRF GRAD Topomap**
101+
![TRF GRAD Topomap](results/AE_TRF_GRAD_TOPO.png)
102+
**TRF MAG Topomap**
103+
![TRF MAG Topomap](results/AE_TRF_MAG_TOPO.png)
104+
105+
* a presentation [made in a Jupyter notebook](https://github.com/Chi-WangPsy/Chi_brainhack_project/blob/main/notebook/TRF.ipynb) showing the analysis process and results.
106+
107+
#### Deliverable 3: Epoching based on word-level timing
108+
109+
Using word-level time-aligned annotations, I segmented the raw MEG data into epochs and saved them for further analysis.
110+
111+
* a presentation [made in a Jupyter notebook](https://github.com/Chi-WangPsy/Chi_brainhack_project/blob/main/notebook/epoch.ipynb)
112+
113+
#### Deliverable 4: SVM classification
114+
115+
I selected nouns and verbs and fed them into an SVM classifier to test whether they could be distinguished based on brain signals. The output included LOSO-CV accuracy and feature weight analysis. However, I later realized that this approach may not be appropriate and needs further refinement.
116+
117+
* a presentation [made in a Jupyter notebook](https://github.com/Chi-WangPsy/Chi_brainhack_project/blob/main/notebook/POVSVM.ipynb)
118+
119+
## Conclusion and acknowledgement
120+
121+
This project marked my first journey into analyzing MEG data in a naturalistic language context. Although I encountered early confusion and technical hurdles, I gradually gained hands-on experience in data pipelines, TRF modeling, and machine learning evaluation.
122+
123+
At the outset, I didn't even know how to use Bash. Thanks to the clear and detailed module instructions, I felt like I had evolved from a digital novice into someone capable of confidently navigating their own computing environment.
124+
125+
During the final presentation, the instructor suggested that I treat the Brainhack School Discord community like a real-time GPT-freely asking questions and receiving instant feedback. I believe this approach could help me clarify confusion more efficiently and explore new analysis directions. Moving forward, I hope to become more proactive in seeking support and initiating discussions.
126+
127+
Special thanks to the Brainhack School team and instructors for fostering such a supportive learning environment-one that transformed initial uncertainty into curiosity and meaningful progress.
528 KB
Loading
360 KB
Loading
513 KB
Loading
377 KB
Loading

0 commit comments

Comments
 (0)