SETEVENT Load/remove events in a dataset. If the EEG dataset and graphic interface type are the only inputs, a window pops up to ask for the relevant parameter values.

Usage: >> [EEG,eventnumbers] = setevent( EEG, interf, 'key1', 'value1', ...);

Input:
EEG   
input dataset
interf   
[0|1], call different type of graphic interface. 0=full file reading. 1=variable name editing. This value is ignored if more than 3 arguments are given to the function and the graphic interface is not needed. Optional input
'append'   
['yes'|'no'] 'yes' = Append to the current events of the EEG dataset {default}: 'no' = Erase the previous events.
'event'   
[ 'filename'|array ] filename of a text file or Matlab array of the global workspace containing an array of events in the folowing format: The first column is the type of the event, the second the latency and the other ones are user defined fields.
'fields'   
{ nested cell array } name for each user-defined column, optionally followed by a description. Ex: { 'type', 'latency' }
'latency'   
[ 'filename'|array|number ], 1-column file or array containing the latency of the events. If the arg is a single number, it will be used for all events.
'type'   
[ 'filename'|array|number ], Type (numbers) of the events. Same format as 'latency' {Default event type is 1}.
'USER_VAR'   
[ 'filename'|array|number|[] ], here 'USER_VAR' is the name of a user-defined field. If the argument is [], the field is removed from all the events.
'skipline'   
number of rows to skip for text files
'rename'   
['USER_VAR1->USER_VAR2'] rename field 'USER_VAR1' into 'USER_VAR2'. Ex: { 'rename', 'type->condition' }.
'indices'   
vector indicating the indices of the events to modify
'timeunit'   
[ latency unit in second ]. Default unit is 1 second.
'delim'   
delimiting characters in file. Default is tab and space.
'align'   
[num] align the first event latency to existing event latency (number num) and check latency consistency. Negative values can also be used and then event number -num is aligned with the first pre-existing event. Default is 0, no latency alignment.
'latencyinfo'   
comment string for the latency field
'typeyinfo'   
comment string for the type field
'USER_VARinfo'   
comment string for the variable USERVAR

Outputs:
EEG   
dataset with updated event field
eventnumbers   
indexes of the appended events

Example: [EEG, eventnumbers] = setevent(EEG, 'type', 1, 'sleepstage', 'sleepstage_values.txt', 'latency', [0.100 0.130 0.123 0.400] );
This appends 4 events to the EEG struct, all of type 1,
with user-defined field ('sleepstage') values read from an
ascii 1-column file ('sleepstage_values.txt').

Notes: As indicated above, to remove a user=defined field, simply
enter an empty array [].
Ex: >> EEG = setevent(EEG,'sleepstage',[]);
To save the events first convert them in 'array' format and
then save the array.
>> tmp = eventformat(EEG.event, 'array');
>> save -ascii filename.txt tmp

Author: Arnaud Delorme & Scott Makeig, CNL / Salk Institute, 9 Feb 2002

See also: eventformat, selectevent

See the matlab file setevent.m (may require other functions)

Back to functions