0001 function [p] = gui_elec_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 ELECOpen = INIT(p,parent);
0041 else
0042 ELECOpen = INIT(p,'');
0043 end
0044 otherwise,
0045 ELECOpen = get(gcbf,'Userdata');
0046 set(ELECOpen.gui,'Pointer','watch');
0047 end
0048
0049
0050 switch command,
0051 case 'plot',
0052
0053 ELECOpen.p.elec.plot = 1;
0054 ELECOpen.p = elec_open(ELECOpen.p);
0055
0056 case 'save',
0057
0058 fprintf('\nGUI_ELEC_OPEN: Save As not implemented yet.\n');
0059
0060 case 'return',
0061
0062 ELECOpen.p.elec.plot = 0;
0063 ELECOpen.p = elec_open(ELECOpen.p);
0064
0065 case 'cancel',
0066
0067 GUI.parent = ELECOpen.parent;
0068 gui_updateparent(GUI);
0069 close gcbf;
0070
0071 otherwise,
0072
0073 end
0074
0075
0076 switch command,
0077 case {'init','cancel'},
0078 otherwise,
0079 set(ELECOpen.gui,'Pointer','arrow');
0080 set(ELECOpen.gui,'Userdata',ELECOpen);
0081 if ~isequal(get(ELECOpen.handles.Bhold,'Value'),0),
0082 [p] = gui_updateparent(ELECOpen,0);
0083 else
0084 [p] = gui_updateparent(ELECOpen);
0085 close gcbf;
0086 end
0087 end
0088
0089
0090
0091 return
0092
0093
0094
0095
0096 function [ELECOpen] = INIT(p,parent)
0097
0098
0099
0100 GUIwidth = 500;
0101 GUIheight = 120;
0102
0103 version = '$Revision: 1.1 $';
0104 name = sprintf('ELEC File Open [v %s]\n',version(11:15));
0105
0106 GUI = figure('Name',name,'Tag','ELEC_OPEN',...
0107 'NumberTitle','off','HandleVisibility','callback',...
0108 'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0109 movegui(GUI,'center');
0110
0111 ELECOpen.gui = GUI;
0112
0113 Font.FontName = 'Helvetica';
0114 Font.FontUnits = 'Pixels';
0115 Font.FontSize = 12;
0116 Font.FontWeight = 'normal';
0117 Font.FontAngle = 'normal';
0118
0119
0120
0121
0122 G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0123 'Position',[.01 .75 .15 .2],...
0124 'String','Coordinates','HorizontalAlignment','left');
0125
0126 switch p.elec.type
0127 case 'Cartesian', elecType = 1;
0128 case 'Spherical1', elecType = 2;
0129 case 'Spherical2', elecType = 3;
0130 case 'scan3ddasc', elecType = 4;
0131 case 'scantri', elecType = 5;
0132 case 'brainstorm', elecType = 6;
0133 case 'EMSE', elecType = 7;
0134 otherwise, elecType = 1;
0135 end
0136 G.PelectrodeType = uicontrol('Tag','PelecType','Parent',GUI,'Style','popupmenu',...
0137 'Units','Normalized',Font, ...
0138 'Position',[.18 .75 .2 .2],...
0139 'String',{'Cartesian' 'Spherical1' 'Spherical2' 'scan3ddasc' 'scantri' 'brainstorm' 'EMSE'},'Value',elecType,...
0140 'TooltipString',strcat('Coordinate Type: ',...
0141 ' ''Spherical1'' = theta and phi in degrees,',...
0142 ' ''Spherical2'' = theta and phi in radians' ,...
0143 ' ''scan3ddasc'' = scan 3Dspace ascii export',...
0144 ' ''scantri'' = scan 3Dspace .tri file',...
0145 ' ''brainstorm'' = brainstorm channel file',...
0146 ' ''EMSE'' = EMSE .elp file'),...
0147 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0148 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0149 'set(gcbf,''Userdata'',ELECOpen); clear ELECOpen;'));
0150
0151 G.Title_elecN = uicontrol('Tag','Title_elecN','Parent',GUI,'Style','text',...
0152 'Units','Normalized',Font,...
0153 'Position',[.58 .75 .1 .2],...
0154 'String','N =',...
0155 'TooltipString','Maximum number of consecutive electrodes to load from file.');
0156 G.EelectrodeN = uicontrol('Tag','EelecN','Parent',GUI,'Style','edit',...
0157 'Units','Normalized',Font, ...
0158 'Position',[.68 .75 .1 .2],...
0159 'String',num2str(p.elec.n),'Value',p.elec.n,...
0160 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0161 'ELECOpen.p.elec.n = str2num( get(ELECOpen.handles.EelectrodeN,''String'') );',...
0162 'set(ELECOpen.handles.EelectrodeN,''Value'',ELECOpen.p.elec.n,''String'',num2str(ELECOpen.p.elec.n) );',...
0163 'set(gcbf,''Userdata'',ELECOpen); clear ELECOpen;'));
0164
0165 G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0166 'Position',[.01 .50 .15 .2],...
0167 'String','Path','HorizontalAlignment','left');
0168 G.EelectrodePath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0169 'Position',[.18 .50 .6 .2], 'String',p.elec.path,...
0170 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0171 'ELECOpen.p.elec.path = get(ELECOpen.handles.EelectrodePath,''String'');',...
0172 'set(gcbf,''Userdata'',ELECOpen); clear ELECOpen;'));
0173
0174 G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0175 'Position',[.01 .25 .15 .2],...
0176 'String','File','HorizontalAlignment','left');
0177 G.EelectrodeFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0178 'Position',[.18 .25 .6 .2], 'String',p.elec.file,...
0179 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0180 'ELECOpen.p.elec.file = get(ELECOpen.handles.EelectrodeFile,''String'');',...
0181 'set(gcbf,''Userdata'',ELECOpen); clear ELECOpen;'));
0182
0183 Font.FontWeight = 'bold';
0184
0185
0186 browsecommand = strcat('ELECOpen = get(gcbf,''Userdata'');',...
0187 'cd(ELECOpen.p.elec.path);',...
0188 '[file, path] = uigetfile(',...
0189 '{''*.*'', ''All Files (*.*)'';', ...
0190 ' ''*.mat'', ''MATLAB (BrainStorm) Files (*.mat)'';', ...
0191 ' ''*.elp'', ''EMSE Files (*.elp)'';', ...
0192 ' ''*.dat'', ''Scan 3Dspace Ascii Export Files (*.dat)'';', ...
0193 ' ''*.tri'', ''Scan 3Dspace Files (*.tri)'';', ...
0194 ' ''*.asc;*.txt'', ''ASCII Data Files (*.asc,*.txt)''},', ...
0195 '''Select Electrode Coordinate File'');',...
0196 'if ~isequal(path,0), ELECOpen.p.elec.path = path; end;',...
0197 'if ~isequal(file,0), ELECOpen.p.elec.file = file; end;',...
0198 'set(ELECOpen.handles.EelectrodePath,''String'',ELECOpen.p.elec.path);',...
0199 'set(ELECOpen.handles.EelectrodeFile,''String'',ELECOpen.p.elec.file);',...
0200 'if ~isempty(findstr(file,''.txt'')) | ~isempty(findstr(file,''.asc'')), ',...
0201 'set(ELECOpen.handles.PelectrodeType,''Value'',1); ',...
0202 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0203 'elseif ~isempty(findstr(file,''.dat'')), ',...
0204 'set(ELECOpen.handles.PelectrodeType,''Value'',4); ',...
0205 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0206 'elseif ~isempty(findstr(file,''.tri'')), ',...
0207 'set(ELECOpen.handles.PelectrodeType,''Value'',5); ',...
0208 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0209 'elseif ~isempty(findstr(file,''.mat'')), ',...
0210 'set(ELECOpen.handles.PelectrodeType,''Value'',6); ',...
0211 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0212 'elseif ~isempty(findstr(file,''.elp'')), ',...
0213 'set(ELECOpen.handles.PelectrodeType,''Value'',7); ',...
0214 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0215 'else, ',...
0216 'set(ELECOpen.handles.PelectrodeType,''Value'',1); ',...
0217 'ELECOpen.p.elec.type = popupstr(ELECOpen.handles.PelectrodeType);',...
0218 'end;',...
0219 'set(gcbf,''Userdata'',ELECOpen); clear ELECOpen;');
0220 G.BelectrodeFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0221 'Position',[.01 .01 .18 .2], 'String','BROWSE',...
0222 'BackgroundColor',[0.8 0.8 0.0],...
0223 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0224 'Callback', browsecommand );
0225
0226
0227 G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0228 'Position',[.20 .01 .18 .2],...
0229 'String','PLOT','BusyAction','queue',...
0230 'TooltipString','Plot the data and return the file parameters.',...
0231 'BackgroundColor',[0.0 0.5 0.0],...
0232 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0233 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0234 'p = gui_elec_open(ELECOpen.p,''plot'');',...
0235 'clear ELECOpen;'));
0236
0237
0238 G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0239 'Position',[.40 .01 .18 .2],'HorizontalAlignment', 'center',...
0240 'String','SAVE AS','TooltipString','ELEC File Conversion Tool (not implemented yet)',...
0241 'BusyAction','queue',...
0242 'Visible','on',...
0243 'BackgroundColor',[0.0 0.0 0.75],...
0244 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0245 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0246 'p = gui_elec_open(ELECOpen.p,''save'');',...
0247 'clear ELECOpen;'));
0248
0249
0250 G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0251 'Position',[.60 .01 .18 .2],...
0252 'String','RETURN','BusyAction','queue',...
0253 'TooltipString','Close and return file parameters',...
0254 'BackgroundColor',[0.75 0.0 0.0],...
0255 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0256 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0257 'p = gui_elec_open(ELECOpen.p,''return'');',...
0258 'clear ELECOpen;'));
0259
0260
0261 G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0262 'Position',[.80 .01 .18 .2],...
0263 'String','CANCEL','BusyAction','queue',...
0264 'TooltipString','Close, do not return parameters.',...
0265 'BackgroundColor',[0.75 0.0 0.0],...
0266 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0267 'Callback',strcat('ELECOpen = get(gcbf,''Userdata'');',...
0268 'p = gui_elec_open(ELECOpen.p,''cancel'');',...
0269 'clear ELECOpen;'));
0270
0271
0272 G.Bhelp = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0273 'Position',[.80 .25 .18 .2],'String','Help','BusyAction','queue',...
0274 'BackgroundColor',[1 1 0],...
0275 'ForegroundColor',[0 0 0], 'HorizontalAlignment', 'center',...
0276 'Callback','doc elec_open;');
0277
0278
0279 G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0280 'Position',[.80 .50 .18 .2],'String','Hold GUI','BusyAction','queue',...
0281 'TooltipString','ELEC File Load GUI remains open after ''Plot'' and ''Return'' commands.',...
0282 'Value',p.hold,'HorizontalAlignment', 'center');
0283
0284
0285
0286 if exist('parent','var'), ELECOpen.parent.gui = parent; end
0287 ELECOpen.handles = G;
0288 ELECOpen.p = p;
0289 set(GUI,'Userdata',ELECOpen);
0290
0291 return