| REREF | Convert common reference EEG data to some other common reference or to average reference |
| Usage: | >> Dataout = reref(data); % convert all channels to average reference >> [Dataout Chanlocs Wout Sout meandata] = reref(data, refchan, 'key', 'val'); % convert data to new reference with options |
| Inputs: | |
data |
2-D data matrix (chans,frames*epochs) |
| refchan - reference channel number(s). There are two possibilities: | 1) [] - if data state (see 'refstate' below) is 'common', compute average reference, otherwise convert from average reference. 2) [1 <= num(s) <= size(data,1)]: re-reference to channel num(s). If the 'withref' method (below) is used, compute the previous common reference channel as well. |
| Optional inputs: | |
'elocs' |
Current data electrode location structure (e.g., EEG.chanlocs). |
'icaweights' |
ICA weight matrix. Note: If this is ICA weights*sphere, then the 'icasphere' input below should be [] or identity. |
'icasphere' |
ICA sphere matrix (if any) |
'icachansind' |
Indices of the channels used in ICA decomposition |
'method' |
['standard'|'withref'] Do not ('standard') or do ('withref') include reference channel data in output {def: 'standard'}. |
| Note: | Option 'withref' not possible when multiple ref channel indices are given as argument to 'refstate' (below). 'refstate ' - ['common'|'averef'|[indices]] Current reference condition, |
('averef') |
average reference; ('common' or 0) = common reference. [indices] designate the current reference channel or channels if present in the data {default: 'common'} |
'refloc' |
Reference channel location {'label' theta radius} cell array containing the name and polar coordinates of the channel. If only 3-D coordinates are available, include the reference channel location as the last channel in the 'elocs' structure. |
'exclude' |
[integer array] channel indices to exclude from re-referencing (e.g., event marker channels, etc.) |
'keepref' |
['on'|'off'] keep reference channel in output (only usable when there are several references). |
| Outputs: | |
Dataout |
Input data converted to the new reference |
Chanlocs |
Updated channel locations structure |
Wout |
ICA weight matrix (former icaweights*icasphere) converted to new data reference |
Sout |
ICA sphere matrix converted to an identity matrix |
ICAinds |
New indices of channels used in ICA decomposition |
meandata |
(1,dataframes) means removed from each data point |
| Notes: | 1) The average reference calculation implements two methods (see www.egi.com/Technotes/AverageReference.pdf) |
V'i |
(Vi-Vref) - sum(Vi-Vref)/number_of_electrodes 2) In conversion of the weight matrix to a new reference where WS = Wts*Sph and ica_act = WS*data, then |
data |
inv(WS)*ica_act; If R*data are the re-referenced data, R*data= R*inv(WS)*ica_act; And Wout = inv(R*inv(WS)); Now, Sout = eye(length(ICAinds)); The re-referenced ICA component maps are now the columns of inv(Wout), and the icasphere matrix, Sout, is an identity matrix. Note: inv() -> pinv() when PCA dimension reduction is used during ICA decomposition. |
| Authors: | Arnaud Delorme & Scott Makeig, SCCN/INC/UCSD, La Jolla, 1999-2002 |