[Eeglablist] online reference

Andreas Widmann widmann at uni-leipzig.de
Fri May 8 13:04:07 PDT 2015


For the workaround it is only relevant that the EEG.chaninfo.nodatchans structure exists and has a 'labels‘ field. The code part where pop_reref crashes is only responsible for removing a possibly existing channel from this structure by matching the labels. So, you do not have to append all channel details/location information yet but just the label as in the example (I just reconfirmed that this works if EEG.chaninfo.nodatchans is empty; please check). 

EEG = pop_chanedit(EEG,  'append‘, 60, 'changefield‘, {61 'labels‘ 'YourRefChanLabel'});

You can add the channel details and location information later while re-referencing. 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.

Hope this helps,
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
> >
> >
> 
> 



More information about the eeglablist mailing list