= Tutorial 16: Average response = ''Authors: Francois Tadel, Elizabeth Bock, Sylvain Baillet'' All the epochs we have imported in the previous tutorial are represented by matrices that have the same size (same number of channels, same number of time points), therefore they can be averaged together by experimental condition. The result is called indifferently "'''evoked response'''", "'''average response'''", "'''event-related field'''" in MEG (ERF) or "'''event-related potential'''" in EEG (ERP). It shows the components of the brain signals that are strictly time-locked to the presentation of a stimulus. . {{attachment:average_slide.gif||height="185",width="390"}} <> == Selecting the trials == We will now compute the average responses for both the "standard" and "deviant" conditions. Two constrains have to be taken into consideration at this stage. '''Averaging runs separately''': With MEG, it is not recommended to average across acquisition runs with different head positions (ie. different "channel files"). If the head of the subject moved between two blocks of recordings, one sensor does not record the same part of the brain before and after, therefore the runs cannot be compared directly. With EEG, you can generally skip this recommendation. '''Using the same number of trials''': As the goal in this analysis is to compare directly the two experimental conditions, we should use the same number of trials for computing the averages. We need to find the group of trials with the lowest number of good trials, and pick the same number in every group. Here we will be limited to 39 trials because of the deviant condition in Run#01. If we had multiple subjects and were planning to compute some group statistics, we should also use equal numbers of trials for all the subjects. The instructions below show how to select easily equal numbers of trials from the database: * Drag and drop all the "'''standard'''" and "'''deviant'''" trials for '''both runs''' in Process1. * In the Process1 list, you can notice that the number of imported trials (comment in the database explorer, eg. "40 files") does not match the number of files selected for processing (between brackets, eg. "[39]"). This difference is due to the '''bad trials''' that we have in these folders. The trials tagged with a red dot in the database explorer are ignored by all the processes. The total number of selected files is 468 instead of 480, it means that we have a total of 12 bad trials. * Select the process "'''Files > Select uniform number of trials'''".<
>Select the options: '''By trial group (folder)''' and '''Uniformly distributed'''.<
><
> {{attachment:select_process.gif||height="394",width="532"}} * If you click on [Run], it doesn't do anything but highlighting the first selected file in the database explorer. This process just performs a file selection, it needs to be followed by another one that uses the selected files for computing something. However, you can see what was done in the process report. The reports are displayed only when an error or a warning was reported, but you can open them manually to check for additional messages. Menu '''File > Report viewer'''.<
><
> {{attachment:select_report.gif||height="226",width="633"}} * The comment in the report shows the 4 groups of trials that were identified based on the option we selected (group "by trial group and folder"), with the number of good trials per group: <
>Run01/deviant (39), Run01/standard (193), Run02/deviant (40), Run01/standard (197).<
>The process picked 39 trials in each group, uniformly distributed in the list of available trials. <
>Example of trial indices selected for Run01/standard: [1, 6, 11, 16, 21, 26, 31, 36, ..., 188, 193] == Process options: Select trials == Available options in the process: File > Select uniform number of trials. * '''By folder''': Groups by subject and by folder, ignoring the trial groups. <
>Here, it would identify two groups, one for each acquisition run: Run01, Run02. * '''By trial group (folder)''': Groups by set of trials with the same name, separately for each folder and each subject. Here it would identify four groups: Run01/deviant, Run01/standard, Run02/deviant, Run01/standard. * '''By trial group (subject)''': Groups by set of trials with the same name, for each subject. The separation in folders is ignored. Here it would identify two groups: deviant, standard. How to select trials in a group that contains more than the requested number (Nf files, selecting only Ns): * '''Random selection''': Select a random subset of Ns trials. Trial indices: randperm(Nf,Ns) * '''First in the list''': Select the first Ns trials. Trial indices: 1:Ns * '''Last in the list''': Select the last Ns trials. Trial indices: Nf-Ns+1:Nf * '''Uniformly distributed''': Select Ns equally spaced trials. Trial indices: round(linspace(1, Nf, Ns))) == Averaging == * Reload the last process executed with the menu: '''File > Reload last pipeline'''. * Add the process "'''Average > Average files'''" after the trial selection process. <
>Select the options: By trial group (folder average), Arithmetic average, Keep all the event markers.<
><
> {{attachment:average_folder.gif||height="576",width="561"}} * You get two new files for each average, each one computed from 39 trials: <
><
> {{attachment:average_files.gif||height="223",width="247"}} == Process options: Average == Description of all the options of the process: * '''Everything''': Averages all the files selected in Process1 together, creates only one file in output. * '''By subject''': Groups the files by subject (ignoring the folders), creates one file per subject. * '''By folder (subject average)''': Groups by subject and by folder, ignoring the trial groups. <
>In the current configuration, it would produce two files, one for each acquisition run. * '''By folder (grand average)''': Groups by folder, across the subjects. All the files located in folders with the same name would be averaged together, no matter in what subject they are. * '''By trial group (folder average)''': Groups by set of trials with the same name, separately for each folder and each subject. * '''By trial group (subject average)''': Groups by set of trials with the same name, for each subject. The separation in folders is ignored. In the current configuration, it would produce two files, one for "deviant" and one for "standard". * '''By trial group (grand average)''': Groups by set of trials with the same name, ignoring the classification by folder or subject. * '''Function''': Documented directly in the option panel. * '''Keep all the event markers''': If this option is selected, all the event markers that were available in all the individual trials are reported to the average file. It can be useful to check the relative position of the artifacts or the subject responses, or quickly detect some unwanted configuration such as a subject who would constantly blink immediately after a visual stimulus. == Visual exploration == The average response contains interesting information about the brain operations that occur shortly after the presentation of the stimulus. We can explore two dimensions: the '''location''' of the various brain regions involved in the sensory processing and the precise '''timing''' of their activation. Because these two types of information are of equal interest, we typically explore the recordings with two figures at the same time, one that shows all the signals in time, one that shows the spatial distribution at one instant. * Open the MEG recordings for the '''deviant average''' in '''Run#01''': double-click on the file. * In the Record tab: Select the "butterfly" view more (first button in the toolbar). * In the Filter tab: Add a '''low-pass filter''' at '''100Hz'''. * In the Record tab: Delete the "cardiac" event type, we are not interested by their distribution.<
><
> {{attachment:deviant_ts.gif||height="176",width="661"}} * This figure shows a typical clean evoked response, with a high signal-to-noise ratio. This represents the brain response to a simple auditory stimulation, the large peak around '''90ms''' probably corresponds to the main response in the primary auditory cortex. * The green line represents the global field power ('''GFP'''), ie the sum of the square of all the sensors at each time point. This measure is sometimes used to identify transient or stable states in ERP/ERF. * This is the response to the deviant beeps (clearly higher in pitch), for which the subject is supposed to press a button to indicate that he/she detected the target. These responses are represented with the "button" events, distributed between 350ms and the end of the file (many responses happened after 500ms). Because of the variability in the response times, we can already anticipate that we won't be able to study correctly the motor response from this average. For studying the activity in the motor area, we need to epoch the recordings again around the "button" events. Add a spatial view: * Open a 2D topography for the same file (right-click on the figure > View topography, or Ctrl+T). * Review the average '''as a movie''' with the keyboard shortcuts (hold the left or right arrow key). * At '''90ms''', we can observe a typical topography for a bilateral auditory response. Both on the left sensors and the right sensors we observe field patterns which seem to indicate a dipolar-like activity in the temporal or central regions. <
><
> {{attachment:deviant_topo.gif||height="136",width="159"}} * Close everything with the button [X] in the top-right corner of the Brainstorm window. <
>Accept to save the modifications (you deleted the "cardiac" events). Repeat the same operations for '''Run#02''': * Open the MEG recordings. * Delete the "cardiac" markers. * The average is cleaner because it was computed from many more trials, but it also contains more unwanted things: a few blinks and probably an error from the subject. The "button" marker at 136ms is not supposed to be here. The task is so easy that we can probably assume that it is not a real detection error but rather a manipulation error, therefore it should not affect the cortical response in the very early stages of the stimulus processing, which is what we are exploring now. * Open a 2D topography and review the recordings. * Close everything. == Interpretation == Let's display the two conditions "'''standard'''" and "'''deviant'''" side-by-side, for '''Run#01'''. * Right-click on average > MEG > Display time series. * Right-click on average > MISC > Display time series (EEG electrodes Cz and Pz) * Right-click on average > MEG > 2D Sensor cap * In the Filter tab: add a '''low-pass filter''' at '''100Hz'''. * In the Record tab: you can set a common amplitude scale for all the figures with the button '''[=]'''. * Here are the results for the standard (top) and deviant (bottom) beeps: <
><
> {{attachment:average_summary.gif||height="371",width="663"}} The legend in blue shows names often used in the EEG ERP literature: * '''P50''': 50ms, bilateral auditory response in both conditions. * '''N100''': 95ms, bilateral auditory response in both conditions. * '''MMN''': 230ms, mismatch negativity in the deviant condition only (detection of an abnormality). * '''P200''': 170ms, in both conditions but much stronger in the standard condition. * '''P300''': 300ms, deviant condition only (decision making in preparation of the button press). * Some seem to have a direct correspondance in MEG (N100) some don't (P300). <> == Averaging across runs == As said previously, it is usually not recommended to average recordings in sensor space across multiple acquisition runs because the subject might have moved between the sessions. Different head positions were recorded for each run, we will reconstruct the sources separately for each each run to take into account these movements. However, in the case of event-related studies it makes sense to start our data exploration with an average across runs, just to evaluate the quality of the evoked responses. We have seen in tutorial #4 that the subject almost didn't move between the two runs, so the error would be minimal. . {{http://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile?action=AttachFile&do=get&target=channel_multiple.gif|channel_multiple.gif|height="218",width="438",class="attachment"}} Let's compute an approximate average across runs. We will run a formal average in source space later. * To run again the same process with different parameters: '''File > Reload last pipeline'''. Select: * '''By trial group (subject average)''': It will compute one average per experimental condition. * '''Arithmetic average + Standard error''': It will save in the same file the average and the standard error across all the trials. Illustrated in the next section. * '''Keep all the event markers''': Do not select this option, we've already seen what it does. * The two files that are created are now saved in a new folder "'''Intra-subject'''". This is where all the results of processes involving multiple folders within one subject will be saved.<
><
> {{attachment:average_stderror.gif||height="184",width="219"}} <> == Standard error == If you computed the '''standard deviation''' or the '''standard deviation''' together with an average, it will be automatically represented in the time series figures. * Double-click on one of the AvgStderr files to display the MEG sensors.<
>The light-grey area around the sensors represent the maximum standard error around the maximum and minimum values across all the sensors. * Select two sensors and plot them separately (right-click > Channels > View selected, or "Enter").<
>The green and red areas represent at each time point the standard error around the signal.<
><
> {{attachment:stderror.gif||height="176",width="379"}} * Right-click on the file > '''File > View file contents'''. <
>The average is saved in the field '''F''', the standard error is saved in the field '''Std'''.<
><
> {{attachment:stderror_file.gif||height="230",width="396"}} <)>> <> <>