Home > bioelectromagnetism > gui_eeg_open.m

gui_eeg_open

PURPOSE ^

gui_eeg_open - Load an EEG data file into matlab workspace

SYNOPSIS ^

function [p] = gui_eeg_open(p,command,parent)

DESCRIPTION ^

 gui_eeg_open - Load an EEG data file into matlab workspace
 
 Usage: [p] = gui_eeg_open(p,[command],[parent])

 p is a structure, generated by 'eeg_toolbox_defaults'
 command is either 'init' or 'load'
 parent is a handle to the gui that calls this gui, useful
 for updating the UserData field of the parent from this gui.
 The p structure is returned to the parent when the parent 
 handle is given.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [p] = gui_eeg_open(p,command,parent)
0002 
0003 % gui_eeg_open - Load an EEG data file into matlab workspace
0004 %
0005 % Usage: [p] = gui_eeg_open(p,[command],[parent])
0006 %
0007 % p is a structure, generated by 'eeg_toolbox_defaults'
0008 % command is either 'init' or 'load'
0009 % parent is a handle to the gui that calls this gui, useful
0010 % for updating the UserData field of the parent from this gui.
0011 % The p structure is returned to the parent when the parent
0012 % handle is given.
0013 %
0014 
0015 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0016 
0017 % Licence:  GNU GPL, no express or implied warranties
0018 % History:  01/2002, Darren.Weber_at_radiology.ucsf.edu
0019 %           08/2002, Darren.Weber_at_radiology.ucsf.edu
0020 %                    added EMSE avg handling
0021 %                    added interpolation of zero point option
0022 %           10/2003, Darren.Weber_at_radiology.ucsf.edu
0023 %                    created gui_avg_open and adapted this
0024 %                    function to handle CNT/EEG data formats
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 if ~exist('p','var'),
0028  [p] = eeg_toolbox_defaults;
0029 elseif isempty(p),
0030  [p] = eeg_toolbox_defaults;
0031 end
0032 
0033 if ~exist('command','var'), command = 'init'; end
0034 
0035 
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 % Paint the GUI
0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0039 
0040 switch command,
0041   
0042   case 'init',
0043     
0044     if exist('parent','var'),
0045       EEGOpen = INIT(p,parent);
0046     else
0047       EEGOpen = INIT(p,'');
0048     end
0049     
0050   case 'plot',
0051     
0052     EEGOpen = get(gcbf,'Userdata');
0053     
0054     EEGOpen.p = cnt_open(EEGOpen.p,EEGOpen.gui);
0055     set(EEGOpen.gui,'Userdata',EEGOpen); % update GUI with CNT data
0056     
0057    [p] = gui_updateparent(EEGOpen,0);
0058     
0059     if isequal(get(EEGOpen.handles.Bhold,'Value'),0),
0060       close gcbf;
0061       if isfield(EEGOpen,'parent'),
0062         parent = EEGOpen.parent.gui;
0063       else
0064         parent = [];
0065       end
0066     else
0067       parent = EEGOpen.gui;
0068     end
0069     
0070     plotfig = figure('Name',EEGOpen.p.cnt.file,...
0071       'NumberTitle','off',...
0072       'UserData',EEGOpen.p);
0073     movegui(plotfig,'center');
0074     
0075     plot(EEGOpen.p.cnt.timeArray,EEGOpen.p.cnt.data); axis tight;
0076     eeg_plot_metric;
0077     
0078     if isempty(parent), [Xpoint,Ypoint] = eeg_crosshair('init',EEGOpen.p);
0079     else                [Xpoint,Ypoint] = eeg_crosshair('init',EEGOpen.p,parent);
0080     end
0081     
0082   case 'save',
0083     
0084     fprintf('\nGUI_EEG_OPEN: Save As not implemented yet.\n');
0085     
0086   case 'return',
0087     
0088     EEGOpen = get(gcbf,'Userdata');
0089     
0090     set(EEGOpen.gui,'Pointer','watch');
0091     
0092     EEGOpen.p = cnt_open(EEGOpen.p);
0093     
0094     set(EEGOpen.gui,'Pointer','arrow');
0095     
0096     if isequal(get(EEGOpen.handles.Bhold,'Value'),1),
0097      [p] = gui_updateparent(EEGOpen,0);
0098     else
0099      [p] = gui_updateparent(EEGOpen);
0100       close gcbf;
0101     end
0102     
0103   otherwise,
0104     
0105     EEGOpen = get(gcbf,'Userdata');
0106     GUI.parent = EEGOpen.parent;
0107     gui_updateparent(GUI);
0108     close gcbf;
0109     
0110 end
0111 
0112 return
0113 
0114 
0115 
0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0118 function [EEGOpen] = INIT(p,parent)
0119 % GUI General Parameters
0120 
0121 GUIwidth  = 500;
0122 GUIheight = 120;
0123 
0124 version = '$Revision: 1.1 $';
0125 name = sprintf('EEG File Open [v %s]\n',version(11:15));
0126 
0127 GUI = figure('Name',name,'Tag','EEG_OPEN',...
0128   'NumberTitle','off',...
0129   'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0130 movegui(GUI,'center');
0131 
0132 Font.FontName   = 'Helvetica';
0133 Font.FontUnits  = 'Pixels';
0134 Font.FontSize   = 12;
0135 Font.FontWeight = 'normal';
0136 Font.FontAngle  = 'normal';
0137 
0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0139 % CNT Data Selection and Parameters
0140 
0141 G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0142   'Position',[.01 .75 .17 .2],...
0143   'String','Data Type:','HorizontalAlignment','left');
0144 
0145 switch lower(p.cnt.type),
0146   case 'scan4x_cnt',  cntType = 1;
0147   case 'scan3x_cnt',  cntType = 2;
0148   otherwise,          cntType = 1;
0149 end
0150 
0151 %  'String',{'ASCII_CNT' 'Scan4x_CNT' 'Scan3x_CNT' 'EEGLAB'},'Value',cntType,...
0152 
0153 G.PcntType = uicontrol('Tag','PcntType','Parent',GUI,'Style','popupmenu',...
0154   'Units','Normalized',Font,  ...
0155   'Position',[.20 .75 .2 .2],...
0156   'String',{'scan4x_cnt' 'scan3x_cnt'},'Value',cntType,...
0157   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0158   'EEGOpen.p.cnt.type = popupstr(EEGOpen.handles.PcntType);',...
0159   'set(gcbf,''Userdata'',EEGOpen); clear EEGOpen;'));
0160 
0161 G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0162   'Position',[.01 .50 .17 .2],...
0163   'String','Path','HorizontalAlignment','left');
0164 G.EcntPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0165   'Position',[.20 .50 .58 .2], 'String',p.cnt.path,...
0166   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0167   'EEGOpen.p.cnt.path = get(EEGOpen.handles.EcntPath,''String'');',...
0168   'set(gcbf,''Userdata'',EEGOpen); clear EEGOpen;'));
0169 
0170 G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0171   'Position',[.01 .25 .17 .2],...
0172   'String','File','HorizontalAlignment','left');
0173 G.EcntFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0174   'Position',[.20 .25 .58 .2], 'String',p.cnt.file,...
0175   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0176   'EEGOpen.p.cnt.file = get(EEGOpen.handles.EcntFile,''String'');',...
0177   'set(gcbf,''Userdata'',EEGOpen); clear EEGOpen;'));
0178 
0179 Font.FontWeight = 'bold';
0180 
0181 % BROWSE: Look for the data
0182 browsecommand = strcat('EEGOpen = get(gcbf,''Userdata'');',...
0183   'cd(EEGOpen.p.cnt.path);',...
0184   '[file, path] = uigetfile(',...
0185   '{''*.cnt'', ''NeuroScan (*.cnt)'';', ...
0186   ' ''*.*'',   ''All Files (*.*)''},', ...
0187   '''Select EEG File'');',...
0188   'if ~isequal(path,0), EEGOpen.p.cnt.path = path; end;',...
0189   'if ~isequal(file,0), EEGOpen.p.cnt.file = file; end;',...
0190   'set(EEGOpen.handles.EcntPath,''String'',EEGOpen.p.cnt.path);',...
0191   'set(EEGOpen.handles.EcntFile,''String'',EEGOpen.p.cnt.file);',...
0192   'set(gcbf,''Userdata'',EEGOpen); clear EEGOpen file path;');
0193 G.BcntFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0194   'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0195   'BackgroundColor',[0.8 0.8 0.0],...
0196   'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0197   'Callback', browsecommand );
0198 
0199 % PLOT: Load & plot the data!
0200 G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0201   'Position',[.20 .01 .18 .2],...
0202   'String','PLOT','BusyAction','queue',...
0203   'TooltipString','Plot the EEG data and return p struct.',...
0204   'BackgroundColor',[0.0 0.5 0.0],...
0205   'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0206   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0207   'p = gui_eeg_open(EEGOpen.p,''plot'');',...
0208   'clear EEGOpen;'));
0209 
0210 % Save As
0211 G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0212   'Position',[.40 .01 .18 .2],'HorizontalAlignment', 'center',...
0213   'String','SAVE AS','TooltipString','EEG File Conversion Tool (not implemented yet)',...
0214   'BusyAction','queue',...
0215   'Visible','off',...
0216   'BackgroundColor',[0.0 0.0 0.75],...
0217   'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0218   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0219   'p = gui_eeg_open(EEGOpen.p,''save'');',...
0220   'clear EEGOpen;'));
0221 
0222 % Quit, return file parameters
0223 G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0224   'Position',[.60 .01 .18 .2],...
0225   'String','RETURN','BusyAction','queue',...
0226   'TooltipString','Return p struct to workspace and parent GUI.',...
0227   'BackgroundColor',[0.75 0.0 0.0],...
0228   'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0229   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0230   'p = gui_eeg_open(EEGOpen.p,''return'');',...
0231   'clear EEGOpen;'));
0232 
0233 % Cancel
0234 G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0235   'Position',[.80 .01 .18 .2],...
0236   'String','CANCEL','BusyAction','queue',...
0237   'TooltipString','Close, do not return parameters.',...
0238   'BackgroundColor',[0.75 0.0 0.0],...
0239   'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0240   'Callback',strcat('EEGOpen = get(gcbf,''Userdata'');',...
0241   'p = gui_eeg_open(EEGOpen.p,''cancel'');',...
0242   'clear EEGOpen;'));
0243 
0244 % Hold GUI Open checkbox
0245 G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0246   'Position',[.80 .25 .18 .2],'String','Hold GUI','BusyAction','queue',...
0247   'TooltipString','EEG File Load GUI remains open after ''Plot'' or ''Return'' commands.',...
0248   'Value',p.hold,'HorizontalAlignment', 'center');
0249 
0250 
0251 % Store userdata
0252 if exist('parent','var'), EEGOpen.parent.gui = parent; end
0253 EEGOpen.gui = GUI;          
0254 EEGOpen.handles = G;
0255 EEGOpen.p = p;
0256 set(GUI,'Userdata',EEGOpen);
0257 set(GUI,'HandleVisibility','callback');
0258 
0259 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003