0001 function [p] = gui_erp_open(p,command,parent)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 if ~exist('p','var'),
0027 [p] = eeg_toolbox_defaults;
0028 elseif isempty(p),
0029 [p] = eeg_toolbox_defaults;
0030 end
0031
0032 if ~exist('command','var'),
0033 command = 'init';
0034 elseif isempty(command),
0035 command = 'init';
0036 end
0037
0038 command = lower(command);
0039
0040 switch command,
0041 case 'init',
0042 if exist('parent','var'),
0043 ERPOpen = INIT(p,parent);
0044 else
0045 ERPOpen = INIT(p,'');
0046 end
0047 otherwise,
0048 ERPOpen = get(gcbf,'Userdata');
0049 set(ERPOpen.gui,'Pointer','watch');
0050 end
0051
0052
0053 switch command,
0054
0055 case 'plot',
0056
0057 ERPOpen.p = erp_open(ERPOpen.p,ERPOpen.gui);
0058
0059 plotfig = figure('Name',ERPOpen.p.volt.file,...
0060 'NumberTitle','off',...
0061 'UserData',ERPOpen.p);
0062 movegui(plotfig,'center');
0063
0064 plot(ERPOpen.p.volt.timeArray,ERPOpen.p.volt.data); axis tight;
0065 eeg_plot_metric;
0066
0067 if isequal(get(ERPOpen.handles.Bhold,'Value'),1),
0068 parent = ERPOpen.gui;
0069 else
0070 if isfield(ERPOpen,'parent'),
0071 parent = ERPOpen.parent.gui;
0072 else
0073 parent = [];
0074 end
0075 end
0076
0077 if isempty(parent), [Xpoint,Ypoint] = eeg_crosshair('init',ERPOpen.p);
0078 else [Xpoint,Ypoint] = eeg_crosshair('init',ERPOpen.p,parent);
0079 end
0080
0081 case 'return',
0082
0083 ERPOpen.p = erp_open(ERPOpen.p);
0084
0085 case 'save',
0086
0087 fprintf('\nGUI_ERP_OPEN: Save As not implemented yet.\n');
0088
0089 case 'cancel',
0090
0091 GUI.parent = ERPOpen.parent;
0092 gui_updateparent(GUI);
0093 close gcbf;
0094
0095 otherwise,
0096
0097 end
0098
0099
0100
0101 switch command,
0102 case {'init','cancel'},
0103 otherwise,
0104 set(ERPOpen.gui,'Pointer','arrow');
0105 set(ERPOpen.gui,'Userdata',ERPOpen);
0106 if isequal(get(ERPOpen.handles.Bhold,'Value'),1),
0107 [p] = gui_updateparent(ERPOpen,0);
0108 else
0109 [p] = gui_updateparent(ERPOpen);
0110 close gcbf;
0111 end
0112 end
0113
0114
0115
0116 return
0117
0118
0119
0120
0121
0122 function [ERPOpen] = INIT(p,parent)
0123
0124
0125 GUIwidth = 500;
0126 GUIheight = 120;
0127
0128 version = '$Revision: 1.1 $';
0129 name = sprintf('ERP File Open [v %s]\n',version(11:15));
0130
0131 GUI = figure('Name',name,'Tag','ERP_OPEN',...
0132 'NumberTitle','off',...
0133 'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0134 movegui(GUI,'center');
0135
0136 Font.FontName = 'Helvetica';
0137 Font.FontUnits = 'Pixels';
0138 Font.FontSize = 12;
0139 Font.FontWeight = 'normal';
0140 Font.FontAngle = 'normal';
0141
0142
0143
0144
0145 G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0146 'Position',[.01 .75 .17 .2],...
0147 'String','Data Type:','HorizontalAlignment','left');
0148
0149 switch lower(p.volt.type),
0150 case 'ascii', voltType = 1;
0151 case 'emse', voltType = 2;
0152 case 'scan4x', voltType = 3;
0153 case 'scan3x', voltType = 4;
0154 case 'matlab', voltType = 5;
0155 otherwise, voltType = 1;
0156 end
0157 G.PvoltType = uicontrol('Tag','PvoltType','Parent',GUI,'Style','popupmenu',...
0158 'Units','Normalized',Font, ...
0159 'Position',[.20 .75 .2 .2],...
0160 'String',{'ASCII' 'EMSE' 'Scan4x' 'Scan3x' 'Matlab'},'Value',voltType,...
0161 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0162 'ERPOpen.p.volt.type = popupstr(ERPOpen.handles.PvoltType);',...
0163 'set(gcbf,''Userdata'',ERPOpen); clear ERPOpen;'));
0164
0165
0166 G.Bascii = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0167 'Position',[.45 .75 .2 .2],...
0168 'String','ERP Parameters','BusyAction','queue',...
0169 'BackgroundColor',[0.0 0.0 0.75],...
0170 'ForegroundColor',[1 1 1], 'HorizontalAlignment', 'center',...
0171 'Callback','tempgui = gui_eeg_ascii_parameters(gcbf); clear tempgui;');
0172
0173
0174 G.BinterpZero = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0175 'Position',[.80 .75 .18 .2],'String','Interp 0','BusyAction','queue',...
0176 'TooltipString','Interpolate zero, mainly for ascii, scan3x, scan4x files.',...
0177 'Value',p.volt.interpZero,'HorizontalAlignment', 'center',...
0178 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0179 'ERPOpen.p.volt.interpZero = get(ERPOpen.handles.BinterpZero,''Value''); ',...
0180 'set(gcbf,''Userdata'',ERPOpen); clear ERPOpen;'));
0181
0182 G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0183 'Position',[.01 .50 .17 .2],...
0184 'String','Path','HorizontalAlignment','left');
0185 G.EvoltPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0186 'Position',[.20 .50 .58 .2], 'String',p.volt.path,...
0187 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0188 'ERPOpen.p.volt.path = get(ERPOpen.handles.EvoltPath,''String'');',...
0189 'set(gcbf,''Userdata'',ERPOpen); clear ERPOpen;'));
0190
0191 G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0192 'Position',[.01 .25 .17 .2],...
0193 'String','File','HorizontalAlignment','left');
0194 G.EvoltFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0195 'Position',[.20 .25 .58 .2], 'String',p.volt.file,...
0196 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0197 'ERPOpen.p.volt.file = get(ERPOpen.handles.EvoltFile,''String'');',...
0198 'set(gcbf,''Userdata'',ERPOpen); clear ERPOpen;'));
0199
0200 Font.FontWeight = 'bold';
0201
0202
0203 browsecommand = strcat('ERPOpen = get(gcbf,''Userdata'');',...
0204 'cd(ERPOpen.p.volt.path);',...
0205 '[file, path] = uigetfile(',...
0206 '{''*.dat;*.asc;*.txt'', ''ASCII Data Files (*.dat,*.asc,*.txt)'';', ...
0207 ' ''*.erp'', ''NeuroScan Average (*.erp)'';', ...
0208 ' ''*.erp'', ''EMSE Average (*.erp)'';', ...
0209 ' ''*.mat'', ''MATLAB Data Files (*.mat)'';', ...
0210 ' ''*.*'', ''All Files (*.*)''},', ...
0211 '''Select ERP File'');',...
0212 'if ~isequal(path,0), ERPOpen.p.volt.path = path; end;',...
0213 'if ~isequal(file,0), ERPOpen.p.volt.file = file; end;',...
0214 'set(ERPOpen.handles.EvoltPath,''String'',ERPOpen.p.volt.path);',...
0215 'set(ERPOpen.handles.EvoltFile,''String'',ERPOpen.p.volt.file);',...
0216 'if ~isempty(findstr(file,''.dat'')) | ~isempty(findstr(file,''.txt'')) | ~isempty(findstr(file,''.asc'')), ',...
0217 ' set(ERPOpen.handles.PvoltType,''Value'',1); ',...
0218 ' ERPOpen.p.volt.type = popupstr(ERPOpen.handles.PvoltType);',...
0219 'elseif ~isempty(findstr(file,''.erp'')), ',...
0220 ' set(ERPOpen.handles.PvoltType,''Value'',3); ',...
0221 ' ERPOpen.p.volt.type = popupstr(ERPOpen.handles.PvoltType);',...
0222 'else, ',...
0223 ' set(ERPOpen.handles.PvoltType,''Value'',5); ',...
0224 ' ERPOpen.p.volt.type = popupstr(ERPOpen.handles.PvoltType);',...
0225 'end;',...
0226 'set(gcbf,''Userdata'',ERPOpen); clear ERPOpen file path;');
0227 G.BvoltFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0228 'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0229 'BackgroundColor',[0.8 0.8 0.0],...
0230 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0231 'Callback', browsecommand );
0232
0233
0234 G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0235 'Position',[.20 .01 .18 .2],...
0236 'String','PLOT','BusyAction','queue',...
0237 'TooltipString','Plot the ERP data and return p struct.',...
0238 'BackgroundColor',[0.0 0.5 0.0],...
0239 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0240 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0241 'p = gui_erp_open(ERPOpen.p,''plot'');',...
0242 'clear ERPOpen;'));
0243
0244
0245 G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0246 'Position',[.40 .01 .18 .2],'HorizontalAlignment', 'center',...
0247 'String','SAVE AS','TooltipString','ERP File Conversion Tool (not implemented yet)',...
0248 'BusyAction','queue',...
0249 'Visible','on',...
0250 'BackgroundColor',[0.0 0.0 0.75],...
0251 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0252 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0253 'p = gui_erp_open(ERPOpen.p,''save'');',...
0254 'clear ERPOpen;'));
0255
0256
0257 G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0258 'Position',[.60 .01 .18 .2],...
0259 'String','RETURN','BusyAction','queue',...
0260 'TooltipString','Return p struct to workspace and parent GUI.',...
0261 'BackgroundColor',[0.75 0.0 0.0],...
0262 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0263 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0264 'p = gui_erp_open(ERPOpen.p,''return'');',...
0265 'clear ERPOpen;'));
0266
0267
0268 G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0269 'Position',[.80 .01 .18 .2],...
0270 'String','CANCEL','BusyAction','queue',...
0271 'TooltipString','Close, do not return parameters.',...
0272 'BackgroundColor',[0.75 0.0 0.0],...
0273 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0274 'Callback',strcat('ERPOpen = get(gcbf,''Userdata'');',...
0275 'p = gui_erp_open(ERPOpen.p,''cancel'');',...
0276 'clear ERPOpen;'));
0277
0278
0279 G.Bhelp = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0280 'Position',[.80 .25 .18 .2],'String','Help','BusyAction','queue',...
0281 'BackgroundColor',[1 1 0],...
0282 'ForegroundColor',[0 0 0], 'HorizontalAlignment', 'center',...
0283 'Callback','doc erp_open;');
0284
0285 G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0286 'Position',[.80 .50 .18 .2],'String','Hold GUI','BusyAction','queue',...
0287 'TooltipString','ERP File Load GUI remains open after ''Plot'' or ''Return'' commands.',...
0288 'Value',p.hold,'HorizontalAlignment', 'center');
0289
0290
0291
0292 if exist('parent','var'), ERPOpen.parent.gui = parent; end
0293 ERPOpen.gui = GUI;
0294 ERPOpen.handles = G;
0295 ERPOpen.p = p;
0296 set(GUI,'Userdata',ERPOpen);
0297 set(GUI,'HandleVisibility','callback');
0298
0299 return