You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/misc/EEGLAB_and_MEG_data.md
+22-17Lines changed: 22 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,56 +9,61 @@ EEGLAB and MEG data
9
9
====================
10
10
11
11
EEGLAB supports reading most MEG data formats through the File-IO
12
-
module. Therefore all the major manufacturers may be imported (CTF,
13
-
Neuromag, Neuroimaging 4-D, BTi). There is also the native *ctfimport* EEGLAB plugin to import CTF data.
12
+
extension. Therefore MEG data from all the major manufacturers may be imported (CTF, Neuromag, Neuroimaging 4-D, BTi). There is also a native *ctfimport* EEGLAB plugin to import CTF data, although we recommend using the File-IO extension first.
14
13
15
-
The BIDS-matlab-tools EEGLAB plugin also support importing BIDSformated MEG data. You may install this plugin from the EEGLAB plugin manager (menu item File > Manage EEGLAB extensions).
14
+
The [BIDS-matlab-tools](https://github.com/sccn/bids-matlab-tools) EEGLAB plugin also supports importing BIDS-formated MEG data. You may install this plugin from the EEGLAB plugin manager (menu item <spanstyle="color: brown">File > Manage EEGLAB extensions</font>).
16
15
17
-
MEG data may be processed as EEG data, although there is added complexity
18
-
for some data formats. For example, EEGLAB does not differentiate
19
-
between gradiometers and magnetometers for Neuromag data. For
20
-
plotting purposes, you should only keep one type of data.
21
-
22
-
Here we show how to import and plot Neuromag MEG and CFT data.
16
+
Below, we show how to import and plot Neuromag MEG and CFT MEG data. For further processing, you should use the EEG tutorial. We recommend using the [clean_rawdata](https://github.com/sccn/clean_rawdata) EEGLAB plugin to clean data (find bad channels and bad portions of data). We also recommend using Independent Component Analysis (ICA) to remove artifacts. Unfortunately, artifactual ICA components need to be manually labeled. Automated methods such as [ICLabel](https://github.com/sccn/ICLabel) and [MARA](https://irenne.github.io/artifacts/) that automatically detect ICA artifacts do not apply to MEG data (they were trained with EEG data, and would need to be retrained with MEG data).
23
17
24
18
Importing Neuromag MEG data
25
19
---------------------------
26
20
27
-
For Neuromag data, you may use the popular "multisubject, multimodal face processing" datasetds000117. Instead of downloading the entire dataset, you may download the file *sub-01_ses-meg_task-facerecognition_run-01_meg.fif* in the *sub-01/ses-meg/meg* folder. After starting EEGLAB, select menu item <spanstyle="color: brown">File > Import data > Using the File-IO interface</span>. You are then asked if you want to import a file or a folder. Select the button to import a file and select the file above.
21
+
For Neuromag data, as an example, we will use the popular "multisubject, multimodal face processing" [dataset](https://nemar.org/dataexplorer/detail?dataset_id=ds000117). Instead of downloading the entire dataset, you may download the file *sub-01_ses-meg_task-facerecognition_run-01_meg.fif* in the *sub-01/ses-meg/meg* folder. After starting EEGLAB, select menu item <spanstyle="color: brown">File > Import data > Using the File-IO interface</span>. You are then asked if you want to import a file or a folder. Select the button to import a file and select the file above on your computer.
28
22
29
23

30
24
31
-
Leave all the import options as default and press OK. Next use menu item <spanstyle="color: brown">Edit > Select data</span>. Click the button to browse channel types and select *megmag* to select the magnetometer channels. Press OK and then OK again to select these channels and remove other channels.
25
+
Leave all the import options as default and press OK. Next, we will select the MEG channel we want to process and plot. Use menu item <spanstyle="color: brown">Edit > Select data</span>. Click the button to browse channel types and select *megmag* to select the magnetometer channel type. Press OK and then OK again to select these channels and remove other channels.
32
26
33
27

34
28
35
-
Let's now plotthe data spectrum. Use menu item <spanstyle="color: brown">Plot > Channel spectra and maps</span>. Change the frequency at which to plot spectral power to 7 and 15 Hz. You may also change the option to plot the electrodes. Press OK, and the following spectrum appears.
29
+
Let's now make a simple plot, for example, the MEG data spectrum. Use menu item <spanstyle="color: brown">Plot > Channel spectra and maps</span>. Change the frequency to plot spectral power to 7 and 15 Hz. You may also change the option to plot the electrodes. Press OK, and the following spectrum appears. For further preprocessing, see the EEG tutorial.
36
30
37
31

38
32
39
33
Importing CTF MEG data
40
34
----------------------
41
-
We will use a dataset which is more challenging than the one above. Some CTF datasets have sensor locations associated with them, but this is not always the case. This is the [tutorial data](https://nemar.org/dataexplorer/detail?dataset_id=ds000246) for Brainstorm. This dataset does not have sensor locations. Let's first import it. After starting EEGLAB, select menu item <span style="color: brown">File > Import data > Using the File-IO interface</span>. You are then asked if you want to import a file or a folder. Select the button to import a folder and select the folder *sub-0001_task-AEF_run-01_meg.ds* located in the *sub-0001/meg* subfolder. We recommend you check the checkbox *Convert data trials to continuous data*. CTF data is sometimes stored as trials because it is large, and may not all be processed in memory. Storing the data as trials allows data to be loaded one trial at a time. This limitation is motly obsolete though, as computer memory has increased over the past decade. Filtering data trials can lead to [decrease in statistical power](https://www.biorxiv.org/content/10.1101/2022.12.03.518987v1) and we do not recommend it. MEG data trials are often contiguous so the data trials may be converted back to continuous data. Press OK when done.
35
+
For CTF, we will use a more challenging dataset than the one above. Some CTF datasets have sensor locations associated with them, but this is not always the case. We will use the [tutorial data](https://nemar.org/dataexplorer/detail?dataset_id=ds000246) for Brainstorm, which has the advantage of being small in size and easy to download. However, this dataset does not have sensor locations.
36
+
37
+
First, download the data, and then let's first import the data. After starting EEGLAB, select menu item <span style="color: brown">File > Import data > Using the File-IO interface</span>. You are then asked to import a file or a folder. Select the button to import a folder and select the folder *sub-0001_task-AEF_run-01_meg.ds* located in the *sub-0001/meg* subfolder. We recommend you check the checkbox *Convert data trials to continuous data*. CTF data is sometimes stored as trials because it is large and may not all be processed in the computer memory. Storing the data as trials allows data to be loaded one trial at a time. This made sense one or two decades ago, but this limitation is obsolete since most computers can now load and process an entire dataset. MEG data trials are often contiguous, so we may convert the data trials back to continuous data. We recommend using that option since filtering data trials can lead to [a decrease in statistical power](https://www.biorxiv.org/content/10.1101/2022.12.03.518987v1). Press OK when done.
42
38
43
39

44
40
45
-
Let's then remove non-MEG channels. We cannot select channels by type in this datasets, so we will instead. Use menu item <spanstyle="color: brown">Edit > Select data</span>. Click the button to browse channels and select select channels *MLC11-4408* to *MZP01-4408*. Press OK and then OK again to select these channels and remove other channels. You should be left with 274 channels.
41
+
Let's then remove non-MEG channels. Unlike the Neuromag dataset, we cannot select channels by type in this dataset, so we will select channels by name (note that some CTF datasets have channel types, but this is not one of them). Use menu item <spanstyle="color: brown">Edit > Select data</span>. Click the button to browse channels and select channels *MLC11-4408* to *MZP01-4408*. Press OK and then OK again to select these channels and remove other channels. You should be left with 274 channels.
46
42
47
43

48
44
49
-
Next, we need to assign sensor locations. To do so call menu item <spanstyle="color: brown">Edit > Channel locations</span> then press the *Look up locs* button. Select the file *CTF275_helmet.mat* which is a layout 2-D files (these files must not be used for 3-D plotting or for source localization), and check the checkbox to import the file instead of looking up channnel locations. Looking up channel locations, would be fine except for the name of the channel which has the "-4480" postfix. To look up channel location we would first need to remove the postfix using MATLAB code on the command line, then EEGLAB would be able to recognize the channel in the layout files. But let's simply remove the missing channel from the newly imported layout file. So simply press OK to import the layout file.
45
+
Next, we need to assign sensor locations. To do so, call menu item <spanstyle="color: brown">Edit > Channel locations</span>, then press the *Look up locs* button. Select the file *CTF275_helmet.mat*, a layout file for 2-D plotting (this type of file must not be used for 3-D plotting or source localization), and check the checkbox to import the file instead of looking up channel locations. Looking up channel locations would be fine except for the channels' names, which have the "-4480" postfix. To look up channel locations, we would first need to remove the postfix on the MATLAB command line, then EEGLAB would be able to look up the channel in the layout files. But let's instead import the layout file. So press OK to import the layout file.
50
46
51
47

52
48
53
-
For some reason, the current dataset is missing channel MRT27, so we need to remove it from the layout. We also need to remove the last 2 channels, *COMNT* and *SCALE* which are no longer in the dataset. Find channel MRT27 then press the delete button. Then find the last 2 channels and press the delete button. You should be left with 274 channels which is the number of data channels. If you do not have 274 channels, EEGLAB will complain and ignore the channel location you have imported (the number of channel having data must correspond to the number of channel locations).
49
+
For some reason, the current dataset is missing channel MRT27, so we need to remove it from the layout. We also need to remove the last 2 channels, *COMNT* and *SCALE*, which are no longer in the dataset. Find channel MRT27, and press the *delete* button. Then find the last two channels and delete them as well. You should be left with 274 channels which is the number of data channels. If you do not have 274 channels, EEGLAB will complain and ignore the channel location you have imported (the number of channels having data must correspond to the number of channel locations).
54
50
55
51

56
52
57
53
Now use menu item <spanstyle="color: brown">Plot > Channel spectra and maps</span> to plot the spectrum. Change the frequency at which to plot spectral power to 10 Hz. You may also change the option to plot the electrodes. Press OK, and the following spectrum appears.
58
54
59
55

60
56
61
-
If you want to perform source localization with this data, you would need to obtain the 3-D location from the sensor. These may be obtained from other datasets recorded with the same system (for example the [NIMH Intramural Healthy Volunteer Dataset](https://openneuro.org/datasets/ds004215/versions/1.0.1) has it; The [Mother of unification studies](https://data.donders.ru.nl/collections/di/dccn/DSC_3011020.09_236?0) dataset has them as well). Once you have imported these datasets, you may use menu item <spanstyle="color: brown">Edit > Dataset info</span>, and for the channel locations, use the button *From other datasets*. You need to check that the two datasets have the same number of data channels and the same channel labels.
57
+
To perform source localization with this data, you would need to obtain the 3-D location from the sensor (instead of a 2-D layout). These may be obtained from other datasets recorded with the same system (for example, the [NIMH Intramural Healthy Volunteer Dataset](https://openneuro.org/datasets/ds004215/versions/1.0.1) has it; The [Mother of unification studies](https://data.donders.ru.nl/collections/di/dccn/DSC_3011020.09_236?0) dataset has them as well). Once you have imported these datasets, you may use menu item <spanstyle="color: brown">Edit > Dataset info</span>, and for the channel locations, use the button *From other datasets*. You will need to check that the two datasets have the same number of data channels and the same channel labels.
58
+
59
+
EEGLAB will automatically detect that you are processing MEG data and adjust the topographic plots. However, if this is not the case, you may manually change the plotting settings on the MATLAB command line. To do so, type:
0 commit comments