[Eeglablist] Re-referrence to average and add Cz back

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Thu Apr 7 14:47:56 PDT 2016


Hello Fang-yu, Some notes are listed below I hope they are useful. All the
best.





***********

If you haven't had a chance to, please try googling the eeglab list for
past useful discussions about your channel topic.

One can create a new channel and/or modify the labels within the EGI
channel locations file or within eeglab. There's an example code snippet
below you can modify and try. It takes a file that has 128 channels (after
import from .raw EGI files with reference channel included) and saves out a
129th interpolated channel at the Cz location. Using the gui or scripts,
one needs to create a new channel or modify the Cz channel information (in
Edit>Channel Locations) to be a real channel, and then interpolate via
method of choice. The code below needs an EGI channel locations text file
where the Cz label on the last line is changed to E129. It's also a good
idea to double-check and formally select which EGI channel locations file
to use, as eeglab may not select the correct one.  Review of EEG.chanlocs
and EEG.urchanlocs in the eeglab data structure may also be useful, they
are modified in the code snippet below. If you find a good solution please
let other egi/eeglab users on the list know.  Last, with the new file
format from EGI (mmf or mff) this may no longer be any issue.

***********






thenameOfYourCurrenFile = NAMEOFYOURFILE.set' ; %this should be the name of
a file that has 128 channels from -eeg data you have.

thenameofthe129ChanFiletobeLoaded = 'GSN-HydroCel-129_cz_as_E129.sfp'; %this
file should be in current directory, it is included in the email with this
code

%this file is the same text file except Cz is renamed to E129 within the
text file on the last line.

directoryoffilethathas129ChannelFiletobeLoaded = cd;

currentdirectory = cd;

pathofyour129chanlocationsfile = cd;

filenameandpathofyour129channellocationsfile =
[pathofyour129chanlocationsfile filesep thenameofthe129ChanFiletobeLoaded]

NameofnewfileToBeSavedoutwithCz = [EEG.filename(1:end-4) '_withCz'];


STUDY = []; CURRENTSTUDY = 0; ALLEEG = []; EEG=[]; CURRENTSET=[]; %empties
memory

EEG = pop_loadset('filename',thenameOfYourCurrenFile,'filepath',currentdirectory);
%loads a 128 channel eeg file that needs an interpolated Cz

[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 ); %checks eeglab and
stores current file

EEG.data(end+1,:) = 0; EEG.nbchan = size(EEG.data,1); %creates new empty
row of time in EEG data

if ~isempty(EEG.chanlocs);  EEG.chanlocs(end+1).label = 'E129'; end; %creates
new chanloc row

if ~isempty(EEG.urchanlocs);    EEG.urchanlocs(end+1).label =
'E129';end; %creates
new urchanloc row

[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET); eeglab redraw

EEG.chanlocs(129).labels = 'E129'; EEG.chanlocs(129).Y =
0;EEG.chanlocs(129).X = 5.4492e-16; %changes info in chanlocs, but not in
urchanlocs

EEG.chanlocs(129).Z = 8.8992;EEG.chanlocs(129).sph_theta =
0;EEG.chanlocs(129).sph_phi = 90;%changes info in chanlocs, but not in
urchanlocs

EEG.chanlocs(129).sph_radius = 8.8992;EEG.chanlocs(129).theta =
0;EEG.chanlocs(129).radius = 0;%changes info in chanlocs, but not in
urchanlocs

EEG.chanlocs(129).type = '';EEG.chanlocs(129).ref = '';EEG.chanlocs(129).urchan
= 129;

%sets it to 132 automatically%changes info in chanlocs, but not in
urchanlocs


eeglab redraw


%loads the extra Cz information into channel 129

EEG=pop_chanedit(EEG, 'load',{filenameandpathofyour129channellocationsfile
'filetype' 'autodetect'});

[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); EEG = eeg_checkset( EEG
); eeglab redraw

%interpolates channel 129 using eeglab pop_interp function and spherical
option

EEG = pop_interp(EEG, [129], 'spherical');

[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); EEG = eeg_checkset( EEG
); eeglab redraw

EEG = pop_editset(EEG, 'setname',   NameofnewfileToBeSavedoutwithCz);

EEG = pop_saveset( EEG,'filename',   NameofnewfileToBeSavedoutwithCz,
'filepath', cd );

[ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, CURRENTSET); EEG =
eeg_checkset( EEG ); eeglab redraw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20160407/6aff0cb0/attachment.html>


More information about the eeglablist mailing list