|
| 1 | +# CARLA on its authors' data (ds004977) |
| 2 | + |
| 3 | +CARLA (common average referencing by least anticorrelation; Huang et al., 2024) chooses, for each stimulation site, |
| 4 | +the channels whose common average carries no evoked response. This page applies it through the iEEGLAB menus to the |
| 5 | +recording of the paper's Figure 5, with the authors' settings: sub-1 of OpenNeuro ds004977, stereo-EEG at 4800 Hz, |
| 6 | +stimulation site RMO8-RMO9. The authors' code puts 154 of 206 channels in the common average there; iEEGLAB chooses the |
| 7 | +same 154. The page then compares CARLA with the common average of every channel. |
| 8 | + |
| 9 | +Each step gives the menu, what you should get (*Expect*), and the same step from the command line. Install iEEGLAB |
| 10 | +first ([Installation](https://github.com/sccn/iEEGLAB#installation)). |
| 11 | + |
| 12 | +## Data |
| 13 | + |
| 14 | +Run 2 of sub-1, from OpenNeuro, with the [AWS command line](https://aws.amazon.com/cli/) (no account needed) or from |
| 15 | +[ds004977](https://openneuro.org/datasets/ds004977): 304 MB. Keep the folder structure. Reading it needs the **MEF3** |
| 16 | +plugin (**File > Manage EEGLAB extensions**). |
| 17 | + |
| 18 | +``` |
| 19 | +aws s3 sync --no-sign-request s3://openneuro.org/ds004977 ds004977 --exclude "*" --include "sub-1/ses-ieeg01/ieeg/*run-02*" --include "sub-1/ses-ieeg01/ieeg/*_electrodes.tsv" --include "sub-1/ses-ieeg01/ieeg/*_coordsystem.json" --include "dataset_description.json" --include "participants.tsv" --include "task-ccep_events.json" |
| 20 | +``` |
| 21 | + |
| 22 | +> **Note.** The public dataset holds only the samples behind the paper's Figures 1 to 6; the other samples are 0 (see |
| 23 | +> its README). In run 2, only the 12 pulses at RMO8-RMO9 have data: the other 9 sites import without an error but are |
| 24 | +> flat, so this page keeps RMO8-RMO9 only. The dataset has no pial surfaces (its FreeSurfer folder holds the T1 and |
| 25 | +> labels), so the page has no brain figure: **iEEGLAB > Visualize electrodes** would draw the contacts on a template |
| 26 | +> brain, which does not line up with these coordinates (ACPC, the participant's own space). |
| 27 | +
|
| 28 | +## Steps |
| 29 | + |
| 30 | +Steps 1 to 4 take about a minute on a Windows laptop with 8 cores. The recording takes under 3 GB of memory. |
| 31 | + |
| 32 | +### 1. Load the data |
| 33 | + |
| 34 | +**iEEGLAB > Import raw recording**: select the `ds004977` folder, then sub-1's run 2 |
| 35 | +(`sub-1_ses-ieeg01_task-ccep_run-02_ieeg.mefd`). Keep the defaults: the whole recording, brain channels only. |
| 36 | + |
| 37 | +> **Expect.** About 25 seconds, with the progress in the command window and a progress bar: 255 stereo-EEG channels |
| 38 | +> at 4800 Hz, 9 minutes. |
| 39 | +
|
| 40 | +> **Note.** *Read only these stimulation sites* (RMO8-RMO9) in the import options reads 44 seconds instead of |
| 41 | +> 9 minutes. The high-pass filter of step 3 then works on that stretch, which changes the covariance of a few channels |
| 42 | +> a little: CARLA still chooses 154 channels, but RP17 instead of RP14, its 154th and 155th channels. Read the whole |
| 43 | +> recording to reproduce the paper exactly. |
| 44 | +
|
| 45 | +```matlab |
| 46 | +rec = fullfile('ds004977', 'sub-1', 'ses-ieeg01', 'ieeg', 'sub-1_ses-ieeg01_task-ccep_run-02_ieeg.mefd'); |
| 47 | +EEG = ieeglab_import(rec); |
| 48 | +``` |
| 49 | + |
| 50 | +### 2. Coordinates and events |
| 51 | + |
| 52 | +**iEEGLAB > Load electrode coordinates and events**: Ok in both windows. The sidecar files next to the recording are |
| 53 | +found automatically; the event type is the stimulation site, and the contacts marked bad in `channels.tsv` are marked |
| 54 | +here and removed during preprocessing. |
| 55 | + |
| 56 | +> **Expect.** 228 of 255 contacts with coordinates, 43 bad (from `channels.tsv`), 120 stimulations at 10 sites. A |
| 57 | +> warning names the 27 contacts with no position in `electrodes.tsv`: 25 of them are bad, the other two are RP18 and |
| 58 | +> ROC14. |
| 59 | +
|
| 60 | +```matlab |
| 61 | +EEG = ieeglab_load(EEG, struct('event_field', 'electrical_stimulation_site')); |
| 62 | +``` |
| 63 | + |
| 64 | +### 3. Preprocess |
| 65 | + |
| 66 | +**iEEGLAB > Preprocess iEEG data**, with the settings of the authors' code: |
| 67 | + |
| 68 | +- *Choose which event types to analyse*: **Open selector**, RMO8-RMO9. |
| 69 | +- Untick *Remove electrodes with no XYZ coordinates*: RP18 and ROC14 are good contacts, and the authors keep them. |
| 70 | +- Untick *Blank the stimulation artifact*. |
| 71 | +- Tick *High-pass filter*, cutoff 0.5 Hz. |
| 72 | +- Untick *Remove line noise*: CARLA removes it from its own copy of the data before it ranks the channels, as the |
| 73 | + authors' code does; the re-referenced data keep it. |
| 74 | +- Untick *Remove the pre-stimulus baseline*. |
| 75 | +- Keep the rest: bad contacts removed, epochs -1 to 1 s. |
| 76 | + |
| 77 | +> **Expect.** About 20 seconds: 212 contacts, 12 epochs. |
| 78 | +
|
| 79 | +> **Note.** The authors high-pass with a Butterworth filter, iEEGLAB with a FIR filter (both zero-phase). The |
| 80 | +> channels chosen at step 4 are the same. |
| 81 | +
|
| 82 | +```matlab |
| 83 | +EEG = ieeglab_preprocess(EEG, struct('event_filters', struct('type', {{'RMO8-RMO9'}}), ... |
| 84 | + 'remove_no_coords', false, 'remove_bad_channels', true, 'apply_blank', false, ... |
| 85 | + 'apply_highpass', true, 'highpass', 0.5, 'apply_notch', false, ... |
| 86 | + 'apply_epoch', true, 'epoch_window', [-1000 1000], 'reject_trials', false, 'apply_baseline', false)); |
| 87 | +EEGpre = EEG; % kept for step 6 |
| 88 | +``` |
| 89 | + |
| 90 | +### 4. CARLA |
| 91 | + |
| 92 | +**iEEGLAB > iEEG re-referencing**: CARLA, defaults. They are the authors' settings for real data: a response window |
| 93 | +of 10 to 300 ms, the sensitive cutoff, and the stimulated pair with 2 contacts on each side of it left out, as the bad |
| 94 | +contacts. |
| 95 | + |
| 96 | +> **Expect.** About 10 seconds. The command window reads *154/212 channels in reference, 6 excluded* (RMO6 to RMO11): of |
| 97 | +> the 206 channels CARLA may use, it keeps 154, the same 154 as the authors' code (Huang et al., 2024, Figure 5). The |
| 98 | +> random draws use a fixed seed, so the result repeats from run to run. |
| 99 | +
|
| 100 | +```matlab |
| 101 | +EEG = pop_ieeglab_reref(EEG, 'method', 'carla'); |
| 102 | +``` |
| 103 | + |
| 104 | +### 5. The curve of Figure 5 |
| 105 | + |
| 106 | +From the command line. CARLA ranks the channels by their covariance across trials, lowest first, and adds them to |
| 107 | +the common average one at a time. For each number of channels, it re-references the data with that average and finds |
| 108 | +the channel of the average most anticorrelated with the re-referenced channels: a channel that carries a response |
| 109 | +becomes anticorrelated with the others once its response is in the average. The curve is that channel's correlation |
| 110 | +(Fisher z, the paper's zeta), averaged over 100 bootstrap draws of the trials. CARLA keeps the number of channels at |
| 111 | +the top of the curve, before the first significant drop (the sensitive cutoff). |
| 112 | + |
| 113 | +> **Expect.** The curve starts at -0.88 with 2 channels (1 channel has no value), rises to a plateau near -0.1 from |
| 114 | +> about 80 to 180 channels, peaks at -0.086 with 154 channels (the star), and falls to -0.29 with 200 channels and |
| 115 | +> -0.45 with all 206: the channels ranked last carry the response. |
| 116 | +
|
| 117 | +```matlab |
| 118 | +S = EEG.ieeglab.car.groups(1).stats; % CARLA's statistics for the site |
| 119 | +z = mean(S.zMinMean, 2); % one value per number of channels: mean of the 100 draws |
| 120 | +n = numel(S.chsUsed); % the number chosen |
| 121 | +figure; plot(z, 'k'); hold on; plot(n, z(n), 'p', 'MarkerSize', 14) |
| 122 | +xlabel('Channels in the common average'); ylabel('\zeta (Fisher z)') |
| 123 | +``` |
| 124 | + |
| 125 | +### 6. Common average, for comparison |
| 126 | + |
| 127 | +In EEGLAB's **Datasets** menu, select the dataset that preprocessing made (before CARLA). Then **iEEGLAB > iEEG |
| 128 | +re-referencing**: *Common average (all good channels)*, with 2 in *Also leave out N contacts on each side*, so that both averages leave |
| 129 | +out the same contacts. |
| 130 | + |
| 131 | +> **Expect.** 206 channels in the common average. Between 10 and 300 ms, its trial mean differs from CARLA's by up to |
| 132 | +> 23 uV, 134 ms after the pulse: the responses of the 52 channels that CARLA leaves out. |
| 133 | +
|
| 134 | +```matlab |
| 135 | +EEGcar = pop_ieeglab_reref(EEGpre, 'method', 'car', 'neighbors', 2); |
| 136 | +% the two common averages, trial mean |
| 137 | +G = EEG.ieeglab.car.groups(1); Gc = EEGcar.ieeglab.car.groups(1); |
| 138 | +avg = @(labels) mean(mean(EEGpre.data(ismember({EEGpre.chanlocs.labels}, labels), :, :), 3), 1); |
| 139 | +figure; plot(EEGpre.times, avg(Gc.reference) - avg(G.reference)); xlim([-100 500]) |
| 140 | +xlabel('Time (ms)'); ylabel('Common average minus CARLA''s (uV)') |
| 141 | +``` |
| 142 | + |
| 143 | +### 7. CCEP analysis of both |
| 144 | + |
| 145 | +**iEEGLAB > CCEP analysis**, defaults, once on the CARLA dataset and once on the common average dataset (select each |
| 146 | +in the **Datasets** menu). The response of each contact is described by the Canonical Response Parameterization (CRP; |
| 147 | +Miller et al., 2023), with a permutation test. |
| 148 | + |
| 149 | +> **Expect.** A few seconds each. After CARLA, 89 of the 210 contacts respond; after the common average, 148 do. The common average subtracts the responses it carries from every contact, which can make contacts |
| 150 | +> without a response of their own look responsive (Huang et al., 2024). |
| 151 | +
|
| 152 | +```matlab |
| 153 | +opt = struct('run_n1', false, 'run_crp', true, 'run_matrix', true, 'matrix_source', 'crp'); |
| 154 | +EEG = ieeglab_stats_subject(EEG, opt); |
| 155 | +EEGcar = ieeglab_stats_subject(EEGcar, opt); |
| 156 | +``` |
| 157 | + |
| 158 | +## Something differs? |
| 159 | + |
| 160 | +If a result differs from *Expect*, a step fails, or a window is unclear, please open an |
| 161 | +[issue](https://github.com/sccn/iEEGLAB/issues) with the message and the MATLAB command window, and the MATLAB and |
| 162 | +EEGLAB versions and operating system. |
| 163 | + |
| 164 | +## References |
| 165 | + |
| 166 | +- Huang, H., Ojeda Valencia, G., Gregg, N. M., Osman, G. M., Montoya, M. N., Worrell, G. A., Miller, K. J., & Hermes, |
| 167 | + D. (2024). CARLA: Adjusted common average referencing for cortico-cortical evoked potential data. *Journal of |
| 168 | + Neuroscience Methods, 407*, 110153. |
| 169 | +- Miller, K. J., Müller, K.-R., Ojeda Valencia, G., Huang, H., Gregg, N. M., Worrell, G. A., & Hermes, D. (2023). |
| 170 | + Canonical response parameterization: Quantifying the structure of responses to single-pulse intracranial electrical |
| 171 | + brain stimulation. *PLOS Computational Biology, 19*(5), e1011105. |
0 commit comments