📄 pop_editeventfield.m
字号:
% pop_editeventfield() - Load/remove event fields in a dataset. If the % EEG dataset is the only inputs, a window pops up to ask for % the relevant parameter values.%% Usage: >> [EEG] = pop_editeventfield( EEG, 'key1', 'value1', ...);%% Input:% EEG - input dataset%% Optional input% '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' }. % 'delold' - ['yes'|'no'] 'yes' = Erase all previous events. Default% is 'no'.% 'indices' - vector indicating the indices of the events to modify% Default is current events.% 'timeunit' - [ latency unit in second ]. Default unit is 1 second. % 'delim' - delimiting characters in file. Default is tab and space.% '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%% Example: [EEG, eventnumbers] = pop_editeventfield(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 = pop_editeventfield(EEG,'sleepstage',[]);% To save the events first convert them in 'array' format and% then save the array.% >> tmp = eeg_eventformat(EEG.event, 'array');% >> save -ascii filename.txt tmp %% Author: Arnaud Delorme & Scott Makeig, CNL / Salk Institute, 9 Feb 2002%% See also: pop_importevent(), eeg_eventformat(), pop_selectevent()%123456789012345678901234567890123456789012345678901234567890123456789012% Copyright (C) Arnaud Delorme, CNL / Salk Institute, 9 Feb 2002, arno@salk.edu%% This program is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2 of the License, or% (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA% $Log: pop_editeventfield.m,v $% Revision 1.31 2004/05/28 19:09:45 arno% do not do anything when press OK%% Revision 1.30 2004/05/27 02:00:14 arno% dealing with urevents%% Revision 1.29 2004/05/26 23:47:03 arno% updating the urevent structure%% Revision 1.28 2004/04/05 16:14:16 arno% allowing one element value%% Revision 1.27 2002/10/29 17:14:14 arno% typo%% Revision 1.26 2002/10/29 01:17:52 arno% pop field for new field%% Revision 1.25 2002/10/29 00:35:23 arno% update gui%% Revision 1.24 2002/10/29 00:22:42 arno% updating gui text/%% Revision 1.23 2002/10/10 01:18:37 arno% debugging% epoch no checkbox%% Revision 1.22 2002/08/27 16:28:44 arno% optimizing window size%% Revision 1.21 2002/08/26 22:06:19 arno% update message%% Revision 1.20 2002/08/21 23:11:15 arno% optimize size%% Revision 1.19 2002/08/21 23:03:48 arno% shorten message%% Revision 1.18 2002/08/20 23:38:12 arno% can not remove epoch field%% Revision 1.17 2002/08/14 16:32:34 arno% constrain description to 1 line%% Revision 1.16 2002/08/13 00:03:10 scott% text%% Revision 1.15 2002/08/13 00:01:34 scott% text%% Revision 1.14 2002/08/12 23:59:00 scott% same%% Revision 1.13 2002/08/12 23:58:11 scott% YES/no button text%% Revision 1.12 2002/08/12 22:49:33 arno% text%% Revision 1.11 2002/08/12 21:48:46 arno% same%% Revision 1.10 2002/08/12 21:48:26 arno% text%% Revision 1.9 2002/08/12 21:47:14 arno% text%% Revision 1.8 2002/07/25 01:08:15 arno% debugging%% Revision 1.7 2002/07/23 18:37:41 arno% removing debug message%% Revision 1.6 2002/05/03 22:11:07 arno% debugging rename%% Revision 1.5 2002/04/18 18:23:14 arno% typo can not%% Revision 1.4 2002/04/09 03:51:32 arno% modifying input comments and history%% Revision 1.3 2002/04/09 01:41:49 arno% debuging array passage, change default%% Revision 1.2 2002/04/08 21:55:09 arno% not edited%% Revision 1.1 2002/04/05 17:32:13 jorn% Initial revision%%02/13/2001 fix bug if EEG.event is empty -ad%03/12/2001 add timeunit option -ad%03/18/2001 debug rename option -ad & sm%03/18/2001 correct allignment problem -ad & jafunction [EEG, com] = pop_editeventfield(EEG, varargin);com ='';if nargin < 1 help pop_editeventfield; return;end; if isempty(EEG.data) disp('Setevent error: cannot process empty dataset'); return;end; I = [];% remove the event field% ----------------------if ~isempty(EEG.event), allfields = fieldnames(EEG.event);else allfields = {}; end; if nargin<2 commandload = [ '[filename, filepath] = uigetfile(''*'', ''Select a text file'');' ... 'if filename ~=0,' ... ' set(findobj(''parent'', gcbf, ''tag'', tagtest), ''string'', [ filepath filename ]);' ... 'end;' ... 'clear filename filepath tagtest;' ]; uilist = { ... { 'Style', 'text', 'string', 'Event indices to modify', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'Delete old events (else modify existing event indices) ?', 'fontweight', 'bold' } }; geometry = { [ 0.63 1.4 0.2] [ 0.63 0.6 1] }; uilist = { uilist{:} {} ... { 'Style', 'edit', 'string', ['1:' int2str(length(EEG.event))] 'tag' 'eventindices'} ... { 'Style', 'checkbox', 'string', 'Yes / NO', 'value', 0, 'callback', ... 'set(findobj(gcbf, ''tag'', ''eventindices''), ''enable'', fastif(get(gcbo, ''value''), ''off'', ''on''));' }, ... { 'Style', 'text', 'string', 'NB: (unchecked) -> modify selected event indices' }, ... { }, ... { 'Style', 'text', 'string', 'Edit fields:', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'Field description', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'Values file|array', 'fontweight', 'bold' }, ... { }, ... { 'Style', 'text', 'string', 'Delete field', 'fontweight', 'bold' } ... }; geometry = { geometry{:} [1] [1.05 1.05 1.1 0.8 0.8] }; listboxtext = 'No field selected'; for index = 1:length(allfields) geometry = { geometry{:} [1 1 1 0.7 0.2 0.32 0.2] }; description = ''; try, description = fastif(isempty(EEG.eventdescription{index}), '', EEG.eventdescription{index}); description = description(1,:); tmplines = find(description == 10); if ~isempty(tmplines), description = description(1:tmplines(1)-1); end; catch, end; if strcmp(allfields{index}, 'latency') tmpfield = [ allfields{index} '(s)' ]; elseif strcmp(allfields{index}, 'duration') tmpfield = [ allfields{index} '(s)' ]; else tmpfield = allfields{index}; end; uilist = { uilist{:}, ... { 'Style', 'text', 'string', tmpfield }, ... { 'Style', 'pushbutton', 'string', description, 'callback', ... [ 'tmpuserdata = get(gcf, ''userdata'');' ... 'tmpuserdata{' int2str(index) '} = pop_comments(tmpuserdata{' int2str(index) '}, ''Comments on event field: ' allfields{index} ''');' ... 'set(gcbo, ''string'', tmpuserdata{' int2str(index) '});' ... 'set(gcf, ''userdata'', tmpuserdata); clear tmpuserdata;' ] }, ... { 'Style', 'edit', 'string', '', 'horizontalalignment', 'left', 'tag', allfields{index} }, ... { 'Style', 'pushbutton', 'string', 'Browse', 'callback', ['tagtest = ''' allfields{index} ''';' commandload ] }, ... { }, { 'Style', 'checkbox', 'string', ' ', 'visible', fastif(strcmp(allfields{index}, 'epoch'),'off', 'on')}, { } }; listboxtext = [ listboxtext '|' allfields{index} ]; end; geometry = { geometry{:} [1 1 1 0.7 0.77] [1] [1 1.2 0.6 1 2] }; index = length(allfields) + 1; uilist = { uilist{:}, ... { 'Style', 'edit', 'string', ''}, ... { 'Style', 'pushbutton', 'string', '', 'callback', ... [ 'tmpuserdata = get(gcf, ''userdata'');' ... 'tmpuserdata{' int2str(index) '} = pop_comments(tmpuserdata{' int2str(index) '}, ''Comments on new event field:'');' ... 'set(gcbo, ''string'', tmpuserdata{' int2str(index) '});' ... 'set(gcf, ''userdata'', tmpuserdata); clear tmpuserdata;' ] }, ... { 'Style', 'edit', 'string', '', 'horizontalalignment', 'left', 'tag', 'newfield' }, ... { 'Style', 'pushbutton', 'string', 'Browse', 'callback', ['tagtest = ''newfield'';' commandload ] }, ... { 'Style', 'text', 'string', '-> add field'} }; uilist = { uilist{:}, ... { } ... { 'Style', 'text', 'string', 'Rename field', 'fontweight', 'bold' }, ... { 'Style', 'listbox', 'string', listboxtext }, ... { 'Style', 'text', 'string', 'as', 'fontweight', 'bold' }, ... { 'Style', 'edit', 'string', '' } ... fastif(isunix,{ 'Style', 'text', 'string', '(Click on field name to select it!)' },{ })}; [results userdat ]= inputgui( geometry, uilist, 'pophelp(''pop_editeventfield'');', ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -