Brainstorm
  • Comments
  • Menu
    • Attachments
    • Versions
    • Raw Text
    • Print View
  • Login

Software

  • Introduction

  • Gallery

  • Download

  • Installation

Users

  • Tutorials

  • Forum

  • Courses

  • Community

  • Publications

Development

  • What's new

  • What's next

  • About us

  • Contact us

  • Contribute

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Differences between revisions 188 and 229 (spanning 41 versions)
⇤ ← Revision 188 as of 2014-04-11 21:00:01 →
Size: 42125
Editor: agrippa
Comment:
← Revision 229 as of 2016-07-12 20:53:18 → ⇥
Size: 41679
Editor: FrancoisTadel
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
== 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 Center 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 1024Hz, 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 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.
<<Include(DatasetEpilepsy, , from="\<\<HTML\(\<!-- START-PAGE --\>\)\>\>", to="\<\<HTML\(\<!-- STOP-SHORT --\>\)\>\>")>>
Line 29: Line 21:
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 a 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. 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.
Line 44: Line 36:
 * Go to the [[http://neuroimage.usc.edu/brainstorm3_register/download.php|Download]] page of this website, and download the file: '''sample_epilepsy.zip'''  * Go to the [[http://neuroimage.usc.edu/bst/download.php|Download]] page of this website, and download the file: '''sample_epilepsy.zip'''
Line 47: Line 39:
 * Select the menu File > Create new protocol. Name it "'''!TutorialEpilepsy'''" and select the options:  * Select the menu File > Create new protocol. Name it "'''TutorialEpilepsy'''" and select the options:
Line 52: Line 44:
 * Right-click on the !TutorialEpilepsy folder > New subject > '''sepi01'''  * Switch to the "anatomy" view of the protocol.
* Right-click on the TutorialEpilepsy folder > '''New subject''' > '''sepi01'''
Line 54: Line 47:
 * Right-click on the subject node > Import anatomy folder:
  * Set the file format: "!FreeSurfer folder"
 * Right-click on the subject node > '''Import anatomy folder''':
  * Set the file format: "FreeSurfer folder"
Line 58: Line 51:
 * Set the 6 required fiducial points (indicated in MRI coordinates):
  * NAS: x=135, y=222, z=75
  * LPA: x=57, y=118, z=68
  * RPA: x=204, y=119, z=76
  * AC: x=131, y=145, z=110
  * PC: x=130, y=119, z=111
  * IH: x=128, y=134, z=170 (anywhere on the midsagittal plane)
 *
At the end of the process, make sure that the file "cortex_15000V" is selected (downsampled pial surface, that will be used for the source estimation). If it is not, double-click on it to select it as the default cortex surface.<<BR>><<BR>> {{attachment:anatomy.gif||height="257",width="442"}}
 * In the MRI Viewer, click on "[[http://neuroimage.usc.edu/brainstorm/Tutorials/ImportAnatomy#MNI_transformation|Click here to compute MNI transformation]]". It compute an affine transformation between the subject space and the MNI ICBM152 space, and sets automatically the anatomical landmarks AC/PC/IH. <<BR>><<BR>> {{attachment:mni_transformation.gif||height="57",width="575"}}
 *
Set the three fiducial points (indicated here in MRI coordinates):
  * NAS: x=134, y=222, z=74
  * LPA: x=58, y=123, z=69
  * RPA: x=204, y=120, z=75
 * Click on [Save] to validate the modifications and continue with the importation of the anatomy. At the end of the process, make sure that the file "cortex_15000V" is selected (downsampled pial surface, that will be used for the source estimation). If it is not, double-click on it to select it as the default cortex surface.<<BR>><<BR>> {{attachment:anatomy.gif||height="257",width="442"}}
Line 68: Line 59:
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.<<BR>>For more information, read the following tutorial: [[Tutorials/TutWarping|Warping default anatomy]] 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.<<BR>>For more information, read the following tutorial: [[Tutorials/TutWarping|Warping default anatomy]]
Line 72: Line 63:
 * Switch to the "functional data" view.
 * Right-click on the subject folder > Review raw file:
 * Switch to the "functional data" view (2nd button, on top of the database explorer).
 * Right-click on the subject folder > '''Review raw file''':
Line 76: Line 67:
  * The new file "Link to raw file" lets you access directly the contents of the EEG recordings
  * The channel file "Deltamed channels" in the (Common files) folder contains the name of the channels, but not their positions. We need to overwrite this file and import manually the positions of the electrodes (either a standard cap or accurate positions digitized with a Polhemus device).
 * The new file "Link to raw file" lets you access directly the contents of the EEG recordings
 * The channel file "Deltamed channels" in the (Common files) folder contains the name of the channels, but not their positions. We need to overwrite this file and import manually the positions of the electrodes (either a standard cap or accurate positions digitized with a Polhemus device). <<BR>><<BR>> {{attachment:channel_positions.gif||height="205",width="357"}}
Line 80: Line 71:
 * Right-click on the subject folder > Import channel file:  * Right-click the channel file in ''Common files'' > '''Add EEG positions''' > '''Import from file''':
Line 83: Line 74:
  * Confirm that you want to overwrite the existing channel file.
  * This file contains the default electrodes positions from the ASA software (ANT)
  * This file contains the default electrodes positions from the ASA software (ANT).
  * If you have digitized the position of the electrodes (eg. with a Polhemus device) you have to make sure it contains the position of the anatomical references NAS/LPA/RPA. This is the best way to make sure the electrode cap will be registered automatically with the MRI in Brainstorm.
  * The channels are matched by name: the position file you import must include the labels of the electrodes and they must be named exactly in the the same way as in your recordings.
Line 92: Line 84:
  * DELR, DELL, QR, QL: Additional

 * The file format for the electrodes positions does not describe the type of the channels correctly, therefore all the signals saved in the files are classified as EEG. We need to redefine this manually to get correct groups of sensors, we want to have only real EEG electrodes in the "EEG" category and put everything that we are not going to use a "MISC" category.
 * Right-click on the channel file > Edit channel file:
  * Note that the EOG, EMG and ECG channels already have a different type
  * Select all the other non-EEG channel
s: SP1, SP2, RS, PHO, DELR, DELL, QR, QL
  * Right-click in the window > Set channel type: type '''MISC'''
  * Close the figure and accept to save the modifications
 {{attachment:channel_type.gif}}
  * DELR, DELL, QR, QL: Not used

 * It happens commonly that the file format for the electrodes positions does not describe the type of the channels correctly, typically all the signals saved in the files are classified as EEG. We need to redefine this manually to get correct groups of sensors, we want to have only real EEG electrodes in the "EEG" category and put everything that we are not going to use a different category.
 * Right-click on the channel file > '''Edit channel file''':
  * Note that the EOG, EMG and ECG channels have their type correctly set.
  * All the other non-EEG channels were set to
"EEG_NO_LOC" when we imported the channel locations: SP1, SP2, RS, PHO, DELR, DELL, QR, QL
  * In many cases you would have to edit manually the type of some channels: select one channel, click on the type and select something in the drop-down list, or select multiple channels > Right-click in the window > Set channel type.
  * For this particular study, we can use the channel file as it is configured now, just close the figure. Discard any modification you may have done.
 {{attachment:channel_type.gif||height="219",width="383"}}
Line 105: Line 97:
 * Right-click on the channel file > MRI registration > Edit... You will see several buttons across the toolbar; to get the function of a button, hover your mouse for a few seconds over it to reveal the tooltip.

 * You can click on the "Label" button in the toolbar to show the electrode names. The default positions are already quite good, and the head shape is correct; only limited manual registration will be required in the next few steps.
 * Right-click on the channel file > '''MRI registration''' > '''Edit...''' You will see several buttons across the toolbar; to get the function of a button, hover your mouse for a few seconds over it to reveal the tooltip.

 * Click on the [Label] button in the toolbar to show the names''' '''of the electrodes. The default positions are already quite good, and the head shape is correct; only limited manual registration will be required in the next few steps.
Line 119: Line 111:
 * Right-click on the "Link to raw file" > EEG > Display time series.
 * In the tab Record, menu File > Add events from files...
  * Select file format "Array of times" (We are importinga a text file containing the timing of the markers)
 * Right-click on the "Link to raw file" > EEG > '''Display time series''' (or simply double-click on the file).
 * In the tab Record, menu File > '''Add events from files'''...
  * Select format '''Array of times''' (importing a a text file containing the timing of the markers)
Line 124: Line 116:
 * Note that a new category SPIKE is visible in the events list, containing 58 markers
 * Close the viewer and agree to save the modifications

==== Display the recordings in one montage ====
 * For basic information on how to manipulate the montages in Brainstorm: [[http://%20neuroimage.usc.edu/brainstorm/Tutorials/TutExploreRecodings#Montages|read this tutorial]].
 * Note that a new category SPIKE is visible in the events list, containing 58 markers. <<BR>><<BR>> {{attachment:events_import.gif}}
 * Close the viewer and agree to save the modifications.

==== Display the recordings ====
Line 132: Line 123:
  * Select the "Average reference" in the drop-down list. This menu allows you to set a predefined montages to linearly re-arranging the waveforms. Note the keyboard shortcuts in the menus.
  * In the Record tab, change the default duration that is reviewed to '''10s'''.
  * In the figure, click on the '''[Flip +/-]''' button to have the negative values pointing up (convention used by most neurologists)
  * Select the "Average reference" in the drop-down list. This menu allows you to set a predefined montages to linearly re-arranging the waveforms. Note the keyboard shortcuts in the menus. <<BR>><<BR>> {{attachment:review_avgref.gif||height="129",width="188"}}
  * In the Record tab, change the default duration that is reviewed to '''10s'''. {{attachment:review_duration.gif||height="66",width="198"}}
  * In the figure, click on the '''[Flip +/-]''' button to have the negative values pointing up (convention used by most neurologists). <<BR>><<BR>> {{attachment:review_flip.gif||height="166",width="360"}}
Line 136: Line 127:
  * Right-click on "Link to raw file" again > EEG > '''2D Sensor cap '''   * Right-click on "Link to raw file" again > EEG > '''2D Sensor cap'''
Line 138: Line 129:
 * Open the '''ECG '''and '''EOG '''traces as well, to avoid confusing spikes with cardiac or ocular artifacts:<<BR>>  * Open the '''ECG '''and '''EOG '''traces as well, to avoid confusing spikes with cardiac or ocular artifacts:
Line 144: Line 135:
 * Review a few existing SPIKE events, to get the feeling of how this reviewing environment works.

{{attachment:reviewall.gif}}
 * Review a few existing SPIKE events, to get the feeling of how this reviewing environment works.<<BR>><<BR>> {{attachment:reviewall.gif||height="322",width="594"}}
Line 152: Line 141:
 * Low-pass filter: '''70 Hz'''<<BR>><<BR>> {{attachment:filters.gif||height="175",width="205"}}  * Low-pass filter: '''80 Hz'''<<BR>><<BR>> {{attachment:filters.gif||height="165",width="196"}}
Line 157: Line 146:
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). Those 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. Then if you modify those parameters (resize the figure, leave the button [AS] selected and scroll in time, etc) the resolution is lost, you have to set it again manually.
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, leave 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.
Line 167: Line 156:
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. This is a good time to use the menu "User setups" to save this window configuration, to 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 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. This is a good time to use the menu "User setups" to save this window configuration, so that you can 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.
Line 183: Line 172:
 * If you don't see the "Longitudinal 3" menu, it is probably because you have using Brainstorm before those predefined montages were made available in the software distribution. To add them manually:  * If you don't see the "Longitudinal 3" menu, it is probably because you have using Brainstorm before these predefined montages were made available in the software distribution. To add them manually:
Line 191: Line 180:
{{attachment:reviewall2.gif}}  {{attachment:reviewall2.gif||height="372",width="678"}}
Line 202: Line 191:
 * Scroll through the recordings using the [<<<] and [>>>] buttons or shortcuts such as F3 or F4 (complete list and descriptions available when you leave your mouse over those buttons).
 * You can adjust the gain of the electrodes to observe better an event with the buttons ['''^'''] and [v] or the shortcut [Shift+mouse wheel].
 * Scroll through the recordings using the [<<<] and [>>>] buttons or shortcuts such as F3 or F4 (complete list and descriptions available when you leave your mouse over these buttons).
 * You can adjust the gain of the electrodes to observe better an event with the buttons ['''^'''] and [v], with the keyboard (+/-) or the mouse ([Shift+mouse wheel] or [Right-click+move up/down]).
Line 208: Line 197:
 * More information on the data viewer, see tutorial: [[Tutorials/TutRawViewer|Review continuous recordings]].  * More information on the data viewer, see tutorial: [[Tutorials/ReviewRaw|Review continuous recordings]].
Line 211: Line 200:
==== Average reference ====
Line 216: Line 206:
 * The sharp drop we observe at 50Hz on all the electrodes indicates that a notch filter was already applied to the data, we do not need to remove the power line contamination again. If we had to, we would run the process "Pre-processing > Sinusoid removal (notch)" as explained in the tutorial [[Tutorials/TutRawSsp|Detect and remove artifacts]].

==== High-pass filter ====
We would like to apply a 0.5Hz high-pass filter to the entire file in order to get rid of the long amplitude fluctuations (longer than 2s). With some MEG file formats, Brainstorm supports the creation of new filtered files in native formats, which means that you can drag and grop directly the "Link to raw file" to the Process1 tab and run the band-pass filter process. Unfortunately, this is currently not supported for the file format we are currently working on (Deltamed Coherence-Neurofile).

There is an alternative option which consists in importing the entire continuous file in the database in one single block, then run the filter on it. This approach works is possible only on rather small files (4 * file size < memory on the computer). Here the file size is less than 80 Mb, so it can be easily processed this way.

 * Right-click on the "Link to raw file" > Import in database.
 * Uncheck all the options and leave the default "Time window" option. <<BR>><<BR>> {{attachment:import_all.gif||height="295",width="490"}}
 * Click on Import, it creates an integral copy of the file in the database. Do NOT try to review it: for imported file, the partial loading and the scrolling in time are disabled and it would take a lot of time to display the waveforms for the entire file. It could event result in a crash of Brainstorm or Matlab.
 * Drag this new file "Raw (0s,3600s)" to the Process1
 * This frequency spectrum does not show any particular peak at 50/60Hz, there is no notch filter to apply on these recordings. If we had to, we would run the process "Pre-processing > Notch filter" as explained in the tutorial [[Tutorials/ArtifactsFilter|Detect and remove artifacts]].

==== Band-pass filter ====
We would like to apply a band-pass filter to keep only the frequencies between 0.5Hz an 80Hz. The high-pass filter at 0.5Hz will rid of the slow amplitude fluctuations (longer than 2s).

 * Leave the "Link to raw file" selected in the Process1 list.
Line 228: Line 213:
  * Lower cutoff frequency: '''0.5Hz''' (high-pass filter at 0.5Hz)
  * Upper cutoff frequency: '''0Hz''' (no low-pass filter)
  * Lower cutoff frequency: '''0.5 Hz''' (high-pass filter)
  * Upper cutoff frequency: '''80 Hz''' (low-pass filter)
Line 231: Line 216:
  * Sensor types: '''EMPTY '''(to process all the signals)
  * Overwrite: '''On''' (we don't need to keep the original copy)<<BR>><<BR>> {{attachment:bandpass.gif||height="284",width="494"}}
  * Sensor types: '''EMPTY '''(to process all the signals)<<BR>><<BR>> {{attachment:bandpass.gif||height="281",width="295"}}

 * Note that this new continuous files is saved in your Brainstorm database, while your original file is saved in a separate folder (sample_epilepsy). If you delete the link to the original file with the database explorer, it would not delete the actual file. If you delete the link to the filtered file, it would delete the file itself.

 * Drag this new file "Raw | band(0.5-80Hz)" to the Process1 list.
 * Run again the process "Frequency > Power spectrum density (Welch)", with same options as before.
 * Double-click on the new PSD file to display the spectrum of the filtered file.<<BR>><<BR>> {{attachment:psd3.gif||height="190",width="489"}}
Line 237: Line 227:
 * Right-click on the imported and filtered file '''"Raw (0s,3600s) | high(0.5Hz)"''' > Import in database<<BR>><<BR>> {{attachment:import_menu.gif||height="177",width="242"}}  * Right-click on the imported and filtered file '''"Raw (0s,3600s) | high(0.5Hz)"''' > Import in database<<BR>><<BR>> {{attachment:import_menu.gif||height="150",width="226"}}
Line 241: Line 231:
 * You should see a new folder "SPIKE" containing 58 epochs in your database.<<BR>><<BR>> {{attachment:import_after.gif||height="242",width="219"}}  * You should see a new folder "SPIKE" containing 58 epochs in your database.<<BR>><<BR>> {{attachment:import_after.gif||height="166",width="228"}}
Line 245: Line 235:
 * Run the process "Average > Average files", with the following options:<<BR>><<BR>> {{attachment:average1.gif||height="473",width="456"}}  * Run the process "Average > Average files", with the following options:<<BR>><<BR>> {{attachment:average1.gif||height="405",width="408"}}
Line 247: Line 237:
 * Go to the Filter tab to __'''disable all the visualization filters'''__: those filters are not working well on short signals, the high-pass filter at 0.5Hz can introduce errors in the display of the average.
 * Open a "2D sensor cap" view on the same file, or simply press [Ctrl+T] from the time series figure.<<BR>><<BR>> {{attachment:average_view.gif||height="238",width="438"}}
 * To have all the figures re-arrange themselves automatically again, select "Weighted" or "Tiled" in the "Window layout" menu (top-right corner).
 * Go to the Filter tab to __'''disable all the visualization filters'''__: these filters are not working well on short signals, the high-pass filter at 0.5Hz can introduce errors in the display of the average.
 * Open a "2D sensor cap" view on the same file, or simply press [Ctrl+T] from the time series figure.<<BR>><<BR>> {{attachment:average_view.gif||height="205",width="409"}}
 * To have all the figures automatically re-arrange themselves again, select "Weighted" or "Tiled" in the "Window layout" menu (top-right corner).
Line 259: Line 249:
 * Use '''1922 vertices '''for each layer (default). Three new surface files are created at the end of the process.<<BR>><<BR>> {{attachment:bem1.gif||height="273",width="196"}} {{attachment:bem2.gif||height="240",width="184"}} {{attachment:bem3.gif||height="272",width="157"}}  * Use '''1922 vertices '''for each layer (default). Three new surface files are created at the end:<<BR>><<BR>> {{attachment:bem1.gif||height="273",width="196"}} {{attachment:bem2.gif||height="240",width="184"}} {{attachment:bem3.gif||height="272",width="157"}}
Line 262: Line 252:
 * If you can't download OpenMEEG automatically, download and install it manually (menu Help)  * If the automatic download doesn't work, download and install OpenMEEG manually (menu Help)
Line 265: Line 255:
 * If you cannot get OpenMEEG to work, or if the results definitely do not make sense, try using a different forward model: "'''3-shell sphere'''". It's a spherical model, so it would perform better in the regions of the head that are close to the sphere. See the [[Tutorials/TutHeadModel|Head model tutorial]].  * If you cannot get OpenMEEG to work, or if the results definitely do not make sense, try using a different forward model: "'''3-shell sphere'''". It's a spherical model, so it would perform better in the regions of the head that are close to the sphere. See the [[Tutorials/HeadModel|Head model tutorial]].
Line 268: Line 258:
 * For minimum norm inverse models, we need to estimate first the level of noise at the level of the sensors. Defining what can be considered as "noise" in the middle of continuous brain recordings is a difficult question, discussed in the [[Tutorials/TutNoiseCov|Noise covariance tutorial]].  * For minimum norm inverse models, we need to estimate first the level of noise at the level of the sensors. Defining what can be considered as "noise" in the middle of continuous brain recordings is a difficult question, discussed in the [[Tutorials/NoiseCovariance|Noise covariance tutorial]].
Line 277: Line 267:
 * This operation creates a shared inversion kernel in the folder (Common files) and one source link for each block of recordings in subject sepi01. If you are not familiar with those concepts, please refer to the [[Tutorials/TutSourceEstimation|Source estimation tutorial]]. <<BR>><<BR>> {{attachment:inverse2.gif||height="201",width="210"}}
 * Double-click on the sources file for the average to open it. Configure its display: surface smoothing, amplitude threshold, colormap. For a reminder on how to manipulate the colormaps, see the tutorial [[http://neuroimage.usc.edu/brainstorm/Tutorials/TutExploreRecodings#Colormap_configuration|Explore recordings]].
 * This operation creates a shared inversion kernel in the folder (Common files) and one source link for each block of recordings in subject sepi01. If you are not familiar with these concepts, please refer to the [[Tutorials/SourceEstimation|Source estimation tutorial]]. <<BR>><<BR>> {{attachment:inverse2.gif||height="201",width="210"}}
 * Double-click on the sources file for the average to open it. Configure its display: surface smoothing, amplitude threshold, colormap. For a reminder on how to manipulate the colormaps, see the tutorial [[Tutorials/Colormaps|Colormaps]].
Line 285: Line 275:
 * The inverse solutions that you calculated are all shared for all the recordings in this subject, so you can go back to your individual epochs, or even the continuous file, and look at the source maps for those files.  * The inverse solutions that you calculated are all shared for all the recordings in this subject, so you can go back to your individual epochs, or even the continuous file, and look at the source maps for these files.
Line 291: Line 281:
 * Plot the overlayed time series for those scouts. Try with the scout functions MEAN and MAX.  * Plot the overlayed time series for these scouts. Try with the scout functions MEAN and MAX.
Line 293: Line 283:
 * If you need a reminder on how to manipulate scouts: see the [[Tutorials/TutScouts|Scouts tutorial]]<<BR>><<BR>> {{attachment:scouts1.gif||height="189",width="478"}}  * If you need a reminder on how to manipulate scouts: see the [[Tutorials/Scouts|Scouts tutorial]]<<BR>><<BR>> {{attachment:scouts1.gif||height="189",width="478"}}
Line 327: Line 317:
Coming soon... This section is on a different page: [[Tutorials/EpilepsyBest|Link]]
Line 337: Line 327:
Benar CG, Grova C, Kobayashi E, Bagshaw AP, Aghakhani Y, Dubeau F, Gotman J (2006)<<BR>>[[http://www.ncbi.nlm.nih.gov/pubmed/16413798|EEG–fMRI of epileptic spikes: Concordance with EEG source localization and intracranial EEG]]<<BR>>!NeuroImage, 30:1161-1170. Benar CG, Grova C, Kobayashi E, Bagshaw AP, Aghakhani Y, Dubeau F, Gotman J (2006)<<BR>>[[http://www.ncbi.nlm.nih.gov/pubmed/16413798|EEG–fMRI of epileptic spikes: Concordance with EEG source localization and intracranial EEG]]<<BR>>NeuroImage, 30:1161-1170.

==== Forum posts ====
 * EEG reference: http://neuroimage.usc.edu/forums/showthread.php?1525#post6718
Line 344: Line 337:
  * Folder to import: '''sample_epilepsy/anatomy''' (format = !FreeSurfer)   * Folder to import: '''sample_epilepsy/anatomy''' (format = FreeSurfer)
Line 346: Line 339:
  * Because of the selection of those points, it usally to run this first step in interactive mode...MISC   * Because of the selection of these points, it is usally better to run this first step in interactive mode.
Line 358: Line 351:
 * Import recordings > Events: Import from file  * Events > Import from file
Line 413: Line 406:
==== Graphic edition ====
{{attachment:script.gif}}

==== Generate Matlab script ====
This list of processes can be converted automatically to a Matlab script.<<BR>>See the results on the page: [[Tutorials/EpilepsyScript|EEG and epilepsy: Script]].

== Feedback ==
<<EmbedContent(http://neuroimage.usc.edu/brainstorm3_register/get_feedback.php?Tutorials/Epilepsy)>>
The following script from the Brainstorm distribution reproduces the analysis presented in this tutorial page: '''brainstorm3/toolbox/script/tutorial_epilepsy''''''.m'''

<<HTML(<div style="border:1px solid black; background-color:#EEEEFF; width:720px; height:500px; overflow:scroll; padding:10px; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif; font-size: 13px; white-space: pre;">)>><<EmbedContent("http://neuroimage.usc.edu/bst/viewcode.php?f=tutorial_epilepsy.m")>><<HTML(</div >)>>

<<EmbedContent(http://neuroimage.usc.edu/bst/get_feedback.php?Tutorials/Epilepsy)>>

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.

Contents

  1. Dataset description
  2. Overview of the data processing
  3. Download and installation
  4. Import the anatomy
  5. Access the recordings
  6. Review EEG recordings
  7. Mark spikes
  8. Pre-process recordings
  9. Epoching and averaging
  10. Source analysis: Cortically constrained
  11. Source analysis: Full head volume
  12. Moving dipoles
  13. MEM inverse solution
  14. Discussion
  15. Scripting

Dataset description

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

Clinical description

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:

  • American Clinical Neurophysiology Society Guidelines

  • Guidelines for Standard Electrode Position Nomenclature #5

  • A Proposal for Standard Montages to Be Used in Clinical EEG #6

Download and installation

  • Requirements: You have already followed all the introduction tutorials and you have a working copy of Brainstorm installed on your computer.

  • Go to the Download page of this website, and download the file: sample_epilepsy.zip

  • Unzip it in a folder that is not in any of the Brainstorm folders (program folder or database folder)

  • Start Brainstorm (Matlab scripts or stand-alone version)
  • Select the menu File > Create new protocol. Name it "TutorialEpilepsy" and select the options:

    • "No, use individual anatomy",

    • "Yes, use one channel file per subject".

Import the anatomy

  • Switch to the "anatomy" view of the protocol.
  • Right-click on the TutorialEpilepsy folder > New subject > sepi01

    • Leave the default options you set for the protocol
  • Right-click on the subject node > Import anatomy folder:

    • Set the file format: "FreeSurfer folder"

    • Select the folder: sample_epilepsy/anatomy

    • Number of vertices of the cortex surface: 15000 (default value)
  • In the MRI Viewer, click on "Click here to compute MNI transformation". It compute an affine transformation between the subject space and the MNI ICBM152 space, and sets automatically the anatomical landmarks AC/PC/IH.

    mni_transformation.gif

  • Set the three fiducial points (indicated here in MRI coordinates):
    • NAS: x=134, y=222, z=74
    • LPA: x=58, y=123, z=69
    • RPA: x=204, y=120, z=75
  • Click on [Save] to validate the modifications and continue with the importation of the anatomy. At the end of the process, make sure that the file "cortex_15000V" is selected (downsampled pial surface, that will be used for the source estimation). If it is not, double-click on it to select it as the default cortex surface.

    anatomy.gif

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

Link the recordings

  • Switch to the "functional data" view (2nd button, on top of the database explorer).
  • Right-click on the subject folder > Review raw file:

    • Select the file format: "EEG: Deltamed Coherence-Neurofile(*.bin)"
    • Select the file: sample_epilepsy/data/tutorial_eeg.bin

  • The new file "Link to raw file" lets you access directly the contents of the EEG recordings
  • The channel file "Deltamed channels" in the (Common files) folder contains the name of the channels, but not their positions. We need to overwrite this file and import manually the positions of the electrodes (either a standard cap or accurate positions digitized with a Polhemus device).

    channel_positions.gif

Prepare the channel file

  • Right-click the channel file in Common files > Add EEG positions > Import from file:

    • Select the file format: "EEG: ANT Xensor (*.elc)"
    • Select the file: sample_epilepsy/data/tutorial_electrodes.elc

    • This file contains the default electrodes positions from the ASA software (ANT).
    • If you have digitized the position of the electrodes (eg. with a Polhemus device) you have to make sure it contains the position of the anatomical references NAS/LPA/RPA. This is the best way to make sure the electrode cap will be registered automatically with the MRI in Brainstorm.
    • The channels are matched by name: the position file you import must include the labels of the electrodes and they must be named exactly in the the same way as in your recordings.
  • The recordings contain signals coming from different types of electrodes:
    • 29 EEG electrodes
    • EOG1, EOG2: Electrooculograms
    • EMG, ECG: Electromyogram and electrocardiogram
    • SP1, SP2: Sphenoidal electrodes
    • RS: Electrode on the right shoulder
    • PHO: Photo stimulation channel
    • DELR, DELL, QR, QL: Not used
  • It happens commonly that the file format for the electrodes positions does not describe the type of the channels correctly, typically all the signals saved in the files are classified as EEG. We need to redefine this manually to get correct groups of sensors, we want to have only real EEG electrodes in the "EEG" category and put everything that we are not going to use a different category.
  • Right-click on the channel file > Edit channel file:

    • Note that the EOG, EMG and ECG channels have their type correctly set.
    • All the other non-EEG channels were set to "EEG_NO_LOC" when we imported the channel locations: SP1, SP2, RS, PHO, DELR, DELL, QR, QL
    • In many cases you would have to edit manually the type of some channels: select one channel, click on the type and select something in the drop-down list, or select multiple channels > Right-click in the window > Set channel type.

    • For this particular study, we can use the channel file as it is configured now, just close the figure. Discard any modification you may have done.

    channel_type.gif

Register electrodes with MRI

  • The channel file we imported contains generic electrodes positions; hence, it cannot be fully aligned with the head surface coming from the MRI. We need to register manually these electrodes positions with the subject anatomy.
  • Right-click on the channel file > MRI registration > Edit... You will see several buttons across the toolbar; to get the function of a button, hover your mouse for a few seconds over it to reveal the tooltip.

  • Click on the [Label] button in the toolbar to show the names of the electrodes. The default positions are already quite good, and the head shape is correct; only limited manual registration will be required in the next few steps.

  • Click on the button "Refine registration using head points" to find a better registration between the head shape defined by the electrodes and the head surface coming from the MRI.
  • Click on the button "Project electrodes on scalp surface", to ensure all the electrodes touch the skin surface.
  • Click on "OK" and agree to save the modifications.

    channel_type.gif

Review EEG recordings

Import the spike markers

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

  • Right-click on the "Link to raw file" > EEG > Display time series (or simply double-click on the file).

  • In the tab Record, menu File > Add events from files...

    • Select format Array of times (importing a a text file containing the timing of the markers)

    • Select file sample_epilepsy/data/tutorial_spikes.txt

    • When prompted, enter the event name "SPIKE"

  • Note that a new category SPIKE is visible in the events list, containing 58 markers.

    events_import.gif

  • Close the viewer and agree to save the modifications.

Display the recordings

  • Open a time series figure with the "Average reference" montage

    • Right-click on the "Link to raw file" > EEG > Display time series.

    • In the Record tab, select the first button in the toolbar (Display mode for time series) to view the signals in columns.
    • Select the "Average reference" in the drop-down list. This menu allows you to set a predefined montages to linearly re-arranging the waveforms. Note the keyboard shortcuts in the menus.

      review_avgref.gif

    • In the Record tab, change the default duration that is reviewed to 10s. review_duration.gif

    • In the figure, click on the [Flip +/-] button to have the negative values pointing up (convention used by most neurologists).

      review_flip.gif

  • Open a 2D Sensor cap map of the EEG sensor values as well:

    • Right-click on "Link to raw file" again > EEG > 2D Sensor cap

    • In the Record tab, set the Montage to this view to "Average reference"

  • Open the ECG and EOG traces as well, to avoid confusing spikes with cardiac or ocular artifacts:

    • Right-click on the Link to raw file > ECG > Display time series

    • Right-click on the Link to raw file > EOG > Display time series

    • The ECG is almost mandatory. The EOG is optional: it can be helpful for beginners but an experienced reviewer will easily recognize the eye movements directly in the EEG data.
  • Re-arrange the figures in a convenient way, for example as illustrated below, and disable the automatic positioning of the figures you the figure arrangement doesn't get lost when you open a new figure (Window layout menu at the top-right of the Brainstorm figure > None)

  • Having a lot of windows open may slow down significantly the display because each time you change the current time, all the figures have to be updated. A lot of space is also wasted on the screen due to window frames. The number of windows to open has to be a balance between the amount of information to display and the ease of use.
  • Review a few existing SPIKE events, to get the feeling of how this reviewing environment works.

    reviewall.gif

Frequency filters

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

  • High-pass filter: 0.5 Hz

  • Low-pass filter: 80 Hz

    filters.gif

Time and amplitude resolution

The resolutions of the time and amplitude axes has 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, leave 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.

Recommendations for this dataset are:

  • Time axis: 170 pixels/sec (~55 mm/sec)

  • Amplitude: 15 μV/pixels (~45 μV/mm)

    resolution.gif

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. This is a good time to use the menu "User setups" to save this window configuration, so that you can 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.

  • usersetup.gif

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). Brainstorm offers a flexible way of doing this.

  • Open your full reviewing environment as described before, where the EEG signals are displayed with the "Average reference" montage.

  • Open another view on the same data with the "Longitudinal 3" montage ("double-banana" LB-18.3)

    • Right-click on the "Link to raw file" again > EEG > Display time series

    • Alternatively, you can right-click on the existing figure > Figure > Clone figure.

    • Then set the montage for this new figure to "Longitudinal 3"
    • Redimension all the figures to make room for the new window
    • Save this as a new "User setup"
  • If you don't see the "Longitudinal 3" menu, it is probably because you have using Brainstorm before these predefined montages were made available in the software distribution. To add them manually:
    • In the Record tab, select "Edit montages" in the drop-down menu
    • Click on the "Load montage" button
    • Go to the folder "brainstorm3/toolbox/sensors/private/", and select the first file
    • Note that a new entry (probably "Longitudinal 1") is added to the list of available montages
    • Repeat the operation with all the files in the folder "brainstorm3/toolbox/sensors/private/"
    • Click on "Save" to close the montage editor and now select "Longitudinal 3"

    reviewall2.gif

Mark spikes

In this dataset, some single spikes have already been identified by experts at the University Hospital of Freiburg. You can see that 58 SPIKE events are available in the Record tab. Click on a few of them and try to identify the shape of the spike.

The procedure if you are marking the events by yourself is the following:

  • Close all the current figures ("Close all" button at the top-right corner of the Brainstorm window)
  • Double-click on the "Link to raw file" to open a continuous file viewer, and load your reviewing environment (menu User setups)
  • Start by creating a group of events (Events > Add group), and select it in the list of events.

  • Make sure that the time and amplitude resolutions are what you are used to
    (right-click on the figure > Figure > Set axes resolution)

  • Scroll through the recordings using the [<<<] and [>>>] buttons or shortcuts such as F3 or F4 (complete list and descriptions available when you leave your mouse over these buttons).

  • You can adjust the gain of the electrodes to observe better an event with the buttons [^] and [v], with the keyboard (+/-) or the mouse ([Shift+mouse wheel] or [Right-click+move up/down]).

  • When you identify a spike, click in a white area of the figure in order to place the time cursor at the peak of the spike. If you click on the signal itself, it selects the corresponding channel, but you can use the shortcut Shift+Click to prevent this behavior and force the time cursor to be moved instead.
  • Press Ctrl+E to add a marker where the time cursor is.
  • If you are marking multiple types of events, it is convenient to set up some additional keyboard shortcuts. Using the menu Events > Edit keyboard shortcuts, you can associate custom events to the key 1 to 9 of the keyboard. Define the name of the event type to create for each key, and then simply press the corresponding key to add/delete a marker at the current time position.

  • To jump to the next/previous event in the current category: use the keyboard shortcuts [Shift+arrow right] and [Shift+arrow left]
  • More information on the data viewer, see tutorial: Review continuous recordings.

Pre-process recordings

Average reference

Evaluation

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

  • Drag the "Link to raw file" to the Process1 box and run the process "Frequency > Power spectrum density (Welch)". Configure it as illustrated in the following figure (window length=10s, overlap=50%).

    psd1.gif

  • Double-click on the new PSD file to display it.

    psd2.gif

  • This frequency spectrum does not show any particular peak at 50/60Hz, there is no notch filter to apply on these recordings. If we had to, we would run the process "Pre-processing > Notch filter" as explained in the tutorial Detect and remove artifacts.

Band-pass filter

We would like to apply a band-pass filter to keep only the frequencies between 0.5Hz an 80Hz. The high-pass filter at 0.5Hz will rid of the slow amplitude fluctuations (longer than 2s).

  • Leave the "Link to raw file" selected in the Process1 list.
  • Run the process "Pre-process > Band-pass filter", with the options:

    • Lower cutoff frequency: 0.5 Hz (high-pass filter)

    • Upper cutoff frequency: 80 Hz (low-pass filter)

    • Mirror signal before filtering: On

    • Sensor types: EMPTY (to process all the signals)

      bandpass.gif

  • Note that this new continuous files is saved in your Brainstorm database, while your original file is saved in a separate folder (sample_epilepsy). If you delete the link to the original file with the database explorer, it would not delete the actual file. If you delete the link to the filtered file, it would delete the file itself.
  • Drag this new file "Raw | band(0.5-80Hz)" to the Process1 list.
  • Run again the process "Frequency > Power spectrum density (Welch)", with same options as before.

  • Double-click on the new PSD file to display the spectrum of the filtered file.

    psd3.gif

Epoching and averaging

Import recordings

  • Now we want to extract all the spikes as 400ms windows from this filtered file.
  • Right-click on the imported and filtered file "Raw (0s,3600s) | high(0.5Hz)" > Import in database

    import_menu.gif

  • Select the option "Use events" and select the category SPIKE, with 58 events.

  • Epoch time: [-100, +300]ms around the spike events

  • Uncheck "Remove DC offset": the DC offset has already been removed with the high-pass filter

    import.gif

  • You should see a new folder "SPIKE" containing 58 epochs in your database.

    import_after.gif

Average spikes

  • Drag and drop all the SPIKE files or the SPIKE folder into the Process1 tab
  • Run the process "Average > Average files", with the following options:

    average1.gif

  • Double click on the new file "Avg: SPIKE" to review it, and set the "Average reference" montage.
  • Go to the Filter tab to disable all the visualization filters: these filters are not working well on short signals, the high-pass filter at 0.5Hz can introduce errors in the display of the average.

  • Open a "2D sensor cap" view on the same file, or simply press [Ctrl+T] from the time series figure.

    average_view.gif

  • To have all the figures automatically re-arrange themselves again, select "Weighted" or "Tiled" in the "Window layout" menu (top-right corner).
  • Explore this average in time with the left and right keyboard arrow.
  • Typically, the analysis could be limited to the ascending part of the peak (from -11ms to 0ms), as it gives a rather clear information on the primary epilepsy focus. For the rest of the tutorial, we will use a larger time window (-40ms to 100ms) in order to illustrate the visualization tools. Just keep in mind that it can be hazardous to interpret waves that are far in time or in space from the primary focus.

  • To get a synthetic view at the sensor level of the evolution of the 2D map in time:
    • Rright-click on the figure > Snapshot > "Time contact sheet: Figure"

    • Set the time window [-40ms, 110ms], with 16 images

      average2.gif

Source analysis: Cortically constrained

Head model

  • We are going to use a realistic head model, this requires to calculate some additional surfaces for the subject, to represent the inner skull and outer skull surface. Go to the "Anatomy" view, right-click on the subject > Generate BEM surfaces.

  • Use 1922 vertices for each layer (default). Three new surface files are created at the end:

    bem1.gif bem2.gif bem3.gif

  • Go back to the "Functional data" view, right-click on the channel file (or any folder containing the channel file) > Compute head model

    headmodel1.gif

  • Select the "cortex surface option" and the "OpenMEEG BEM" forward model. Leave all the OpenMEEG options to their defaults except for one: select the option "Use adjoint formulation".

    [ATTACH] [ATTACH]

  • If the automatic download doesn't work, download and install OpenMEEG manually (menu Help)
  • If the OpenMEEG calculation crashes, please refer to the OpenMEEG tutorial.

  • If you can compute the model but then later the source maps you get don't make any sense, it is probably because the BEM surfaces were poorly defined. When some cortex vertices are too close to the inner skull surface, the model can be unstable and after the source estimation you would typically see source maps containing zeros everywhere except for a few vertices. If this happens, delete the existing BEM surfaces and try computing new ones with a higher number of vertices for the inner and outer skull BEM surfaces.
  • If you cannot get OpenMEEG to work, or if the results definitely do not make sense, try using a different forward model: "3-shell sphere". It's a spherical model, so it would perform better in the regions of the head that are close to the sphere. See the Head model tutorial.

Noise covariance matrix

  • For minimum norm inverse models, we need to estimate first the level of noise at the level of the sensors. Defining what can be considered as "noise" in the middle of continuous brain recordings is a difficult question, discussed in the Noise covariance tutorial.

  • Here we chose what is described as option 1b in the section "Noise and epilepsy" in that tutorial: we are going to calculate the noise covariance matrix using 10 seconds from the continuous file that are very "quiet", ie. that contain no apparent epileptic activity, no REM and no other special artifacts. We can use for this purpose the 10s segment between 120s and 130s.
  • The file you use for the calculation of the noise covariance matrix must be pre-processed in the same way as the files for which you want to estimate the sources (the SPIKE epochs), so we need to use the imported+filtered continuous file.
  • Right-click on the "Raw (0s,3600s) | high(0.5Hz)" > Noise covariance > Compute from recordings

    noisecov1.gif

  • Select the time window [120s - 130s] and leave the other options to the default values

    [ATTACH]

Inverse model

  • Right-click on the head model > Compute sources.

  • Leave all the default options to calculate a wMNE solution with constrained dipole orientation

    inverse1.gif

  • This operation creates a shared inversion kernel in the folder (Common files) and one source link for each block of recordings in subject sepi01. If you are not familiar with these concepts, please refer to the Source estimation tutorial.

    inverse2.gif

  • Double-click on the sources file for the average to open it. Configure its display: surface smoothing, amplitude threshold, colormap. For a reminder on how to manipulate the colormaps, see the tutorial Colormaps.

  • Make sure that all the visualization filters are turned OFF.
  • Double-click on the recordings as well to get a visual reference of the time. In the Record tab, you can click on the "Display mode" button in the toolbar to switch back to the "butterfly" view.

    [ATTACH]

  • To display the same information re-interpolated in the volume, right-click on the source file > Cortical activation > Display on MRI

    inverse4.gif

  • You can save movies or contact sheets of the source maps with the Snapshot popup menu

    snapshot_menu.gif

  • Example: Video made with three figures: Download

    spike_video.gif

  • Example: Contact sheet

    [ATTACH]

  • The inverse solutions that you calculated are all shared for all the recordings in this subject, so you can go back to your individual epochs, or even the continuous file, and look at the source maps for these files.

Regions of interest

  • The scouts are a very interesting feature for studying the spike spatial propagation. From the displays we generated previously, there is no clear propagation of the spike. Let's try to explore this in more details, at least to illustrate the method.
  • Start by placing a small scout at the focus (~7 vertices)
  • Place a few other scouts of a similar size at other places around the spike location, in places at which you could suspect a possible propagation.
  • Plot the overlayed time series for these scouts. Try with the scout functions MEAN and MAX.
  • There is no delay in the peaks for the different regions at -20ms, 0ms and 35ms This temporal exploration seems to confirm that there is no clear spatial propagation of the spike.
  • If you need a reminder on how to manipulate scouts: see the Scouts tutorial

    scouts1.gif

Z-score normalization

A good way to reveal better the source activity at the cortex level is to calculate a Z-score of the source maps with respect with a quiet baseline. We can use the same baseline as for the calculation of the noise covariance matrix.

  • Import the block a recordings to use as the baseline. Right-click on the imported and processed file "Raw (0s,3600s) | high(0.5Hz)" > Import in database. Uncheck all the options and select the time window: [120, 130] secondes.

    [ATTACH]

  • Click on the Process2 tab
  • In Files A: Drag the sources for the segment you just imported "Raw (120.00s,130.00s)"
  • In Files B: Drag the sources for the averaged spike
  • Alternatively, select the recordings and manually select the "Process sources" button on both sides

    [ATTACH]

  • Run the process: Standardize > Z-score (static). Double-click on the new file to display it

    [ATTACH] [ATTACH]

  • The amplitude in the figure is now displayed without units, it represents a multiple of the standard deviation over the baseline. The interpretation of this new figure is not very different from the previous one, but it helps observing the things with a different angle. This process usually provides smoother maps, with less bias due to the depth of the sources. On the non-standardized minimum norm maps, the values of the deeper sources are usually lower than the ones at the surface. The Z-score helps showing deeper sources that have minimum norm values that are low, but higher than during the baseline.

Source analysis: Full head 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 of being constrained to the surface. More information about this method in the Volume source estimation tutorial.

Head model

  • Right-click on the channel file > Compute head model, select "MRI volume" instead of "Cortex surface". This feature is now stable, but still tagged as experimental because not all the Brainstorm features are available for volume-based source models (eg. no regions of interest, no group analysis, etc). Use the same options as before for OpenMEEG.

    headmodel_vol2.gif [ATTACH]

Inverse model

  • Right-click on the head model > Compute sources. Use all the default options.

    inverse_vol2.gif

  • Right-click on the unconstrained sources > Cortical activation > Display on MRI (3D).

    • To move the slices in the 3D view: right-click + move your mouse in the slice direction.
    • Use all the sliders in the Surface tab to configure the display.

      [ATTACH]

  • Right-click on the same file > Cortical activation > Display on MRI (MRI Viewer)

    • To smooth the display across slices: right-click on the figure > Smooth sources > "3"

    • For a glass brain view: select the option "MIP: Functional" in the MRI Viewer

      [ATTACH]

Moving dipoles

See tutorial: Computing and displaying dipoles

Note: you can also load dipoles calculated with other programs.

MEM inverse solution

This section is on a different page: ?Link

Discussion

Distributed source models vs. ECD (equivalent current dipole)

Kobayashi K, Yoshinaga H, Ohtsuka Y, Gotman J (2005)
Dipole modeling of epileptic spikes can be accurate or misleading
Epilepsia, 2005 Mar;46(3):397-408.

Distributed source models vs. BOLD

Heers M, Hedrich T, An D, Dubeau F, Gotman J, Grova C, Kobayashi E (2014)
Spatial correlation of hemodynamic changes related to interictal epileptic discharges with electric and magnetic source imaging. Human Brain Mapping, published online 24 Feb 2014.

ECD vs. BOLD

Benar CG, Grova C, Kobayashi E, Bagshaw AP, Aghakhani Y, Dubeau F, Gotman J (2006)
EEG–fMRI of epileptic spikes: Concordance with EEG source localization and intracranial EEG
NeuroImage, 30:1161-1170.

Forum posts

  • EEG reference: http://neuroimage.usc.edu/forums/showthread.php?1525#post6718

Scripting

To reproduce this entire analysis with a script, use the following processes:

  • Import recordings > Import anatomy folder

    • Subject name: sepi01

    • Folder to import: sample_epilepsy/anatomy (format = FreeSurfer)

    • Enter the fiducials positions indicated at the beginning of the tutorial
    • Because of the selection of these points, it is usally better to run this first step in interactive mode.
  • Import anatomy > Generate BEM surfaces

    • Set all the values to 1922 and the skull thickness to 4mm
  • Import recordings > Create link to raw file

    • File to import: sample_epilepsy/data/tutorial_eeg.bin (format = Deltamed Coherence-Neurofile)

    • Uncheck the option "Align sensors using headpoints"
  • Import recordings > Set channel file

    • File to import: sample_epilepsy/data/tutorial_electrodes.elc (format = EEG:ANT Xensor)

    • Check the option "Align sensors using headpoints"
  • Import recordings > Project electrodes on scalp

  • Import recordings > Set channels type

    • Channel types or names: SP1, SP2, RS, PHO, DELR, DELL, QR, QL

  • Events > Import from file

    • Event file: sample_epilepsy/data/tutorial_spikes.txt: (format = Array of times)

    • Event name: SPIKE

  • Import recordings > Import MEG/EEG: Time

    • Condition name: Empty
    • Time window: default (entire file)
    • Split recordings in time blocks: 0s
  • Pre-process > Band-pass filter:

    • Lower cutoff frequency: 0.5 Hz

    • Upper cutoff frequency: 0
    • Sensor types: Empty
    • Check: Overwrite input file

  • Sources > Compute noise covariance

    • Baseline: [120s - 130s]

    • Remove DC offset: Block by block
    • Ouptut: Full noise covariance matrix
  • Import recordings > Import MEG/EEG: Events

    • Condition name: Empty
    • Event names: SPIKE

    • Time window: default (entire file)
    • Epoch time: [-101.6s, 300.8s]

    • Check all the additional options
  • Average > Average files

    • By condition (subject average)
    • Arithmetic average
    • Uncheck: Keep all the events
  • File > Save snapshot

    • Snapshot: Sensors/MRI registration
    • Sensor type: EEG
    • Orientation: Left
    • Comment: "Average spike"
  • File > Save snapshot

    • Snapshot: Recordings time series
    • Sensor type: EEG
  • File > Save snapshot

    • Snapshot: Recordings topography (contact sheet)
    • Sensor type: EEG
    • Contact sheet (start time, stop time): "-40 110"
    • Contact sheet (number of images): 16
  • Sources > Compute head model

    • EEG Method: OpenMEEG BEM
    • Edit OpenMEEG options
      • BEM Layers: Select all (scalp, skull, brain)
      • Check: Use adjoint formulation
      • Check: Use adaptive integration
  • Sources > Compute sources

    • wMNE
    • Sensor types: EEG
    • Kernel onle: Shared
  • File > Save snapshot

    • Snapshot: Sources (one time)
    • Orientation: top
    • Time: 0s

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





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


  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01