Published on *elan* (http://elan.lyon.inserm.fr)

*Description**Usage*- myeegfile.eeg : input EEG file to process (with extension).
- myposfile.pos : event position file.
- myparfile.par : parameter file, similar to that used for eegavg, but with some additional parameters.
- nb_drawings : number of drawings that are made to estimate the distribution of differences under the null hypothesis (example: 10000 drawings enables a resolution of p=0.0001).
*Fields of parameter file and example*- .p file of the p values of the randomization test computed between event codes 2 and 5 :

*myfilename.2-5.rand.p.p* - For the multiple-test correction across samples : list of the maximum number of successive significant samples n_max (or the minimum probability p_min) under the null hypothesis for each channel when eegranddiff_compute is set to 1 or 2 :

*myfilename.2-5.n_max.txt* - For the multiple-test correction : only p values included in a succession of samples that is above the

computed minimum number of significant samples (or smaller than the p_min value) are kept. The other samples are set to p=1 :

*myfilename.2-5.rand.mask.p.p*

Performs a statistical randomization test without replacement between k conditions from single-trials stored in an EEG file.

This programme creates a .rand.p.p file representing the probability values p that the events in k conditions are drawn from the same population of events* (the trials from the k conditions are shuffled and the distribution of an equivalent of the F statistic under the null hypothesis is estimated by randomly assigning trials to conditions), independently computed for each channel over each moving window. They can be viewed by erpa as curve plots.

* if the null hypothesis is rejected, assuming equivalence of the variances, it can further be concluded that the k types of events are drawn from k populations of events with different means.

Optionally, this program can take into account the number of samples of the window of analysis and correct for multiple tests in different ways:

- The minimum number of consecutive significant samples (at a given probability threshold proba_measure) appearing in permutations with a given probability threshold proba_compute is computed independently for each channel (i.e. the maximum number of significant samples appearing with a given probability under the null hypothesis).

- The maximum significance probability appearing in permutations with a given probability threshold proba_compute (i.e. the minimum significance probability appearing with a given probability under the null hypothesis) is computed across samples (i.e. independently for each channel) or accross channels and electrodes.

The output files for these options are 2 statistical .p files (uncorrected and corrected) and a .txt file including the correction value for each channel.

eegranddiff myeegfile.eeg myposfile.pos myparfile.par nb_drawings

with :

fileprefix myfilename | Prefix of the output .p files. |

nb_eventcode 2 | Number of event codes to process. |

list_eventcode 2 5 | List of the event codes to process. |

prestim_nbsample 400 400 | List of the numbers of samples in the prestimulus period; one value for each event code. |

poststim_nbsample 800 800 | List of the numbers of samples in the poststimulus period; one value for each event code; the total number of samples of the analysis is prestim_nbsample + poststim_nbsample + 1, the extra sample corresponds to the event itself |

ep_channel_flag 1 1 0 1 0 0 0 | List of the channels to average: 1/0 for selected/unselected channels; the total number of flags is N+2, N being the number of recorded channels in myeegfile.eeg file; the last 2 flags should be set to 0. In this example, N=5, and only channels number 1, 2, 4 will be averaged and stored in the output .p files. |

ep_channel_ref 0 5 0 6 0 0 0 | List of the new reference for each channel before averaging (bipolar montage for instance): 0: no change of the reference, ≠0: electrode number (rank) to which the current channel should be re-referenced. The total number of values is N+2, N being the number of recorded channels in myeegfile.eeg file; the last 2 flags should be set to 0. This field is optional. If omitted, the channels are not modified. In this example, N=5, and channel 1 is unchanged, channel 2 is referenced to channel 5, and channel 4 re-referenced to channel 6. |

eegranddiff_baseline_eventcode 2 2 | List of the event codes used to compute the baseline. 0: no baseline correction (default), ≠0: event code on which baseline will be computed. In this example, the baseline for event code 2 will be computed from event code 2, and the baseline of event code 5 from event code 2. Warning: the event-code should be chosen among those listed in list_eventcodes. This field is optional. |

eegranddiff_baseline_msec_start -300 -300 | List of the baseline start latencies (in ms); one value for each event code; required only if baseline_eventcode≠0. If omitted and baseline_eventcode≠0, the baseline value is computed on the whole epoch. |

eegranddiff_baseline_msec_stop -100 -100 | List of the baseline stop latencies (in ms); one value for each event code; required only if baseline_eventcode≠0. If omitted and baseline_eventcode≠0, the baseline value is computed on the whole epoch. |

eegranddiff_time_hw 200 200 200 | List of the time half-windows (in ms) by event code, used to defined the moving time-window on which statistical analysis will be performed. If omitted, no smoothing is applied and computation is performed on each time-sample. |

eegranddiff_time_step 50 50 50 | List of the time steps (in ms) by event code, used to defined the moving step of the moving time-window on which statistical analysis will be performed. If omitted, the time step is one sample. |

eegranddiff_measure 1 | Statistic on which the permutation test will be made : 1: Sum of squared sums of values by conditions (two-sided test) 2: Sum of values in the first condition (one-sided test), valid only if k=2 conditions. If omitted, default value is 1. |

eegranddiff_compute 1 | Choice for multiple test correction : 0: no multiple test correction 1: multiple test correction based on the maximum number of consecutive samples 2: multiple test correction based on the minimum significance across samples 3: same as 2 across samples and channels If omitted, default value is 0 (no correction). |

eegranddiff_proba_measure 0.05 | If eegrandiff_compute = 1, statistical probability threshold for the determination of significant samples. |

eegranddiff_proba_compute 0.05 | If eegrandiff_compute ≥ 1, statistical probability threshold for the computation of consecutive significant sample. |

eegranddiff_compute_msec_start 50 | If eegrandiff_compute ≥ 1, start latency (in msec) of the analysis window for the correction across samples. |

eegranddiff_compute_msec_stop 50 | If eegrandiff_compute ≥ 1, stop latency (in msec) of the analysis window for the correction across samples. |

erpa_positivity_up 1 | Value stored in all output .p file to set the default upward/downward positivity orientation for curve display (by erpa). -1 (positivity down) or 1 (positivity up) This field is optional. If omitted, erpa will display curve with positivity down. |

erpa_view 4 | Value stored in all output .p file. It is used by erpa to set the default mapping view. 1: right view 2: left view 3: top view 4: back view 5: large top view 6: back-top view This field is optional. If omitted, it is set to 0, and erpa default will be top view. |

In the example above, all trials with codes 2 and 5 will be processed on a time window ranging from 400 samples prior to 1000 samples after event code. The analysis will be performed on channels 1 (not re-referenced), 2 (re-referenced to channel 3),and 4 (re-referenced to channel 5). On each trial, the data are averaged over a moving window having 200 ms of half duration (total duration of 400 ms), moving by step of 50 ms, and with a baseline correction

defined between –300 and –100 ms.

Output :

- See eegchref [1] to create a re-referenced .eeg data file (several referencing options available).

2.13 15-04-2011

- 1.03 18-08-2005 (PEA) : 1st documented version. Adds a smoothing temporal window (eegrand_time_hw and eegrand_time_step parameters).
- 1.04 26-01-2006 (PEA) : minor modification.
- 1.05 20-06-2006 (PEA-JB) : fixes statistic (unilateral or bilateral with eegranddiff_measure parameter). Changes in loop for channels.
- 1.06 29-06-2006 (JB) : generalization for case 1 factor, k conditions (bilateral test).
- 1.07 29-06-2006 (PEA) : reads file if channel loop to limit memory usage.
- 2.01 30-06-2006 (JB) : adds multiple-test correction (eegranddiff_compute, eegranddiff_proba_compute and eegranddiff_proba_measure parameters).
- 2.02 01-07-2006 (JB) : fixes smoothing (compatible with eegstat).
- 2.03 04-07-2006 (JB) : fixes baseline correction.
- 2.04 05-07-2006 (JB) : adds compute_msec_start and compute_msec_stop to have independant analysis window and baseline window.
- 2.05 06-07-2006 (JB) : optimizes computing with copy of data out of permutations loop.
- 2.06 11-12-2006 (PEA) : fixes memory size.
- 2.07 12-12-2006 (PEA) : modifies decision for loading data to memory (if data size<= whole memory, not just available).
- 2.08 18-12-2006 (AC - JB) : fixes bilateral statistic : sum of square sum by condition must be weighted by the size. The statitic was wrong when the sizes were very different. Adds comparison for k > 2 conditions.
- 2.09 20-10-2009 (PEA) : changes for baseline parameters : baseline_eventcode, baseline_msec_start and baseline_msec_stop become eegranddiff_baseline_eventcode, eegranddiff_baseline_msec_start and eegranddiff_baseline_msec_stop.
- 2.10 21-10-2009 (PEA) : changes for parameter names : compute_msec_start and compute_msec_stop become eegranddiff_compute_msec_start and eegranddiff_compute_msec_stop.
- 2.11 26-10-2009 (PEA) : fixes reading of parameter eegranddiff_compute_msec_stop (only one value).
- 2.12 27-09-2010 (PEA) : update to use cmake and free release of Elan.
- 2.13 15-04-2011 (PEA) : changes Shell sort to Heap sort in FDR (faster algorithm).

$ELANPATH/bin/eegranddiff

eegrandadd [2], eegstat [3], eegavg [4], epranddiff [5], eegchref [6]

**Links:**

[1] http://elan.lyon.inserm.fr/?q=eegchref

[2] http://elan.lyon.inserm.fr/?q=eegrandadd

[3] http://elan.lyon.inserm.fr/?q=eegstat

[4] http://elan.lyon.inserm.fr/?q=eegavg

[5] http://elan.lyon.inserm.fr/?q=epranddiff

[6] http://elan.lyon.inserm.fr/?q=eechref