[Eeglablist] Error in deprecated EEG.ref flag value

Johnson, John T. john.johnson at gatech.edu
Sat Jun 19 06:00:27 PDT 2021


This sounds like a good opportunity to encapsulate that implementation detail by using getter and setter functions. Future changes/fixes then only need attention in those two functions. For example is_average_ref(EEG) would return true or false. Similarly, EEG = set_average_ref(EEG, true) would handle the details of changing the EEG struct.

This would help readability of other code too. Rather than:

if ~strcmp(EEG.ref, 'average’) % why am I comparing a string again?

becomes

if ~is_average_ref(EEG) % okay, I’m checking if it’s an average ref...

Similarly,

if ~strcmp(EEG.ref, ‘Average’)

does not become an insidious, "presentation tomorrow code is broken" bug.

Regards,
John

John T. Johnson
PhD Candidate - Cognitive Motor Control Laboratory
School of Biological Sciences
Georgia Institute of Technology
678-575-2093
john.johnson at gatech.edu<mailto:john.johnson at gatech.edu>
he/him/his


On Jun 18, 2021, at 1:24 PM, Curtis Bingham via eeglablist <eeglablist at sccn.ucsd.edu<mailto:eeglablist at sccn.ucsd.edu>> wrote:

Folks,



There is a persistent error in handling the flag for average referenced EEG data, stored in EEG.ref.

EEG.ref  is set to ‘average’ and a number of code segments are acting upon what appears to be a deprecated ‘averef’ value.



The file averef.m has the disclaimer at the top saying “Note that this old function is not being used in EEGLAB. The function used by EEGLAB is reref().”



The function reref() in file reref.m accepts a varargin key pair ‘averef’ but sets the elocs(x).ref field to ‘average’ on line 217 (and not ‘averef’).



This creates problems in ICL_feature_extractor.m on line 15 (called from iclabel), where it checks to see if you’re dealing with an average reference (EEG.ref = ‘averef’) and if not, it then unnecessarily rereferences the data by calling pop_reref() on line 16. The test in ICL_feature_extractor on line 15 should read “if ~strcmp(EEG.ref, 'average')” instead of “averef’.



A search for ‘averef’ in the EEGLAB distribution shows a number of hits, some using it as a varargin input, some actually erroneously setting EEG.ref to ‘averef’ (pop_biosig16.m:261), some correcting the deprecated value, etc.



It appears that eeg_checkset will correct this deprecated value on line 1039.



It shouldn’t be too much effort to go through and standardize the application of ‘average’ and put in a handful of try/catches to ensure none get through the cracks.



Curtis











_______________________________________________
Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu<mailto: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<mailto:eeglablist-request at sccn.ucsd.edu>



More information about the eeglablist mailing list