Home > bioelectromagnetism > gui_cnt_open.m

gui_cnt_open

PURPOSE ^

gui_cnt_open - Load a CNT data file into matlab workspace

SYNOPSIS ^

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

DESCRIPTION ^

 gui_cnt_open - Load a CNT data file into matlab workspace
 
 Usage: [p] = gui_cnt_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.

 This function returns values into p.cnt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

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