# <center> Assignment 2 </center> **Objective** : Objective: Apply the techniques learned in class to **preprocess** the data (including ICA), compute **ERP**, utilize wavelet transform for **time-frequency analysis**, and assess **HEP**. **Note: If you can't see the image clearly, you can view it by right-clicking -> 在新分頁開啟圖片** ~~**<font color=#f00>Deadline : May 13, 2024 (Monday) 18:00 </font>**~~ **<font color=#f00>Deadline : May 14, 2024 (Tuesday) 18:00 </font>** **<font color=#f00>Office hour : May 13, 2024 (Monday) 13:00~16:00, Place : 65410 </font>** **Format of report:** * Written report * Powerpoint * Reqiured component: * Please take a screenshot at each STEP and explain what you did at each STEP (including preprocessing and data analysis). * The report should include comparison between **just listening** and **memorizing** conditions for following elements : (1) ERPs (Event-related potential) (2) Time-frequency map (3) ERSP (Event-related spectral perturbations) (4) HEP (Heartbeat-evoked potential) * Self-assessment: (1) Describe what you learn from this assignment. (2) Describe the difficulty and problem that you encounter and what you do to solve the problem. (3) Score your work from 1 (Poor) to 100 (Excellent). <font color =#f00>**Your score will be determined by the quality of your PowerPoint.**</font> **Please submit your report to Moodle before the deadline. Late submissions will not be accepted.** **Outstanding performers will be notified on Wednesday night, May 15. Selected students are requested to share their methods during class on May 16.** **If you encounter any difficulties with this assignment, don't hesitate to ask questions on Moodle, or you can seek assistance from the TA.** **Email of TA : `P76121330@gs.ncku.edu.tw`(唐翊峰)** <div style="page-break-after:always"></div> --- # Data description This dataset consists of raw 64-channel EEG, cardiovascular (electrocardiography and photoplethysmography), and pupillometry data from 86 human participants during 4 minutes of eyes-closed resting and during performance of a classic working memory task – digit span task with serial recall. The participants either memorized (memory) or just listened to (control condition) sequences of 5, 9, or 13 digits presented auditorily with 2 second stimulus onset asynchrony. A visual depiction of the experimental paradigm (not in scale). The participants were instructed to either memorize or just listen to sequences of 5, 9, or 13 digits, and then in the memory condition, they recalled the whole sequence in the serial order. The presentation of each digit is marked in the physiological recordings with event codes varying from 500105 to 6013131. For example, event code 5002091 means that the task was to passively listen to the sequence, the digit is the second in a sequence of nine digits, and the digit was correctly recalled. ![image](https://hackmd.io/_uploads/ByBXHQGG0.png) **If you want to know more information about this dataset, please [click here](https://openneuro.org/datasets/ds003838/versions/1.0.6)** <div style="page-break-after:always"></div> ## Data aquistion --- You can get data from **NAS** * Open browser * type 140.116.246.33 * ![image](https://hackmd.io/_uploads/B1H3Cd7MA.png) * click 進階 -> 繼續前往(140.116.246.33) * Sucess enter NAS * Account * **使用者帳戶 : Neuroimaging** * **密碼 : baisp65410** * File * Please download the file **sub_034_ecg.set,** **sub_034_eeg_ecg.set** and **sub_034_eeg_ecg.fdt** * sub_034_eeg.set : only contains eeg * sub_034_eeg_ecg.set : contains eeg and ecg <div style="page-break-after:always"></div> ## Sample of executing data ### Software for EEG data analysis **Python-based** : * [MNE-python](https://mne.tools/stable/index.html) **Matlab-based** : * [Brainstorm](https://neuroimage.usc.edu/brainstorm/Introduction) * [EEGLAB](https://sccn.ucsd.edu/eeglab/index.php) (TA will use this software for example) * **Note** : TA will only answer questions about operating EEGLAB. ### Tutorials If you have any problem when operating software, please check the following tutorials. * [MNE-python](https://mne.tools/stable/auto_tutorials/index.html) * [Brainstorm](https://neuroimage.usc.edu/brainstorm/Tutorials) * [EEGLAB](https://eeglab.org/tutorials/) <div style="page-break-after:always"></div> --- # Example (EEGLAB) ## Preprocessing ### Load data ![image](https://hackmd.io/_uploads/Hkrv0mGGC.png) If you can see this frame, which means you success load data. --- ### Bandpass filter (1~45Hz) ![image](https://hackmd.io/_uploads/B1QtxEGMA.png) If you want to examine whether you are doing right or not in this step. You can draw the power spectral density(PSD) to check. ![image](https://hackmd.io/_uploads/SJxHV4MG0.png) We observe a significant decrease at 1Hz and 45Hz, indicating successful bandpass filtering of these frequencies. --- ### ICA **Note : To save your time, FastICA is highly recommended.** In EEGLAB, upon completing the Independent Component Analysis (ICA) on your data, you will observe that the ICA weights change to "yes", signifying the successful execution of the ICA process. The subsequent step involves removing these IC components. ![image](https://hackmd.io/_uploads/rJsVYLmfR.png) --- In EEGLAB, you can utilize the classify IC component feature to identify which components you wish to remove. ![image](https://hackmd.io/_uploads/By3stUQMC.png) <div style="page-break-after:always"></div> --- ## Data analysis ### Extract data Please compare the **just listening** and **memorizing** conditions for digit lengths **9** and **13**. Extract data from **digit-6**, **digit-7**, **digit-8**, **digit-9** within the time range [-0.1s, 1s]. * The **event code** for digit lengths 9 | digit index | Just listening | memorizing | |:-----------:|:--------------:|:------------------:| | 6 | 500609 | 6006090 or 6006091 | | 7 | 500709 | 6007090 or 6007091 | | 8 | 500809 | 6008090 or 6008091 | | 9 | 500909 | 6009090 or 6009091 | * The **event code** for digit lengths 13 | digit index | Just listening | memorizing | |:-----------:|:--------------:|:------------------:| | 6 | 500613 | 6006130 or 6006131 | | 7 | 500713 | 6007130 or 6007131 | | 8 | 500813 | 6008130 or 6008131 | | 9 | 500913 | 6009130 or 6009131 | Note: When extracting data, visually inspect for any noise. If present, please reject it. ![image](https://hackmd.io/_uploads/B1VuPrIfR.png) ### Time frequency Analysis Please compare about **time frequency map** about two condition in **Fz** channel. Please also compare the power change within theta (4~8Hz) and alpha (8~12Hz) bands. ### Time frequency map **Just Listening** ![image](https://hackmd.io/_uploads/SkVtOS8z0.png) **Memorizing** ![image](https://hackmd.io/_uploads/SydIOB8zC.png) ### ERSP Please also compare about **ERSP (Event-Related Spectral Perturbation)** 2 condition in **Fz** channel. ERSP : ERSP stands for Event-Related Spectral Perturbation, a method used to analyze time-frequency data. ERSP is commonly applied in the analysis of electroencephalogram (EEG) or other physiological signal data to study the spectral changes in brain activity induced by specific events, such as stimuli or behaviors. ERSP aims to illustrate how the spectral power changes across different frequency ranges when specific events or stimuli occur. It provides information about the time-frequency characteristics of event-related brain activity. Typically, ERSP involves dividing the time window into different segments and then calculating the changes in frequency power within each segment. These changes are then presented graphically to observe how brain activity varies across different frequency ranges when events occur. ERSP analysis is often combined with other techniques such as wavelet transforms or Fourier transforms to better understand the dynamic properties of brain activity in both time and frequency domains. **Just listening** ![image](https://hackmd.io/_uploads/H1Z1KHIfA.png) **Memorizing** ![image](https://hackmd.io/_uploads/HkYMtH8z0.png) --- ### ERP Analysis **ERP Analysis** ![image](https://hackmd.io/_uploads/B1-hYBIzR.png) If you'd like more detailed information about a channel, simply double-click on the channel of your choice. ![image](https://hackmd.io/_uploads/rkMg9rLM0.png) --- ### HEP * Extension : HEPLAB * Tutorial : [HEPLAB](https://github.com/perakakis/HEPLAB) If you success using HEPLAB to add ECG events, you can see the event code when you plotting eeg signal. ![image](https://hackmd.io/_uploads/r1NooOLzC.png) After completing all preprocessing steps, please compare the heartbeat-evoked potentials (HEP) between the conditions of **just listening** and **memorization** of all digits. This entails selecting event codes starting with **50** to signify **just listening**, and those starting with **60** to indicate **memorizing**, within the time range [-0.1 seconds, 1 second]. Extract ECG events within the time span [-0.1 seconds, 0.6 seconds] for the purpose of HEP comparison. Additionally, ensure to manually eliminate any noise. ![image](https://hackmd.io/_uploads/SJbuGKIz0.png) The final HEP for channel Fz ![image](https://hackmd.io/_uploads/B1d94F8MR.png)