Search Results
49 items found
- Filtering
In order to analyze our data as accurately as possible, it is important that we filter out the extreme high and low frequency waves in our data, as these recordings are most likely due to the environment and other artifacts. Typically, frequencies less than 0.01 Hz - 0.1 Hz and greater than 40 Hz - 50 Hz are filtered out. BESA automatically turns on low and high cutoff filters that can be edited if desired. Keep in mind that filters distort data, and filtering too much can alter waveforms and wave amplitudes significantly. Filtering tutorial day 1 of the BESA workshop: 52:10 - 1:06:17
- Delete or Interpolate Bad Channels
Affected data segments may be rejected (deleted) or replaced (interpolated) with estimations based on nearby non-artifact contaminated data. Interpolation should be less than 5% of the total channels (so interpolate 3-4 channels max if you have 64 channels total) This is due to the data warping interpolation does to nearby data. Deleting Channels We may want to delete bad channels that contain too many artifacts (noise, movement, blinking, etc.). Right click on the desired channel and click “Define this channel as bad”. The channel will automatically delete. This process can be reversed by clicking “Define this channel as bad” again. Interpolating Channels Interpolating creates a new, computer generated version of a bad channel using the data from the channels directly above and below it. This is not actual data and is merely an approximation. The channel label will turn pink when this is done.
- Set Channel Locations
BESA is capable of automatically recognizing the electrode coordinates and their labels for certain EEG caps. Channels that have been successfully identified by BESA have 10-10 names (E.g. Fp1, C1, P3) and are called Scalp Channels. Channels that have not been successfully identified by BESA have different names (E.g. EXG1, EA7, EB28) and are called Polygraphic Channels. In order to match up polygraphic channels with their locations, additional files containing EEG cap information must be imported into BESA. Dr. Thom has several of these files stored in the computer. If none of the channels are polygraphic, you do not need to manually set channel locations. Click on “Load Channel Configuration…” under the file tab This warning will pop up. Click “Yes” All the files on the computer will pop up. Go to… Windows (C:)→Users→Public→Public Documents→BESA→Research_7_0→Montages→Channels In the channels folder, there are folders of four different companies and the type of EEG caps they use. If you don’t know the type of cap used in the experiment, try counting the number of channels and finding a file in the StandardElectrodes that has around the same number of channels. In the example above, I was able to find a file (81 electrodes) within the StandardElectordes folder that allowed BESA to recognize and locate each of the electrodes. Here is a before and after setting the channel locations. Notice how the polygraphic channels are all black, with little readable data. Also, if you need to upload files into BESA in order to add additional information about channel configuration (*.ela), digitized head surface points (*.sfp, *.eps), labels (*.sfn), etc., watch the tutorial in day 1 of the BESA workshop: 22:02 - 23:00
- Import Data
After choosing a dataset, isolate the raw EEG data from the metadata and other contextual information about the experiment. Download the raw EEG data onto your device (common data formats used to store EEG data: .bdf, .cnt, .mff, .edf). Here is a list of all the data formats BESA supports. Import the file into BESA by clicking “Open…” under the file tab, and choosing the desired file. *Note: Certain files must be manipulated in order to be imported into BESA and require third party file converters. Files exclusively containing metadata can’t be opened in BESA (usually .json, .csv, .txt, and .tsv files)
- Collect Data
There are hundreds of sites with free, downloadable EEG data that can be imported into BESA. Usually, each dataset will include an abstract, procedures, metadata, and different information about the study. Here are a few examples of the many public databases available: OpenNeuro PhysioNet Nemar EEG Dataset Github
- Other Info
BIOPAC 101 NetStation, EEGLAB, and FieldTrip often use different words to describe the same thing. When turning on the laptop, hold down option while you push the power button, and hold option down until the white screen appears. The following error means that the function is not on the computer or is not in the correct location: Undefined function ‘ft_timelockanalysis’ for input arguments of type ‘struct’. Links https://eeglab.org/tutorials/ https://eeglab.org/tutorials/ConceptsGuide/EEGLAB_functions.html https://www.fieldtriptoolbox.org/tutorial/ https://matlabacademy.mathworks.com/
- Automation Scripts
I’ve written a set of scripts that work data through our analysis pipeline. Each dataset will have its own set of scripts because every dataset will have slightly different parameters and need adjusted scripts. These are here to serve as a guide. You can look at past scripts and their comments to see what they’re doing. automation1.m - imports .raw files - selects channel location file - deletes bad channels - filters data - runs ICA - divides dataset into epochs - removes baseline - saves file SASICA - removing non-neural components with SASICA - no script for this one; see ICA automation3.m - separates each stimulus type into its own file automation4.m - converts data to FieldTrip format - loads data into FieldTrip - calculates average waveform for each event type for each person automation5.m - plots and saves headplots for the N170, EPN, and LLP for each subject for each stimulus type automation6.m - plots and saves waveforms for N170, EPN, and LLP for each subject for each stimulus type automation7.m - calculates average amplitude for a set of channels for a time window for N170, EPN, and LLP for each subject for each stimulus type
- Writing EEGLAB Scripts
A script is a set of steps (functions) that are all called at once, and can be run on a batch of files. Writing scripts will save you hours, and will do repetitive tasks for you. Also, you can run multiple slow steps (such as ICA) back-to-back overnight. For more info and another tutorial, here is the EEGLAB script writing tutorial. Steps: C R E A T E A N E W S C R I P T & A D D H E A D E R C O P Y T H E F R A M E W O R K D O T H E S T E P S W I T H T H E E E G L A B M E N U S G E T T H E H I S T O R Y S C R I P T R E P L A C E F I L E N A M E S W I T H V A R I A B L E S Create a New Script & Add a Header Create a new Script. Click New → Script OR type Command N. Add an appropriate header. Copy the Framework Copy this framework and paste it into your own script, after your header. Copy and paste everything between the yellow lines. Use this framework anytime you want to be able to select one or more files to run a process on. Example Code: clear all close all %-----------------------These are the things you need to specify--------------------------------------------------------- % PUT THE THINGS THAT WILL BE THE SAME FOR EVERY FILE HERE. FOR EXAMPLE: A SAVE FOLDER OR THE LOCATION OF THE CHANNEL LOCATIONS FILE. % EXAMPLE: % exampleFolder = ('/Users/eeglab/Desktop/Post ICA Files 2/'); % Folder where finished files will be saved. % % CLpath = '/Users/eeglab/Documents/MATLAB/GSN256.sfp'; % The full path of the file containing the channel locations % DEFINE YOUR VARIABLES HERE: =========================================================================================== %======================================================================================================================== %------------------------------------------------------------------------------------------------------------------------ %% Ask for .raw file % This function opens up a popup menu where you can click the files you % want to run your function on. If you want to select multiple files, hold % down command or shift while clicking. % Get the files from a popup menu % Use this function as [fileName, pathName] = uigetfile(filetype, title, % defaultFolder, 'MultiSelect','on') % % filetype: * followed by the extention for the filetype you want, all in single quotes. Example: '*.raw' or '*.mat' % title: the title of the popup window. You can put instructions to the user here, such as 'Select the .raw file(s).' % defaultFolder: the path to the folder the menu opens up with. You can click to other folders from there. The path % needs to be in single quotes. Example: '/Users/eeglab/Desktop/First Draft Data/After Comp Removal' [fileName, pathName] = uigetfile('*.set', 'Select the file(s)', '/Users/eeglab/Desktop/First Draft Data/After Comp Removal', ... 'MultiSelect', 'on'); length = size(fileName); if (iscellstr(fileName) == 0) iMax = 1; else iMax = length(1,2); end for i = 1:iMax if (iscellstr(fileName) == 0) dataPath = strcat(pathName, fileName); else dataPath = strcat(pathName, char(fileName(1,i))); end % Parse the file path [pathName,name,ext] = fileparts(dataPath); % pathstr = String containing the part of filename interpreted as a path name % name = String containing the name of the file without any extension % ext = String containing the file extension only, beginning with a period (.) fileNameWithExt = strcat(name,ext); % Combine file's name and extention into one string called fileNameWithExt % PUT YOUR CODE HERE: =================================================================================================== %======================================================================================================================== end This code is from framework.m. Your code goes between the sets of rows of equals signs. Do the process with EEGLAB menus (aka Graphic User Interface) If you’re using EEGLAB functions, this step is a bit easier because EEGLAB will do some of the work for you. Open (or close and reopen) eeglab. If you don’t restart eeglab, you’ll have extra functions show up in your history script. Load or import a dataset. To import a dataset, follow these instructions. To load a dataset, in the EEGLAB window click File → Load existing dataset Do the process you want your function to do using the graphic interface (menus). For more info on these functions, see the other sections of this website, or the EEGLAB tutorials website. Carefully set the parameters in the menus. Most popup menus have the name of the function in the title bar: For popup menus like the first two above (pop_eegfiltnew and pop_topoplot), the parameters you type in the boxes (inside the blue boxes) will show up correctly formatted as inputs to these functions in the history script. This’ll make more sense when we get to the history script section. Save the dataset. Click File → Save current dataset as History Script Now save the session history script. Click File → History scripts → Save session history script Add a brief description to the file name. Note that the history script is saved to the MATLAB folder. Now open the history file you just saved (from the MATLAB folder, which can be accessed in the left sidebar) Copy and paste it into the framework in your script in the “PUT YOUR CODE HERE ” section (almost at the bottom of the script). Also, add this line of code right before the code you just pasted. This code opens EEGLAB. [ALLEEG EEG CURRENTSET ALLCOM] = eeglab; Now add comments that describe what the functions are accomplishing. The functions tend to have somewhat descriptive names, for example, pop_loadset loads the dataset, and pop_epoch epochs the data. Most of the EEGLAB functions have “eeg_” or “pop_” at the beginning to designate that they are EEGLAB functions. If you’re not sure what a function is doing, look it up in the documentation by clicking here. The eeg_checkset function makes sure the dataset is ok. Leave those where they are, but you don’t need to specifically comment them. Replace filenames with Variables You now need to replace some of the filenames with variables so that you are processing the correct file and naming it correctly. For file names & paths that refer to the file you selected/loaded/opened: For file names & paths that refer to the name and place you saved the file (after the processing) Replace the path name with a variable such as saveFolder, and define this variable in the “Define your variables here” section. For the example in the video, I replace ‘/Users/eeglab/Desktop/’ with saveFolder, and then I define saveFolder as ‘/Users/eeglab/Desktop/’ in the DEFINE YOUR VARIABLES HERE section: Replace the filename with strcat(name, ‘_yourTagHere.ext’) where: ‘_yourTagHere’ is a brief description of what was done to the file. For example: ‘_ICA’ or ‘_epoched’. .ext is the extension that the file will be saved with. For example: .set or .mat For dataset names Anywhere the specific file name is, replace it with strcat(name, and the other parenthesis where appropriate. For example: ‘001_B Epoched’ → strcat(name, ‘ Epoched’).
- Filename Key
Please update the keys as you create new abbreviations. AA_017_preQR_ICA_Af.set StudyCode_SubjectNumber_Condition_AnalysisPerformed_Stimulus Type.extension Study Code Each study has its own study code consisting of two letters. Every file name will contain a study number. KEY: AA: Dr. Thom’s Dissertation Experiment 1 AB: Dr. Thom’s Dissertation Experiment 2 AC: AD: ZZ: Miscellaneous Tests Subject Number Each participant gets their own three digit number. Every file name will contain a subject number. When data is recorded, it is saved with the study number, subject number, and condition (if there is a condition). For example: 003_015.mff or 004_003_postQR.mff Condition For example, in the Dissertation Experiment 2 dataset, each participant was tested before quiet rest (preQR), after quiet rest (postQR), before exercise (preEX), and after exercise (postEX). A study may not have multiple conditions. If it doesn’t, then the file name just wouldn’t have a dime or condition indicator, for example: “001_011_ICA.set” KEY: preQR: Before Quiet Rest postQR: After Quiet Rest preEX: Before Exercise postEX: After Exercise Analysis Performed Each script you run a dataset through should add a short tag to the file name when the file is saved. This way, if a file is misplaced, you know what has been done to the file. You don’t need to add a tag for every single step, just every script. For example, if my first analysis script deletes bad channels, filters the data, and runs ICA, I’ll have it add “_ICA” when it saves each file. So after this step, the file name is “001_009_postEX_ICA.set.” My second step would be deleting bad components by hand and saving the file by hand, so I’d save it as “002_009_postEX_ICA_CR.set.” KEY: _ICA : ICA has been run _CR : Bad components have been rejected Stimulus Type When you sort the data into files by stimulus type, label the file with the stimulus type abbreviation. KEY: A: angry scenes Af: angry faces N: neutral scenes Nf: neutral faces F: fearful scenes Ff: fearful faces J: joyful scenes Jf: joyful faces ple: pleasant stimuli unp: unpleasant stimuli File Extension .mff – Net station default file type .raw – raw. (able to be opened in EEGLAB) .set – EEGLAB dataset. Corresponds to .raw file. .fdt – EEGLAB dataset. Corresponds to .set file. .mat – Matlab matrix. FieldTrip data is saved as .mat
- SPSS & Statistics
We use SPSS to calculate statistics for our data.
- Analysis
Amplitude Averaging The last step in the data analysis process is to make a matrix of the average amplitudes. For each cell, the amplitudes for a time range and a set of channels are averaged. This matrix is exported from Matlab in a .txt format that can be imported into SPSS. See an automation7 script for more info. Example from the AA Dataset: For the N170 time window, a set of channels was averaged over the 150 to 200 ms time range. N170 & EPN Channel Set: {’94’, ’95’, ’96’, ‘105’, ‘106’, ‘107’, ‘115’, ‘116’, ‘117’, ‘124’, ‘125’, ‘138’, ‘150’, ‘151’, ‘159’, ‘160’, ‘161’, ‘162’, ‘169’, ‘170’, ‘171’, ‘178’, ‘179’} LPP Channel Set: {’85’, ’86’, ’95’, ‘122’, ‘104’, ‘120’, ‘112’, ‘121’, ‘132’, ‘133’, ‘143’, ‘103 94′, ’93’, ’84’, ’83’, ’82’, ’92’, ’91’, ‘102’, ‘101’, ‘111’, ‘118’, ‘119’, ‘131’, ‘130’, ‘141’, ‘142’, ‘152’, ‘110’, ‘151’} Wavelet Analysis Read the section on wavelets in the ERP Technique book. Also, these articles are a helpful introduction to wavelets. They can be found on Mendeley in our EEG Analysis Group. Wavelet analysis of neuroelectric waveforms: a conceptual tutorial. V J Samar, a Bopardikar, R Rao, K Swartz in Brain and language (1999) FFT Phase Coherence
- Average Waveforms
Here, we plot the waveform of the averaged data using EEGLAB. For example, we may want to plot the average waveform of the scene stimuli for a specific subject. Now we switch back to EEGLAB. In this example, I’ll plot the average waveform for all the scene stimuli for subject 005. Grand Grand Averaging Grand grand averaging refers to averaging all of the data of one type (such as all scene stimuli or all face stimuli) together. The more data is averaged together, the better the waveform will be. To plot a grand grand average, you use the same process as plotting an average waveform, except you select all of the scene (or face) stimuli for all of the subjects.