0001 function [p] = gui_avg_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 AVGOpen = INIT(p,parent);
0044 else
0045 AVGOpen = INIT(p,'');
0046 end
0047 otherwise,
0048 AVGOpen = get(gcbf,'Userdata');
0049 set(AVGOpen.gui,'Pointer','watch');
0050 end
0051
0052
0053 switch command,
0054
0055 case 'plot',
0056
0057 AVGOpen.p = avg_open(AVGOpen.p,AVGOpen.gui);
0058
0059 plotfig = figure('Name',AVGOpen.p.volt.file,...
0060 'NumberTitle','off',...
0061 'UserData',AVGOpen.p);
0062 movegui(plotfig,'center');
0063
0064 plot(AVGOpen.p.volt.timeArray,AVGOpen.p.volt.data); axis tight;
0065 eeg_plot_metric;
0066
0067 if isequal(get(AVGOpen.handles.Bhold,'Value'),1),
0068 parent = AVGOpen.gui;
0069 else
0070 if isfield(AVGOpen,'parent'),
0071 parent = AVGOpen.parent.gui;
0072 else
0073 parent = [];
0074 end
0075 end
0076
0077 if isempty(parent), [Xpoint,Ypoint] = eeg_crosshair('init',AVGOpen.p);
0078 else [Xpoint,Ypoint] = eeg_crosshair('init',AVGOpen.p,parent);
0079 end
0080
0081 case 'return',
0082
0083 AVGOpen.p = avg_open(AVGOpen.p);
0084
0085 case 'save',
0086
0087 fprintf('\nGUI_AVG_OPEN: Save As not implemented yet.\n');
0088
0089 case 'cancel',
0090
0091 GUI.parent = AVGOpen.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(AVGOpen.gui,'Pointer','arrow');
0105 set(AVGOpen.gui,'Userdata',AVGOpen);
0106 if isequal(get(AVGOpen.handles.Bhold,'Value'),1),
0107 [p] = gui_updateparent(AVGOpen,0);
0108 else
0109 [p] = gui_updateparent(AVGOpen);
0110 close gcbf;
0111 end
0112 end
0113
0114
0115
0116 return
0117
0118
0119
0120
0121
0122 function [AVGOpen] = INIT(p,parent)
0123
0124
0125 GUIwidth = 500;
0126 GUIheight = 120;
0127
0128 version = '$Revision: 1.1 $';
0129 name = sprintf('AVG File Open [v %s]\n',version(11:15));
0130
0131 GUI = figure('Name',name,'Tag','AVG_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('AVGOpen = get(gcbf,''Userdata'');',...
0162 'AVGOpen.p.volt.type = popupstr(AVGOpen.handles.PvoltType);',...
0163 'set(gcbf,''Userdata'',AVGOpen); clear AVGOpen;'));
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('AVGOpen = get(gcbf,''Userdata'');',...
0179 'AVGOpen.p.volt.interpZero = get(AVGOpen.handles.BinterpZero,''Value''); ',...
0180 'set(gcbf,''Userdata'',AVGOpen); clear AVGOpen;'));
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('AVGOpen = get(gcbf,''Userdata'');',...
0188 'AVGOpen.p.volt.path = get(AVGOpen.handles.EvoltPath,''String'');',...
0189 'set(gcbf,''Userdata'',AVGOpen); clear AVGOpen;'));
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('AVGOpen = get(gcbf,''Userdata'');',...
0197 'AVGOpen.p.volt.file = get(AVGOpen.handles.EvoltFile,''String'');',...
0198 'set(gcbf,''Userdata'',AVGOpen); clear AVGOpen;'));
0199
0200 Font.FontWeight = 'bold';
0201
0202
0203 browsecommand = strcat('AVGOpen = get(gcbf,''Userdata'');',...
0204 'cd(AVGOpen.p.volt.path);',...
0205 '[file, path] = uigetfile(',...
0206 '{''*.dat;*.asc;*.txt'', ''ASCII Data Files (*.dat,*.asc,*.txt)'';', ...
0207 ' ''*.avg'', ''NeuroScan Average (*.avg)'';', ...
0208 ' ''*.avg'', ''EMSE Average (*.avg)'';', ...
0209 ' ''*.mat'', ''MATLAB Data Files (*.mat)'';', ...
0210 ' ''*.*'', ''All Files (*.*)''},', ...
0211 '''Select ERP File'');',...
0212 'if ~isequal(path,0), AVGOpen.p.volt.path = path; end;',...
0213 'if ~isequal(file,0), AVGOpen.p.volt.file = file; end;',...
0214 'set(AVGOpen.handles.EvoltPath,''String'',AVGOpen.p.volt.path);',...
0215 'set(AVGOpen.handles.EvoltFile,''String'',AVGOpen.p.volt.file);',...
0216 'if ~isempty(findstr(file,''.dat'')) | ~isempty(findstr(file,''.txt'')) | ~isempty(findstr(file,''.asc'')), ',...
0217 ' set(AVGOpen.handles.PvoltType,''Value'',1); ',...
0218 ' AVGOpen.p.volt.type = popupstr(AVGOpen.handles.PvoltType);',...
0219 'elseif ~isempty(findstr(file,''.avg'')), ',...
0220 ' set(AVGOpen.handles.PvoltType,''Value'',3); ',...
0221 ' AVGOpen.p.volt.type = popupstr(AVGOpen.handles.PvoltType);',...
0222 'else, ',...
0223 ' set(AVGOpen.handles.PvoltType,''Value'',5); ',...
0224 ' AVGOpen.p.volt.type = popupstr(AVGOpen.handles.PvoltType);',...
0225 'end;',...
0226 'set(gcbf,''Userdata'',AVGOpen); clear AVGOpen 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 AVG data and return p struct.',...
0238 'BackgroundColor',[0.0 0.5 0.0],...
0239 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0240 'Callback',strcat('AVGOpen = get(gcbf,''Userdata'');',...
0241 'p = gui_avg_open(AVGOpen.p,''plot'');',...
0242 'clear AVGOpen;'));
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','AVG 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('AVGOpen = get(gcbf,''Userdata'');',...
0253 'p = gui_avg_open(AVGOpen.p,''save'');',...
0254 'clear AVGOpen;'));
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('AVGOpen = get(gcbf,''Userdata'');',...
0264 'p = gui_avg_open(AVGOpen.p,''return'');',...
0265 'clear AVGOpen;'));
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('AVGOpen = get(gcbf,''Userdata'');',...
0275 'p = gui_avg_open(AVGOpen.p,''cancel'');',...
0276 'clear AVGOpen;'));
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 avg_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','AVG File Load GUI remains open after ''Plot'' or ''Return'' commands.',...
0288 'Value',p.hold,'HorizontalAlignment', 'center');
0289
0290
0291
0292 if exist('parent','var'), AVGOpen.parent.gui = parent; end
0293 AVGOpen.gui = GUI;
0294 AVGOpen.handles = G;
0295 AVGOpen.p = p;
0296 set(GUI,'Userdata',AVGOpen);
0297 set(GUI,'HandleVisibility','callback');
0298
0299 return