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

Revision 353 as of 2024-04-13 12:45:04
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

Corticomuscular coherence (CTF MEG)

Authors: Raymundo Cassani, Francois Tadel, Sylvain Baillet.

Corticomuscular coherence measures the degree of similarity between electrophysiological signals (MEG, EEG, ECoG sensor traces or source time series, especially over the contralateral motor cortex) and the EMG signals recorded from muscle activity during voluntary movements. Cortical-muscular signals similarities are conceived as due mainly to the descending communication along corticospinal pathways between primary motor cortex (M1) and the muscles attached to the moving limb(s). For consistency purposes, the present tutorial replicates, with Brainstorm tools, the processing pipeline "Analysis of corticomuscular coherence" of the FieldTrip toolbox.

Contents

  1. Dataset description
  2. Download and installation
  3. Importing anatomy
  4. MEG and EMG recordings
    1. Link the recordings
    2. MEG-MRI coregistration
    3. Reviewing
    4. Event markers
  5. Pre-processing
    1. Power line artifacts
    2. EMG: Filter and rectify
    3. MEG: Blink SSP and bad segments
  6. Epoching
  7. Coherence: EMG x MEG
  8. Source estimation
    1. MRI segmentation
    2. Head models
    3. Noise covariance
    4. Inverse models
  9. Coherence: EMG x Sources
    1. Surface
    2. Volume
    3. Method for constrained sources
    4. Method for unconstrained sources
  10. Coherence: EMG x Scouts
    1. Method for constrained sources
    2. Method for unconstrained sources
  11. Coherence Scouts x Scouts
    1. Input options
    2. Mixed source models
  12. Additional documentation
  13. Scripting

Dataset description

The dataset is identical to that of the FieldTrip tutorial: Analysis of corticomuscular coherence:

  • One participant,
  • MEG recordings: 151-channel CTF MEG system,
  • Bipolar EMG recordings: from left and right extensor carpi radialis longus muscles,
  • EOG recordings: used for detection and attenuation of ocular artifacts,
  • MRI: 1.5T Siemens system,
  • Task: The participant lifted their hand and exerted a constant force against a lever for about 10 seconds. The force was monitored by strain gauges on the lever. The participant performed two blocks of 25 trials using either their left or right hand.
  • Here we describe relevant Brainstorm tools via the analysis of the left-wrist trials. We encourage the reader to practice further by replicating the same pipeline using right-wrist trials!

Corticomuscular coherence:

  • Coherence measures the linear relationship between two signals in the frequency domain.

  • Previous studies (Conway et al., 1995, Kilner et al., 2000) have reported corticomuscular coherence effects in the 15–30 Hz range during maintained voluntary contractions.

  • TODO: IMAGE OF EXPERIMENT, SIGNALS and COHERENCE

Download and installation

Pre-requisites

  • Please make sure you have completed the get-started tutorials, prior to going through the present tutorial.

  • Have a working copy of Brainstorm installed on your computer.
  • Install the CAT12 Brainstorm plugin, to perform MRI segmentation from the Brainstorm dashboard.

Download the dataset

  • Download SubjectCMC.zip from the FieldTrip download page:
    https://download.fieldtriptoolbox.org/tutorial/SubjectCMC.zip

  • Unzip the downloaded archive file in a folder outside the Brainstorm database or app folders (for instance, directly on your desktop).

Brainstorm

  • Launch Brainstorm (via the Matlab command line or the Matlab-free stand-alone version of Brainstorm).
  • Select from the menu File > Create new protocol. Name the new protocol TutorialCMC and select the options:
    No, use individual anatomy,
    No, use one channel file per acquisition run.

Importing anatomy

  • Right-click on the newly created TutorialCMC node > New subject > Subject01.
    Keep the default options defined for the study (aka "protocol" in Brainstorm's vernacular).

  • Switch to the Anatomy view of the protocol ().

  • Right-click on the Subject01 > Import MRI:

    • Select the file format: All MRI files (subject space)

    • Select the file: SubjectCMC/SubjectCMC.mri

  • This step will launch Brainstorm's MRI viewer, where coronal, sagittal and axial cross-sections of the MRI volume are displayed. note that three anatomical fiducials (left and right pre-auricular points (LPA and RPA), and nasion (NAS)) are automatically identified. These fiducials are located near the left/right ears and just above the nose, respectively. Click on Save.

    mri_viewer.gif

  • In all typical Brainstorm workflows from this tutorial handbook, we recommend processing the MRI volume at this stage, before importing the functional (MEG/EEG) data. However, we will proceed differently, for consistency with the original FieldTrip pipeline, and readily obtain sensor-level coherence results. We will proceed with MRI segmentation below, before performing source-level analyses.

  • We still need to verify the proper geometric registration (alignment) of MRI with MEG. We will therefore now extract the scalp surface from the MRI volume.
  • Right-click on the MRI () > MRI segmentation > Generate head surface.

    head_process.gif

  • Double-click on the newly created surface to display the scalp in 3-D.

    head_display.gif

MEG and EMG recordings

Link the recordings

  • Switch now to the Functional data view of your database contents ().

  • Right-click on Subject01 > Review raw file:

    • Select the appropriate MEG file format: MEG/EEG: CTF(*.ds; *.meg4; *.res4)

    • Select the data file: SubjectCMC.ds

  • A new folder SubjectCMC is created in the Brainstorm database explorer. Note the "RAW" tag over the icon of the folder (), indicating that the MEG files contain unprocessed, continuous data. This folder includes:

  • CTF channels (191) is a file with all channel information, including channel types (MEG, EMG, etc.), names, 3-D locations, etc. The total number of channels available (MEG, EMG, EOG etc.) is indicated between parentheses.

  • Link to raw file is a link to the original data file. Brainstorm reads all the relevant metadata from the original dataset and saves them into this symbolic node of the data tree (e.g., sampling rate, number of time samples, event markers). As seen elsewhere in the tutorial handbook, Brainstorm does not create copies by default of (potentially large) unprocessed data files (more information).

  • review_raw.png

MEG-MRI coregistration

  • This registration step is to align the MEG coordinate system with the participant's anatomy from MRI (more info). Here we will use only the three anatomical landmarks stored in the MRI volume and specific at the moment of MEG data collection. From the FieldTrip tutorial:
    "To measure the head position with respect to the sensors, three coils were placed at anatomical landmarks of the head (nasion, left and right ear canal). [...] During the MRI scan, ear molds containing small containers filled with vitamin E marked the same landmarks. This allows us, together with the anatomical landmarks, to align source estimates of the MEG with the MRI."

  • To visually appreciate the correctness of the registration, right-click on the CTF channels node > MRI registration > Check. This opens a 3-D figure showing the inner surface of the MEG helmet (in yellow), the head surface, the fiducial points and the axes of the subject coordinate system (SCS).

    fig_registration.gif

Reviewing

  • Right-click on the Link to raw file > Switch epoched/continuous to convert how the data i stored in the file to a continuous reviewing format, a technical detail proper to CTF file formatting.

  • Right-click on the Link to raw file > MEG > Display time series (or double-click on its icon). This will display data time series and enable the Time panel and the Record tab in the main Brainstorm window (see specific features in "explore data time series").

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

  • https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=timeseries_meg_emg.png

Event markers

The colored dots at the top of the figure, above the data time series, indicate event markers (or triggers) saved along with MEG data. The actual onsets of the left- and right-wrist trials are not displayed yet: they are saved in an auxiliary channel of the raw data named Stim. To add these markers to the display, follow this procedure:

  • With the time series figure still open, go to the Record tab and select File > Read events from channel. Event channels = Stim, select Value, Reject events shorter than 12 samples. Click Run.

  • read_evnt_ch.gif

  • The rejection of short events is nececessary in this dataset, because transitions between values in the Stim channel may span over several time samples. Otherwise, and for example, an event U1 would be created at 121.76s because the transition from the event U1025 back to zero features two unwanted values at the end of the event. The rejection criteria is set to 12 time samples (10ms), because the duration of all the relevant triggers is longer than 15ms. This value is proper to each dataset, so make sure you verify trigger detections from your own dataset.

    triggers_min_duration.gif

  • New event markers are created and now shown in the Events section of the tab, along with previous event categories. In this tutorial, we will only use events U1 through U25, which correspond to the beginning of each of the 25 left-wrist trials of 10 seconds. Following FieldTrip's tutorial, let's reject trial #7, event U7.

  • Delete all unused events: Select all the events except U1-U6 and U8-25 (Ctrl+click / Shift+click), then menu Events > Delete group (or press the Delete key).

  • Merge events: Select all the event groups, then select from the menu Events > Merge group > "Left". A new event category called "Left" now indicate the onsets of 24 trials of left-wrist movements.

    left_24.gif

Pre-processing

In this tutorial, we will analyze only the Left trials (left-wrist extensions). In the following sections, we will process only the first 330 s of the original recordings, where the left-wrist trials were performed.

Power line artifacts

  • In the Process1 box: Drag and drop the Link to raw file.

  • Run process Frequency > Power spectrum density (Welch):

    • Time window: 0-330 s

    • Window length: 10 s

    • Overlap: 50%

    • Sensor types: MEG, EMG

  • pro_psd.png

  • Double-click on the new PSD file to visualize the power spectrum density of the data.

  • psd_before_notch.png

  • The PSD plot shows two groups of sensors: EMG (highlighted in red above) and the MEG spectra below (black lines). Peaks at 50Hz and harmonics (100, 150, 200Hz and above) indicate the European power line frequency and are clearly visible. We will now use notch filters to attenuate power line contaminants at 50, 100 and 150 Hz.
  • In the Process1 box: Drag and drop the Raw | clean node.

  • Run the process Pre-processing > Notch filter with:

    • Check Process the entire file at once

    • Sensor types: MEG, EMG

    • Frequencies to remove (Hz): 50, 100, 150

  • pro_notch.png

  • In case you get a memory error message:
    These MEG recordings have been saved before applying the CTF 3rd-order gradient compensation, for noise reduction. The compensation weights are therefore applied on the fly when Brainstorm reads data from the file. However, this requires reading all the channels at once. By default, the frequency filter are optimized to process channel data sequentially, which is incompatible with applying the CTF compensation on the fly. This setting can be overridden with the option Process the entire file at once, which requires loading the entire file in memory at once, which may crash teh process depending on your computing resources (typically if your computer's RAM < 8GB). If this happens: run the process Artifacts > Apply SSP & CTF compensation on the file first, then rune the notch filter process without the option "Process the entire file at once" (more information).

  • A new folder named SubjectCMC_clean_notch is created. Obtain the PSD of these data to appreciate the effect of the notch filters. As above, please remember to indicate a Time window restricted from 0 to 330 s in the options of the PSD process.

  • psd_after_notch.png

EMG: Filter and rectify

Two typical pre-processing steps for EMG consist in high-pass filtering and rectifying.

  • In the Process1 box: drag and drop the Raw | notch(50Hz 100Hz 150Hz) node.

  • Add the process Pre-process > Band-pass filter

    • Sensor types = EMG

    • Lower cutoff frequency = 10 Hz

    • Upper cutoff frequency = 0 Hz

  • Add the process Pre-process > Absolute values

    • Sensor types = EMG

  • Run the pipeline
  • emg_processing.png

  • Delete intermediate files that won't be needed anymore: Select folders SubjectCMC_notch and SubjectCMC_notch_high, then press the Delete key (or right-click > File > Delete).

    db_filters.gif

MEG: Blink SSP and bad segments

Stereotypical artifacts such eye blinks and heartbeats can be identified from their respective characteristic spatial distributions. Their contamination of MEG signals can then be attenuated specifically using Signal-Space Projections (SSPs). For more details, consult the specific tutorial sections about the detection and removal of artifacts with SSP. The present tutorial dataset features an EOG channel but no ECG. We will therefore only remove artifacts caused by eye blinks.

Blink correction with SSP

  • Right-click on the pre-processed file > MEG > Display time series and EOG > Display time series.

  • In the Record tab: Artifacts > Detect eye blinks, and use the parameters:

    • Channel name= EOG

    • Time window = 0 - 330 s

    • Event name = blink

  • detect_blink_process.png

  • Three categories of blink events are created. Review the traces of the EOG channels around a few of these events to ascertain they are related to eye blinks. In the present case, we note that the blink group contains genuine eye blinks, and that groups blink2 and blink3 capture saccades.

  • blinks.png

  • To remove blink artifacts with SSP, go to Artifacts > SSP: Eye blinks:

    • Event name=blink

    • Sensors=MEG

  • ssp_blink_process.png

  • Display the time series and topographies of the first two SSP components identified. In the present case, only the first SSP component can be clearly related to blinks: the percentage of variance explained is substantially higher than the other compoments', the spatial topography of the component is also typical of eye blinks, and the corresponding time series is similar to the EOG signal around blinks. Select only component #1 for removal.

  • ssp_blink.png

  • Close all visualization figures by clicking on the large × at the top-right of the main Brainstorm window.

Detection of "bad" data segments

Here we will use the automatic detection of artifacts to identify data segments contaminated by e.g., large eye and head movements, or muscle contractions.

  • Display the MEG and EOG time series. In the Record tab, select Artifacts > Detect other artifacts and enter the following parameters:

    • Time window = 0 - 330 s

    • Sensor types=MEG

    • Sensitivity=3

    • Check both frequency bands 1-7 Hz and 40-240 Hz

  • detect_other.png

  • You are encouraged to review all the segments marked using this procedure. With the present data, all marked segments do contain clear artifacts.
  • Select the 1-7Hz and 40-240Hz event groups and select Events > Mark group as bad. Alternatively, you can add the prefix bad_ to the event names. Brainstorm will automatically discard these data segments from further processing.

  • bad_other.png

  • Close all visualization windows and reply "Yes" to the save the modifications query.

Epoching

We are now finished with the pre-processing of EMG and MEG recordings. We will now extract and import specific data segments of interest into the Brainstorm database for further derivations. As mentioned previously, we will focus on the Left category of events (left-wrist movements). For consistency with the FieldTrip tutorial, we will analyze 8s of recordings following each movement (from the original 10s around each trial), and split them in 1-s epochs. For each 1-s epoch, the DC offset will be also removed from each MEG channel. And finally, we will uniform the time vector for all 1-s epochs. This last steps is needed as the time vector of each 1-s vector is with respect to the event that was used to import the 8-s trial.

  • In the Process1 box: Drag-and-drop the pre-processed file.
  • Select the process Import > Import recordings > Import MEG/EEG: Events:

    • Subject name = Subject01

    • Folder name = empty

    • Event names = Left

    • Time window = 0 - 330 s

    • Epoch time = 0 - 8000 ms

    • Split recordings in time blocks = 1 s

    • Uncheck Create a separate folder for each event type

    • Check Ignore shorter epochs

    • Check Use CTF compensation

    • Check Use SSP/ICA projectors

  • Add the process Pre-process > Remove DC offset:

    • Baseline = All file

    • Sensor types = MEG

    • Check Overwrite input files

  • Add the process Standardize > Uniform epoch time:

    • Interpolation method = spline

    • Check Overwrite input files

  • Run the pipeline

pro_import.png

pro_remove_dc.png

  • A new folder SubjectCMC_notch_high_abs without the 'raw' indication is now created, which includes 192 individual epochs (24 trials x 8 1-s epochs each). The epochs that overlap with a "bad" event are also marked as bad, as shown with an exclamation mark in a red circle (). These bad epochs will be automatically ignored by the Process1 and Process2 tabs, and from all further processing.

  • trials.png

Comparison with FieldTrip

The figures below show the EMG and MRC21 channels (a MEG sensor over the left motor-cortex) from the epoch #1.1, in Brainstorm (left), and from the FieldTrip tutorial (right).

bst_ft_trial1.png

Coherence: EMG x MEG

Let's compute the magnitude-squared coherence (MSC) between the left EMG and the MEG channels.

  • In the Process1 box, drag and drop the Left (192 files) trial group.

  • dragdrop_trialgroup.png

  • Select the process Connectivity > Coherence 1xN [2023]:

    • Time window = Check All file

    • Source channel = EMGlft

    • Sensor types = MEG

    • Do not check Include bad channels

    • Select Magnitude squared coherence as Connectivity metric

    • Select Fourier transform as Time-freq decomposition method

    • Click in the [Edit] button to set the parameters of the Fourier transform:

      • Select Matlab's FFT defaults as Frequency definition

      • FT window length = 0.5 s

      • FT window overlap = 50%

      • Highest frequency of interest = 80 Hz

    • Time resolution = None

    • Estimate & save = across combined files/epochs

    More details on the Coherence process can be found in the Connectivity Tutorial.

  • Add the process File > Add tag with the following parameters:

    • Tag to add = MEG sensors

    • Select Add to file name

  • Run the pipeline:

coh_meg_emgleft.png

coh_meg_emgleft2.png

  • Double-click on the resulting data node MSCoh-stft: EMGlft (185 files) | MEG sensors to display the MSC spectra. Click on the maximum peak in the 15 to 20 Hz range, and press Enter to display the spectrum from the selected sensor in a new window. This spectrum is that of channel MRC21, and shows a prominent peak at 17.58 Hz. Use the frequency slider (under the Time panel) to explore the MSC output across frequencies.

  • Right-click on the spectrum and select 2D Sensor cap for a topographical representation of the magnitude of the coherence results across the sensor array. You may also use the shortcut Ctrl-T. The sensor locations can be displayed with a right-click and by selecting Channels > Display sensors from the contextual menu (shortcut Ctrl-E).

  • res_coh_meg_emgleft.png

  • We can now average the magnitude of the MSC across the beta band (15-20 Hz).
    In the Process1 box, select the new mscohere file.

  • Run process Frequency > Group in time or frequency bands:

    • Select Group by frequency bands

    • Type cmc_band / 15, 20 / mean in the text box.

  • pro_group_freq.png

  • The resulting MSCoh-stft:...|tfbands node contains one MSC value for each sensor (the MSC average in the 15-20 Hz band). Right-click on the file to display the 2D or 3D topography of the MSC beta-band measure.

    res_coh_tfgroup.gif

  • Higher MSC values the EMG signal and MEG sensor signals map over the contralateral set of central sensors in the beta band. Sensor-level connectivity can be ambiguous to interpret anaotmically though. We will now map the magnitude of EMG-coherence across the brain (MEG sources).

Source estimation

MRI segmentation

We first need to extract the cortical surface from the T1 MRI volume we imported at the beginning of this tutorial. CAT12 is a Brainstorm pluing that will perform this task in 30-60min.

  • Switch back to the Anatomy view of the protocol ().

  • Right-click on the MRI () > MRI segmentation > CAT12:

    • Number of vertices: 15000

    • Anatomical parcellations: Yes

    • Cortical maps: No

  • cat12.png

  • Keep the low-resolution central surface selected as the default cortex (central_15002V). This surface is the primary output of CAT12, and is shown half-way between the pial envelope and the grey-white interface (more information). The head surface was recomputed during the process and duplicates the previous surface obtained above: you can either delete one of the head surfaces or ignore this point for now.

  • For quality control, double-click on the head and central_15002V surfaces to visualize them in 3D.

    cat12_files.gif

Head models

We will perform source modeling using a distributed model approach for two different source spaces: the cortex surface and the entire MRI volume. Forward models are called head models in Brainstorm. They account for how neural electrical currents produce magnetic fields captured by sensors outside the head, considering head tissues electromagnetic properties and geometry, independently of actual empirical measurements (more information). A distinct head model is required for the cortex surface and head volume source spaces.

Cortical surface

  • Go back to the Functional data view of the database.

  • Right-click on the channel file of the imported epoch folder > Compute head model.

    • Comment = Overlapping spheres (surface)

    • Source space = Cortex surface

    • Forward model = MEG Overlapping spheres.

  • pro_head_model_srf.gif

Whole-head volume

  • Right-click on the channel file again > Compute head model.

    • Comment = Overlapping spheres (volume)

    • Source space = MRI volume

    • Forward model = Overlapping spheres.

    • Select Regular grid and Brain

    • Grid resolution = 5 mm

  • pro_head_model_vol.gif

  • The Overlapping spheres (volume) head model is now added to the database explorer. The green color of the name indicates this is the default head model for the current folder: you can decide to use another head model available by double clicking on its name.

  • tre_head_models.gif

Noise covariance

The recommendation for MEG source imaging is to extract basic noise statistics from empty-room recordings. When not available, as here, resting-state data can be used as proxies for MEG noise covariance. We will use a segment of the MEG recordings, away from the task and major artifacts: 18s-29s.

  • Right-click on the clean continuous file > Noise covariance > Compute from recordings.

    pro_noise_cov.gif

  • Right-click on the Noise covariance () > Copy to other folders.

    tre_covmat.gif

Inverse models

We will now compute three inverse models, with different source spaces: cortex surface with constrained dipole orientations (normal to the cortex), cortex surface with unconstrained orientation, and MRI volume (more information).

Cortical surface

  • Right-click on Overlapping spheres (surface) > Compute sources:

    • Minimum norm imaging

    • Current density map

    • Constrained: Normal to the cortex

    • Comment = MN: MEG (surface)

  • Repeat the previous step, but this time select Unconstrained in the Dipole orientations field.

pro_sources_srfc.png

pro_sources_srfu.png

Whole-head volume

  • Right-click on the Overlapping spheres (volume) > Compute sources:

    • Current density map

    • Unconstrained

    • Comment = MN: MEG (volume)

  • pro_sources_vol.png

  • Three imaging kernels () are now available in the database explorer. Note that each trial is associated with three source links (). The concept of imaging kernels is explained in Brainstorm's main tutorial on source mapping.

  • tre_sources.gif

Coherence: EMG x Sources

We can now compute the coherence between the EMG signal and all brain source time series, for each of the source models considered. Let's start with the cortical surface/constrained model.

  • To select the source maps to include in the coherence estimation, click on the Search Database button (), and select New search. Set the parameters as shown below, and click on Search.

  • gui_search_srf.png

  • This creates a new tab in the database explorer, showing only the files that match the search criteria.
  • tre_search_srf.gif

  • Click the Process2 tab at the bottom of the main Brainstorm window.

    • Files A: Drag-and-drop the Left (192 files) group, select Process recordings ().

    • Files B: Drag-and-drop the Left (192 files) group, select Process sources ().

    • Objective: Extract from the same files both the EMG recordings (Files A) and the sources time series (Files B), then compute the coherence measure between these two categories of time series. Note that the blue labels over the file lists indicate that there are 185 "good" files (7 bad epochs).
  • process2.png

  • Select the process Connectivity > Coherence AxB [2023]:

    • Time window = All file

    • Source channel (A) = EMGlft

    • Uncheck Use scouts (B)

    • Check Flatten unconstrained source orientations

    • Click in the [Edit] button of the PCA options:

      • Select across all epochs/files as PCA method

      • PCA time window = All file

      • Check Remove DC offset

      • Baseline = All file

    • Ignore the Scout function options as we are not using scouts

    • Select Magnitude squared coherence as Connectivity metric

    • Select Fourier transform as Time-freq decomposition method

    • Click in the [Edit] button to set the parameters of the Fourier transform:

      • Select Matlab's FFT defaults as Frequency definition

      • FT window length = 0.5 s

      • FT window overlap = 50%

      • Highest frequency of interest = 80 Hz

    • Time resolution = None

    • Estimate & save = across combined files/epochs

  • Add the process File > Add tag:

    • Tag to add = (surface)(Constr)

    • Select Add to file name

  • Run the pipeline

pro_coh_srf.png

pro_coh_srf2.png

  • Repeat the steps above to compute the EMG-sources coherence for the other source models: surface/unconstrained and volume:

    • Edit the search criteria accordingly: Right-click on the search tab > Edit search.

    • This updates automatically the file selection in the Process2 tab.
    • Select the processes as indicated above and update the file tag according to the type of sources.

      The option Flatten unconstrained source orientations did not have any impact with constrained sources. However when used with unconstrained sources, these these sources are flattened before computing coherence. If the option is unchecked for unconstrained sources, coherence is computed between the sensor and each of the the three orientations per source, these resulting three coherence spectra are then collapsed into one using the maximum value for each frequency band. Find mode details in the connectivity tutorial

  • Close the search tab. If the 3 new connectivity files ) are not featured in the database explorer: refresh the dabase display by pressing [F5] or by clicking again on the selected button "Functional data".

    tre_coh_src_files.gif

Surface

Double-click on the 1xN connectivity files for the two (surface) source spaces (constrained and unconstrained source orientations) to visualize the cortical maps. See main tutorial Display: Cortex surface for all available options. Pick the cortical location and frequency with the highest coherence value.

  • In the Surface tab: Smooth=30%, Amplitude=0%.

  • To compare visually different cortex maps, set manually the colormap range (e.g.[0 - 0.07])

  • Explore with coherence spectra with the frequency slider

  • The highest coherence value is located at 14.65 Hz, in the right primary motor cortex (precentral gyrus). To observe the coherence spectrum at a given location: right-click on the cortex > Source: Power spectrum.

    res_coh_surf.gif

  • The constrained (top) and unconstrained (bottom) orientations coherence maps are qualitatively similar in terms of peak location and frequency. The unconstrained source map appears smoother because of the maximum aggregation across all three current directions at each brain location, as explained below. These maps results are similar to those obtained with the FieldTrip tutorial.

  • To obtain the 3D coordinates of the peak coherence location: right-click on the figure > Get coordinates. Then click on the right motor cortex with the crosshair cursor. Let's keep note of these coordinates for later comparision with the whole-head volume results below.

    res_get_coordinates.gif

Volume

  • Double-click the 1xN connectivity file to display the (volume) source space.

  • Set the frequency to 14.65 Hz, and the data transparency to 20% (Surface tab).
  • Find the peak in the head volume by navigating in all 3 dimensions, or use the coordinates from the surface results as explained above.
  • Right-click on the figure > Anatomical atlas > None. The coherence value under the cursor is then shown on the top-right corner of the figure.

    res_coh_vol.gif

Method for constrained sources

For cortical and orientation-constrained sources, each vertex in the source grid is associated with 1 time series. As such, when coherence is computed with the EMG signal (also consisting of one time series), this result is 1 coherence spectrum per vertex. In other words, for each frequency bin, we obtain one coherence brain map.

width="100%"

Method for unconstrained sources

In the case of orientation-unconstrained (either surface or volume) sources, each vertex (source location) is associated with 3 time series, each one corresponding to the X, Y and Z directions. Thus, a dimension reduction across directions is needed. In this tutorial the dimension reduction consisted in first flattening the 3D maps to a single orientation with the PCA method. This results in a source model similar to that with orientation-constrained sources, thus, coherence is then computed as with orientation-constrained (described above).

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_flattened.png

  • Another alternative to address the issue of the dimension reduction across directions when estimating coherence with unconstrained sources is to compute coherence between the EMG signal (one time series) and each of the 3 time series (one for each source orientation: x, y and z) associated with each source location, resulting in 3 coherence spectra per source location. Then, these coherence spectra are collapsed into a single coherence spectrum by keeping the maximum coherence value across those in the three directions for each frequency bin. The choice of the maximum statistic is empirical: it is not rotation invariant (if the specifications of the NAS/LPA/RPA fiducials change, the x,y,z axes also change, which may influence connectivity measures quantitatively). Nevertheless, our empirical tests showed this option produced smooth and robust (to noise) connectivity estimates.

    https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_unconstr.png

    Below the comparison of the coherence between the EMG sensor and unconstrained surface sources using: PCA flattening in the source space (left) and "Flattening of the coherence, by maximum coherence across directions"

    https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_unconstr.png

Coherence: EMG x Scouts

We have now obtained coherence spectra at each of the 15002 brain source locations. This is a very large amount of data to shift through. We therefore recommend to further reduce the dimensionality of the source space by using a surface- or volume-parcellation scheme. In Brainstorm vernacular, this can be achieved via an atlas consisting of scout regions. See the Scout Tutorial for detailed information about atlases and scouts in Brainstorm. To compute scout-wise coherence, it is necessary to specify two parameters to indicate how the data is aggregated in each scout:

1. The scout function (for instance, the mean), and

2. When the scout aggregation procedure if performed, either before or after the coherence computation).

Method for constrained sources

When the scout function is used with constrained sources, the computation of coherence is carried as follows:

  • If the scout function is applied before: The scout function (e.g., mean) is applied for all the source time series in the scout; resulting in 1 time series per scout. This scout time series is then used to compute coherence with the reference signal (here, with EMG) resulting in 1 coherence spectrum per scout.

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_sct_bef.png

  • If the scout function applied after: coherence is first computed between the reference signal (here, EMG) and each source time series in the scout, resulting in N coherence spectra, with N being the number of sources in the scout. Finally the scout function is applied to the resulting coherence spectra for each source within the scout to obtain one coherence spectrum per scout. This is a considerably more greedy option that the "before" option above, as it computes coherence measures between the EMG signal and each of the 15000 elementary source signals. This requires more computing resources; see introduction for an example.

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_sct_aft.png

Method for unconstrained sources

As ?described above, when computing coherence with unconstrained sources it is necessary to perform dimension reduction across directions. When this reduction is done by first flattening the unconstrained sources, is performed on unconstrained sources coherence computations is carried out as described in the ?previous section. However, if the sources are not flattened before computing coherence is carried out as follows:

  • If the scout function is applied before, the scout function (e.g., mean) is applied for each direction on the elementary source time series in the scout; resulting in 3 time series per scout, one time series per orientation (x, y, z). These scout time series are then used to compute coherence with the reference signal (here, with EMG), and the coherence spectra for each scout are aggregated across the x, y and z dimensions, with the max function as shown previously, to obtain 1 coherence spectrum per scout.

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_sct_bef.png

  • If scout function is applied after, coherence is computed between the reference signal (here, EMG) and each elementary sources (number of sources in each scout x 3 orientations). Then the coherence spectra for each elementary source are aggregated across the x, y and z dimensions. Finally the scout function is applied to the resulting coherence spectra for each elementary source within the scout. This is a considerably more greedy option that the "before" option above, as it computes coherence measures between the EMG signal and each of the 45000 elementary source signals. This requires more computing resources; see introduction for an example.

https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence?action=AttachFile&do=get&target=diagram_1xn_coh_sct_aft.png

Here, we will compute the coherence from scouts, using mean as scout function with the before option. We will use the Schaefer 100 parcellation atlas on to the orientation-constrained source map.

  • Use Search Database () to select the Left trials with their respective (surface)(Constr) source maps, as shown in the previous section.

  • In the Process2: Left trial group into both the Files A and Files B boxes. Select Process recordings () for Files A, and Process sources () for Files B.

  • process2.png

Open the Pipeline editor:

  • Add the process Connectivity > Coherence AxB [2023] with the following parameters:

    • Time window = All file

    • Source channel (A) = EMGlft

    • Check Use scouts (B)

    • From the menu at the right, select Schaefer_100_17net

    • Select all the scouts
    • Scout function: Apply: before

    • Scout function: mean

    • Select Magnitude squared coherence as Connectivity metric

    • Select Fourier transform as Time-freq decomposition method

    • Click in the [Edit] button to set the parameters of the Fourier transform:

      • Select Matlab's FFT defaults as Frequency definition

      • FT window length = 0.5 s

      • FT window overlap = 50%

      • Highest frequency of interest = 80 Hz

    • Time resolution = None

    • Estimate & save = across combined files/epochs

  • Add the process File > Add tag with the following parameters:

    • Tag to add = (surface)(Constr)

    • Select Add to file name

  • Run the pipeline

pro_coh_srfc_bef_sct.png

pro_coh_srfc_bef_sct2.png

Double-click on the new file: the coherence spectra are not displayed on the cortex; they are plotted for each scout. The 1xN connectivity file can also be shown as an image as displayed below:

res_coh_srfc_bef_sct.png

res_coh_srfc_bef_sct2.png

Note that at 14.65 Hz, the two highest peaks correspond to the SomMotA_4 R and SomMotA_2 R scouts, both located over the right primary motor cortex.

The brain parcellation scheme is the user's decision. We recommend the Schaefer100 atlas used here by default.

Coherence Scouts x Scouts

The sections above explain the computation of various connectivity measures between pairs of time series. When computing whole-brain connectomes (i.e., NxN connectivity matrices between all brain sources), additional technical considerations need to be taken into account: the number of time series is typically too large to be computationally tractable on most workstations (see introduction above); if using unconstrained source maps, with 3 time series at each brain location, this requires an extra step to derive connectivity estimates.

The tutorial Corticomuscular coherence explains the computation of connectivity measures between one sensor (EMG) and brain source maps, with sensor x sources and sensor x scouts scenarios, both with constrained and unconstrained source orientation models.

This section explains dimension reduction using ROIs (or Brainstorm "scouts"), using the coherence NxN (scouts x scouts) as an example, in the case of unconstrained source maps (three orthogonoal source orientations at each brain location). In this configuration, as for constrained sources, the process returns one connectivity estimate (i.e., coherence spectrum) for each distinct pair of scouts.

Input options

When the input(s) to a connectivity process are source files, there are additional input options available to select scouts from existing atlases, and specify the aggregating function and when to perform the aggregation.

[ATTACH]

Scout function: It is necessary to specify two parameters to indicate how the data is aggregated in each scout: The scout function (for instance, the mean), and whether this within-scout aggregation procedure is applied before or after the computation of the connectivity measure. This is illustrated below. The available functions depend on when it is applied.

Unconstrained maps: There are two options for dealing with unconstrained source orientations, specified with the checkbox "Flatten unconstrained source orientations with PCA first".

  • If selected, the very first step will be to reduce the 3d maps to "flat" maps with a single orientation per source location, and the computation will proceed as for constrained models.

  • If not selected, the connectivity measure is computed for each pair of sources in all three orientations (1x-2x, 1x-2y, 1x-2z, 1y-2x, ..., 1z-2z), yielding 9 coherence spectra per source pair. From these 9 values at each frequency bin, the maximum value is kept to summarize the connectivity estimate between the two regions. This step happens after the connectivity estimate, but before the "after" scout function (if selected), as illustrated below. The choice of the maximum statistic is empirical: it is not rotation invariant (if the specifications of the NAS/LPA/RPA fiducials change, the x,y,z axes also change, which may influence connectivity measures quantitatively). Nevertheless, our empirical tests showed this option produced smooth and robust (to noise) connectivity estimates.

PCA Options: If PCA is selected as the scout function or for flattening unconstrained maps, additional options are available through this Edit button.

The graphs below show the processing steps for the cases when the Scout function is applied with the "before" and "after" options, for two scouts (Scout-1 and Scout-2), with 3 orientations each (x,y,z). In either case, the outcome is one coherence spectrum per pair of scouts.

Before: The scout function (e.g., mean) is applied on each direction on the elementary source time series in the scout, which results in one time series per elementary direction, per scout. These scouts time series are then used to compute coherence measures, and the resulting coherence spectra are finally aggregated across the x, y and z dimensions, yielding one single coherence spectrum for each pair of scouts. [ATTACH]

After: With this option, coherence is first computed between each pair of elementary sources (number of sources in each scout x 3 orientations) for two scouts, yielding 9 coherence spectra for each pair of elementary sources in the scouts. Then, these coherence spectra are aggregated across the 9 combinations of dimensions (1x-2x, 1x-2y, 1x-2z, 1y-2x, ..., 1z-2z) to obtain one single coherence spectrum for each pair of elementary sources within the scouts. Finally, the scout function (e.g., mean) is applied to the coherence spectra for each elementary source within the scouts to obtain one single coherence spectrum for each pair of scouts. Applying the scout function "after" is a considerably more greedy option that the applying the scout function "before" (option described above), as it computes coherence measures between all 45000x45000 elementary source signals. This requires more computing resources; see the introduction for an example.[ATTACH]

The result is a connectivity file () that contains Scouts x Scouts coherence spectra.

  • [ATTACH]

The connectivity graph and the adjacency matrix are displayed for each frequency bin of the coherence spectra. For more details, see the connectivity graph tutorial.

Mixed source models

Mixed models refer to source models with mutliple regions that may include surface and volume regions, and regions with different source orientation constraints. To compute connectivity between surface and volume regions, you must first create volume scouts for the volume regions of the mixed model, and then use the process2 tab with the same files on both sides. On one side you can select surface scouts, and the other, the volume scouts you created. For connectivity between surface regions only, or volume regions only, use the process1 tab.

Advanced

Additional documentation

Articles

  • Conway BA, Halliday DM, Farmer SF, Shahani U, Maas P, Weir AI, et al.
    Synchronization between motor cortex and spinal motoneuronal pool during the performance of a maintained motor task in man.
    The Journal of Physiology. 1995 Dec 15;489(3):917–24.

  • Kilner JM, Baker SN, Salenius S, Hari R, Lemon RN.
    Human Cortical Muscle Coherence Is Directly Related to Specific Motor Parameters.
    J Neurosci. 2000 Dec 1;20(23):8838–45.

  • Liu J, Sheng Y, Liu H.
    Corticomuscular Coherence and Its Applications: A Review.
    Front Hum Neurosci. 2019 Mar 20;13:100.

  • Sadaghiani S, Brookes MJ, Baillet S.
    Connectomics of human electrophysiology.
    NeuroImage. 2022 Feb;247:118788.

Tutorials

  • Tutorial: Functional connectivity

  • Tutorial: Source estimation

  • Tutorial: Volume source estimation

  • Tutorial: Scouts

  • Tutorial: Connectivity graphs

Scripting

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

1 function tutorial_coherence(tutorial_dir, reports_dir) 2 % TUTORIAL_COHERENCE: Script that runs the Brainstorm corticomuscular coherence tutorial 3 % https://neuroimage.usc.edu/brainstorm/Tutorials/CorticomuscularCoherence 4 % 5 % INPUTS: 6 % - tutorial_dir : Directory where the SubjectCMC.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 & Francois Tadel, 2022 28 29 % Output folder for reports 30 if (nargin < 2) || isempty(reports_dir) || ~isfolder(reports_dir) 31 reports_dir = []; 32 end 33 % You have to specify the folder in which the tutorial dataset is unzipped 34 if (nargin == 0) || isempty(tutorial_dir) || ~file_exist(tutorial_dir) 35 error('The first argument must be the full path to the dataset folder.'); 36 end 37 38 % Protocol name 39 ProtocolName = 'TutorialCMC'; 40 % Subject name 41 SubjectName = 'Subject01'; 42 % Channel selection 43 emg_channel = 'EMGlft'; % Name of EMG channel 44 meg_sensor = 'MRC21'; % MEG sensor over the left motor-cortex (MRC21) 45 % Coherence parameters 46 cohmeasure = 'mscohere'; % Magnitude-squared Coherence |C|^2 = |Cxy|^2/(Cxx*Cyy) 47 win_length = 0.5; % 500ms 48 overlap = 50; % 50% 49 maxfreq = 80; % 80Hz 50 51 % Build the path of the files to import 52 MriFilePath = fullfile(tutorial_dir, 'SubjectCMC', 'SubjectCMC.mri'); 53 MegFilePath = fullfile(tutorial_dir, 'SubjectCMC', 'SubjectCMC.ds'); 54 % Check if the folder contains the required files 55 if ~file_exist(MriFilePath) || ~file_exist(MegFilePath) 56 error(['The folder ' tutorial_dir ' does not contain the folder from the file SubjectCMC.zip.']); 57 end 58 59 60 %% ===== CREATE PROTOCOL ===== 61 % Start brainstorm without the GUI 62 if ~brainstorm('status') 63 brainstorm nogui 64 end 65 % Delete existing protocol 66 gui_brainstorm('DeleteProtocol', ProtocolName); 67 % Create new protocol 68 gui_brainstorm('CreateProtocol', ProtocolName, 0, 0); 69 % Start a new report 70 bst_report('Start'); 71 % Reset colormaps 72 bst_colormaps('RestoreDefaults', 'meg'); 73 % Hide scouts 74 panel_scout('SetScoutShowSelection', 'none'); 75 76 77 %% ===== IMPORT ANATOMY ===== 78 % Process: Import MRI 79 bst_process('CallProcess', 'process_import_mri', [], [], ... 80 'subjectname', SubjectName, ... 81 'mrifile', {MriFilePath, 'ALL'}, ... 82 'nas', [0, 0, 0], ... 83 'lpa', [0, 0, 0], ... 84 'rpa', [0, 0, 0], ... 85 'ac', [0, 0, 0], ... 86 'pc', [0, 0, 0], ... 87 'ih', [0, 0, 0]); 88 % Process: Generate head surface 89 bst_process('CallProcess', 'process_generate_head', [], [], ... 90 'subjectname', SubjectName, ... 91 'nvertices', 10000, ... 92 'erodefactor', 0, ... 93 'fillfactor', 2); 94 95 96 %% ===== LINK TO RAW FILE AND DISPLAY REGISTRATION ===== 97 % Process: Create link to raw files 98 sFileRaw = bst_process('CallProcess', 'process_import_data_raw', [], [], ... 99 'subjectname', SubjectName, ... 100 'datafile', {MegFilePath, 'CTF'}, ... 101 'channelalign', 1); 102 % Process: Snapshot: Sensors/MRI registration 103 bst_process('CallProcess', 'process_snapshot', sFileRaw, [], ... 104 'target', 1, ... % Sensors/MRI registration 105 'modality', 1, ... % MEG (All) 106 'orient', 1, ... % left 107 'Comment', 'MEG/MRI Registration'); 108 % Process: Convert to continuous (CTF): Continuous 109 bst_process('CallProcess', 'process_ctf_convert', sFileRaw, [], ... 110 'rectype', 2); % Continuous 111 112 113 %% ===== EVENT MARKERS ===== 114 % Process: Read from channel 115 sFileRaw = bst_process('CallProcess', 'process_evt_read', sFileRaw, [], ... 116 'stimchan', 'Stim', ... 117 'trackmode', 1, ... % Value: detect the changes of channel value 118 'zero', 0, ... 119 'min_duration', 12); 120 % Load all Event group labels 121 DataMat = in_bst_data(sFileRaw.FileName, 'F'); 122 eventList = {DataMat.F.events.label}; 123 % Labels for Event groups to keep 124 eventKeep = cellfun(@(c)sprintf('U%d',c), num2cell([1:6, 8:25]), 'UniformOutput', 0); 125 % Find useless Events 126 eventDelete = setdiff(eventList, eventKeep); 127 % Process: Delete events 128 sFileRaw = bst_process('CallProcess', 'process_evt_delete', sFileRaw, [], ... 129 'eventname', strjoin(eventDelete, ', ')); 130 % Process: Merge events 131 sFileRaw = bst_process('CallProcess', 'process_evt_merge', sFileRaw, [], ... 132 'evtnames', strjoin(eventKeep, ', '), ... 133 'newname', 'Left'); 134 135 136 %% ===== REMOVAL OF POWER LINE ARTIFACTS ===== 137 % Process: Notch filter: 50Hz 100Hz 150Hz 138 sFileRawNotch = bst_process('CallProcess', 'process_notch', sFileRaw, [], ... 139 'freqlist', [50, 100, 150], ... 140 'sensortypes', 'MEG, EMG', ... 141 'read_all', 1); 142 % Process: Power spectrum density (Welch) 143 sFilesPsd = bst_process('CallProcess', 'process_psd', [sFileRaw, sFileRawNotch], [], ... 144 'timewindow', [0 330], ... 145 'win_length', 10, ... 146 'win_overlap', 50, ... 147 'clusters', {}, ... 148 'sensortypes', 'MEG, EMG', ... 149 'edit', struct(... 150 'Comment', 'Power', ... 151 'TimeBands', [], ... 152 'Freqs', [], ... 153 'ClusterFuncTime', 'none', ... 154 'Measure', 'power', ... 155 'Output', 'all', ... 156 'SaveKernel', 0)); 157 % Process: Snapshot: Frequency spectrum 158 bst_process('CallProcess', 'process_snapshot', sFilesPsd, [], ... 159 'target', 10, ... % Frequency spectrum 160 'Comment', 'Power spectrum density'); 161 162 163 %% ===== EMG PRE-PROCESSING ===== 164 % Process: High-pass:10Hz 165 sFileRawNotchHigh = bst_process('CallProcess', 'process_bandpass', sFileRawNotch, [], ... 166 'sensortypes', 'EMG', ... 167 'highpass', 10, ... 168 'lowpass', 0, ... 169 'tranband', 0, ... 170 'attenuation', 'strict', ... % 60dB 171 'ver', '2019', ... % 2019 172 'mirror', 0, ... 173 'read_all', 0); 174 % Process: Absolute values 175 sFileRawNotchHighAbs = bst_process('CallProcess', 'process_absolute', sFileRawNotchHigh, [], ... 176 'sensortypes', 'EMG'); 177 % Process: Delete folders 178 bst_process('CallProcess', 'process_delete', [sFileRawNotch, sFileRawNotchHigh], [], ... 179 'target', 2); % Delete folders 180 181 182 %% ===== MEG PRE-PROCESSING ===== 183 % Process: Detect eye blinks 184 bst_process('CallProcess', 'process_evt_detect_eog', sFileRawNotchHighAbs, [], ... 185 'channelname', 'EOG', ... 186 'timewindow', [0 330], ... 187 'eventname', 'blink'); 188 % Process: SSP EOG: blink 189 bst_process('CallProcess', 'process_ssp_eog', sFileRawNotchHighAbs, [], ... 190 'eventname', 'blink', ... 191 'sensortypes', 'MEG', ... 192 'usessp', 1, ... 193 'select', 1); 194 % Process: Snapshot: SSP projectors 195 bst_process('CallProcess', 'process_snapshot', sFileRawNotchHighAbs, [], ... 196 'target', 2, ... % SSP projectors 197 'Comment', 'SSP projectors'); 198 199 % Process: Detect other artifacts 200 bst_process('CallProcess', 'process_evt_detect_badsegment', sFileRawNotchHighAbs, [], ... 201 'timewindow', [0 330], ... 202 'sensortypes', 'MEG', ... 203 'threshold', 3, ... % 3 204 'isLowFreq', 1, ... 205 'isHighFreq', 1); 206 % Process: Rename event (1-7Hz > bad_1-7Hz) 207 bst_process('CallProcess', 'process_evt_rename', sFileRawNotchHighAbs, [], ... 208 'src', '1-7Hz', ... 209 'dest', 'bad_1-7Hz'); 210 % Process: Rename event (40-240Hz > bad_40-240Hz) 211 bst_process('CallProcess', 'process_evt_rename', sFileRawNotchHighAbs, [], ... 212 'src', '40-240Hz', ... 213 'dest', 'bad_40-240Hz'); 214 215 216 %% ===== IMPORTING DATA EPOCHS ===== 217 % Process: Import MEG/EEG: Events 218 sFilesEpochs = bst_process('CallProcess', 'process_import_data_event', sFileRawNotchHighAbs, [], ... 219 'subjectname', SubjectName, ... 220 'condition', '', ... 221 'eventname', 'Left', ... 222 'timewindow', [0, 330], ... 223 'epochtime', [0, 7.9992], ... 224 'split', 1, ... 225 'createcond', 0, ... 226 'ignoreshort', 1, ... 227 'usectfcomp', 1, ... 228 'usessp', 1, ... 229 'freq', [], ... 230 'baseline', 'all', ... 231 'blsensortypes', 'MEG'); 232 % Process: Uniform epoch time 233 sFilesEpochs = bst_process('CallProcess', 'process_stdtime', sFilesEpochs, [], ... 234 'method', 'spline', ... % spline 235 'overwrite', 1); 236 % Process: Snapshot: Recordings time series 237 bst_process('CallProcess', 'process_snapshot', sFilesEpochs(1), [], ... 238 'type', 'data', ... % Recordings time series 239 'modality', 1, ... % MEG (All) 240 'rowname', meg_sensor, ... 241 'Comment', ['Epoch #1: ' meg_sensor]); 242 % Process: Snapshot: Recordings time series 243 bst_process('CallProcess', 'process_snapshot', sFilesEpochs(1), [], ... 244 'type', 'data', ... % Recordings time series 245 'modality', 10, ... % EMG 246 'rowname', '', ... 247 'Comment', 'Epoch #1: EMG'); 248 249 250 %% ===== COHERENCE: EMG x MEG ===== 251 % Process: Coherence NxN [2023] 252 sFileCoh1N = bst_process('CallProcess', 'process_cohere1', {sFilesEpochs.FileName}, [], ... 253 'timewindow', [], ... 254 'src_channel', emg_channel, ... 255 'dest_sensors', 'MEG', ... 256 'includebad', 0, ... 257 'removeevoked', 0, ... 258 'cohmeasure', cohmeasure, ... % Magnitude-squared coherence 259 'tfmeasure', 'stft', ... % Fourier transform 260 'tfedit', struct(... 261 'Comment', 'Complex', ... 262 'TimeBands', [], ... 263 'Freqs', [], ... 264 'StftWinLen', win_length, ... 265 'StftWinOvr', overlap, ... 266 'StftFrqMax', maxfreq, ... 267 'ClusterFuncTime', 'none', ... 268 'Measure', 'none', ... 269 'Output', 'all', ... 270 'SaveKernel', 0), ... 271 'timeres', 'none', ... % None 272 'avgwinlength', 1, ... 273 'avgwinoverlap', 0, ... 274 'outputmode', 'avg'); % across combined files/epochs 275 % Process: Add tag 276 sFileCoh1N = bst_process('CallProcess', 'process_add_tag', sFileCoh1N, [], ... 277 'tag', 'MEG sensors', ... 278 'output', 1); % Add to file name 279 % Set selected sensors 280 bst_figures('SetSelectedRows', {meg_sensor}); 281 % Process: Snapshot: Frequency spectrum 282 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 283 'target', 10, ... % Frequency spectrum 284 'freq', 17.58, ... 285 'Comment', ['MSC ' emg_channel ' x MEG']); 286 % Process: Snapshot: Frequency spectrum 287 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 288 'target', 10, ... % Frequency spectrum 289 'freq', 17.58, ... 290 'rowname', meg_sensor, ... 291 'Comment', ['MSC ' emg_channel ' x ', meg_sensor]); 292 % Process: Snapshot: Recordings topography (one time) 293 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 294 'type', 'topo', ... % Recordings topography (one time) 295 'modality', 1, ... % MEG (All) 296 'freq', 17.58, ... 297 'Comment', ['2D sensor cap MSC ' emg_channel ' x MEG']); 298 299 300 %% ===== COHERENCE: EMG x MEG (FREQUENCY BAND) ===== 301 % Process: Group in time or frequency bands 302 sFileCoh1NBand = bst_process('CallProcess', 'process_tf_bands', sFileCoh1N, [], ... 303 'isfreqbands', 1, ... 304 'freqbands', {'cmc_band', '15, 20', 'mean'}, ... 305 'istimebands', 0, ... 306 'timebands', '', ... 307 'overwrite', 0); 308 % Process: Snapshot: Recordings topography (one time) 309 bst_process('CallProcess', 'process_snapshot', sFileCoh1NBand, [], ... 310 'type', 'topo', ... % Recordings topography (one time) 311 'modality', 1, ... % MEG (All) 312 'Comment', ['2D topography MSC 15-20Hz ' emg_channel ' x MEG']); 313 314 315 %% ===== SOURCE ESTIMATION ===== 316 % Process: Segment MRI with CAT12 317 bst_process('CallProcess', 'process_segment_cat12', [], [], ... 318 'subjectname', SubjectName, ... 319 'nvertices', 15000, ... 320 'tpmnii', {'', 'Nifti1'}, ... 321 'sphreg', 1, ... 322 'vol', 1, ... 323 'extramaps', 0, ... 324 'cerebellum', 0); 325 % Process: Compute covariance (noise or data) 326 bst_process('CallProcess', 'process_noisecov', sFileRawNotchHighAbs, [], ... 327 'baseline', [18, 29], ... 328 'datatimewindow', [], ... 329 'sensortypes', 'MEG', ... 330 'target', 1, ... % Noise covariance (covariance over baseline time window) 331 'dcoffset', 1, ... % Block by block, to avoid effects of slow shifts in data 332 'identity', 0, ... 333 'copycond', 1, ... 334 'copysubj', 0, ... 335 'copymatch', 0, ... 336 'replacefile', 1); % Replace 337 338 % Process: Compute head model (surface) 339 bst_process('CallProcess', 'process_headmodel', sFilesEpochs(1).FileName, [], ... 340 'Comment', 'Overlapping spheres (surface)', ... 341 'sourcespace', 1, ... % Cortex 342 'meg', 3); % Overlapping spheres 343 % Process: Compute sources [2018] 344 bst_process('CallProcess', 'process_inverse_2018', sFilesEpochs(1).FileName, [], ... 345 'output', 1, ... % Kernel only: shared 346 'inverse', struct(... 347 'Comment', 'MN: MEG (surface)', ... 348 'InverseMethod', 'minnorm', ... 349 'InverseMeasure', 'amplitude', ... 350 'SourceOrient', {{'fixed'}}, ... 351 'Loose', 0.2, ... 352 'UseDepth', 1, ... 353 'WeightExp', 0.5, ... 354 'WeightLimit', 10, ... 355 'NoiseMethod', 'reg', ... 356 'NoiseReg', 0.1, ... 357 'SnrMethod', 'fixed', ... 358 'SnrRms', 1e-06, ... 359 'SnrFixed', 3, ... 360 'ComputeKernel', 1, ... 361 'DataTypes', {{'MEG'}})); 362 % Process: Compute sources [2018] 363 bst_process('CallProcess', 'process_inverse_2018', sFilesEpochs(1).FileName, [], ... 364 'output', 1, ... % Kernel only: shared 365 'inverse', struct(... 366 'Comment', 'MN: MEG (surface)', ... 367 'InverseMethod', 'minnorm', ... 368 'InverseMeasure', 'amplitude', ... 369 'SourceOrient', {{'free'}}, ... 370 'Loose', 0.2, ... 371 'UseDepth', 1, ... 372 'WeightExp', 0.5, ... 373 'WeightLimit', 10, ... 374 'NoiseMethod', 'reg', ... 375 'NoiseReg', 0.1, ... 376 'SnrMethod', 'fixed', ... 377 'SnrRms', 1e-06, ... 378 'SnrFixed', 3, ... 379 'ComputeKernel', 1, ... 380 'DataTypes', {{'MEG'}})); 381 382 % Process: Compute head model (volume) 383 bst_process('CallProcess', 'process_headmodel', sFilesEpochs(1).FileName, [], ... 384 'Comment', 'Overlapping spheres (volume)', ... 385 'sourcespace', 2, ... % MRI volume 386 'volumegrid', struct(... 387 'Method', 'isotropic', ... 388 'nLayers', 17, ... 389 'Reduction', 3, ... 390 'nVerticesInit', 4000, ... 391 'Resolution', 0.005, ... 392 'FileName', []), ... 393 'meg', 3 ); % Overlapping spheres 394 % Process: Compute sources [2018] 395 bst_process('CallProcess', 'process_inverse_2018', sFilesEpochs(1).FileName, [], ... 396 'output', 1, ... % Kernel only: shared 397 'inverse', struct(... 398 'Comment', 'MN: MEG (volume)', ... 399 'InverseMethod', 'minnorm', ... 400 'InverseMeasure', 'amplitude', ... 401 'SourceOrient', {{'free'}}, ... 402 'Loose', 0.2, ... 403 'UseDepth', 1, ... 404 'WeightExp', 0.5, ... 405 'WeightLimit', 10, ... 406 'NoiseMethod', 'reg', ... 407 'NoiseReg', 0.1, ... 408 'SnrMethod', 'fixed', ... 409 'SnrRms', 1e-06, ... 410 'SnrFixed', 3, ... 411 'ComputeKernel', 1, ... 412 'DataTypes', {{'MEG'}})); 413 414 415 %% ===== COHERENCE: EMG x SOURCES ===== 416 % Process: Select data files 417 sFilesRecEmg = bst_process('CallProcess', 'process_select_files_data', [], [], ... 418 'subjectname', SubjectName, ... 419 'condition', '', ... 420 'tag', 'Left', ... 421 'includebad', 0, ... 422 'includeintra', 0, ... 423 'includecommon', 0); 424 % Coherence between EMG signal and sources (for different source types) 425 sourceTypes = {'(surface)(Constr)', '(surface)(Unconstr)', '(volume)(Unconstr)'}; 426 for ix = 1 : length(sourceTypes) 427 sourceType = sourceTypes{ix}; 428 % Process: Select results files 429 sFilesResMeg = bst_process('CallProcess', 'process_select_files_results', [], [], ... 430 'subjectname', SubjectName, ... 431 'condition', '', ... 432 'tag', sourceType, ... 433 'includebad', 0, ... 434 'includeintra', 0, ... 435 'includecommon', 0); 436 % Process: Coherence NxN [2023] 437 sFileCoh1N = bst_process('CallProcess', 'process_cohere2', sFilesRecEmg, sFilesResMeg, ... 438 'timewindow', [], ... 439 'src_channel', emg_channel, ... 440 'dest_scouts', {}, ... 441 'flatten', 1, ... 442 'scouttime', 'after', ... % after connectivity metric 443 'scoutfunc', 'mean', ... % Mean 444 'scoutfuncaft', 'mean', ... % Mean 445 'pcaedit', struct(... 446 'Method', 'pcaa', ... 447 'Baseline', [], ... 448 'DataTimeWindow', [], ... 449 'RemoveDcOffset', 'file'), ... 450 'removeevoked', 0, ... 451 'cohmeasure', cohmeasure, ... % Magnitude-squared coherence 452 'tfmeasure', 'stft', ... % Fourier transform 453 'tfedit', struct(... 454 'Comment', 'Complex', ... 455 'TimeBands', [], ... 456 'Freqs', [], ... 457 'StftWinLen', win_length, ... 458 'StftWinOvr', overlap, ... 459 'StftFrqMax', maxfreq, ... 460 'ClusterFuncTime', 'none', ... 461 'Measure', 'none', ... 462 'Output', 'all', ... 463 'SaveKernel', 0), ... 464 'timeres', 'none', ... % None 465 'avgwinlength', 1, ... 466 'avgwinoverlap', 50, ... 467 'outputmode', 'avg'); % across combined files/epochs 468 % Process: Add tag 469 sFileCoh1N = bst_process('CallProcess', 'process_add_tag', sFileCoh1N, [], ... 470 'tag', sourceType, ... 471 'output', 1); % Add to file name 472 % View surface 473 if ~isempty(strfind(sourceType, 'surface')) 474 % Process: Snapshot: Sources (one time) 475 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 476 'type', 'sources', ... % Sources (one time) 477 'orient', 3, ... % top 478 'threshold', 0, ... 479 'surfsmooth', 30, ... 480 'freq', 14.65, ... 481 'Comment', ['MSC 14.65Hz ', sourceType]); 482 % View volume 483 elseif ~isempty(strfind(sourceType, 'volume')) 484 % Process: Snapshot: Sources (MRI Viewer) 485 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 486 'type', 'mriviewer', ... % MRI viewer 487 'threshold', 0, ... 488 'freq', 14.65, ... 489 'mni', [26, -11, 73], ... 490 'Comment', ['MSC 14.65Hz ', sourceType]); 491 end 492 end 493 494 495 %% ===== COHERENCE: EMG x SCOUTS (BEFORE) ===== 496 % Process: Select data files 497 sFilesRecEmg = bst_process('CallProcess', 'process_select_files_data', [], [], ... 498 'subjectname', SubjectName, ... 499 'condition', '', ... 500 'tag', 'Left', ... 501 'includebad', 0, ... 502 'includeintra', 0, ... 503 'includecommon', 0); 504 % Only performed for (surface)(Constrained) 505 sourceType = '(surface)(Constr)'; 506 sFilesResSrfCon = bst_process('CallProcess', 'process_select_files_results', [], [], ... 507 'subjectname', SubjectName, ... 508 'condition', '', ... 509 'tag', sourceType, ... 510 'includebad', 0, ... 511 'includeintra', 0, ... 512 'includecommon', 0); 513 % Process: Coherence NxN [2023] 514 sFileCoh1N = bst_process('CallProcess', 'process_cohere2', sFilesRecEmg, sFilesResSrfCon, ... 515 'timewindow', [], ... 516 'src_channel', emg_channel, ... 517 'dest_scouts', {'Schaefer_100_17net', {'Background+FreeSurfer_Defined_Medial_Wall L', 'Background+FreeSurfer_Defined_Medial_Wall R', 'ContA_IPS_1 L', 'ContA_IPS_1 R', 'ContA_PFCl_1 L', 'ContA_PFCl_1 R', 'ContA_PFCl_2 L', 'ContA_PFCl_2 R', 'ContB_IPL_1 R', 'ContB_PFCld_1 R', 'ContB_PFClv_1 L', 'ContB_PFClv_1 R', 'ContB_Temp_1 R', 'ContC_Cingp_1 L', 'ContC_Cingp_1 R', 'ContC_pCun_1 L', 'ContC_pCun_1 R', 'ContC_pCun_2 L', 'DefaultA_IPL_1 R', 'DefaultA_PFCd_1 L', 'DefaultA_PFCd_1 R', 'DefaultA_PFCm_1 L', 'DefaultA_PFCm_1 R', 'DefaultA_pCunPCC_1 L', 'DefaultA_pCunPCC_1 R', 'DefaultB_IPL_1 L', 'DefaultB_PFCd_1 L', 'DefaultB_PFCd_1 R', 'DefaultB_PFCl_1 L', 'DefaultB_PFCv_1 L', 'DefaultB_PFCv_1 R', 'DefaultB_PFCv_2 L', 'DefaultB_PFCv_2 R', 'DefaultB_Temp_1 L', 'DefaultB_Temp_2 L', 'DefaultC_PHC_1 L', 'DefaultC_PHC_1 R', 'DefaultC_Rsp_1 L', 'DefaultC_Rsp_1 R', 'DorsAttnA_ParOcc_1 L', 'DorsAttnA_ParOcc_1 R', 'DorsAttnA_SPL_1 L', 'DorsAttnA_SPL_1 R', 'DorsAttnA_TempOcc_1 L', 'DorsAttnA_TempOcc_1 R', 'DorsAttnB_FEF_1 L', 'DorsAttnB_FEF_1 R', 'DorsAttnB_PostC_1 L', 'DorsAttnB_PostC_1 R', 'DorsAttnB_PostC_2 L', 'DorsAttnB_PostC_2 R', 'DorsAttnB_PostC_3 L', 'LimbicA_TempPole_1 L', 'LimbicA_TempPole_1 R', 'LimbicA_TempPole_2 L', 'LimbicB_OFC_1 L', 'LimbicB_OFC_1 R', 'SalVentAttnA_FrMed_1 L', 'SalVentAttnA_FrMed_1 R', 'SalVentAttnA_Ins_1 L', 'SalVentAttnA_Ins_1 R', 'SalVentAttnA_Ins_2 L', 'SalVentAttnA_ParMed_1 L', 'SalVentAttnA_ParMed_1 R', 'SalVentAttnA_ParOper_1 L', 'SalVentAttnA_ParOper_1 R', 'SalVentAttnB_IPL_1 R', 'SalVentAttnB_PFCl_1 L', 'SalVentAttnB_PFCl_1 R', 'SalVentAttnB_PFCmp_1 L', 'SalVentAttnB_PFCmp_1 R', 'SomMotA_1 L', 'SomMotA_1 R', 'SomMotA_2 L', 'SomMotA_2 R', 'SomMotA_3 R', 'SomMotA_4 R', 'SomMotB_Aud_1 L', 'SomMotB_Aud_1 R', 'SomMotB_Cent_1 L', 'SomMotB_Cent_1 R', 'SomMotB_S2_1 L', 'SomMotB_S2_1 R', 'SomMotB_S2_2 L', 'SomMotB_S2_2 R', 'TempPar_1 L', 'TempPar_1 R', 'TempPar_2 R', 'TempPar_3 R', 'VisCent_ExStr_1 L', 'VisCent_ExStr_1 R', 'VisCent_ExStr_2 L', 'VisCent_ExStr_2 R', 'VisCent_ExStr_3 L', 'VisCent_ExStr_3 R', 'VisCent_Striate_1 L', 'VisPeri_ExStrInf_1 L', 'VisPeri_ExStrInf_1 R', 'VisPeri_ExStrSup_1 L', 'VisPeri_ExStrSup_1 R', 'VisPeri_StriCal_1 L', 'VisPeri_StriCal_1 R'}}, ... 518 'flatten', 0, ... 519 'scouttime', 'before', ... % before connectivity metric 520 'scoutfunc', 'mean', ... % Mean 521 'scoutfuncaft', 'mean', ... % Mean 522 'pcaedit', struct(... 523 'Method', 'pcaa', ... 524 'Baseline', [], ... 525 'DataTimeWindow', [], ... 526 'RemoveDcOffset', 'file'), ... 527 'removeevoked', 0, ... 528 'cohmeasure', cohmeasure, ... % Magnitude-squared coherence 529 'tfmeasure', 'stft', ... % Fourier transform 530 'tfedit', struct(... 531 'Comment', 'Complex', ... 532 'TimeBands', [], ... 533 'Freqs', [], ... 534 'StftWinLen', win_length, ... 535 'StftWinOvr', overlap, ... 536 'StftFrqMax', maxfreq, ... 537 'ClusterFuncTime', 'none', ... 538 'Measure', 'none', ... 539 'Output', 'all', ... 540 'SaveKernel', 0), ... 541 'timeres', 'none', ... % None 542 'avgwinlength', 1, ... 543 'avgwinoverlap', 50, ... 544 'outputmode', 'avg'); % across combined files/epochs 545 % Process: Add tag 546 sFileCoh1N = bst_process('CallProcess', 'process_add_tag', sFileCoh1N, [], ... 547 'tag', sourceType, ... 548 'output', 1); % Add to file name 549 % Highlight scout of interest 550 bst_figures('SetSelectedRows', {'SomMotA_2 R', 'SomMotA_4 R'}); 551 % Process: Snapshot: Frequency spectrum 552 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 553 'target', 10, ... % Frequency spectrum 554 'freq', 14.65, ... 555 'Comment', ['MSC ,' sourceType, ' Before']); 556 % Process: Snapshot: Connectivity matrix 557 bst_process('CallProcess', 'process_snapshot', sFileCoh1N, [], ... 558 'type', 'connectimage', ... % Connectivity matrix 559 'freq', 14.65, ... 560 'Comment', ['MSC 14.65Hz,' sourceType, ' Before']); 561 562 563 %% ===== COHERENCE: SCOUTS x SCOUTS (BEFORE) ===== 564 % Only performed for (surface)(Constrained) 565 sourceType = '(surface)(Constr)'; 566 sFilesResSrfCon = bst_process('CallProcess', 'process_select_files_results', [], [], ... 567 'subjectname', SubjectName, ... 568 'condition', '', ... 569 'tag', sourceType, ... 570 'includebad', 0, ... 571 'includeintra', 0, ... 572 'includecommon', 0); 573 % Process: Coherence NxN [2023] 574 sFileCohNN = bst_process('CallProcess', 'process_cohere1n', sFilesResSrfCon, [], ... 575 'timewindow', [], ... 576 'scouts', {'Schaefer_100_17net', {'SomMotA_2 R', 'SomMotA_4 R', 'VisCent_ExStr_2 L'}}, ... 577 'flatten', 0, ... 578 'scouttime', 'before', ... % before 579 'scoutfunc', 'mean', ... % Mean 580 'scoutfuncaft', 'mean', ... % Mean 581 'pcaedit', struct(... 582 'Method', 'pcaa', ... 583 'Baseline', [], ... 584 'DataTimeWindow', [], ... 585 'RemoveDcOffset', 'file'), ... 586 'removeevoked', 0, ... 587 'cohmeasure', 'mscohere', ... % Magnitude-squared coherence 588 'tfmeasure', 'stft', ... % Fourier transform 589 'tfedit', struct(... 590 'Comment', 'Complex', ... 591 'TimeBands', [], ... 592 'Freqs', [], ... 593 'StftWinLen', 0.5, ... 594 'StftWinOvr', 50, ... 595 'StftFrqMax', 80, ... 596 'ClusterFuncTime', 'none', ... 597 'Measure', 'none', ... 598 'Output', 'all', ... 599 'SaveKernel', 0), ... 600 'timeres', 'none', ... % None 601 'avgwinlength', 1, ... 602 'avgwinoverlap', 50, ... 603 'outputmode', 'avg'); % across combined files/epochs 604 % Process: Add tag 605 sFileCohNN = bst_process('CallProcess', 'process_add_tag', sFileCohNN, [], ... 606 'tag', sourceType, ... 607 'output', 1); % Add to file name 608 % Highlight scout of interest 609 bst_figures('SetSelectedRows', {'SomMotA_2 R', 'SomMotA_4 R'}); 610 % Process: Snapshot: Frequency spectrum 611 bst_process('CallProcess', 'process_snapshot', sFileCohNN, [], ... 612 'target', 10, ... % Frequency spectrum 613 'freq', 14.65, ... 614 'Comment', ['MSC ,' sourceType, ' Before']); 615 % Process: Snapshot: Connectivity matrix 616 bst_process('CallProcess', 'process_snapshot', sFileCohNN, [], ... 617 'type', 'connectimage', ... % Connectivity matrix 618 'freq', 14.65, ... 619 'Comment', ['MSC 14.65Hz,' sourceType, ' Before']); 620 % Process: Snapshot: Connectivity graph 621 bst_process('CallProcess', 'process_snapshot', sFileCohNN, [], ... 622 'type', 'connectgraph', ... % Connectivity graph 623 'freq', 14.65, ... 624 'threshold', 0, ... 625 'Comment', ['MSC 14.65Hz,' sourceType, ' Before']); 626 627 628 %% ===== SAVE REPORT ===== 629 % Save and display report 630 ReportFile = bst_report('Save', []); 631 if ~isempty(reports_dir) && ~isempty(ReportFile) 632 bst_report('Export', ReportFile, reports_dir); 633 else 634 bst_report('Open', ReportFile); 635 end 636 637 disp([10 'DEMO> Corticomuscular coherence tutorial completed' 10]); 638





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


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