Home > bioelectromagnetism > gui_eeg_contours.m

gui_eeg_contours

PURPOSE ^

gui_eeg_contours - GUI controls for topographic mapping of scalp potentials

SYNOPSIS ^

function [G,p] = gui_eeg_contours(p,parent)

DESCRIPTION ^

 gui_eeg_contours - GUI controls for topographic mapping of scalp potentials

 Paint Graphical user interface (GUI) for eeg_contour_engine.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [G,p] = gui_eeg_contours(p,parent)
0002 
0003 % gui_eeg_contours - GUI controls for topographic mapping of scalp potentials
0004 %
0005 % Paint Graphical user interface (GUI) for eeg_contour_engine.m
0006 %
0007 
0008 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0009 
0010 % Licence:  GNU GPL, no express or implied warranties
0011 % History:  09/99 Chris Harvey, initial development
0012 %                 diagnostics, optional plots, interactive timepoint selection
0013 %           07/01 Darren.Weber_at_radiology.ucsf.edu
0014 %                 completely revised. Significant improvement to GUI painting
0015 %                 and general parameter handling and callback functions. Added
0016 %                 various functionality to take advantage of better engines.
0017 %
0018 % Depends:        eeg_contours.m
0019 %                 eeg_colormap.m, ColorMapsShow.m, ColorMapsMake.m
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 % initial values.
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 
0026 if ~exist('p','var'),
0027     % Default parameters
0028    [p] = eeg_toolbox_defaults('create');
0029 elseif isempty(p),
0030    [p] = eeg_toolbox_defaults('create');
0031 end
0032 EEGCONTOURS.p = p;
0033 
0034 
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 % Paint the GUI
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 
0039 
0040     % GUI General Parameters
0041     
0042     version = ' [alpha 1.0]';
0043 
0044     GUIwidth  = 550;
0045     GUIheight = 500;
0046     
0047     GUI = figure('Name',strcat('EEG Contours ',version),'Tag','EEG_Contours',...
0048                 'NumberTitle','off','HandleVisibility','callback',...
0049                 'MenuBar','none');
0050     set(GUI,'Position',[1 1 GUIwidth GUIheight]);  % Activate GUI Figure
0051     movegui(GUI,'center');
0052     
0053     filewidth       = .70;          %Normalized GUI units
0054     frameindent     = .01;
0055     frameheight     = .06;
0056     framewidth      = .98;
0057     
0058     titlewidth      = .20;
0059     textheight      = .04;  
0060     textwidth       = .10;
0061     editheight      = textheight;  
0062     editwidth       = textwidth;   
0063     boxheight       = .05;
0064     boxwidth        = textwidth + .02;
0065     radioheight     = textheight;
0066     radiowidth      = .22;
0067     popupheight     = textheight;
0068     popupwidth      = .25;
0069     sliderheight    = textheight;
0070     sliderwidth     = .35;
0071     
0072     Font.FontName   = 'Helvetica';
0073     Font.FontUnits  = 'Pixels';
0074     Font.FontSize   = 12;
0075     Font.FontWeight = 'normal';
0076     Font.FontAngle  = 'normal';
0077     
0078     
0079     
0080     
0081     indent      = [frameindent .25 .50 .75 .85];
0082     L           = [.01 .06 .11 .16 .21 .26 .31 .36 .41];
0083     
0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0085 % Electrode File Selection
0086 % Cartesian or Spherical Coordinates? Units of measurement: cm or m?
0087     height = .99 - frameheight*4;
0088     
0089     G.Frame_elec = uicontrol('Tag','Frame_elec','Parent',GUI,'Style','frame',...
0090         'Units','Normalized','Position',[frameindent height framewidth frameheight*4]);
0091     
0092     G.Title_elec = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0093         'Position',[frameindent*2 height+L(4) titlewidth textheight],...
0094         'String','Electrode File','HorizontalAlignment','left',...
0095         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0096         'Callback',strcat('EEGCONTOURS = get(gcbf,''UserData'');',...
0097                           'gui_elec_open(EEGCONTOURS.p,''init'',EEGCONTOURS.gui);',...
0098                           'clear EEGCONTOURS;'));
0099     
0100     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0101     % Surface Interpolation
0102 
0103     G.Title_gridMethod = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
0104         'Position',[frameindent*2 height+L(2) titlewidth textheight*2],...
0105         'String','Surface Interpolation','HorizontalAlignment','left');
0106     
0107     switch p.elec.shape
0108     case 'sphere',    shape = 1;    % spherical fitting
0109     case 'ellipse',   shape = 2;    % elliptical fitting
0110     case 'realistic', shape = 3;    % no fitting, use real locations
0111     otherwise,        shape = 3;
0112     end
0113        G.PelecShape = uicontrol('Tag','PelecShape','Parent',GUI,'Style','popupmenu',...
0114         'Units','Normalized',Font,...
0115         'TooltipString','Fit ''sphere'' or ''ellipse'' to ''realistic'' electrode positions.',...
0116         'Position',[indent(2) height+L(3)+.005 popupwidth popupheight],...
0117         'String',{'sphere' 'ellipse' 'realistic'},'Value',shape,...
0118         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0119                           'EEGCONTOURS.p.elec.shape = popupstr(EEGCONTOURS.handles.PelecShape);',...
0120                           'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0121    
0122     switch p.interpMethod
0123     case 'linear',        interp = 1;
0124     case 'cubic',         interp = 2;
0125     case 'nearest',       interp = 3;
0126     case 'v4 or invdist', interp = 4;
0127     end
0128     G.PinterpMethod = uicontrol('Tag','PinterpMethod','Parent',GUI,'Style','popupmenu',...
0129         'Units','Normalized',Font,...
0130         'TooltipString','Matlab ''griddata'' interpolation methods.',...
0131         'Position',[indent(3) height+L(3)+.005 popupwidth popupheight],...
0132         'String',{'linear' 'cubic' 'nearest' 'v4' 'invdist'},'Value',interp,...
0133         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0134                           'EEGCONTOURS.p.interpMethod = popupstr(EEGCONTOURS.handles.PinterpMethod);',...
0135                           'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0136    
0137     switch p.grid.method
0138         case 1,     gridM = [1 0]; gridEnable = {'on', 'off'};
0139         otherwise,  gridM = [0 1]; gridEnable = {'off','on' };
0140     end
0141     
0142     G.BgridMethod1 = uicontrol('Parent',GUI,'Style','Radiobutton','Units','Normalized', Font, ...
0143         'Position',[indent(2) height+L(2)+.002 .2 textheight], 'String','Grid Size','Value',gridM(1));
0144     G.SgridSize = uicontrol('Parent',GUI,'Style','slider','Units','Normalized', ...
0145         'Position',[indent(3) height+L(2)+.002 sliderwidth boxheight],'Enable',char(gridEnable(1)),...
0146         'Min', p.grid.sizeMin, 'Max', p.grid.sizeMax, 'Value', p.grid.size, 'SliderStep',[0.005 0.05]);
0147     G.EgridSize = uicontrol('Parent',GUI,'Style','edit','Units','Normalized', Font, ...
0148         'Position',[indent(5) height+L(2)+.002 .1 boxheight],'Enable',char(gridEnable(1)),...
0149         'Min', p.grid.sizeMin, 'Max', p.grid.sizeMax, 'Value', p.grid.size, 'String', num2str(p.grid.size));
0150     
0151     G.BgridMethod2 = uicontrol('Parent',GUI,'Style','Radiobutton','Units','Normalized', Font, ...
0152         'Position',[indent(2) height+L(1) .2 textheight], 'String','Grid Resolution','Value',gridM(2));
0153     G.SgridRes = uicontrol('Parent',GUI,'Style','slider','Units','Normalized', ...
0154         'Position',[indent(3) height+L(1) sliderwidth boxheight],'Enable',char(gridEnable(2)),...
0155         'Min', p.grid.resMin, 'Max', p.grid.resMax, 'Value', p.grid.res, 'SliderStep',[0.005 0.05]);
0156     G.EgridRes = uicontrol('Parent',GUI,'Style','edit','Units','Normalized', Font, ...
0157         'Position',[indent(5) height+L(1) .1 boxheight],'Enable',char(gridEnable(2)),...
0158         'Min', p.grid.resMin, 'Max', p.grid.resMax, 'Value', p.grid.res, 'String', num2str(p.grid.res));
0159     
0160     % Set grid size parameters
0161     set(G.BgridMethod1,'Callback', strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0162         'set(EEGCONTOURS.handles.BgridMethod1,''Value'',1);',...
0163         'set(EEGCONTOURS.handles.BgridMethod2,''Value'',0);',...
0164         'set(EEGCONTOURS.handles.SgridSize,''Enable'',''on'');',...
0165         'set(EEGCONTOURS.handles.EgridSize,''Enable'',''on'');',...
0166         'set(EEGCONTOURS.handles.SgridRes,''Enable'',''off'');',...
0167         'set(EEGCONTOURS.handles.EgridRes,''Enable'',''off''); ',...
0168         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0169     
0170     set(G.SgridSize,'Callback',...
0171         strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0172         'EEGCONTOURS.p.grid.size = round( get(EEGCONTOURS.handles.SgridSize,''Value'') ); ',...
0173         'set(EEGCONTOURS.handles.EgridSize,''String'', num2str(EEGCONTOURS.p.grid.size),''Value'', EEGCONTOURS.p.grid.size ); ',...
0174         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0175     
0176     set(G.EgridSize,'Callback',...
0177         strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0178         'EEGCONTOURS.p.grid.size = round( str2num( get(EEGCONTOURS.handles.EgridSize,''String'') ) ); ',...
0179         'set(EEGCONTOURS.handles.EgridSize,''String'', num2str(EEGCONTOURS.p.grid.size),''Value'', EEGCONTOURS.p.grid.size ); ',...
0180         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0181     
0182     % Set grid resolution parameters
0183     set(G.BgridMethod2,'Callback', strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0184         'set(EEGCONTOURS.handles.BgridMethod1,''Value'',0);',...
0185         'set(EEGCONTOURS.handles.BgridMethod2,''Value'',1);',...
0186         'set(EEGCONTOURS.handles.SgridSize,''Enable'',''off'');',...
0187         'set(EEGCONTOURS.handles.EgridSize,''Enable'',''off'');',...
0188         'set(EEGCONTOURS.handles.SgridRes,''Enable'',''on'');',...
0189         'set(EEGCONTOURS.handles.EgridRes,''Enable'',''on''); ',...
0190         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0191     
0192     set(G.SgridRes,'Callback',...
0193         strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0194         'EEGCONTOURS.p.grid.res = get(EEGCONTOURS.handles.SgridRes,''Value''); ',...
0195         'set(EEGCONTOURS.handles.EgridRes,''String'', num2str(EEGCONTOURS.p.grid.res),''Value'', EEGCONTOURS.p.grid.res ); ',...
0196         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0197     set(G.EgridRes, 'Callback',...
0198         strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0199         'EEGCONTOURS.p.grid.res = str2num( get(EEGCONTOURS.handles.EgridRes,''String'') ); ',...
0200         'set(EEGCONTOURS.handles.EgridRes,''String'', num2str(EEGCONTOURS.p.grid.res),''Value'', EEGCONTOURS.p.grid.res ); ',...
0201         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0202 
0203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0204 % Voltage Data Selection and Parameters
0205 
0206     height = (height - .01) - frameheight*5;
0207     
0208     G.Frame_data = uicontrol('Parent',GUI,'Style','frame','Units','Normalized',...
0209         'Position',[frameindent height framewidth frameheight*5]);
0210     
0211     G.Title_data = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0212         'Position',[frameindent*2 height+L(5) titlewidth textheight],...
0213         'String','Voltage File','HorizontalAlignment','left',...
0214         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0215         'Callback',strcat('EEGCONTOURS = get(gcbf,''UserData'');',...
0216                           'gui_eeg_open(EEGCONTOURS.p,''init'',EEGCONTOURS.gui);',...
0217                           'clear EEGCONTOURS;'));
0218     
0219     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0220     % Range of Data to Visualise
0221     
0222     G.Title_range = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0223         'Position',[frameindent*2 height+L(4) titlewidth textheight],...
0224         'String','Voltage Range','HorizontalAlignment','left');
0225 
0226     switch p.rangeMethod
0227         case 'minmaxall', range = [1 0 0 0]; rangeEnable = 'off'; % Min/Max,all points
0228         case 'minmaxone', range = [0 1 0 0]; rangeEnable = 'off'; % Min/Max, single point
0229         case 'minmaxabs', range = [0 0 1 0]; rangeEnable = 'off'; % Min/Max, Absolute
0230         otherwise,        range = [0 0 0 1]; rangeEnable = 'on' ; % Specified range
0231     end
0232     % Min/Max across whole window
0233     G.BrangeMethod1 = uicontrol('Parent',GUI,'Style','Radiobutton',...
0234         'Units','Normalized',Font, ...
0235         'Position',[indent(2) height+L(3) radiowidth radioheight], 'String','Min/Max all points','Value',range(1),...
0236         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0237             'EEGCONTOURS.p.rangeMethod = ''minmaxall'';',...
0238             'set(EEGCONTOURS.handles.BrangeMethod1,''Value'',1);',...
0239             'set(EEGCONTOURS.handles.BrangeMethod2,''Value'',0);',...
0240             'set(EEGCONTOURS.handles.BrangeMethod3,''Value'',0);',...
0241             'set(EEGCONTOURS.handles.BrangeMethod4,''Value'',0);',...
0242             'set(EEGCONTOURS.handles.EminimumIntensity,''Enable'',''off'');',...
0243             'set(EEGCONTOURS.handles.EmaximumIntensity,''Enable'',''off'');',...
0244             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0245     
0246     % Min/Max across time point only
0247     G.BrangeMethod2 = uicontrol('Parent',GUI,'Style','Radiobutton',...
0248         'Units','Normalized',Font,  ...
0249         'Position',[indent(2) height+L(4) radiowidth radioheight],...
0250         'String','Min/Max','Value',range(2),...
0251         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0252             'EEGCONTOURS.p.rangeMethod = ''minmaxone'';',...
0253             'set(EEGCONTOURS.handles.BrangeMethod1,''Value'',0);',...
0254             'set(EEGCONTOURS.handles.BrangeMethod2,''Value'',1);',...
0255             'set(EEGCONTOURS.handles.BrangeMethod3,''Value'',0);',...
0256             'set(EEGCONTOURS.handles.BrangeMethod4,''Value'',0);',...
0257             'set(EEGCONTOURS.handles.EminimumIntensity,''Enable'',''off'');',...
0258             'set(EEGCONTOURS.handles.EmaximumIntensity,''Enable'',''off'');',...
0259             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0260     
0261     % Abs Min/Max across time point only
0262     G.BrangeMethod3 = uicontrol('Parent',GUI,'Style','Radiobutton',...
0263         'Units','Normalized',Font,  ...
0264         'Position',[indent(3) height+L(4) radiowidth radioheight],...
0265         'String','Abs Min/Max','Value',range(3),...
0266         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0267             'EEGCONTOURS.p.rangeMethod = ''minmaxabs'';',...
0268             'set(EEGCONTOURS.handles.BrangeMethod1,''Value'',0);',...
0269             'set(EEGCONTOURS.handles.BrangeMethod2,''Value'',0);',...
0270             'set(EEGCONTOURS.handles.BrangeMethod3,''Value'',1);',...
0271             'set(EEGCONTOURS.handles.BrangeMethod4,''Value'',0);',...
0272             'set(EEGCONTOURS.handles.EminimumIntensity,''Enable'',''off'');',...
0273             'set(EEGCONTOURS.handles.EmaximumIntensity,''Enable'',''off'');',...
0274             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0275     
0276     % scale by specified range
0277     G.BrangeMethod4 = uicontrol('Parent',GUI,'Style','Radiobutton',...
0278         'Units','Normalized',Font,  ...
0279         'Position',[indent(3) height+L(3) radiowidth radioheight], 'String','Specified Range', 'Value',range(4),...
0280         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0281             'EEGCONTOURS.p.rangeMethod = ''minmaxgiv'';',...
0282             'set(EEGCONTOURS.handles.BrangeMethod1,''Value'',0);',...
0283             'set(EEGCONTOURS.handles.BrangeMethod2,''Value'',0);',...
0284             'set(EEGCONTOURS.handles.BrangeMethod3,''Value'',0);',...
0285             'set(EEGCONTOURS.handles.BrangeMethod4,''Value'',1);',...
0286             'min = EEGCONTOURS.p.minimumIntensity;',...
0287             'max = EEGCONTOURS.p.maximumIntensity;',...
0288             'set(EEGCONTOURS.handles.EminimumIntensity,''Enable'',''on'',''Value'',min,''String'',num2str(min) );',...
0289             'set(EEGCONTOURS.handles.EmaximumIntensity,''Enable'',''on'',''Value'',max,''String'',num2str(max) );',...
0290             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0291     
0292     G.Title_min = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0293         'Position',[indent(5)           height+L(4) textwidth textheight],'String','Min');
0294     G.EminimumIntensity = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0295         'Position',[indent(5)-editwidth height+L(4) editwidth editheight],'Enable',rangeEnable,...
0296         'String',num2str(p.minimumIntensity),'Value',p.minimumIntensity,...
0297         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0298             'min = str2num( get(EEGCONTOURS.handles.EminimumIntensity,''String'') );',...
0299             'set(EEGCONTOURS.handles.EminimumIntensity,''Value'',min,''String'',num2str(min) );',...
0300             'EEGCONTOURS.p.minimumIntensity = min; ',...
0301             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0302         
0303     G.Title_max = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0304         'Position',[indent(5)           height+L(3) textwidth textheight],'String','Max');
0305     G.EmaximumIntensity = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0306         'Position',[indent(5)-editwidth height+L(3) editwidth  editheight],'Enable',rangeEnable,...
0307         'String',num2str(p.maximumIntensity),'Value',p.maximumIntensity,...
0308         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0309             'max = str2num( get(EEGCONTOURS.handles.EmaximumIntensity,''String'') );',...
0310             'set(EEGCONTOURS.handles.EmaximumIntensity,''Value'',max,''String'',num2str(max) );',...
0311             'EEGCONTOURS.p.maximumIntensity = max; ',...
0312             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0313     
0314     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0315     % Range of TimePoints
0316     G.Title_range = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0317         'Position',[frameindent*2 height+L(2) titlewidth textheight],...
0318         'String','Time Range','HorizontalAlignment','left');
0319 
0320     switch p.timeMethod
0321         case 1, time = [1 0]; endEnable = 'off'; singleEnable = 'on';  % Single Timepoint
0322         case 2, time = [0 1]; endEnable = 'on';  singleEnable = 'off'; % Range Timepoints
0323     end
0324     G.BclickTimePoint = uicontrol('Parent',GUI,'Style','Checkbox','Units','Normalized',Font,  ...
0325         'Position',[indent(1)+.05 height+L(1) radiowidth radioheight],...
0326         'String','Click Plot',...
0327         'TooltipString','Interactive data timepoint selection.',...
0328         'Value',p.clickTimePoint,...
0329         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0330             'EEGCONTOURS.p.clickTimePoint = get(EEGCONTOURS.handles.BclickTimePoint,''Value'');',...
0331             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0332         
0333     G.Title_sample1   = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0334         'Position',[indent(2)-.04           height+L(2) radiowidth textheight],...
0335         'String','Sample Rate',...
0336         'TooltipString','Disabled until functionality developed.');
0337     G.EtimeSample     = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0338         'Position',[indent(2)               height+L(1) editwidth  editheight],...
0339         'Min', 1, 'Max', 50000, ...
0340         'Value', p.volt.sampleMsec, 'String', num2str(p.volt.sampleMsec),...
0341         'TooltipString','Specify EEG/ERP sample rate in milliseconds.');
0342     
0343     G.BtimeMethod1    = uicontrol('Parent',GUI,'Style','Radiobutton',...
0344         'Units','Normalized',Font, ...
0345         'Position',[indent(3) height+L(2) radiowidth radioheight],...
0346         'String','Single Point','Value',time(1));
0347     G.EtimePoint      = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0348         'Position',[indent(4) height+L(2) editwidth  editheight], 'Min', 1, 'Max', 50000, ...
0349         'Value', p.volt.samplePoint, 'String', num2str(p.volt.samplePoint));
0350     G.Title_start     = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0351         'Position',[indent(5) height+L(2) textwidth textheight],'String','Start');
0352     
0353     G.BtimeMethod2 = uicontrol('Parent',GUI,'Style','Radiobutton',...
0354         'Units','Normalized',Font,  ...
0355         'Position',[indent(3)           height+L(1) radiowidth radioheight],...
0356         'String','Range','Value',time(2),...
0357         ...
0358         ...
0359         'TooltipString','Disabled until functionality developed.',...
0360         'Enable','off');
0361     
0362     G.EendTime  = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0363         'Position',[indent(4) height+L(1) editwidth  editheight],'Enable',endEnable,...
0364         'String',num2str(p.endTime),'Value',p.endTime);
0365     G.Title_end = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0366         'Position',[indent(5)           height+L(1) textwidth  textheight],'String','End');
0367 
0368     % Single Timepoint
0369     set(G.BtimeMethod1,'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0370         'set(EEGCONTOURS.handles.BtimeMethod1,''Value'',1);',...
0371         'set(EEGCONTOURS.handles.BtimeMethod2,''Value'',0);',...
0372         'set(EEGCONTOURS.handles.EendTime,''Enable'',''off'');',...
0373         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0374     
0375     % Specify a time point range
0376     set(G.BtimeMethod2,'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0377         'set(EEGCONTOURS.handles.BtimeMethod1,''Value'',0);',...
0378         'set(EEGCONTOURS.handles.BtimeMethod2,''Value'',1);',...
0379         'set(EEGCONTOURS.handles.EendTime,''Enable'',''on'');',...
0380         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0381     
0382     set(G.EtimeSample,'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0383         'EEGCONTOURS.p.timeSample = str2num( get(EEGCONTOURS.handles.EtimeSample,''String'') );',...
0384         'set(EEGCONTOURS.handles.EtimeSample,''Value'',EEGCONTOURS.p.timeSample,''String'',num2str(EEGCONTOURS.p.timeSample) );',...
0385         'set(EEGCONTOURS.handles.EtimePoint,''Value'',EEGCONTOURS.p.volt.samplePoint,''String'',num2str(EEGCONTOURS.p.volt.samplePoint) );',...
0386         'set(EEGCONTOURS.handles.EendTime,  ''Value'',EEGCONTOURS.p.endTime,  ''String'',num2str(EEGCONTOURS.p.endTime) );',...
0387         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0388     
0389     set(G.EtimePoint,'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0390         'EEGCONTOURS.p.volt.samplePoint = str2num( get(EEGCONTOURS.handles.EtimePoint,''String'') );',...
0391         'set(EEGCONTOURS.handles.EtimePoint,''Value'',EEGCONTOURS.p.volt.samplePoint,''String'',num2str(EEGCONTOURS.p.volt.samplePoint) );',...
0392         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0393     
0394     set(G.EendTime,'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0395         'EEGCONTOURS.p.endTime = str2num( get(EEGCONTOURS.handles.EendTime,''String'') );',...
0396         'set(EEGCONTOURS.handles.EendTime,  ''Value'',EEGCONTOURS.p.endTime,  ''String'',num2str(EEGCONTOURS.p.endTime) );',...
0397         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0398     
0399     
0400     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0401     % Contour Size
0402     height = (height - .01) - frameheight;
0403     
0404     G.Frame_step = uicontrol('Parent',GUI,'Style','frame','Units','Normalized',...
0405         'Position',[frameindent   height framewidth frameheight]);
0406     
0407     G.Bcontourstep = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0408         'Position',[frameindent*2 height+L(1) titlewidth textheight],...
0409         'String','Contour Steps','HorizontalAlignment','left',...
0410         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0411         'Callback','gui_eeg_contour_steps(gcbf);');
0412     
0413     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0414     % Contour ColorMap
0415     height = (height - .01) - frameheight;
0416     
0417     G.Frame_step = uicontrol('Parent',GUI,'Style','frame','Units','Normalized',...
0418         'Position',[frameindent   height framewidth frameheight]);
0419     
0420     G.Title_step = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
0421         'Position',[frameindent*2 height+L(1) titlewidth textheight],...
0422         'String','Color Maps','HorizontalAlignment','left');
0423 
0424     G.BEEGcolorMap = uicontrol('Parent',GUI,'Style','pushbutton',...
0425         'Units','Normalized', Font, ...
0426         'Position',[indent(2)+.01 height+L(1) radiowidth radioheight], 'String','EEG ColorMaps',...
0427         'BusyAction','queue','HorizontalAlignment', 'center',...
0428         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0429         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0430             'tmp = gui_eeg_colormap(EEGCONTOURS.gui);',...
0431             'clear tmp EEGCONTOURS;'));
0432     
0433     G.BcolorMap = uicontrol('Parent',GUI,'Style','pushbutton',...
0434         'Units','Normalized', Font, ...
0435         'Position',[indent(3)+.01 height+L(1) radiowidth radioheight], 'String','MATLAB ColorMaps',...
0436         'BusyAction','queue','HorizontalAlignment', 'center',...
0437         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0438         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0439             'EEGCONTOURS.p.colorMap.map = ColorMapsShow;',...
0440             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0441     
0442     G.BcreateCMap = uicontrol('Parent',GUI,'Style','pushbutton',...
0443         'Units','Normalized', Font, ...
0444         'Position',[indent(4) height+L(1) radiowidth radioheight], 'String','Create ColorMap',...
0445         'BusyAction','queue','HorizontalAlignment', 'center',...
0446         'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
0447         'Tooltipstring','Not yet integrated fully with EEG toolbox - can export to main workspace.',...
0448         'Callback','ColorMapsMake;');
0449 
0450     
0451     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0452     % Plot Controls
0453     height = (height - .01) - frameheight*3;
0454     
0455     G.Frame_plots = uicontrol('Parent',GUI,'Style','frame','Units','Normalized', ...
0456         'Position',[frameindent   height  framewidth frameheight*3]);
0457     
0458     G.Title_plots = uicontrol('Parent',GUI,'Style','text','Units','Normalized', Font, ...
0459         'Position',[frameindent*2 height+L(3) titlewidth  textheight],...
0460         'String','Plot Control','HorizontalAlignment','left');
0461     
0462     G.BplotElec = uicontrol('Parent',GUI,'Style','Checkbox','Units','Normalized', Font, ...
0463         'Position',[indent(2) height+L(3) radiowidth radioheight],...
0464         'String','Electrodes','Value',p.elec.plot,...
0465         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0466         'EEGCONTOURS.p.elec.plot = get(EEGCONTOURS.handles.BplotElec, ''Value'');',...
0467         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0468     
0469     G.BplotESurface    = uicontrol('Parent',GUI,'Style','Checkbox',...
0470         'Units','Normalized', Font, ...
0471         'Position',[indent(2) height+L(2) radiowidth radioheight],...
0472         'String','Elec Surface','Value',p.elec.plotSurf,...
0473         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0474         'EEGCONTOURS.p.elec.plotSurf = get(EEGCONTOURS.handles.BplotESurface, ''Value'');',...
0475         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0476 
0477     G.BplotMSurface    = uicontrol('Parent',GUI,'Style','Checkbox',...
0478         'Units','Normalized', Font, ...
0479         'Position',[indent(2) height+L(1) radiowidth radioheight],...
0480         'String','Mesh Surface','Value',p.mesh.plotSurf,...
0481         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0482         'EEGCONTOURS.p.mesh.plotSurf = get(EEGCONTOURS.handles.BplotMSurface, ''Value'');',...
0483         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0484     
0485     G.BplotRaw2D      = uicontrol('Parent',GUI,'Style','Checkbox',...
0486         'Units','Normalized', Font, ...
0487         'Position',[indent(3) height+L(3) radiowidth radioheight],...
0488         'String','2D Contour','Value',p.contour.raw2D,...
0489         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0490         'EEGCONTOURS.p.contour.raw2D =      get(EEGCONTOURS.handles.BplotRaw2D, ''Value'');',...
0491         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0492 
0493     G.Bplot2D = uicontrol('Parent',GUI,'Style','Checkbox','Units','Normalized', Font, ...
0494         'Position',[indent(3) height+L(2) radiowidth radioheight],...
0495         'String','2D Projected','Value',p.contour.plot2D,...
0496         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0497         'EEGCONTOURS.p.contour.plot2D =     get(EEGCONTOURS.handles.Bplot2D, ''Value'');',...
0498         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0499     
0500     G.Bplot3D = uicontrol('Parent',GUI,'Style','Checkbox','Units','Normalized', Font, ...
0501         'Position',[indent(3) height+L(1) radiowidth radioheight],...
0502         'String','3D contour','Value',p.contour.plot3D,...
0503         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0504         'EEGCONTOURS.p.contour.plot3D =     get(EEGCONTOURS.handles.Bplot3D, ''Value'');',...
0505         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0506 
0507     switch p.saveGraphics
0508     case 'Save Plots', graphics = 1;
0509     case 'eps',  graphics = 2;
0510     case 'jpg',  graphics = 3;
0511     case 'tif',  graphics = 4;
0512     case 'png',  graphics = 5;
0513     otherwise,   graphics = 1;
0514     end
0515     G.BsaveGraphics = uicontrol('Tag','PinterpMethod','Parent',GUI,'Style','popupmenu',...
0516         'Units','Normalized',Font,...
0517         'TooltipString','Automatically save plot(s) to specified graphics file format.',...
0518         'Position',[indent(4) height+L(3) radiowidth popupheight],...
0519         'String',{'Save Plots' 'eps' 'jpg' 'tif' 'png'},...
0520         'Value',graphics,...
0521         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0522         'EEGCONTOURS.p.saveGraphics = popupstr(EEGCONTOURS.handles.BsaveGraphics);',...
0523         'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); clear EEGCONTOURS;'));
0524     
0525     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0526     % GUI Controls
0527     height = (height - .01) - frameheight;
0528     boxwidth = 0.2;
0529     
0530     Font.FontWeight = 'bold';
0531     
0532     G.Bquit = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0533         'Position',[indent(1) height+L(1) boxwidth boxheight],...
0534         'String','QUIT','BusyAction','queue',...
0535         'BackgroundColor',[0.75 0.0 0.0],...
0536         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0537         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0538                           'p = EEGCONTOURS.p;',...
0539                           'if isfield(EEGCONTOURS,''parent''), ',...
0540                               'parent = get(EEGCONTOURS.parent.gui,''Userdata''); ',...
0541                               'parent.p = EEGCONTOURS.p; ',...
0542                               'set(EEGCONTOURS.parent.gui,''Userdata'',parent); ',...
0543                               'clear parent; ',...
0544                           'end; ',...
0545                           'clear EEGCONTOURS; close gcbf;'));
0546     
0547     % SAVE GUI PARAMETERS
0548     G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0549         'Position',[indent(2) height+L(1) boxwidth boxheight],...
0550         'String','SAVE','BusyAction','queue',...
0551         'TooltipString','Save current parameters as defaults for current working directory.',...
0552         'BackgroundColor',[0.0 0.0 0.75],...
0553         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0554         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0555                           'eeg_toolbox_defaults(''write'',EEGCONTOURS.p);',...
0556                           'clear EEGCONTOURS;'));
0557     
0558 
0559     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0560     % NEXT: Run the engine!
0561     
0562     G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0563         'Position',[indent(3) height+L(1) boxwidth boxheight],...
0564         'String','PLOT','BusyAction','queue',...
0565         'TooltipString','Create plots for given parameters.',...
0566         'BackgroundColor',[0.0 0.5 0.0],...
0567         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0568         'Callback',strcat('EEGCONTOURS = get(gcbf,''Userdata'');',...
0569         'set(EEGCONTOURS.gui,''Pointer'',''watch'');',...
0570         'p = eeg_contours_engine(EEGCONTOURS.p);',...
0571         'set(EEGCONTOURS.handles.EminimumIntensity,''String'', num2str(p.minimumIntensity), ''Value'', p.minimumIntensity ); ',...
0572         'set(EEGCONTOURS.handles.EmaximumIntensity,''String'', num2str(p.maximumIntensity), ''Value'', p.maximumIntensity ); ',...
0573         'set(EEGCONTOURS.handles.EtimePoint,''String'', num2str(p.volt.samplePoint),''Value'', p.volt.samplePoint ); ',...
0574         'set(EEGCONTOURS.handles.EgridSize,''String'', num2str(p.grid.size),''Value'', p.grid.size ); ',...
0575         'set(EEGCONTOURS.handles.EgridRes,''String'', num2str(p.grid.res),''Value'', p.grid.res ); ',...
0576         'EEGCONTOURS.p = p; ',...
0577         'if isequal(get(EEGCONTOURS.handles.Bhold,''Value''),0),',...
0578             'p = gui_updateparent(EEGCONTOURS,0);',...
0579             'set(EEGCONTOURS.gui,''Pointer'',''arrow'');',...
0580             'close gcbf;',...
0581         'else, ',...
0582             'set(EEGCONTOURS.gui,''Userdata'',EEGCONTOURS); ',...
0583             'set(EEGCONTOURS.gui,''Pointer'',''arrow'');',...
0584         'end; clear EEGCONTOURS;'));
0585 
0586     % Hold GUI Open checkbox
0587     G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0588         'Position',[indent(4) height+L(1) boxwidth boxheight],...
0589         'String','Hold GUI','BusyAction','queue',...
0590         'TooltipString','EEG Contours remains open after ''Plot'' command.',...
0591         'Value',p.hold,'HorizontalAlignment', 'center');
0592     
0593     EEGCONTOURS.gui = GUI;
0594     EEGCONTOURS.handles = G;
0595     if exist('parent','var'), EEGCONTOURS.parent.gui = parent; end
0596     set(EEGCONTOURS.gui,'UserData',EEGCONTOURS);
0597

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