Contents
function [EEGout] = mg_eeg_interpol_spherical(EEGin,eloc)
% MG_EEG_INTERPOL_SPHERICAL - interpolate missing EEG channels using % spherical interpolation. % % [EEGout] = mg_eeg_interpol_spherical(EEGin,ELOC); % % INPUT: % EEGin - [struct] input EEGLAB dataset % ELOC - [struct] channel locations of the interpolated dataset % Note: Only recentered (see POP_CHANCENTER) monopolar EEG channels!!! % OUPUT: % EEGout - [struct] interpolated EEGLAB dataset % % Note: The output dataset is re-referenced to the common average of all EEG channels. % % See also: EEG_INTERP, POP_CHANCENTER. % Author: Maren Grigutsch, MPI CBS Leipzig % $Id: mg_eeg_interpol_spherical.m,v 1.1 2012/11/15 15:15:28 grigu Exp grigu $ % MODIFIED to not do average referencing -- muralir -- 02.03.2017 EEGout = EEGin; EEGout.data = double(EEGout.data);
Find channels to be interpolated.
badchan = setdiff({eloc.labels},{EEGin.chanlocs.labels}); % feedback message idx = match_str({eloc.labels},badchan); % sort channels w.r.t. to their order % of appearance in eloc badchan = {eloc(idx).labels}; fprintf('Interpolating %d channels: ',length(badchan)); cellfun(@(x) fprintf(' %s',x), badchan); fprintf('\n');
Find channels to be removed from the dataset.
nochan = setdiff({EEGin.chanlocs.labels},{eloc.labels}); if ~isempty(nochan), fprintf('Removing %d channels: ',length(nochan)); EEGout = pop_select(EEGout,'nochannel',nochan); end
Spherical interpolation using eeg_interp.
% % eloc = pop_chancenter(eloc,[]); % FIXme! % tmp = pop_reref(EEGout,[]); % force average reference of input data % EEGout = pop_interp(tmp,eloc,'spherical'); % spherical interpolation % EEGout = pop_reref(EEGout,[]); % force average reference of output data % clear tmp; EEGout = pop_interp(EEGout,eloc,'spherical'); % spherical interpolation EEGout.chaninfo.interpolated = badchan;