[Eeglablist] concatenate .set files

Thomas Ferree tom.ferree at gmail.com
Fri Jan 25 09:39:47 PST 2008


Darren,
Below please find a simple function that concatenates two EEG
data structures across epochs.  If you have more than two data
structures, you could use this function first to combine 1 and 2,
then combine that result with 3, etc.
Best, Tom.

-- 
Thomas Ferree, PhD
Department of Radiology
UT Southwestern Medical Center
Email: tom.ferree at gmail.com
Voice: (214) 648-9767

--------------------------------------------------------------------------------------------------

function EEG = EEG_combine(EEG1,EEG2)

% function EEG = EEG_combine(EEG1,EEG2)
% Combines two EEG data sets by concatenating across trials.
% Thomas Ferree
% Created 9/19/2007

% error catching
if EEG1.pnts ~= EEG2.pnts
    error('Number of time points must be equal.');
end
if EEG1.nbchan ~= EEG2.nbchan
    error('Number of channels must be equal.');
end
if EEG1.xmin ~= EEG2.xmin
    error('Starting times must be equal.');
end

display(['Combining ' EEG1.setname ' and ' EEG2.setname '.']);

EEG = EEG1;
EEG.trials = EEG1.trials + EEG2.trials;
EEG.data = zeros(EEG.nbchan,EEG.pnts,EEG.trials);
EEG.data(:,:,1:EEG1.trials) = EEG1.data;
EEG.data(:,:,EEG1.trials+1:EEG.trials) = EEG2.data;



More information about the eeglablist mailing list