Home > bioelectromagnetism > eeg_toolbox.m

eeg_toolbox

PURPOSE ^

eeg_toolbox - Graphical user interface (GUI) to various EEG/ERP tools

SYNOPSIS ^

function [ varargout ] = eeg_toolbox(command)

DESCRIPTION ^

 eeg_toolbox - Graphical user interface (GUI) to various EEG/ERP tools

 The main gui is the primary store for general parameters 
 and provides access to other tools.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ varargout ] = eeg_toolbox(command)
0002 
0003 % eeg_toolbox - Graphical user interface (GUI) to various EEG/ERP tools
0004 %
0005 % The main gui is the primary store for general parameters
0006 % and provides access to other tools.
0007 %
0008 
0009 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0010 
0011 % Licence:  GNU GPL, no express or implied warranties
0012 % History:  01/2002, Darren.Weber_at_radiology.ucsf.edu
0013 %           08/2002, Darren.Weber_at_radiology.ucsf.edu
0014 %                    added MRI viewer
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 if ~exist('command','var'),
0019     command = 'init';
0020 elseif isempty(command),
0021     command = 'init';
0022 end
0023 
0024 command = lower(command);
0025 
0026 switch command,
0027 case 'init',
0028 otherwise,
0029     EEGTOOLBOX = get(gcbf,'Userdata');
0030 end
0031 
0032 switch command,
0033     
0034 case 'init',
0035     EEGTOOLBOX = init;
0036     
0037 case 'openerp',
0038     gui_erp_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0039 
0040 case 'openerf',
0041     gui_erf_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0042 
0043 case 'opencnt',
0044     gui_cnt_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0045     
0046 case 'openeeg',
0047     gui_eeg_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0048     
0049 case 'opene',
0050     gui_elec_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0051     
0052 case 'opent',
0053     gui_mesh_open(EEGTOOLBOX.p,'init',EEGTOOLBOX.gui);
0054     
0055 case 'openm',
0056     mri_toolbox('init');
0057     
0058 case 'defaultreturn',
0059     % keep this command so the return action is tidy
0060     %p = EEGTOOLBOX.p; % done below
0061     
0062 case 'defaultreset',
0063     EEGTOOLBOX.p = eeg_toolbox_defaults('create');
0064     
0065 case 'defaultsave',
0066     eeg_toolbox_defaults('write',EEGTOOLBOX.p);
0067     
0068 case 'saveas',
0069     eeg_toolbox_defaults('write_other',EEGTOOLBOX.p);
0070     
0071 case 'recent',
0072     
0073     % -- get recent files list
0074     
0075     recentfiles = eeg_toolbox_recent;
0076     
0077     % -- remove current menu items for recent files
0078     
0079     if isfield(EEGTOOLBOX.menu,'recentfiles'),
0080         handleIndex = find(ishandle(EEGTOOLBOX.menu.recentfiles));
0081         delete(EEGTOOLBOX.menu.recentfiles(handleIndex));
0082     end
0083     EEGTOOLBOX.menu.recentfiles = [];
0084     
0085     % -- recreate recent files menu items
0086     
0087     if and(size(recentfiles,2) == 1, isempty(recentfiles{1})),
0088         if ishandle(EEGTOOLBOX.menu.recent),
0089             set(EEGTOOLBOX.menu.recent,'Label','No Recent Files');
0090         end
0091     else
0092         if ishandle(EEGTOOLBOX.menu.recent),
0093             set(EEGTOOLBOX.menu.recent,'Label','Recent Files');
0094         end
0095         
0096         % -- add recent files to menu and setup their callbacks
0097         
0098         for i=1:length(recentfiles),
0099             if ~isempty(recentfiles{i}),
0100                 EEGTOOLBOX.menu.recentfiles(i) = uimenu(EEGTOOLBOX.menu.recent,...
0101                     'Label',recentfiles{i},...
0102                     'Callback',strcat('[recentfiles,p] = eeg_toolbox_recent(''',...
0103                     recentfiles{i},''',''load''); ',...
0104                     'EEGTOOLBOX = get(gcbf,''Userdata''); ',...
0105                     'gui_eeg_open(p,''init'',EEGTOOLBOX.gui); ',...
0106                     'clear EEGTOOLBOX recentfiles;'));
0107             end
0108         end
0109         
0110         % -- add recent files clear command
0111         
0112         EEGTOOLBOX.menu.recentfiles(i+1) = uimenu(EEGTOOLBOX.menu.recent,...
0113             'Label','Clear All',...
0114             'Callback',strcat('eeg_toolbox_recent('''',''clear''); ',...
0115             'eeg_toolbox(''recent''); '));
0116     end
0117     
0118 case 'exit',
0119     close gcbf;
0120     
0121 otherwise,
0122     fprintf('...invalid command to eeg_toolbox\n\n');
0123     
0124 end
0125 
0126 
0127 switch command,
0128 case 'exit',
0129 otherwise,
0130     set(EEGTOOLBOX.gui,'UserData',EEGTOOLBOX);
0131 end
0132 
0133 if nargout > 0,
0134     if isfield(EEGTOOLBOX,'p'),
0135         if ~isempty(EEGTOOLBOX.p),
0136             varargout{1} = EEGTOOLBOX.p;
0137         end
0138     end
0139 end
0140 
0141 return
0142 
0143 
0144 
0145 
0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0147 % Paint the GUI
0148 function [H] = init()
0149 
0150 % Parameters are supplied in the file defaultfile.
0151 H.p = eeg_toolbox_defaults('read');
0152 
0153 GUIwidth  = 250;
0154 GUIheight = 50;
0155 
0156 if exist('ctf_read'),
0157   name = 'EEG/MEG Toolbox';
0158 else
0159   name = 'EEG Toolbox';
0160 end
0161 
0162 H.gui = figure('Name',name,'Tag','EEG_TOOLBOX',...
0163     'NumberTitle','off','HandleVisibility','callback',...
0164     'MenuBar','none');
0165 set(H.gui,'Position',[1 1 GUIwidth GUIheight]);  % Activate GUI Figure
0166 movegui(H.gui, 'center');
0167 
0168 
0169 license = ['EEG_TOOLBOX, Copyright (C) 2004 Darren L. Weber\n',...
0170 'EEG_TOOLBOX comes with ABSOLUTELY NO WARRANTY; for details\n',...
0171 'see `help gpl`.  This is free software, and you are welcome\n',...
0172 'to redistribute it under certain conditions; see `help gpl`\n',... 
0173 'for details.\n\n'];
0174 fprintf(license);
0175 
0176 
0177 % -- file menu
0178 
0179 H.menu.file_menu = uimenu(H.gui,'Label','File',...
0180                           'Callback','eeg_toolbox(''recent'');');
0181 
0182 H.menu.open_eeg   = uimenu(H.menu.file_menu,'Label','Open EEG');
0183 H.menu.open_erp   = uimenu(H.menu.open_eeg,'Label','Average ERP',...
0184                            'Callback','p = eeg_toolbox(''openERP'');','Accelerator','v');
0185 H.menu.open_cont  = uimenu(H.menu.open_eeg,'Label','Neuroscan Continuous (CNT)',...
0186                            'Callback','p = eeg_toolbox(''openCNT'');','Accelerator','c');
0187 H.menu.open_epoch = uimenu(H.menu.open_eeg,'Label','Neuroscan Epochs (EEG)',...
0188                            'Callback','p = eeg_toolbox(''openEEG'');','Accelerator','e');
0189 
0190 if exist('ctf_read'),
0191   H.menu.open_meg = uimenu(H.menu.file_menu,'Label','Open MEG');
0192   H.menu.open_erf = uimenu(H.menu.open_meg,'Label','Average ERF',...
0193                            'Callback','p = eeg_toolbox(''openERF'');','Accelerator','f');
0194 end
0195 
0196 H.menu.open_elec = uimenu(H.menu.file_menu,'Label','Open Sensors/Electrodes',...
0197     'Callback','p = eeg_toolbox(''openE'');','Accelerator','s');
0198 H.menu.open_tess = uimenu(H.menu.file_menu,'Label','Open Tesselation',...
0199     'Callback','p = eeg_toolbox(''openT'');','Accelerator','t');
0200 if exist('avw_img_read.m') == 2,
0201     H.menu.open_mri = uimenu(H.menu.file_menu,'Label','Open MRI',...
0202         'Callback','mri = mri_toolbox(''init'');','Accelerator','m');
0203 end
0204 
0205 H.menu.recent = uimenu(H.menu.file_menu,'Label','Recent');
0206 H.menu.quit   = uimenu(H.menu.file_menu,'Label','Exit',...
0207     'Callback','eeg_toolbox(''exit'');','Accelerator','x');
0208 
0209 % -- Parameters menu
0210 
0211 H.menu.p_menu = uimenu(H.gui,'Label','Parameters');
0212 H.menu.show   = uimenu(H.menu.p_menu,'Label','Return to Workspace',...
0213     'Callback','p = eeg_toolbox(''defaultreturn'')');
0214 H.menu.reset  = uimenu(H.menu.p_menu,'Label','Reset to Defaults',...
0215     'Callback','p = eeg_toolbox(''defaultreset'');');
0216 H.menu.save   = uimenu(H.menu.p_menu,'Label','Save Defaults',...
0217     'Callback','p = eeg_toolbox(''defaultsave'');');
0218 H.menu.saveas = uimenu(H.menu.p_menu,'Label','Save As Data Workspace',...
0219     'Callback','p = eeg_toolbox(''saveas'');');
0220 
0221 % -- help menu
0222 
0223 H.menu.Help = uimenu(H.gui,'Label','Help');
0224 H.menu.help = uimenu(H.menu.Help,'Label','Help','Callback','doc eeg_toolbox;');
0225 H.menu.gpl  = uimenu(H.menu.Help,'Label','GPL',...
0226     'Callback',['eegpath = eeg_toolbox_path; cd(eegpath);',...
0227         'fid = fopen([eegpath,''\gpl.txt'']);',...
0228         'fseek(fid,0,''eof''); eof_bytes = ftell(fid); fseek(fid,0,''bof'');',...
0229         'while ftell(fid) < eof_bytes,',...
0230         '      tline = fgetl(fid); disp(tline);',...
0231         'end;']);
0232 
0233 return

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