📄 pop_selectevent.m
字号:
% pop_selectevent() - Find events in an EEG dataset. If the dataset% is the only input, a window pops up to% ask for the relevant parameter values.%% Usage: >> [EEGOUT,event_indices] = pop_selectevent( EEG, 'key1', value1, ...% 'key2', value2, ... );% Input:% EEG - EEG dataset%% Optional inputs:% 'type' - [type_range] event type(s) to include% Ex: 'type',3 or [2 3 5] or 1:10% 'omittype' - [type_range], type(s) of events to exclude% 'latency' - [latency_range] latency range of events to include% Ex: 'latency','400 <= 700' Include all events with% latnecy in the range [400,700]% 'omitlatency' - [latency_range] latency range of events to exclude% 'event' - [event_range], indices of events to include% 'omitevent' - [event_range], indices of events to exclude% 'USER_VAR' - [VAR_range], 'USER_VAR' is any user-defined field in% the event structure. Includes events with values of% field 'USER_VAR' in the specified range. Use [vector]% format for integers, 'min<max' format for real numbers.% 'omitUSER_VAR' - [VAR_range], 'USER_VAR' range of events to exclude% 'select' - ['normal'|'inverse'] invert the selection of events. % {Default is 'normal'}% 'deleteepochs' - ['on'|'off'] 'on' = Delete ALL epochs that do not include% the specified events. {Default = 'on'}.% This option is relevant only for epoched datasets derived% from continuous datasets.% 'deleteevents' - ['on'|'off'] 'on' = Delete ALL events except% the selected events. {Default = 'off'}.% 'renametype' - [string] rename the type of selected events with the% string given as parameter. {Default is [], do not rename% field}.% 'oldtypefield' - [string] in conjunction with the previous parameter, % create a new field (whose 'name' is provided as parameter)% to store the (old) type of the event whose type has been % renamed. {Default is [], do not create field}.%% Outputs:% EEGOUT - EEG dataset with the selected events only% event_indices - indexes of the selected events%% Ex: [EEGTARGETS,target_indices] = getevent(EEG,'type',[1 6 11 16 21]);%% % Returns ONLY THOSE epochs containing any of the 5 specified% types of target events.%% Note: By default, if several optional inputs are given, the function% performs their conjunction (&).%% Author: Arnaud Delorme, CNL / Salk Institute, 27 Jan 2002%% See also: eeg_eventformat(), pop_importevent()%123456789012345678901234567890123456789012345678901234567890123456789012% Copyright (C) Arnaud Delorme, CNL / Salk Institute, 27 Jan 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_selectevent.m,v $% Revision 1.52 2004/07/09 16:26:38 arno% debug duration selection%% Revision 1.51 2004/05/26 23:29:47 arno% implementing duration%% Revision 1.50 2004/05/07 17:11:48 arno% checking event consistency%% Revision 1.49 2004/03/19 17:45:19 arno% including limits when selecting event boundaries%% Revision 1.48 2003/07/20 19:41:49 scott% typos%% Revision 1.47 2003/04/16 01:47:42 arno% removing function call bug%% Revision 1.46 2003/01/02 17:19:43 arno% changing exemple fom 'target' to "target" for type%% Revision 1.45 2002/11/14 22:49:44 arno% debugging command line call%% Revision 1.44 2002/11/09 18:49:28 arno% adding text in gui%% Revision 1.43 2002/11/09 17:32:59 scott% "Rename..." legend edit%% Revision 1.42 2002/10/29 23:26:30 arno% optimize size%% Revision 1.28-40 2002/10/29 22:25:59 scott% text%% Revision 1.27 2002/10/29 17:27:17 arno% change location of time unit message%% Revision 1.26 2002/10/29 17:07:07 arno% text editing%% Revision 1.25 2002/10/29 16:40:35 arno% text%% Revision 1.24 2002/10/29 16:14:18 arno% debug continuous data call%% Revision 1.23 2002/10/29 16:07:23 arno% new version with renaming etc ...%% Revision 1.22 2002/10/27 17:11:06 julie% help msg%% Revision 1.21 2002/09/05 16:33:28 arno% remove warning%% Revision 1.20 2002/08/28 00:57:19 arno% [Amodifying error message%% Revision 1.19 2002/08/19 21:57:55 arno% debug for MAC%% Revision 1.18 2002/08/19 19:06:52 arno% debugging%% Revision 1.17 2002/08/13 16:15:29 scott% text%% Revision 1.16 2002/08/12 18:36:10 arno% questdlg2%% Revision 1.15 2002/08/08 02:09:19 arno% contraining boundary event to be preserved for continuous data%% Revision 1.14 2002/08/01 22:21:41 arno% debugging%% Revision 1.13 2002/07/10 02:16:41 arno% adding the 'select' input, the function check%% Revision 1.12 2002/05/03 02:49:53 arno% updating interface%% Revision 1.11 2002/05/03 02:42:11 arno% editing interface%% Revision 1.10 2002/05/03 02:29:17 arno% allow to select latencies%% Revision 1.9 2002/04/25 17:17:15 scott% editting msg -sm%% Revision 1.8 2002/04/25 02:14:43 arno% debugging multi-line event field description%% Revision 1.7 2002/04/22 23:37:29 arno% temporary modification removed%% Revision 1.6 2002/04/22 23:36:53 arno% temporary modif%% Revision 1.5 2002/04/18 18:25:51 arno% typo can not%% Revision 1.4 2002/04/10 22:39:47 arno% removing debuging comment%% Revision 1.3 2002/04/10 00:37:47 arno% debuging string event selection%% Revision 1.2 2002/04/09 03:02:38 arno% debuging epoch selection%% Revision 1.1 2002/04/05 17:32:13 jorn% Initial revision%%02/01/2002 added inputgui and finalize function - ad%02/06/2002 work on the header and event format - sm & ad%02/09/2002 modify function according to new structure - ad%02/12/2002 add getepoch compatibility - ad%02/19/2002 add event indices & correct event selection - adfunction [EEG, Ievent, com] = pop_selectevent(EEG, varargin);if nargin < 1 help pop_selectevent; return;end;Ievent = [];com ='';event_indices = [];% note that this function is also used for epochs% -----------------------------------------------I = [];if isempty(EEG.event) disp('Getevent: cannot deal with empty event structure'); return;end; % remove the event field if present% ---------------------------------allfields = fieldnames(EEG.event);if isfield(EEG, 'tmpevent') & strmatch('event', allfields) indexmatch = strmatch('event', allfields); allfields = { allfields{1:indexmatch-1} allfields{indexmatch+1:end}};end; if nargin<2 geometry = { [0.6 1.3 2.0 0.8 ] [0.6 1.3 2.0 0.8 ] [0.55 0.65 1.3 0.1 0.22 0.1] }; uilist = { ... { 'Style', 'text', 'string', 'Selection', 'horizontalalignment', 'center', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'Field Descriptions', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'Selection (value, list or real range "min<=max")', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'If set, select', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', ' Field', 'fontweight', 'bold' }, ... { 'Style', 'text', 'string', 'To edit: Edit > Event fields' }, ... { 'Style', 'text', 'string', 'Ex: "Target" or 2:4,5 or 4.5 <= 13' }, ... { 'Style', 'text', 'string', 'all BUT these', 'fontweight', 'bold' }, ... ... { 'Style', 'text', 'string', 'Event indices' }, ... { }, ... { 'Style', 'edit', 'string', '' }, ... { }, { 'Style', 'checkbox', 'string', ' ' },{ } }; % add all fields to graphic interface % ----------------------------------- for index = 1:length(allfields) % format the description to fit a help box % ---------------------------------------- if index <= length( EEG.eventdescription ) tmptext = EEG.eventdescription{ index }; if ~isempty(tmptext) if size(tmptext,1) > 15, stringtext = [ tmptext(1,1:15) '...' ]; else stringtext = tmptext(1,:); end; else stringtext = 'no description'; tmptext = 'no description'; end; else stringtext = 'no description'; tmptext = 'no description'; end; descrip = { 'string', stringtext, 'callback', ['questdlg2(' vararg2str(tmptext) ... ',''Description of field ''''' allfields{index} ''''''', ''OK'', ''OK'');' ] }; % create the gui for this field % ----------------------------- textfield = allfields{index}; if strcmp(allfields{index}, 'latency') if EEG.trials > 1, textfield = [ textfield ' (ms)' ]; else textfield = [ textfield ' (s)' ]; end; end; if strcmp(allfields{index}, 'duration') if EEG.trials > 1, textfield = [ textfield ' (ms)' ]; else textfield = [ textfield ' (s)' ]; end; end; geometry = { geometry{:} [0.55 0.65 1.3 0.1 0.22 0.1] }; uilist = { uilist{:}, ... { 'Style', 'text', 'string', textfield }, ... { 'Style', 'pushbutton', descrip{:}, 'horizontalalignment', 'left' }, ... { 'Style', 'edit', 'string', '' }, ... { }, { 'Style', 'checkbox', 'string', ' ' },{ } }; end; geometry = { geometry{:} [1] [1.3 2] }; uilist = { uilist{:} ... { }, ... { 'Style', 'checkbox', 'string','Select all events NOT selected above',} ... { 'Style', 'text', 'string','Set this button (to left) and "all BUT" buttons (above) for logical OR' } ... }; geometry = { geometry{:} [1] [2 1 1] [2 1 1] [2 1] }; uilist = { uilist{:} { } ... { 'Style', 'text', 'string', 'Rename selected event type(s) as type:' } ... { 'Style', 'edit', 'string', '' } { } ... { 'Style', 'text', 'string', 'Retain old event type name(s) in (new) field named:' } ... { 'Style', 'edit', 'string', '' } { } ... { 'Style', 'checkbox', 'string','Keep only selected events and remove all other events', ... 'value', fastif(EEG.trials>1, 0, 1) } { } };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -