UNDER CONSTRUCTION

ECoG/sEEG tutorial

Authors: Francois Tadel, Marcel Heers.

This tutorial introduces some concepts that are specific to the management of ECoG/sEEG recordings in the Brainstorm environment. It is based on a clinical case from the Epilepsy Center at the University Hospital of Freiburg, Germany.

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.

NOT FOR CLINICAL USE:
The performance characteristics of the methods and software implentation presented in this tutorial have not been certified as medical devices and should be used for research purposes only.

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

Acknowledgements

We would like to thank the patient for providing his dataset for this tutorial, the clinical team of the Epilepsy Center Freiburg for the aquisition of the dataset and Verena Schulte for her help in preparing the dataset for the tutorial.

Clinical description

The patient is a 38yr male who suffered from drug resistant focal epilepsy since his 13th year of age with two different types of focal aware seizures that rarely evolved at nighttime to bilateral tonic-clonic seizures. Seizure type I consisted of daily aware focal seizures with myoclonic or clonic jerks of the right leg that occasionally led to falls. Type II consisted of formication paraesthesias that propagated from the right calf to the hip region. It could be provoked by stress or hot weather and occurred 2-3 times a week. In the presurgical 3T epilepsy MRI no structural abnormality was detected.

Implantation scheme

After non-invasive telemetry intracranial recordings were performed. It was decided to implant a 64 channels Ad-Tech subdural grid with 8x8 contacts (stainless steel, 10mm between centers of contacts, 2.3mm diameter exposure) over the left fronto-centro-parietal convexity covering the central region. The most inferior lateral row of contacts of the grid electrode is named A and the row of contacts next to the midline is named H. The contacts of the grid have numbers between 1-8 with the most posterior contacts of each row starting with number 1.

Additionally, 3 interhemispheric Ad-Tech strip electrodes with 4 contacts each named from posterior to anterior with IHA being the most posterior followed by IHB and IHC being the most anterior strip electrode. The numbering convention is that the deepest contact is named contact "1": and the most superficial contact of each electrode has the highest number.

In addition, 2 Ad-Tech sEEG electrodes were implanted in the right parietal lobe facing to the insula (TA & TB, distance between centers of contacts: 10mm, diameter: 0.86mm). Both sEEG electrodes have 10 electrode contacts each. The contacts are counted from anterior to posterior starting with contact number 1 at the tip of each sEEG electrode.

The figure illustrating the electrode positions was created as reported by Kovalev et al. 2005.

epos_scheme_1.gif epos_scheme_2.gif epos_scheme_3.gif

Recordings

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 (cut-off frequency ~ 0.16Hz) and a low-pass filter with a cut-off frequency of 344 Hz.

Clinical evaluation

Interictal findings:

  • Repetitive sharp waves and interictal fast epileptic activity in the gamma frequency band (FEA; for advanced spectral analysis of FEA see also (Heers et al., 2018)) was almost continuously recorded in contacts G5-6 extending towards H5-6 or F5-6 and less frequently expanding to H3-4 & 7, IHA1-3, IHB1-3

Ictal findings:

  • Seizure onset pattern: Repetitive gamma bursts interrupted by sharp slow waves in G5-6, H3-4 and IHA1-3
  • Semiology: Myoclonic and clonic movements of the right leg intermingled with not clearly localizing habitual formication paraesthesias of the right leg

Electrical stimulation:

  • Stimulation of contacts G5: habitual myoclonic seizures
  • Stimulation of contact G6: habitual paraesthesias of the right leg
  • Detailed function mapping was performed, which is not reported in detail here.

Resection, histopathology and postsurgical outcome:

  • Resection of the posterior part of the superior frontal gyrus anterior of the precentral gyrus including the cingulate gyrus was performed. Because there was overlap between the primary motor cortex (confirmed by functional mapping) at contact H3 position H3, which was also involved in the seizure onset zone this brain area was spared and only multiple subpial transections were added here.
  • Histological examination revealed focal cortical dysplasia type Ib (Palmini et al., 2004). After surgery the patient developed a severe SMA syndrome with diminished activity, problems in movement initiation and speech production from which he recovered completely after rehabilitation.
  • After surgery the patient remained completely seizure free (Engel IA outcome, follow up 10 years).

sub-ecog01_ses-postimp_acq-render01_photo.png sub-ecog01_ses-postimp_acq-render02_photo.png

References

Heers M, Helias M, Hedrich T, Dümpelmann M, Schulze-Bonhage A, Ball T (2018): Spectral bandwidth of interictal fast epileptic activity characterizes the seizure onset zone. NeuroImage Clin 17.

Kovalev D, Spreer J, Honegger J, Zentner J, Schulze‐Bonhage A, Huppertz HJ (2005): Rapid and fully automated visualization of subdural electrodes in the presurgical evaluation of epilepsy patients. AJNR Am J Neuroradiol 26:1078–1083.

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

Files

The dataset we distribute with this tutorial follows the Brain Imaging Data Structure (BIDS) standard for neuroimaging data organization. This specification was first established for MRI and fMRI (Gorgolewski, 2016) and then refined with an extension dedicated to iEEG (Holdgraf, 2019). The files that will be imported in this tutorial are the following:

sample_ecog/

  • derivatives/: Everything that cannot be considered as raw data

    • freesurfer/sub-ecog01_ses-preimp/: Result of the FreeSurfer 7.1.1 segmentation for subject ecog01 (T1 pre-implantation)

  • sub-ecog01/: Raw data for subject ecog01

    • ses-preimp/: Imaging exams performed before the implantation of the ECoG/sEEG.

      • anat/sub-ecog01_ses-preimp_T1w.nii.gz: T1-weighted MRI pre-implantation

    • ses-postimp/: Exams performed with the sEEG/ECoG devices implanted.

      • anat/sub-ecog01_ses-postimp_T1w.nii.gz: T1-weighted MRI post-implantation

      • ieeg/..._task-seizure_run-01_ieeg.eeg: 1 hour ECoG+sEEG recordings with 3 seizures (saved using the BrainVision file format, with the header files .vhdr and .vmrk)

      • ieeg/..._space-IXI549Space_electrodes.tsv: Position of the contacts in MNI space (SPM12 Segment non-linear normalization)

      • ieeg/..._space-other_electrodes.tsv: Position of the contacts in world coordinates

  • All the anatomical images have been de-identified with mri_deface from FreeSurfer 6.

Download and installation

Import the anatomy

Pre-implantation MRI

Post-implantation MRI

Generate default surfaces

Access the recordings

Edit the contacts positions

In order to generate epileptogenicity maps, we need accurate 3D positions for the contacts of the depth electrodes. Placing the contacts requires a good understanding of the implantation scheme reported by the neurosurgeon, and some skills in reading MRI scans. To make this tutorial easier to reproduce and follow, we distribute the positions of the contacts saved in a text file (folder /anat/implantation). For instructions to place the SEEG contacts using Brainstorm, read the advanced section Editing the contacts positions.

Editing the contacts positions

If you don't have access to the positions of the SEEG contacts in a text file, as illustrated in this tutorial, you can place the contacts in the MRI viewer.

You can also start defining an implantation scheme without any recordings in your database. You can use this option for creating a text file with all the contacts positions, and use it in Brainstorm or any other program.

Display the depth electrodes

3D figures

MRI Viewer

Panel iEEG

Display the SEEG recordings

SEEG time series

Interpolate on the anatomy

2D topography

Two additional popup menus allow you to display the SEEG recordings grouped by electrode, but without any 3D information: 2DLayout and 2DElectrodes.

[ATTACH]

Review recordings

Power spectrum

We recommend you always start your data analysis with a spectral evalution of the recordings, it may help you identify bad channels. This is described in tutorials Power spectrum and EEG and epilepsy.

Bad channels

We will now to review the recordings of the three seizures recorded for this subject: SZ1, SZ2, SZ3. All the following steps are illustrated only for SZ1 but need to be reproduced for the other files.

Import epochs of interest

At this point of the analysis, we are still looking at the original files, no SEEG data was copied to the database. The montages are saved in the Brainstorm preferences, the bad channels and new events are saved in the links of the database but not reported to the original .TRC files. If you delete your protocol at this point, you would only lose the event marking and bad channel selection.

We are now going to import two segments of recordings for each seizure file: the seizure (10s before and 40s after the onset) and the baseline (all the segment selected). This will make real copies of the data in the database, so we can run additional processes on them.

Import in database

Time-frequency analysis (pre-onset baseline)

The aim of this section is to evaluate the frequency range for the computation of the epileptogenicity maps. We need to identify which frequency band is the most representation and specific of the high-frequency activity at the beginning of the seizures.

Starting from this step, you need to have the SPM12 toolbox installed on your computer and added to your Matlab path. We need here the multitaper functions from the FieldTrip toolbox, which are also already in the SPM package.

Time-frequency analysis (separate baseline)

Another approach is to normalize the time-frequency maps based on the baseline file used for the computation of the epileptogenicity maps, instead of the short baseline immediately before the seizure onset. This is a bit more complicated but produces maps that are more coherent with the epileptogenicity measures used in the next section. To increase the educational value of this section, let's manage the time differently: we'll compute the time-frequency decomposition for the entire Onset epochs (-10s,+40s) and then extract only the section we are interested in.

Create a movie with the SEEG signals

Saving the conclusions of your visual exploration as a video file is an efficient solution for keeping track of your analyses and sharing them with your colleagues. In such a movie, it can be interesting to display simultaneously the original SEEG recordings with the epileptogenicity maps. However, if you try to open the two files, you get an error message explaining that Brainstorm cannot display two files with different time definitions at the same time.

A solution to go around this limitation is to resample the epileptogenicity results (one value every two seconds = 0.5Hz) with the same frequency as the SEEG recordings (initially 512Hz). This would multiply the size of the file containing the epileptogenicity results by 2*512, creating a file of several Gb. To avoid wasting too much disk space and risking to crash Matlab by creating gigantic variables, we can cut and downsample the SEEG recordings of interest. Let's illustrate this with the seizure SZ2.

Advanced

Video-EEG

Advanced

Importing realistic surfaces

Instead of using the default SPM canonical surfaces, you can use realistic cortex envelopes, extracted with FreeSurfer, BrainSuite or BrainVISA. Instead of importing the anatomy as described previously (pre MRI then post MRI), follow these steps. Note that this cannot be done with the simplified interface in the Guidelines tab.

Advanced

Volume coregistration

When importing two volumes successively in the subject anatomy, you need to coregister all the new volumes with the first volume imported, otherwise you wouldn't be able to do anything with them. The questions that are asked when importing a second volume are the following.

Advanced

On the hard drive

The definition of the depth electrodes is saved in the channel file, in the field IntraElectrodes. It contains all the information that can be edited in the iEEG tab. The position of the SEEG contacts is saved in the field Channel(i).Loc, as described in the tutorial Channel file. ChannelMat.IntraElectrodes is an array of structures with the following fields.

Scripting

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

1 function tutorial_ecog(tutorial_dir, reports_dir) 2 % TUTORIAL_ECOG: Script that runs ECoG/sEEG tutorial 3 % https://neuroimage.usc.edu/brainstorm/Tutorials/ECoG 4 % 5 % INPUTS: 6 % - tutorial_dir : Directory where the sample_ecog.zip file has been unzipped 7 % - reports_dir : Directory where to save the execution report (instead of displaying it) 8 9 % @============================================================================= 10 % This function is part of the Brainstorm software: 11 % https://neuroimage.usc.edu/brainstorm 12 % 13 % Copyright (c) University of Southern California & McGill University 14 % This software is distributed under the terms of the GNU General Public License 15 % as published by the Free Software Foundation. Further details on the GPLv3 16 % license can be found at http://www.gnu.org/copyleft/gpl.html. 17 % 18 % FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND THE 19 % UNIVERSITY OF SOUTHERN CALIFORNIA AND ITS COLLABORATORS DO NOT MAKE ANY 20 % WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF 21 % MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY 22 % LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE. 23 % 24 % For more information type "brainstorm license" at command prompt. 25 % =============================================================================@ 26 % 27 % Author: Raymundo Cassani, 2025 28 29 30 % Output folder for reports 31 if (nargin < 2) || isempty(reports_dir) || ~isdir(reports_dir) 32 reports_dir = []; 33 end 34 % You have to specify the folder in which the tutorial dataset is unzipped 35 if (nargin == 0) || isempty(tutorial_dir) || ~file_exist(tutorial_dir) 36 error('The first argument must be the full path to the dataset folder.'); 37 end 38 39 %% ===== FILES TO IMPORT ===== 40 % Subject name 41 SubjectName = 'ecog01'; 42 % Build the path of the files to import 43 AnatDir = fullfile(tutorial_dir, 'sample_ecog', 'derivatives', 'freesurfer', 'sub-ecog01_ses-preimp'); 44 PostMri = fullfile(tutorial_dir, 'sample_ecog', 'sub-ecog01', 'ses-postimp', 'anat', 'sub-ecog01_ses-postimp_T1w.nii.gz'); 45 EegRawFile = fullfile(tutorial_dir, 'sample_ecog', 'sub-ecog01', 'ses-postimp', 'ieeg', 'sub-ecog01_ses-postimp_task-seizure_run-01_ieeg.eeg'); 46 EegLocFile = fullfile(tutorial_dir, 'sample_ecog', 'sub-ecog01', 'ses-postimp', 'ieeg', 'sub-ecog01_ses-postimp_space-ScanRAS_electrodes.tsv'); 47 % Check if the folder contains the required files 48 if ~file_exist(EegRawFile) 49 error(['The folder ' tutorial_dir ' does not contain the folder from the file sample_ecog.zip.']); 50 end 51 52 53 %% ===== 01: CREATE PROTOCOL =================================================== 54 % ============================================================================= 55 disp([10 'DEMO> 01: Create protocol' 10]); 56 % The protocol name has to be a valid folder name (no spaces, no weird characters...) 57 ProtocolName = 'TutorialEcog'; 58 % Start brainstorm with GUI 59 if ~brainstorm('status') 60 brainstorm 61 end 62 % Delete existing protocol 63 gui_brainstorm('DeleteProtocol', ProtocolName); 64 % Create new protocol 65 gui_brainstorm('CreateProtocol', ProtocolName, 0, 0); 66 % Start a new report 67 bst_report('Start'); 68 % Reset colormaps 69 bst_colormaps('RestoreDefaults', 'eeg'); 70 71 72 %% ===== 02: IMPORT ANATOMY ==================================================== 73 % ============================================================================= 74 disp([10 'DEMO> 02: Import anatomy' 10]); 75 76 % === Pre-implantation MRI === 77 % Process: Import FreeSurfer folder 78 bst_process('CallProcess', 'process_import_anatomy', [], [], ... 79 'subjectname', SubjectName, ... 80 'mrifile', {AnatDir, 'FreeSurfer'}, ... 81 'nvertices', 15000); 82 % Rename reference MRI 83 [sSubject, iSubject] = bst_get('Subject', SubjectName); 84 file_update(file_fullpath(sSubject.Anatomy(sSubject.iAnatomy).FileName), 'Field', 'Comment', 'T1pre'); 85 db_reload_subjects(iSubject); 86 87 % === Post-implantation MRI === 88 % Process: Import MRI 89 bst_process('CallProcess', 'process_import_mri', [], [], ... 90 'subjectname', SubjectName, ... 91 'mrifile', {PostMri, 'Nifti1'}); 92 sSubject = bst_get('Subject', SubjectName); 93 iAnatPost = length(sSubject.Anatomy); 94 file_update(file_fullpath(sSubject.Anatomy(iAnatPost).FileName), 'Field', 'Comment', 'T1post'); 95 db_reload_subjects(iSubject); 96 97 % === Coregister and reslice post-implantation with pre-implantation === 98 % Coregister (without reslicing) 99 MriPostReg = mri_coregister(sSubject.Anatomy(iAnatPost).FileName, [], 'SPM', 0); 100 % Delete post-implantation (without coregistration) 101 file_delete(file_fullpath(sSubject.Anatomy(iAnatPost).FileName), 1); 102 db_reload_subjects(iSubject); 103 sSubject = bst_get('Subject', SubjectName); 104 % Reslice coregisted post-implantation MRI with world coordinates 105 iAnatPostReg = find(strcmp(MriPostReg, {sSubject.Anatomy.FileName})); 106 MriPostRegReslice = mri_reslice(sSubject.Anatomy(iAnatPostReg).FileName, [], 'vox2ras', 'vox2ras'); 107 % Figure: Overlay T1post_spm_reslice on T1pre 108 hFig = view_mri(sSubject.Anatomy(sSubject.iAnatomy).FileName, MriPostRegReslice); 109 % Amplitude to 20% 110 panel_surface('SetDataThreshold', hFig, 1, 0.2); 111 bst_report('Snapshot', hFig, '', 'Coregistration T1pre on T1post_spm_reslice'); 112 pause(0.5); 113 close(hFig); 114 115 % === Generate BEM surfaces === 116 % Process: Generate BEM surfaces 117 bst_process('CallProcess', 'process_generate_bem', [], [], ... 118 'subjectname', SubjectName, ... 119 'nscalp', 1922, ... 120 'nouter', 1922, ... 121 'ninner', 1922, ... 122 'thickness', 4, ... 123 'method', 'brainstorm'); % Brainstorm 124 % Set default head surface and update Subject node 125 [sSubject, iSubject] = bst_get('Subject', SubjectName); 126 iScalp = find(strcmp('head mask (10000,0,2,18)', {sSubject.Surface.Comment})); 127 db_surface_default(iSubject, 'Scalp', iScalp, 1); 128 panel_protocols('UpdateNode', 'Subject', iSubject); 129 % Figure: BEM surfaces 130 hFig = view_surface(sSubject.Surface(sSubject.iScalp).FileName); 131 view_surface(sSubject.Surface(sSubject.iOuterSkull).FileName); 132 view_surface(sSubject.Surface(sSubject.iInnerSkull).FileName); 133 view_surface(sSubject.Surface(sSubject.iCortex).FileName); 134 iTess = 3; % InnerSkull 135 panel_surface('SetShowSulci', hFig, iTess, 1); 136 panel_surface('SetSurfaceColor', hFig, iTess, [1 0 0]); 137 figure_3d('SetStandardView', hFig, 'left'); 138 pause(0.5); 139 bst_report('Snapshot', hFig, '', 'BEM surfaces and Cortex'); 140 close(hFig); 141 142 143 %% ===== 03: ACCESS THE RECORDINGS ============================================== 144 % ============================================================================= 145 disp([10 'DEMO> 03: Access the recordings' 10]); 146 % === Link the recordings === 147 % Process: Create link to raw files 148 sFileRaw = bst_process('CallProcess', 'process_import_data_raw', [], [], ... 149 'subjectname', SubjectName, ... 150 'datafile', {EegRawFile, 'ECOG-ALL'}); 151 152 % === Edit channel and intracranial electrodes in channel file === 153 sChannelMat = in_bst_channel(sFileRaw.ChannelFile); 154 % ECOG grid 'G' 155 iIntraElec = find(strcmp('G', {sChannelMat.IntraElectrodes.Name})); 156 sChannelMat.IntraElectrodes(iIntraElec).Type = 'ECOG'; 157 sChannelMat.IntraElectrodes(iIntraElec).ContactNumber = [8 8]; 158 sChannelMat.IntraElectrodes(iIntraElec).ContactSpacing = 0.01; % 10 mm 159 sChannelMat.IntraElectrodes(iIntraElec).ContactLength = 0.001; % 1 mm 160 sChannelMat.IntraElectrodes(iIntraElec).ContactDiameter = 0.004; % 4 mm 161 % ECOG strips 'IHA', 'IHB' and 'IHC' 162 [~, iIntraElec] = ismember({'IHA', 'IHB', 'IHC'}, {sChannelMat.IntraElectrodes.Name}); 163 [sChannelMat.IntraElectrodes(iIntraElec).Type] = deal('ECOG-mid'); 164 [sChannelMat.IntraElectrodes(iIntraElec).ContactNumber] = deal(4); 165 [sChannelMat.IntraElectrodes(iIntraElec).ContactSpacing] = deal(0.01); % 10 mm 166 [sChannelMat.IntraElectrodes(iIntraElec).ContactLength] = deal(0.001); % 1 mm 167 [sChannelMat.IntraElectrodes(iIntraElec).ContactDiameter] = deal(0.004); % 4 mm 168 % SEEG electrodes 'TA' and 'TB' 169 % Change groups TA and TB to be type SEEG 170 iChSeeg = find(strcmp('TA', {sChannelMat.Channel.Group}) | strcmp('TB', {sChannelMat.Channel.Group})); 171 [sChannelMat.Channel(iChSeeg).Type] = deal('SEEG'); 172 [~, iIntraElec] = ismember({'TA', 'TB'}, {sChannelMat.IntraElectrodes.Name}); 173 [sChannelMat.IntraElectrodes(iIntraElec).Type] = deal('SEEG'); 174 [sChannelMat.IntraElectrodes(iIntraElec).ContactNumber] = deal(10); 175 [sChannelMat.IntraElectrodes(iIntraElec).ContactSpacing] = deal(0.01); % 10.0 mm 176 [sChannelMat.IntraElectrodes(iIntraElec).ContactLength] = deal(0.0025); % 2.5 mm 177 [sChannelMat.IntraElectrodes(iIntraElec).ContactDiameter] = deal(0.001); % 1.0 mm 178 [sChannelMat.IntraElectrodes(iIntraElec).ElecDiameter] = deal(0.0009); % 0.9 mm 179 [sChannelMat.IntraElectrodes(iIntraElec).ElecLength] = deal(0.120); % 120.0 mm 180 % Save modified channel file 181 bst_save(file_fullpath(sFileRaw.ChannelFile), sChannelMat); 182 % === Edit the contacts positions === 183 % Process: Add EEG positions 184 bst_process('CallProcess', 'process_channel_addloc', sFileRaw, [], ... 185 'channelfile', {EegLocFile, 'BIDS-SCANRAS-MM'}, ... 186 'usedefault', '', ... 187 'fixunits', 1, ... 188 'vox2ras', 1, ... 189 'mrifile', {MriPostReg, 'BST'}, ... 190 'fiducials', []); 191 % Plot electrodes and open iEEG panel 192 [hFig, iDS, iFig] = view_channels_3d(sFileRaw.ChannelFile, 'ECOG+SEEG', 'cortex', 1); 193 bst_report('Snapshot', hFig, sFileRaw.ChannelFile, 'Before projecting ECOG grid on innerskull: ECOG'); 194 % Project ECOG grid 'G' on innerskull surface 195 panel_ieeg('SetSelectedElectrodes', 'G'); 196 panel_ieeg('ProjectContacts', iDS, iFig, 'innerskull'); 197 bst_report('Snapshot', hFig, sFileRaw.ChannelFile, 'After projecting ECOG grid on innerskull: ECOG'); 198 bst_memory('SaveChannelFile', iDS); 199 bst_memory('UnloadAll', 'Forced'); 200 201 202 %% ===== 04: DISPLAY THE RECORDINGS ============================================ 203 % ============================================================================= 204 disp([10 'DEMO> 04: Display the recordings' 10]); 205 % ECoG/sEEG time series 206 hFig = view_timeseries(sFileRaw.FileName, 'ECOG+SEEG'); 207 % Set the current display mode to 'column' 208 bst_set('TSDisplayMode', 'column'); 209 panel_record('SetTimeLength', 20); 210 panel_record('SetStartTime', 888); 211 panel_montage('SetCurrentMontage', hFig, 'ecog01: ECOG_SEEG (bipolar 1)[tmp]'); 212 pause(0.5); 213 bst_report('Snapshot', hFig, sFileRaw.FileName, 'Time series: ECOG+SEEG'); 214 close(hFig); 215 216 % 2D Layout 217 hFig2dL = view_topography(sFileRaw.FileName, 'ECOG+SEEG', '2DLayout'); 218 panel_record('SetTimeLength', 2); 219 panel_record('SetStartTime', 888); 220 panel_time('SetCurrentTime', 889.6); 221 222 % 2D electrodes 223 hFig2dE = view_topography(sFileRaw.FileName, 'ECOG+SEEG', '2DElectrodes'); 224 225 % 3D electrodes (MRI) 226 hFig3dE = view_topography(sFileRaw.FileName, 'ECOG+SEEG', '3DElectrodes-MRI'); 227 228 % Project activity on cortex 229 sSubject = bst_get('Subject', SubjectName); 230 hFigCtx = view_surface_data(sSubject.Surface(sSubject.iCortex).FileName, sFileRaw.FileName, 'ECOG+SEEG'); 231 % Project activity on MRI 232 % Set Maximum intensity projection (MIP) for projected data) 233 MriOptions = bst_get('MriOptions'); 234 MriOptions.isMipFunctional = 1; 235 bst_set('MriOptions', MriOptions); 236 hFigMri = view_mri(sSubject.Anatomy(sSubject.iAnatomy).FileName, sFileRaw.FileName, 'ECOG+SEEG'); 237 238 % Set colormap max to 'local' and range [-max,max] 239 ColormapInfo = getappdata(hFigCtx, 'Colormap'); 240 bst_colormaps('SetMaxMode', ColormapInfo.Type, 'local', []); 241 bst_colormaps('SetColormapRealMin', ColormapInfo.Type, 0); 242 243 pause(0.5); 244 bst_report('Snapshot', hFig2dL, sFileRaw.FileName, '2D Layout: ECOG+SEEG'); 245 bst_report('Snapshot', hFig2dE, sFileRaw.FileName, '2D Electrodes: ECOG+SEEG'); 246 bst_report('Snapshot', hFig3dE, sFileRaw.FileName, '3D Electrodes: ECOG+SEEG'); 247 bst_report('Snapshot', hFigCtx, sFileRaw.FileName, 'Interpolate on cortex: ECOG+SEEG'); 248 bst_report('Snapshot', hFigMri, sFileRaw.FileName, 'Interpolate on MRI: ECOG+SEEG'); 249 close([hFig2dL, hFig2dE, hFig3dE, hFigCtx, hFigMri]); 250 MriOptions.isMipFunctional = 0; 251 bst_set('MriOptions', MriOptions); 252 253 % Process: Power spectrum density (Welch) 254 sFilePsd = bst_process('CallProcess', 'process_psd', sFileRaw, [], ... 255 'timewindow', [], ... 256 'win_length', 10, ... 257 'win_overlap', 50, ... 258 'units', 'physical', ... % Physical: U2/Hz 259 'sensortypes', 'ECOG, SEEG', ... 260 'win_std', 0, ... 261 'edit', struct(... 262 'Comment', 'Power', ... 263 'TimeBands', [], ... 264 'Freqs', [], ... 265 'ClusterFuncTime', 'none', ... 266 'Measure', 'power', ... 267 'Output', 'all', ... 268 'SaveKernel', 0)); 269 % Spectrum figure 270 hFig = view_spectrum(sFilePsd.FileName); 271 sOptions = panel_display('GetDisplayOptions'); 272 sOptions.Function = 'log'; 273 panel_display('SetDisplayOptions', sOptions); 274 xlim(gca, [0, 40]); 275 pause(0.5); 276 bst_report('Snapshot', hFig, sFilePsd.FileName, 'Power spectrum (log): ECOG+SEEG'); 277 close(hFig); 278 279 280 %% ===== 05: IMPORT EPOCHS ===================================================== 281 % ============================================================================= 282 disp([10 'DEMO> 05: Import epochs' 10]); 283 % Process: Import MEG/EEG: Events 284 sFilesEpochs = bst_process('CallProcess', 'process_import_data_event', sFileRaw, [], ... 285 'subjectname', SubjectName, ... 286 'condition', '', ... 287 'eventname', 'seizure', ... 288 'timewindow', [], ... 289 'epochtime', [-10, 20], ... 290 'createcond', 0, ... 291 'ignoreshort', 1, ... 292 'usectfcomp', 1, ... 293 'usessp', 1, ... 294 'freq', [], ... 295 'baseline', []); 296 % TB SEEG electrode time series 297 hFig = view_timeseries(sFilesEpochs(1).FileName, 'ECOG+SEEG'); 298 % Set the current display mode to 'column' 299 bst_set('TSDisplayMode', 'column'); 300 panel_montage('SetCurrentMontage', hFig, 'ecog01: TB (bipolar 2)[tmp]'); 301 pause(0.5); 302 bst_report('Snapshot', hFig, sFileRaw.FileName, 'Time series: electrode TB'); 303 close(hFig); 304 305 306 %% ===== 06: ANATOMICAL LABELLING ============================================== 307 % ============================================================================= 308 disp([10 'DEMO> 06: Anatomical labelling' 10]); 309 TsvFile = bst_fullfile(fileparts(file_fullpath(sFileRaw.FileName)), 'anatomical_labelling.tsv'); 310 export_channel_atlas(sFileRaw.ChannelFile, 'ECOG+SEEG', TsvFile, 3, 1, 0); 311 % View TSV file 312 T = readtable(TsvFile, 'FileType', 'text', 'Delimiter', '\t', 'ReadVariableNames', true); 313 jFrame = view_table(table2cell(T), T.Properties.VariableNames, 'sFileRaw.ChannelFile'); 314 bst_report('Snapshot', jFrame, sFileRaw.ChannelFile, 'Anatomical labelling: ECOG+SEEG'); 315 jFrame.dispose(); 316 317 318 %% ===== SAVE REPORT ===== 319 % Save and display report 320 ReportFile = bst_report('Save', []); 321 if ~isempty(reports_dir) && ~isempty(ReportFile) 322 bst_report('Export', ReportFile, reports_dir); 323 else 324 bst_report('Open', ReportFile); 325 end 326 disp([10 'DEMO> Done.' 10]); 327





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


Tutorials/ECoG (last edited 2019-04-10 14:26:36 by FrancoisTadel)