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