EEG and epilepsy

Authors: Francois Tadel, Elizabeth Bock, John C. Mosher.

This tutorial introduces some concepts that are specific to the management of EEG recordings in the Brainstorm environment. It also describes a standard pipeline for analyzing epilepsy recordings. It is based on a clinical case from the Epilepsy Center at the University Hospital of Freiburg, Germany. The anonymized dataset can be downloaded directly from the Brainstorm download page.

Note that the operations used here are not detailed, the goal of this tutorial is not to introduce Brainstorm to new users. For in-depth explanations of the interface and theoretical foundations, please refer to the introduction tutorials.

License

This tutorial dataset (EEG and MRI data) remains proprietary of the Epilepsy Centre, University Hospital Freiburg, Germany. Its use and transfer outside the Brainstorm tutorial, e.g. for research purposes, is prohibited without written consent from the Epilepsy Centre in Freiburg. For questions please contact A. Schulze-Bonhage, MD, PhD: andreas.schulze-bonhage@uniklinik-freiburg.de

Presentation of the clinical case

This tutorial dataset was acquired in a patient who suffered from focal epilepsy with focal sensory, dyscognitive and secondarily generalized seizures since the age of eight years. He does not have any typical risk factors for epilepsy. The high resolution 3T epilepsy MRI including postprocessing was found to be normal. FDG-PET of the brain did not show any pathological changes in the glucose metabolism. Non-invasive telemetry revealed left fronto-central sharp waves, polyspikes and bursts of beta band activity (max. amplitude FC1, Cz) especially during sleep. The tutorial dataset was acquired during one night of the non-invasive telemetry recording at the Epilepsy Center Freiburg, Germany.

Afterwards the patient underwent invasive EEG to identify the epileptogenic area and to map functionally important cortex. Details about invasive EEG and source localization from invasive EEG in this patient are reported in Dümpelmann, et al. (2011). Subsequently a left frontal tailored resection was performed. The histological analysis revealed a focal cortical dysplasia type IIB according to the classification of Palmini, et al. (2004). The postsurgical outcome is Engel 1A with a follow-up of 5 years.

The EEG data distributed here was recorded at 256Hz, using a Neurofile NT digital video-EEG system with 128 channels and a 16-bit A/D converter. The signal was filtered in the recording system with a high-pass filter with a time constant of 1 second (cutoff frequency ~ 0.16Hz) and a low-pass filter with a cutoff frequency of 344 Hz. The spikes were marked with Brainstorm by the epileptologists at the Epilepsy Center in Freiburg.

Overview of the data processing

The proper identification of epileptiform discharges ("spikes") is a complicated topic beyond the scope of this tutorial. Residents in Neurology train intensively on how to identify true interictal and ictal discharges, particularly as distinct from so-called "normal variants" that can be abundant. Sleep and drowsy states of the brain can generate "vertex waves," "K-complexes," "positive occipital sharp transients of sleep" (POSTS), and "wickets," to name a few variants, none of which are epileptic. A good overview of terminology and application can be found, for example, on the Medscape website, Epileptiform Discharges.

With this caveat, we nonetheless give an overview of the processing approach. Although automation has been proposed for decades, "spike hunting" is often done by manual inspection of the recorded EEG waveforms (whether scalp, subdural, or depths). The classic scalp sensor arrangement is the International 10-20 System (Wikipedia Site, Bioelectromagnetism Book, Chapter 13.3) arranged at 10 percent and 20 percent distances about the circumference of the head. Each of these 21 electrodes is acquired with respect to some reference (as all potentials must be). In reviewing the recordings, however, several "montages" are traditionally recommended that digitally "re-reference" the original recordings into new linear combinations of electrodes.

A classic montage is the "double banana" (Google Search) which emphasizes local changes in the scalp EEG by forming sequential bipolar pairs, such as "Fp1-F3", "F3-C3." Because F3 is found twice in this montage and of opposite sign, then an epileptic spike centered under F3 will appear as a reversed polarity in these two channels, a visual cue the trained epileptologist seeks when rapidly scanning through hours of recordings. This montage is more formally known as "LB-18.3" or "Longitudinal Bipolar 3" in the nomenclature of the American Clinical Neurophysiology Society (ACNS) Guidelines (see References Below).

ACNS guidelines suggest using both "longitudinal" and "transversal" bipolar montages to survey your data. For temporal epilepsy cases, you may also add a "temporal ring" montage. European neurologists often prefer to review the recordings using an average reference montage. Brainstorm provides several variations of all these montages, allows the users full flexibility in creating their own, and can run different montages simultaneously in multiple windows.

The user has to step along through the data, look for abnormal brain activity, then use Brainstorm's event markers to tag suspect intervals. With the suspected events marked and saved, the user can return later to perform source analyses on these intervals. With this brief overview, we detail below an exercise with the sample epilepsy data.

Note that the aim of this tutorial is not to train you on how to do spike recognition itself, but rather to illustrate how to manipulate the Brainstorm interface to build an environment adapted to this task. The formal data reviewing should be done by clinical neurophysiologists or other experienced personnel, with specialized training in separating true epileptic activity from other more normal variants of brain activity.

References

Dümpelmann M, Ball T, Schulze-Bonhage A (2011)
sLORETA allows reliable distributed source reconstruction based on subdural strip and grid recordings. Human Brain Mapping.

Palmini A, Najm I, Avanzini G, Babb T, Guerrini R, Foldvary-Schaefer N, Jackson G, Luders HO, Prayson R, Spreafico R, Vinters HV (2004) Terminology and classification of the cortical dysplasias.
Neurology, 62:S2-8.

Standard montages recommended by the American Clinical Neurophysiology Society:

Download and installation

Import the anatomy

Without the individual MRI

If you do not have access to an individual MR scan of the subject (or if its quality is too low to be processed with FreeSurfer), but if you have digitized the head shape of the subject using a tracking system, you have an alternative: deform one of the Brainstorm templates (Colin27 or ICBM152) to match the shape of the subject's head.
For more information, read the following tutorial: Warping default anatomy

Access the recordings

Prepare the channel file

Register electrodes with MRI

Review EEG recordings

Display the recordings

Frequency filters

Go to the Filter tab to enable some display frequency filters. General recommendations are:

Time and amplitude resolution

The resolutions of the time and amplitude axes have a lot of importance for the visual detection of epileptic spikes. The shapes we are looking for are altered by the horizontal and vertical scaling. The distance unit on a screen is the pixel, we can set how much time is represented by one pixel horizontally and how much amplitude is represented by one pixel vertically.

In the Brainstorm interface, this resolution is usually set implicitly: you can set the size of the window, the duration or recordings reviewed at once (text box "duration" in tab Record) and the maximum amplitude to show in the figure (buttons [...] and [AS] on the right of the time series figure). From there, you can also zoom in time ([<], [>], mouse wheel) or amplitude ([^], [v], Shift+mouse wheel). These parameters are convenient to explore the recordings interactively but don't allow us to have reproducible displays with constant time and amplitude resolutions.

To set the figure resolution explicitly: right-click on the figure > Figure > Set axes resolution. Note that this interface does not store the input values, it just modifies the other parameters (figure size, time window, max amplitude) to fit the resolution objectives. If you modify these parameters (resize the figure, keep the button [AS] selected and scroll in time, etc) the resolution is lost, you have to set it again manually. In particular, make sure you disable the auto-scaling ([AS] button in the time series figure) if you want to preserve the aspect ratio while you scroll through the data.

This operation typically has to be repeated everytime you open a new file. For a faster access to this option, use the keyboard shortcut Ctrl+O. The option window offers by default the last values that you entered, just press Enter to apply them again.

Recommendations for this dataset are:

User setups

This preparation of the reviewing environment requires a large number of operations, and would become quickly annoying if you have to repeat it every time you open a file. You can use the menu "User setups" to save a window configuration and reload it in one click later. In the menu "Window layout", at the top-right of the Brainstorm window, select User setup > New setup. Enter a name of your choice for this particular window arrangement.

This operation will also disable the automatic window arrangement (Window layout > None). To reload it later, open one figure on the dataset you want to review and then select your new entry in the User setup menu.

Multiple montages

It may be interesting for some cases to display different groups of sensors in multiple windows (eg. with an MEG system with 300 sensors), or some complicated epilepsy cases where you would like to review at the same time multiple montages (eg. longitudinal and transversal bipolar montages).

Mark spikes

Detect heartbeats

When you have a clean ECG signal for your patient, you can automatically identify all the heartbeats in the recordings. Because heartbeats can cause sharp waves in some EEG traces, it helps the reviewing process to have all the cardiac events marked in the recordings.

Import the spike markers

Some spikes were marked by the epileptologists at the Epilepsy Center in Freiburg and saved in an external text file. We are going to import this file manually.

Manual marking

If you are marking the events by yourself, you could follow this procedure:

Pre-process recordings

Two of the typical pre-processing steps consist in removing the power lines artifacts (50 Hz or 60Hz) and the frequencies we are not interested in (a low-pass filter to remove the high-frequency noise and a high-pass filter to remove the very slow components of the signals). Let's start with a spectral evaluation of this file.

Power spectrum

Band-pass filter

The filters we selected for reviewing the recordings were for visualization only, they were not applied to the file. In order to apply these filters permanently to the recordings, we need to do the following:

Average reference

The average reference montage we used to review the recordings was for visualization only, it did not modify the file. To apply this transformation permanently, we need to run the re-referencing process.

Evaluate the modifications

Artifact cleaning with ICA

The standard cleaning pipeline presented in the introduction tutorials recommends to use the SSP approach to remove the cardiac and blink artifacts. This is valid in most MEG experiments.

In EEG, there is usually not such a clear artifact caused by the heartbeats: cleaning for cardiac artifacts is not part of the standard processing pipeline. Eye movements typically cause huge artifacts on the frontal channels and need to be marked as bad or corrected. In the present case, the patient is sleeping, therefore there are no blinks, but we can observe a lot of fast eye movements during the periods of REM sleep, and other slower eye movements in the rest of the recordings.

The SSP technique is not adapted for cleaning events for which we cannot set markers, and in general it is not suitable for low-density EEG. The topographies are a lot smoother in EEG than in MEG, it is more difficult to identify a spatial filter that targets one specific artifact with a simple spatial PCA decomposition, especially with a very low number of sensors.

The ICA approach (Independent Component Analysis) is much more popular in the EEG community. It relies on the the same logic as the SSP: identifying spatial topographies that are specific from an artifact and then removing them from the recordings. But instead of simply identifying the most powerful spatial components with a PCA decomposition, it tries to identify components that are independent in time. Using the information from the time dimension makes it possible to work with a very low number of sensors, and to identify some components of the signal that are completely uncorrelated with the others.

The ICA analysis can also be used to identify the signals from a few brain sources of interest: in this case, we select a few components and remove all the others. For more information on ICA, please refer to the documentation of the EEGLAB software.

Import the recordings

Epoching

Now we want to extract all the spikes from this filtered file and import them in the database.

You can overlay one or more electrodes from multiple files with the tab "Cluster":

Alternatively, you can display all the trials as an image, for one sensor at a time:

Averaging spikes

Source analysis: Surface

Head model

Noise covariance matrix

Inverse model

Regions of interest

Source analysis: Volume

If the results you obtain are not satisfying with the surface-based source estimation, you can run again the same analysis with a different source space, sampling the entire head volume instead. More information about this method in the Volume source estimation tutorial. We will use this new example to estimate the dipole scanning tools.

Head model

Dipole scanning

Dipole fitting

The dipole scanning approach presented in the previous section estimates the activity of a fixed grid of dipoles and selects the most significant one at each time. Another option to represent the source activity as a sequence of moving dipoles is to use the FieldTrip function ft_dipolefitting.m to run a non-linear dipole fit at each time point. This process requires that you install the FieldTrip toolbox on your computer.

Source analysis: MEM inverse solution

The maximum of entropy on the mean (MEM) framework solution gathers several source localization techniques dedicated to estimate accurately the spatial extent of the EEG/MEG generators, a very important property in the context of localizing the generators of epileptic discharges, for which it is known that a relatively extended brain region should be involved (several cm2) in order to detect these discharges from the scalp. You can read more information on MEM in the Brain entropy in space and time (BEst) in the BEst tutorial.

Here are the steps to perform MEM localization on epileptic spikes.

Time-frequency

We will illustrate two ways of computing time-frequency maps. Exploring the continuous recordings in time-frequency space can help with the detection of the epileptic activity, while computing the average of the time-frequency power of a few epochs can help understanding the dynamic of the event.

Continuous recordings

Spike average

Additional documentation

Forum posts

Inverse models in epilepsy

MEM in clinical epilepsy

Related methodological developments:

Ability of MEM to recover the spatial extent of epileptic spikes:

Multimodal concordance on clinical cases:

Background readings: Epilepsy and EEG/MEG

Scripting

The following script from the Brainstorm distribution reproduces the analysis presented in this tutorial page: brainstorm3/toolbox/script/tutorial_epilepsy.m

1 function tutorial_epilepsy(tutorial_dir) 2 % TUTORIAL_EPILEPSY: Script that reproduces the results of the online tutorial "EEG/Epilepsy". 3 % 4 % CORRESPONDING ONLINE TUTORIALS: 5 % http://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy 6 % 7 % INPUTS: 8 % tutorial_dir: Directory where the sample_epilepsy.zip file has been unzipped 9 10 % @============================================================================= 11 % This function is part of the Brainstorm software: 12 % http://neuroimage.usc.edu/brainstorm 13 % 14 % Copyright (c)2000-2017 University of Southern California & McGill University 15 % This software is distributed under the terms of the GNU General Public License 16 % as published by the Free Software Foundation. Further details on the GPLv3 17 % license can be found at http://www.gnu.org/copyleft/gpl.html. 18 % 19 % FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE 20 % UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY 21 % WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF 22 % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY 23 % LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE. 24 % 25 % For more information type "brainstorm license" at command prompt. 26 % =============================================================================@ 27 % 28 % Author: Francois Tadel, 2014-2016 29 30 31 % ===== FILES TO IMPORT ===== 32 % You have to specify the folder in which the tutorial dataset is unzipped 33 if (nargin == 0) || isempty(tutorial_dir) || ~file_exist(tutorial_dir) 34 error('The first argument must be the full path to the tutorial dataset folder.'); 35 end 36 % Build the path of the files to import 37 AnatDir = fullfile(tutorial_dir, 'sample_epilepsy', 'anatomy'); 38 RawFile = fullfile(tutorial_dir, 'sample_epilepsy', 'data', 'tutorial_eeg.bin'); 39 ElcFile = fullfile(tutorial_dir, 'sample_epilepsy', 'data', 'tutorial_electrodes.elc'); 40 SpikeFile = fullfile(tutorial_dir, 'sample_epilepsy', 'data', 'tutorial_spikes.txt'); 41 % Check if the folder contains the required files 42 if ~file_exist(RawFile) 43 error(['The folder ' tutorial_dir ' does not contain the folder from the file sample_epilepsy.zip.']); 44 end 45 % Subject name 46 SubjectName = 'sepi01'; 47 48 49 % ===== CREATE PROTOCOL ===== 50 % The protocol name has to be a valid folder name (no spaces, no weird characters...) 51 ProtocolName = 'TutorialEpilepsy'; 52 % Start brainstorm without the GUI 53 if ~brainstorm('status') 54 brainstorm nogui 55 end 56 % Delete existing protocol 57 gui_brainstorm('DeleteProtocol', ProtocolName); 58 % Create new protocol 59 gui_brainstorm('CreateProtocol', ProtocolName, 0, 1); 60 % Start a new report 61 bst_report('Start'); 62 63 64 % ===== IMPORT ANATOMY ===== 65 % Process: Import anatomy folder 66 bst_process('CallProcess', 'process_import_anatomy', [], [], ... 67 'subjectname', SubjectName, ... 68 'mrifile', {AnatDir, 'FreeSurfer'}, ... 69 'nvertices', 15000, ... 70 'nas', [134, 222, 74], ... 71 'lpa', [ 58, 123, 69], ... 72 'rpa', [204, 120, 75]); 73 74 75 % ===== ACCESS THE RECORDINGS ===== 76 % Process: Create link to raw file 77 sFilesRaw = bst_process('CallProcess', 'process_import_data_raw', [], [], ... 78 'subjectname', SubjectName, ... 79 'datafile', {RawFile, 'EEG-DELTAMED'}, ... 80 'channelreplace', 1, ... 81 'channelalign', 0); 82 83 % Process: Add EEG positions 84 bst_process('CallProcess', 'process_channel_addloc', sFilesRaw, [], ... 85 'channelfile', {ElcFile, 'XENSOR'}, ... 86 'usedefault', 1); 87 % Process: Refine registration 88 bst_process('CallProcess', 'process_headpoints_refine', sFilesRaw, []); 89 % Process: Project electrodes on scalp 90 bst_process('CallProcess', 'process_channel_project', sFilesRaw, []); 91 92 % Process: Snapshot: Sensors/MRI registration 93 bst_process('CallProcess', 'process_snapshot', sFilesRaw, [], ... 94 'target', 1, ... % Sensors/MRI registration 95 'modality', 4, ... % EEG 96 'orient', 1, ... % left 97 'comment', 'MEG/MRI Registration'); 98 99 100 % ===== EVENTS: SPIKES AND HEARTBEATS ===== 101 % Process: Detect heartbeats 102 bst_process('CallProcess', 'process_evt_detect_ecg', sFilesRaw, [], ... 103 'channelname', 'ECG', ... 104 'timewindow', [], ... 105 'eventname', 'cardiac'); 106 % Process: Events: Import from file 107 bst_process('CallProcess', 'process_evt_import', sFilesRaw, [], ... 108 'evtfile', {SpikeFile, 'ARRAY-TIMES'}, ... 109 'evtname', 'SPIKE'); 110 111 112 % ===== PRE-PROCESSING ===== 113 % Process: Power spectrum density (Welch) 114 sFilesPsd = bst_process('CallProcess', 'process_psd', sFilesRaw, [], ... 115 'timewindow', [], ... 116 'win_length', 10, ... 117 'win_overlap', 50, ... 118 'sensortypes', 'EEG', ... 119 'edit', struct(... 120 'Comment', 'Power', ... 121 'TimeBands', [], ... 122 'Freqs', [], ... 123 'ClusterFuncTime', 'none', ... 124 'Measure', 'power', ... 125 'Output', 'all', ... 126 'SaveKernel', 0)); 127 % Process: Snapshot: Frequency spectrum 128 bst_process('CallProcess', 'process_snapshot', sFilesPsd, [], ... 129 'target', 10, ... % Frequency spectrum 130 'comment', 'Power spectrum density'); 131 132 % Process: Band-pass:0.5-80Hz 133 sFilesRaw = bst_process('CallProcess', 'process_bandpass', sFilesRaw, [], ... 134 'sensortypes', 'EEG', ... 135 'highpass', 0.5, ... 136 'lowpass', 80, ... 137 'attenuation', 'strict', ... % 60dB 138 'mirror', 0); 139 140 % Process: Re-reference EEG 141 bst_process('CallProcess', 'process_eegref', sFilesRaw, [], ... 142 'eegref', 'AVERAGE', ... 143 'sensortypes', 'EEG'); 144 145 % Process: Power spectrum density (Welch) 146 sFilesPsdClean = bst_process('CallProcess', 'process_psd', sFilesRaw, [], ... 147 'timewindow', [], ... 148 'win_length', 10, ... 149 'win_overlap', 50, ... 150 'sensortypes', 'EEG', ... 151 'edit', struct(... 152 'Comment', 'Power', ... 153 'TimeBands', [], ... 154 'Freqs', [], ... 155 'ClusterFuncTime', 'none', ... 156 'Measure', 'power', ... 157 'Output', 'all', ... 158 'SaveKernel', 0)); 159 % Process: Snapshot: Frequency spectrum 160 bst_process('CallProcess', 'process_snapshot', sFilesPsdClean, [], ... 161 'target', 10, ... % Frequency spectrum 162 'comment', 'Power spectrum density'); 163 164 165 % ===== ICA ===== 166 % Process: ICA components: Infomax 167 bst_process('CallProcess', 'process_ica', sFilesRaw, [], ... 168 'timewindow', [500, 700], ... 169 'eventname', '', ... 170 'eventtime', [-0.1992, 0.1992], ... 171 'bandpass', [0, 0], ... 172 'nicacomp', 24, ... 173 'sensortypes', 'EEG', ... 174 'usessp', 1, ... 175 'ignorebad', 1, ... 176 'saveerp', 0, ... 177 'method', 1, ... % Infomax: EEGLAB / RunICA 178 'select', [1 2]); % Force the selection: components #1 and #2 179 180 181 % ===== IMPORT RECORDINGS ===== 182 % Process: Import MEG/EEG: Events 183 sFilesEpochs = bst_process('CallProcess', 'process_import_data_event', sFilesRaw, [], ... 184 'subjectname', SubjectName, ... 185 'condition', '', ... 186 'eventname', 'SPIKE', ... 187 'timewindow', [], ... 188 'epochtime', [-0.3, 0.5], ... 189 'createcond', 1, ... 190 'ignoreshort', 1, ... 191 'usectfcomp', 1, ... 192 'usessp', 1, ... 193 'freq', [], ... 194 'baseline', []); 195 196 % Process: Average: By condition (subject average) 197 sFilesAvg = bst_process('CallProcess', 'process_average', sFilesEpochs, [], ... 198 'avgtype', 3, ... 199 'avg_func', 1, ... % Arithmetic average: mean(x) 200 'weighted', 0, ... 201 'keepevents', 0); 202 203 % Configure the display so that the negative values points up 204 bst_set('FlipYAxis', 1); 205 % Process: Snapshot: Recordings time series 206 bst_process('CallProcess', 'process_snapshot', sFilesAvg, [], ... 207 'target', 5, ... % Recordings time series 208 'modality', 4, ... % EEG 209 'comment', 'Average spike'); 210 % Process: Snapshot: Recordings topography (contact sheet) 211 bst_process('CallProcess', 'process_snapshot', sFilesAvg, [], ... 212 'target', 7, ... % Recordings topography (contact sheet) 213 'modality', 4, ... % EEG 214 'contact_time', [-0.040, 0.110], ... 215 'contact_nimage', 16, ... 216 'comment', 'Average spike'); 217 218 219 % ===== SOURCE ANALYSIS: SURFACE ===== 220 % Process: Generate BEM surfaces 221 bst_process('CallProcess', 'process_generate_bem', [], [], ... 222 'subjectname', SubjectName, ... 223 'nscalp', 642, ... 224 'nouter', 482, ... 225 'ninner', 482, ... 226 'thickness', 4); 227 % Process: Compute head model 228 bst_process('CallProcess', 'process_headmodel', sFilesAvg, [], ... 229 'sourcespace', 1, ... % Cortex surface 230 'eeg', 3, ... % OpenMEEG BEM 231 'openmeeg', struct(... 232 'BemSelect', [0, 0, 1], ... 233 'BemCond', [1, 0.0125, 1], ... 234 'BemNames', {{'Scalp', 'Skull', 'Brain'}}, ... 235 'BemFiles', {{}}, ... 236 'isAdjoint', 0, ... 237 'isAdaptative', 1, ... 238 'isSplit', 0, ... 239 'SplitLength', 4000)); 240 241 % Process: Compute noise covariance 242 bst_process('CallProcess', 'process_noisecov', sFilesRaw, [], ... 243 'baseline', [110, 160], ... 244 'sensortypes', 'EEG', ... 245 'target', 1, ... % Noise covariance (covariance over baseline time window) 246 'dcoffset', 1, ... % Block by block, to avoid effects of slow shifts in data 247 'identity', 0, ... 248 'copycond', 0, ... 249 'copysubj', 0, ... 250 'replacefile', 1); % Replace 251 252 % Process: Compute sources [2016] 253 sAvgSrc = bst_process('CallProcess', 'process_inverse_2016', sFilesAvg, [], ... 254 'output', 1, ... % Kernel only: shared 255 'inverse', struct(... 256 'Comment', 'sLORETA: EEG', ... 257 'InverseMethod', 'minnorm', ... 258 'InverseMeasure', 'sloreta', ... 259 'SourceOrient', {{'free'}}, ... 260 'Loose', 0.2, ... 261 'UseDepth', 0, ... 262 'WeightExp', 0.5, ... 263 'WeightLimit', 10, ... 264 'NoiseMethod', 'reg', ... 265 'NoiseReg', 0.1, ... 266 'SnrMethod', 'fixed', ... 267 'SnrRms', 1e-06, ... 268 'SnrFixed', 3, ... 269 'ComputeKernel', 1, ... 270 'DataTypes', {{'EEG'}})); 271 % Process: Snapshot: Sources (one time) 272 bst_process('CallProcess', 'process_snapshot', sAvgSrc, [], ... 273 'target', 8, ... % Sources (one time) 274 'modality', 1, ... % MEG (All) 275 'orient', 3, ... % top 276 'time', 0, ... 277 'threshold', 60, ... 278 'comment', 'Average spike'); 279 280 281 % ===== SOURCE ANALYSIS: VOLUME ===== 282 % Process: Compute head model 283 bst_process('CallProcess', 'process_headmodel', sFilesAvg, [], ... 284 'sourcespace', 2, ... % MRI volume 285 'volumegrid', struct(... 286 'Method', 'adaptive', ... 287 'nLayers', 17, ... 288 'Reduction', 3, ... 289 'nVerticesInit', 4000, ... 290 'Resolution', 0.005, ... 291 'FileName', []), ... 292 'eeg', 2); % 3-shell sphere 293 294 % Process: Compute sources [2016] 295 sAvgSrcVol = bst_process('CallProcess', 'process_inverse_2016', sFilesAvg, [], ... 296 'output', 1, ... % Kernel only: shared 297 'inverse', struct(... 298 'Comment', 'Dipoles: EEG', ... 299 'InverseMethod', 'gls', ... 300 'InverseMeasure', 'performance', ... 301 'SourceOrient', {{'free'}}, ... 302 'Loose', 0.2, ... 303 'UseDepth', 1, ... 304 'WeightExp', 0.5, ... 305 'WeightLimit', 10, ... 306 'NoiseMethod', 'reg', ... 307 'NoiseReg', 0.1, ... 308 'SnrMethod', 'rms', ... 309 'SnrRms', 1e-06, ... 310 'SnrFixed', 3, ... 311 'ComputeKernel', 1, ... 312 'DataTypes', {{'EEG'}})); 313 % Process: Snapshot: Sources (one time) 314 bst_process('CallProcess', 'process_snapshot', sAvgSrcVol, [], ... 315 'target', 8, ... % Sources (one time) 316 'modality', 1, ... % MEG (All) 317 'orient', 3, ... % top 318 'time', 0, ... 319 'threshold', 0, ... 320 'comment', 'Dipole modeling'); 321 322 % Process: Dipole scanning 323 sDipScan = bst_process('CallProcess', 'process_dipole_scanning', sAvgSrcVol, [], ... 324 'timewindow', [-0.040, 0.100], ... 325 'scouts', {}); 326 % Process: Snapshot: Dipoles 327 bst_process('CallProcess', 'process_snapshot', sDipScan, [], ... 328 'target', 13, ... % Dipoles 329 'orient', 3, ... % top 330 'threshold', 90, ... 331 'Comment', 'Dipole scanning'); 332 % Process: Snapshot: Dipoles 333 bst_process('CallProcess', 'process_snapshot', sDipScan, [], ... 334 'target', 13, ... % Dipoles 335 'orient', 1, ... % left 336 'threshold', 90, ... 337 'Comment', 'Dipole scanning'); 338 339 % Process: FieldTrip: ft_dipolefitting 340 sDipFit = bst_process('CallProcess', 'process_ft_dipolefitting', sFilesAvg, [], ... 341 'timewindow', [-0.040, 0.100], ... 342 'sensortypes', 'EEG', ... 343 'dipolemodel', 1, ... % Moving dipole 344 'numdipoles', 1, ... 345 'volumegrid', [], ... 346 'symmetry', 0, ... 347 'filetag', ''); 348 % Process: Snapshot: Dipoles 349 bst_process('CallProcess', 'process_snapshot', sDipFit, [], ... 350 'target', 13, ... % Dipoles 351 'orient', 3, ... % top 352 'threshold', 95, ... 353 'Comment', 'Dipole fitting'); 354 % Process: Snapshot: Dipoles 355 bst_process('CallProcess', 'process_snapshot', sDipFit, [], ... 356 'target', 13, ... % Dipoles 357 'orient', 1, ... % left 358 'threshold', 95, ... 359 'Comment', 'Dipole fitting'); 360 361 362 % ===== TIME-FREQUENCY ===== 363 % Process: Import MEG/EEG: Time 364 sRawImport = bst_process('CallProcess', 'process_import_data_time', sFilesRaw, [], ... 365 'subjectname', SubjectName, ... 366 'condition', '', ... 367 'timewindow', [1890, 1900], ... 368 'split', 0, ... 369 'ignoreshort', 1, ... 370 'usectfcomp', 1, ... 371 'usessp', 1); 372 % Process: Time-frequency (Morlet wavelets) 373 sRawTf = bst_process('CallProcess', 'process_timefreq', sRawImport, [], ... 374 'sensortypes', 'EEG', ... 375 'edit', struct(... 376 'Comment', 'Power,2-80Hz', ... 377 'TimeBands', [], ... 378 'Freqs', [2, 2.5, 3.1, 3.7, 4.3, 5, 5.7, 6.4, 7.2, 8.1, 9, 9.9, 10.9, 12, 13.1, 14.3, 15.6, 17, 18.4, 19.9, 21.6, 23.3, 25.1, 27, 29.1, 31.3, 33.6, 36, 38.6, 41.4, 44.3, 47.4, 50.7, 54.1, 57.8, 61.8, 65.9, 70.3, 75, 80], ... 379 'MorletFc', 1, ... 380 'MorletFwhmTc', 3, ... 381 'ClusterFuncTime', 'none', ... 382 'Measure', 'power', ... 383 'Output', 'all', ... 384 'SaveKernel', 0), ... 385 'normalize', 'multiply'); % 1/f compensation: Multiply output values by frequency 386 % Process: Snapshot: Time-frequency maps 387 bst_process('CallProcess', 'process_snapshot', sRawTf, [], ... 388 'target', 14, ... % Time-frequency maps 389 'rowname', 'FC1'); 390 391 % Process: Time-frequency (Morlet wavelets) 392 sAvgTf = bst_process('CallProcess', 'process_timefreq', sFilesEpochs, [], ... 393 'sensortypes', 'EEG', ... 394 'edit', struct(... 395 'Comment', 'Avg,Power,2-80Hz', ... 396 'TimeBands', [], ... 397 'Freqs', [2, 2.5, 3.1, 3.7, 4.3, 5, 5.7, 6.4, 7.2, 8.1, 9, 9.9, 10.9, 12, 13.1, 14.3, 15.6, 17, 18.4, 19.9, 21.6, 23.3, 25.1, 27, 29.1, 31.3, 33.6, 36, 38.6, 41.4, 44.3, 47.4, 50.7, 54.1, 57.8, 61.8, 65.9, 70.3, 75, 80], ... 398 'MorletFc', 1, ... 399 'MorletFwhmTc', 3, ... 400 'ClusterFuncTime', 'none', ... 401 'Measure', 'power', ... 402 'Output', 'average', ... 403 'RemoveEvoked', 0, ... 404 'SaveKernel', 0), ... 405 'normalize', 'none'); % None: Save non-standardized time-frequency maps 406 % Process: Event-related perturbation (ERS/ERD): [-199ms,-102ms] 407 sAvgTfNorm = bst_process('CallProcess', 'process_baseline_norm', sAvgTf, [], ... 408 'baseline', [-0.200, -0.100], ... 409 'method', 'ersd', ... % Event-related perturbation (ERS/ERD): x_std = (x - μ) / μ * 100 410 'overwrite', 0); 411 % Process: Snapshot: Time-frequency maps 412 bst_process('CallProcess', 'process_snapshot', sAvgTfNorm, [], ... 413 'target', 14, ... % Time-frequency maps 414 'rowname', 'FC1'); 415 416 417 418 % Save and display report 419 ReportFile = bst_report('Save', []); 420 bst_report('Open', ReportFile); 421





Feedback: Comments, bug reports, suggestions, questions
Email address (if you expect an answer):


Tutorials/Epilepsy (last edited 2017-11-14 10:03:14 by FrancoisTadel)