[Mne_analysis] Averaging multiple event classes in mne_process_raw

sheraz at nmr.mgh.harvard.edu sheraz at nmr.mgh.harvard.edu
Thu Jun 16 10:44:11 EDT 2011
Search archives:

Hi Per,
It is very simple, copy matlab file below, and use it to create new event
file, it can merge the events you want. You can then use this new event
file for averaging. Code requires MNE matlab toolbox in the path.
Fell free if you have any questions.

Sheraz Khan
Martinos center

%---------------------------------------------------------------------------
function newfile=mergeEvents(eventfile,orignalevents,newevents)

% mergeEvents: Merge Event in the event file
%
% USAGE: newfile=mergeEvents(eventfile,orignalevents,newevents)
%
% INPUT:
%      eventfile = Orignal Event File
%      orignalevents= Structure containg orignal event you want to merge
%      newevents= Number of the new events
%  OUTPUT:
%      newfile= New Event file Name
%     Example Use
%     orignalevents{1}=[1 2 3];
%     orignalevents{2}=[4 5];
%     newevents(1)=[997]
%     newevents(2)=[998]
%
newfile=mergeEvents('Orignal_eventfile-eve.fif',orignalevents,newevents)
%     This code will merge events 1, 2 ,3 to event 997' and 4 , 5 to 998
%
% Author: Sheraz Khan, PhD
%         Martinos Center
%         MGH, Boston, USA
%         sheraz at nmr.mgh.harvard.edu
% --------------------------- Script History ------------------------------
% SK 19-Nov-2010  Creation
% -------------------------------------------------------------------------

if size(orignalevents,2)~=length(newevents)
    error('both need to be same')
end

[eventlist] = mne_read_events(eventfile);
eventlist_temp = eventlist;

for i=1:size(orignalevents,2)

events=orignalevents{i};
for j=1:length(events)
    eventlist(eventlist==events(j))=newevents(i);

end
end
eventlist=[eventlist_temp;eventlist];

temp = regexp(eventfile,'.fif');
name = eventfile(1:temp-1);
newfile=strcat(name,'_merg-eve','.fif');

mne_write_events(newfile,eventlist)

%---------------------------------------------------------------------------


> Hello All,
>
>     My apologies if this question has been posted before. I would like to
> create an average of the epochs from several different stimulus conditions
> in my experiment. Unfortunately I did not have the foresight to specify a
> single trigger bit that would achieve the desired combination, and the
> "ignore" mask will not serve either. (The decimal triggers, are 1, 4, 7,
> and
> 8, but I need to exclude 10.) The 2.7.3 manual mentions being able to
> include multiple events into an average (sect. 4.13.3, pg 79, new text in
> the uppermost change bar under "events" heading). However, I do not seem
> to
> be able to make this feature work. I have tried including multiple "event"
> lines in my category block, including the multiple codes (with and without
> comma separators) on a single event line, and adding the codes together
> (20)
> as is suggested by the sample.ave file from the median nerve example.
>
>     Has anyone else had this problem? Thanks in advance,
>
> Per Lysne
> MIND Research Network/University of New Mexico
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis




More information about the Mne_analysis mailing list