POP_EDITEVENTFIELD Add/remove/rename/modify a field in the event structure of an EEG dataset. Can also be used to append new events to the end of the event structure or to delete all current events. If the dataset is the only input, a window pops up to ask for relevant parameter values.

Usage: >> [EEG] = pop_editeventfield( EEG, 'key1', 'value1', ...);

Input:
EEG   
input dataset

Optional inputs:
'FIELDNAME'   
[ 'filename'|vector|number|[] ]. Name of a current or new user-defined event field. The ascii file, vector variable, or explicit numeric vector should contain values for this field for all events specified in 'indices' (below) or in new events appended to the dataset (if 'indices' not specified). If one arg value is given, it will be used for all the specified events. If the arg is [], the named field is *removed* from all the specified (or new) events. Use this option to add a new field to all events in the dataset, or to modify the field values of specified events, to specify field information for new events appended to the event structure, or to remove an event field.
'FIELDNAMEinfo'   
new comment string for field FIELDNAME.
'indices'   
[vector of event indices] The indices of the events to modify. If adding a new event field, events not listed here will have an empty field value IF they are not in an epoch containing events whose field value is specified. However, if adding a new (FIELDNAME) field to an epoched dataset, and the field value for only one event in some data epoch is specified, then the other events in the same epoch will be given the specified value. If field values of more than one, but not all the events in an epoch are specified, then unspecified events at the beginning of the epoch will be given the value of the first specified event, unspecified epoch events after this event will be given the field value of the second specified epoch event, etc. {default|[]: modify all events in the dataset}
'rename'   
['FIELDNAME1->FIELDNAME2'] rename field 'FIELDNAME1' to field 'FIELDNAME2'. Ex: { 'rename', 'blocktype->condition' }.
'delold'   
['yes'|'no'] 'yes' = delete ALL previous events. {default: 'no'}
'timeunit'   
[latency field time unit in fraction of seconds]. Ex: 1e-3 -> read specified latencies as msec {default: 1 (-->seconds)}
'skipline'   
number of leading text file lines to skip in named text files
'delim'   
delimiting characters in named text files {default: tabs and spaces}

Outputs:
EEG   
dataset with updated event field

Example: [EEG, eventnumbers] = pop_editeventfield(EEG, 'type', 1, 'sleepstage', 'sleepstage_values.txt', 'latency', [100 130 123 400],'timeunit',1e-3);
% Append 4 events to the EEG struct, all of type 1, at the latencies
% given (in msec) with user-defined field ('sleepstage') values read
% from a one-column ascii file ('sleepstage_values.txt').

Example: [EEG, eventnumbers] = pop_editeventfield(EEG, 'indices', 1:2:3277, 'sleepstage', 'sleepstage_values.txt');
% Add a new 'sleepstage' field to all events in the EEG struct.
% Read 'sleepstage' field values for odd-numbered events from a one-column
% ascii file ('sleepstage_values.txt') -- even-numbered % events will have
% an empty 'sleepstage' value (unless the data are epoched, see 'indices' above).

Note: To save events into a readable table, first convert them to 'array' format,
then save the array.
>> events = eeg_eventformat(EEG.event, 'array');
>> save -ascii myevents.txt events

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

See also: pop_importevent(), eeg_eventformat, pop_selectevent()

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

Back to functions