[Eeglablist] Need help converting common reference (Pz) to average reference using pop_reref()

Hamza Imtiaz hm477041 at dal.ca
Tue Aug 1 06:03:01 PDT 2023


Hello,

I am currently working on preprocessing EEG data, and I have encountered a challenge while trying to re-referencing data from common Pz reference to average reference. I would be grateful if you could assist me with this issue.

Following the EEGLAB tutorial (5b), I have tried to retain the reference channel "Pz" using the code provided below:

% Add layout information
EEG = pop_chanedit(EEG, 'lookup', lookup_filepath, 'load', {channelloc_filepath, 'filetype', 'autodetect'});
EEG = eeg_checkset(EEG);

% Change reference to Pz
[EEG.chanlocs.ref] = deal('Pz');

% Append Pz
EEG = pop_chanedit(EEG, 'append', 18, 'changefield',{19 'labels' 'Pz'},...
    'changefield',{19 'type' 'REF'}, 'changefield',{19 'theta' '180'}, 'changefield',{19 'radius' '.256'},...
    'changefield',{19 'X' '-0.719'}, 'changefield',{19 'Y' '0'}, 'changefield',{19 'Z' '.695'},...
    'changefield',{19 'sph_theta' '-180'}, 'changefield',{19 'sph_phi' '44'}, 'changefield',{19 'sph_radius' '1'},...
    'changefield',{19 'urchan' '1'});

% Rereference to Pz
EEG = pop_reref(EEG, [],'refloc',struct('labels',{'Pz'},'type',{'REF'},...
        'theta',{180},'radius',{.256},'X',{-0.719},'Y',{0},...
        'Z',{.695},'sph_theta',{-180},'sph_phi',{44},'sph_radius',...
        {1},'urchan',{1},'ref',{''},'datachan',{0}));


Unfortunately, running this code generates an error message:
Error using pop_reref
Missing reference channel information. Edit channels and add reference first.

Thank you all in advance for your time and support.

Best regards,
Hamza Imtiaz



More information about the eeglablist mailing list