[Eeglablist] append channels to an existing set file

Matthias Moosmann moosmann at gmail.com
Tue Jul 1 05:01:36 PDT 2008


Hi Andreas!
Thanks for the answer. I found another approach which does the job
without going too deep into matlab fopen/fread issues. I post it here
in case someone else stumbles over the same problem. This solution
follows an earlier post by Arno Delorme ->
http://sccn.ucsd.edu/pipermail/eeglablist/2007/001776.html
%-------------------------------------------------
%% Do some analysis channel by channel
for ch=1:32 % Loop over channels
    % Load channel
    [EEG_temp, com] =
pop_loadbv(data.eeg_path,[data.eeg_filename,'.vhdr'],  1, ch);
    % Filter & Reasample data
    EEG_temp=pop_eegfilt( EEG_temp, 0, par.filter_lp, [], [0]);  % LP
    EEG_temp=pop_eegfilt( EEG_temp, par.filter_hp, 0, [], [0]); % HP
    EEG_ch{ch} = pop_resample( EEG_temp, par.downsampled_frq); % Resample
    clear EEG_temp
end

%% Merge channels
EEG = EEG_ch{1};
for ch=channels_to_correct(2:end)
    % Append data
    EEG.data(end+1: end+EEG_ch{ch}.nbchan,:) = EEG_ch{ch}.data;
    % Adjust EEG.nbchan
    EEG.nbchan=EEG.nbchan+EEG_ch{ch}.nbchan;
    % Append channel locations
    if ~isempty(EEG.chanlocs)
        EEG.chanlocs(end+1: end+EEG_ch{ch}.nbchan) = EEG_ch{ch}.chanlocs;
    end;
    EEG = eeg_checkset(EEG);
end
clear EEG_ch

%% Save dataset
EEG = pop_saveset(EEG,'filename',[data.eeg_filename,'_filtered']);

-- 
--
Matthias Moosmann, PhD
--
Department of Biological and Medical Psychology
University of Bergen
Jonas Lies vei 91
5009 Bergen - Norway



More information about the eeglablist mailing list