[Eeglablist] online reference

Andreas Widmann widmann at uni-leipzig.de
Wed May 13 03:45:53 PDT 2015


> bug submitted.
The problem(s) you reported in your last post are actually unrelated to the initial bug:
In the channel location file submitted with the bug report you define the Nz-channel as „fiducial“ (allchanlocs(61).type = 'FID‘). This is not a valid data channel type, thus, eeg_checkset  removes it from the chanlocs structure and you end up with inconsistent numbers of channels in data and chanlocs.

If you clear the type field of your Nz channel, e.g.
allchanlocs(61).type = [];
after loading the channel locations both workarounds do work (see below).

Please update the bug report with a corrected channel locations file to avoid a confusion of the different problems.
Hope this helps,
Andreas

%% Version 1

%load
EEG=pop_loadset('sixty_channel_data.set');
load chanlocs.mat
allchanlocs(61).type = [];

% locations
chanlocs_active=allchanlocs(1:60); %sixty active channels
ref=allchanlocs(61) % implicit reference (Nz/forehead) 

%assign locations to active chans
EEG.chanlocs=chanlocs_active
eeg_checkset(EEG)

% Append Nz channel
EEG = pop_chanedit(EEG,  'append', 60, 'changefield', {61 'labels' 'Nz'});
ref.ref = [];
ref.urchan = [];

%rereference to average mastoids [59-60] while keeping both and
%reconstructing forehead electrode
EEG=pop_reref(EEG,[59 60],'keepref','on','refloc',ref);

%% Version 2

EEG=pop_loadset('sixty_channel_data.set');
load chanlocs.mat
allchanlocs(61).type = [];

EEG.data(EEG.nbchan + 1, :) = zeros(1, EEG.pnts); % Append implicit reference
EEG.nbchan = EEG.nbchan + 1;
EEG.data = EEG.data - repmat(mean(EEG.data(59:60, :), 1), [EEG.nbchan 1]); % Re-reference
EEG.chanlocs=allchanlocs; % 61 channel location struct;

EEG=eeg_checkset(EEG)

> On Tue, May 12, 2015 at 5:26 AM, Andreas Widmann <widmann at uni-leipzig.de> wrote:
> > your first suggestion does not work:
> My first suggestion included: "Your chanlocs_ref structure used for re-referencing must have the same fields as the EEG.chanlocs structure. In case fields are missing you have to add them manually and fill with empty values.“ E.g.,
> ref.ref = [];
> and likely also
> ref.urchan = [];
> 
> > EEG = pop_chanedit(EEG,  'append‘, 60, 'changefield‘, {61 'labels‘ 'ref.abel'});
> Actually indeed any string can be used for the channel label even 'ref.abel‘. Intended use was to use the label of the implicit reference, e.g. 'Fz‘. Only if use the same label as in the ref-structure for pop_reref it will be automatically removed from the chaninfo.nodatchans structure during re-referencing. Remove manually otherwise.
> 
> > EEG=pop_reref(EEG,[59 60],'keepref','on','refloc',ref);
> >
> > Reference to non-existent field 'ref'.
> >
> > Error in getfield (line 36)
> >     f = s.(deblank(strField)); % deblank field name
> >
> > Error in reref (line 155)
> >                     g.elocs(end) = setfield(g.elocs(end), fieldloc{ind}, getfield(g.refloc(iLocs), fieldloc{ind}));
> >
> > Error in pop_reref (line 189)
> > [EEG.data EEG.chanlocs refchan ] = reref(EEG.data, ref, optionscall{:});
> >
> > line 155 of reref is expecting a "ref" field that doesn't exist.
> >
> > so I went for your alternative:
> >
> > EEG.data(EEG.nbchan + 1, :) = zeros(1, EEG.pnts); % Append implicit reference
> > EEG.nbchan = EEG.nbchan + 1;
> > EEG.data = EEG.data - repmat(mean(EEG.data(59:60, :), 1), [EEG.nbchan 1]); % Re-reference
> > EEG.chanlocs=allchanlocs; %61 channel location struct;
> > but if I then call:
> >
> > EEG=eeg_checkset(EEG);
> I cannot replicate the problem. Same code works here. Please, double check that allchanlocs is a valid chanlocs structure of length 61 and EEG.nbchan is 61 and size(EEG.data, 1) is 61. EEGLAB version?
> 
> Best,
> Andreas
> 
> >
> > I still get:
> >
> > Warning: the size of the channel location structure does not match with
> >
> >          number of channels. Channel information have been removed.
> >
> > looks like EEG.chaninfo and EEG.chanlocs must match on certain aspects to get everything going.
> >
> > almost there? :)
> >
> > Roy
> >
> >
> >
> >
> >
> > On Sat, May 9, 2015 at 2:36 AM, Andreas Widmann <widmann at uni-leipzig.de> wrote:
> > > (I might submit a bug report later on, but I'm hoping for a faster solution.)
> > Ok, fastest solution is to manually re-reference on the command line:
> >
> > EEG.data(EEG.nbchan + 1, :) = zeros(1, EEG.pnts); % Append implicit reference
> > EEG.nbchan = EEG.nbchan + 1;
> > EEG.data = EEG.data - repmat(mean(EEG.data(59:60, :), 1), [EEG.nbchan 1]); % Re-reference
> >
> > And adjust the EEG.chanlocs structure.
> > Please file a bug report anyway as also others might tap into that problem.
> > Andreas
> >
> > > Am 08.05.2015 um 19:23 schrieb Roy Cox <roycox.roycox at gmail.com>:
> > >
> > > Thanks for the clear explanation Andreas.
> > >
> > > Unfortunately, pop_chanedit only gets me into deeper trouble.
> > >
> > > %split into active and ref locs
> > >
> > > chanlocs_active=allchanlocs(1:60);
> > >
> > > ref=allchanlocs(61);
> > >
> > >
> > >
> > > %read in 63 channel EDF and remove eyes and emg
> > >
> > > EEG=pop_biosig(fullfile(subjectFolder,dataFile),'importevent','off');
> > >
> > > EEG=pop_select(EEG,'nochannel',[1 2 63]);  #60 chans now
> > >
> > >
> > >
> > >
> > > EEG.chanlocs=chanlocs_active;
> > >
> > >
> > >
> > > I crash when I now call:
> > >
> > > EEG=pop_chanedit(EEG,'append',{60,ref.labels,ref.theta,ref.radius,ref.X,ref.Y,ref.Z,ref.sph_theta,ref.sph_phi,ref.sph_radius});
> > >
> > >
> > >
> > > Error using pop_chanedit (line 601)
> > >
> > > pop_chanedit: not enough arguments to change all field values
> > >
> > >
> > >
> > > the reason seems to be that the ref structure (with 10 fields) ends up as a 10 element cell in pop_chanedit, where the allfields variable has 13 elements, including 'datachan', 'ref', and 'urchan'. But I never set these other fields for the other channels.
> > >
> > >
> > >
> > > I also tried:
> > >
> > > EEG=pop_chanedit(EEG,'append',60,'changefield',{61,'labels', ref.labels,'theta', ref.theta, 'radius',ref.radius,...
> > >
> > >
> > >     'X',ref.X,'Y',ref.Y,'Z',ref.Z,'sph_theta',ref.sph_theta,'sph_phi',ref.sph_phi,'sph_radius',ref.sph_radius});
> > >
> > >
> > >
> > > but: Wrong channel structure size, changes ignored
> > >
> > >
> > >
> > > Finally, I also tried:
> > >
> > > EEG.chaninfo.nodatchans=ref;
> > >
> > >
> > > EEG=pop_reref(EEG,[59 60],'keepref','on','refloc',ref);
> > >
> > >
> > >
> > > which actually results in a 61 channel EEG struct, but I get a warning:
> > >
> > > Warning: the size of the channel location structure does not match with
> > >
> > >          number of channels. Channel information have been removed.
> > >
> > >
> > >
> > > Now, EEG.chanlocs is empty so I don't want to assume everything went according to plan and I can just re-attach my 61-channel location struct. If someone knows what chaninfo.nodatachans is supposed to look like that might help.
> > >
> > >
> > >
> > > (I might submit a bug report later on, but I'm hoping for a faster solution.)
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Fri, May 8, 2015 at 6:37 AM, Andreas Widmann <widmann at uni-leipzig.de> wrote:
> > > Hi Roy,
> > >
> > > this is presumably a bug. I suggest reporting to the bugtracker. From GUI perspective it might be considered as unintended use of the function but it should actually work.
> > >
> > > In the GUI you can only select a channel for the 'refloc'-option if it was appended before in the channel editor and appears in the EEG.chaninfo.nodatchans structure. pop_reref tries to remove the channel from this structure after re-referencing (as it is a data channel now). In your case there is no such structure and pop_reref crashes.
> > >
> > > Temporary workaround is to append the channel first from the command line before re-referencing:
> > > EEG = pop_chanedit(EEG,  'append‘, 60, 'changefield‘, {61 'labels‘ 'YourLabel'});
> > >
> > > Hope this helps,
> > > Andreas
> > >
> > > > Am 07.05.2015 um 20:32 schrieb Roy Cox <roycox.roycox at gmail.com>:
> > > >
> > > > hi all,
> > > >
> > > > (apologies for possibly sending this twice)
> > > >
> > > > saw this discussion and I'm trying to do something similar from the command line, but no luck.
> > > >
> > > > I import 63 channel data that I know to be referenced to the forehead. then I remove 3 EOG and EMG channels (60 remaining).
> > > >
> > > > I've created a 61 channel electrode location file, that I read in and separate into the first 60 "active" locations and the 61st ref/forehead location. I assign the 60 channel locations to my EEG, and then want to rereference to average mastoids, while keeping both mastoid channels and reconstructing the forehead channel. I've tried a couple of things, calling both pop_reref and reref. I'm sure there's a simple solution but can't get it to work. the code to my latest attempt:
> > > >
> > > > %read in electrode locations
> > > > allchanlocs=readlocs(electrodeFile,'filetype','custom','format',{'labels' 'X' 'Y' 'Z'});
> > > >
> > > >
> > > > %split into active and ref locs
> > > >
> > > > chanlocs_active=allchanlocs(1:60);
> > > >
> > > > chanlocs_ref=allchanlocs(61);
> > > >
> > > >
> > > > %read in 63 channel EDF and remove eyes and emg
> > > >
> > > > EEG=pop_biosig(fullfile(subjectFolder,dataFile),'importevent','off');
> > > >
> > > > EEG=pop_select(EEG,'nochannel',[1 2 63]);
> > > >
> > > > EEG.chanlocs=chanlocs_active;
> > > >
> > > > EEG=eeg_checkset(EEG)  ##STILL OK
> > > >
> > > >
> > > > %rereference to average mastoids
> > > >
> > > > EEG=pop_reref(EEG,[59 60],'keepref','on','refloc',chanlocs_ref);
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > this now crashes like this:
> > > >
> > > >
> > > >
> > > > Attempt to reference field of non-structure array.
> > > >
> > > >
> > > >
> > > > Error in pop_reref (line 215)
> > > >
> > > >          allinds = [allinds strmatch( g.refloc(iElec).labels, { tmpchaninfo.nodatchans.labels }) ];
> > > >
> > > >
> > > >
> > > > thanks for any input,
> > > >
> > > >
> > > >
> > > > Roy
> > > >
> > > >
> > > > On Thu, May 7, 2015 at 2:30 PM, Roy Cox <r.cox at uva.nl> wrote:
> > > > hi all,
> > > >
> > > > saw this discussion and I'm trying to do something similar from the command line, but no luck.
> > > >
> > > > I import 63 channel data that I know to be referenced to the forehead. then I remove 3 EOG and EMG channels (60 remaining).
> > > >
> > > > I've created a 61 channel electrode location file, that I read in and separate into the first 60 "active" locations and the 61st ref/forehead location. I assign the 60 channel locations to my EEG, and then want to rereference to average mastoids, while keeping both mastoid channels and reconstructing the forehead channel. I've tried a couple of things, calling both pop_reref and reref. I'm sure there's a simple solution but can't get it to work. the code to my latest attempt:
> > > >
> > > > %read in electrode locations
> > > > allchanlocs=readlocs(electrodeFile,'filetype','custom','format',{'labels' 'X' 'Y' 'Z'});
> > > >
> > > >
> > > > %split into active and ref locs
> > > >
> > > > chanlocs_active=allchanlocs(1:60);
> > > >
> > > > chanlocs_ref=allchanlocs(61);
> > > >
> > > >
> > > > %read in 63 channel EDF and remove eyes and emg
> > > >
> > > > EEG=pop_biosig(fullfile(subjectFolder,dataFile),'importevent','off');
> > > >
> > > > EEG=pop_select(EEG,'nochannel',[1 2 63]);
> > > >
> > > > EEG.chanlocs=chanlocs_active;
> > > >
> > > > EEG=eeg_checkset(EEG)  ##STILL OK
> > > >
> > > >
> > > > %rereference to average mastoids
> > > >
> > > > EEG=pop_reref(EEG,[59 60],'keepref','on','refloc',chanlocs_ref);
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > this now crashes like this:
> > > >
> > > >
> > > >
> > > > Attempt to reference field of non-structure array.
> > > >
> > > >
> > > >
> > > > Error in pop_reref (line 215)
> > > >
> > > >          allinds = [allinds strmatch( g.refloc(iElec).labels, { tmpchaninfo.nodatchans.labels }) ];
> > > >
> > > >
> > > > On Tue, Apr 28, 2015 at 5:36 AM, Dezhong Yao <dyao at uestc.edu.cn> wrote:
> > > >  Hi, all reference-issue followers;
> > > >   Physically,  "add current reference channel back to data" actually adds a channel with zero potential to current configuration,
> > > > then you may re-reference to any other configuration, such average, linked ears reference.
> > > > The best re-reference is  the  "zero reference" realized  by "REST" (reference electrode standardization technique) at www.neuro.uestc.edu.cn/rest , where free-software is available,
> > > > and it may interpolate bad channel the same time.
> > > >     Best wishes
> > > > ------------------
> > > > Dezhong Yao  PhD
> > > > Cheung Kong Professor of Neuroengineering, Neuroimaging
> > > > E-mail: dyao at uestc.edu.cn
> > > > Fax: 86-28-83208238; Tel: 86-28-83201018
> > > > Director, Key Laboratory for NeuroInformation,  Ministry of Education, China
> > > >               International Joint Research Center for NeuroInformation, Ministry of Science and Technology, China
> > > > Dean,      School of Life Science and Technology, University of Electronic Science and Technology of China, Sichuan,Chengdu 610054, China
> > > > Director,  Center for Information in BioMedicine, University of Electronic Science and Technology of China, China
> > > > http://www.neuro.uestc.edu.cn/bci/member/yao/yao.html
> > > > 2015-04-28
> > > > -------------------------------------------------------------
> > > > 发件人:Brittany Alperin
> > > > 发送日期:2015-04-28 14:04:07
> > > > 收件人:Andreas Widmann
> > > > 抄送:EEGLAB List
> > > > 主题:Re: [Eeglablist] online reference
> > > >
> > > > Hi Andreas
> > > >
> > > > You're right. I forgot that compute average reference is automatically
> > > > checked, so I was looking at the data with the average reference instead of
> > > > a Cz reference.
> > > >
> > > > I think I have this all cleared up now. Thanks for the help!
> > > >
> > > > Brittany
> > > >
> > > > On Sat, Apr 25, 2015 at 9:17 AM, Andreas Widmann <widmann at uni-leipzig.de>
> > > > wrote:
> > > >
> > > > > > To clarify, I have 31 channels + ref (Cz) + ground. So 33 in total.
> > > > > Good!
> > > > >
> > > > > > I added Cz to my channel locations and selected "add current reference
> > > > > channel back to data" without re-referencing to anything else.
> > > > > Sorry, could you please clarify how you use the "add current reference
> > > > > channel back to data“-option *without* actually re-referencing? To my
> > > > > understanding this should be impossible. Either the „Compute average
> > > > > reference“ or the „Re-reference data to channel(s)“-option is always
> > > > > selected in the pop_reref GUI. In case „Compute average reference“ was
> > > > > selected, the data were re-referenced to the mean of all channels.
> > > > >
> > > > > > I can now see Cz, but it isn't a flat line. Am I incorrect in thinking
> > > > > that it should be totally flat?
> > > > > Without re-referencing the implicit reference should indeed be a flat
> > > > > line/zero.
> > > > >
> > > > > Hope this helps!
> > > > > Andreas
> > > > >
> > > > > > Thanks,
> > > > > > Brittany
> > > > > >
> > > > > > On Thu, Apr 23, 2015 at 5:29 AM, Andreas Widmann <widmann at uni-leipzig.de>
> > > > > wrote:
> > > > > > Hi Brittany,
> > > > > >
> > > > > > this sounds like two different problems:
> > > > > > If you record from 32 channels + Ref + Ground the imported file should
> > > > > have 32 channels (but not your Cz Ref channel). Please reconfirm that your
> > > > > Pycorder setup really records from 32 data channels (34 electrodes). In
> > > > > case there is really a channel missing, please, submit a bug report to the
> > > > > bugtracker including a short sample file.
> > > > > >
> > > > > > If you want to keep the implicit online reference (Cz) as a new channel
> > > > > after re-referencing the data to another channel you have to use the „Add
> > > > > current reference channel back to the data“-option (GUI; 'refloc‘ on
> > > > > command line). To use this option you have to first append a (Cz-) channel
> > > > > in the GUI channel editor (appearing in EEG.chaninfo.nodatchans) which you
> > > > > can subsequently select during re-referencing. The „new“ Cz-channel is the
> > > > > inverse of the channel the data were re-referenced to (now missing in the
> > > > > data or being flat if "Retain old reference channels in data“ was selected).
> > > > > >
> > > > > > Please note that the „Add current reference channel back to the
> > > > > data“-option should not be used for systems where common mode rejection is
> > > > > applied offline (e.g. Biosemi).
> > > > > >
> > > > > > Hope this helps,
> > > > > > Andreas
> > > > > >
> > > > > > > Am 22.04.2015 um 21:59 schrieb Brittany Alperin <balperin07 at gmail.com
> > > > > >:
> > > > > > >
> > > > > > > Hello
> > > > > > >
> > > > > > > I'm using a 32 channel brain vision system and am recording with
> > > > > PyCorder. When I import my data using the brain vision recorder plugin,
> > > > > only 31 channels are present. I'm recording with Cz as an online reference
> > > > > and Cz is the channel that is missing. I can re-reference, but Cz is still
> > > > > absent.
> > > > > > >
> > > > > > > Has anyone had an issue with recording with an online reference and
> > > > > not having that data import into EEGlab? Or does anyone have a different
> > > > > way to import brain vision data?
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Brittany
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > > > > To unsubscribe, send an empty email to
> > > > > eeglablist-unsubscribe at sccn.ucsd.edu
> > > > > > > For digest mode, send an email with the subject "set digest mime" to
> > > > > eeglablist-request at sccn.ucsd.edu
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > > _______________________________________________
> > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> > > > _______________________________________________
> > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> > > >
> > > >
> > >
> > >
> > > _______________________________________________
> > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> >
> >
> > _______________________________________________
> > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> 
> 



More information about the eeglablist mailing list