⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eeg_crosshair.m

📁 Matlab下的EEG处理程序库
💻 M
📖 第 1 页 / 共 4 页
字号:
    H.handles.xnext       = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.96 .65 .04 .05],...
                              'String','>',...
                              'Tag','XNEXT',...
                              'TooltipString','Goto Next X Index (no interpolation).',...
                              'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''nextx'');');
    H.handles.xinterp     = uicontrol('Style','Edit','Units','Normalized',...
                              'Position',[.92 .60 .08 .05],...
                              'String','0',...
                              'Value',0,....
                              'Tag','XINTERP',...
                              'TooltipString','Interpolation X increment (zero = nearest X).',...
                              'Callback',strcat('XHR = get(gcbf,''userdata''); ',...
                                                'xint = str2num(get(XHR.handles.xinterp,''string'')); ',...
                                                'set(XHR.handles.xinterp,''value'',xint); figure(XHR.gui); clear XHR;'));
    
    interpstr     =   'none|nearest|linear|spline|cubic';
    H.handles.interp      =   uicontrol(H.gui,'Style','popup','Units','Normalized',Font,...
                              'Position',[.92 .55 .08 .05],...
                              'Tag','INTERP',...
                              'TooltipString','INTERP1 methods (none = raw values).', ...
                              'String',interpstr,...
                              'Callback',strcat('XHR = get(gcbf,''userdata'');',...
                                                'xint = get(XHR.handles.xinterp,''Value''); ',...
                                                'if xint == 0, ',...
                                                '   xint = 0.5; ',...
                                                '   set(XHR.handles.xinterp,''value'',xint); ',...
                                                '   set(XHR.handles.xinterp,''string'',num2str(xint)); ',...
                                                '   set(XHR.handles.xindex, ''string'',''interp''); ',...
                                                'end; ',...
                                                'set(XHR.gui,''userdata'',XHR); figure(XHR.gui); clear XHR; '));
    
    Font.FontWeight = 'bold';
    H.handles.store       = uicontrol('Style','Push','Units','Normalized',Font,...
                              'Position',[.92 .45 .08 .05],...
                              'BackgroundColor',[0 0.7 0],'ForegroundColor', [1 1 1],...
                              'String','Store',...
                              'Tag','STORE',...
                              'TooltipString','Store current values into base XYhist array.', ...
                              'CallBack','eeg_crosshair(''store'');');
    Font.FontWeight = 'normal';
    
    H.handles.topo        = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.92 .35 .08 .05],...
                              'String','Topo',...
                              'Tag','TOPO',...
                              'TooltipString','Show Topographic Map (or GUI)', ...
                              'CallBack',strcat('XHR = get(gcbf,''userdata'');',...
                                                'if isfield(XHR,''p''), ',...
                                                    'XHR.p.clickTimePoint = 0;',...
                                                    'XHR.p.volt.samplePoint = XHR.data.xindex;',...
                                                    'XHR.p.volt.sampleTime = XHR.data.xpoint;',...
                                                    'if get(XHR.handles.topo_opt,''Value''),',...
                                                        '[G,XHR.p] = gui_eeg_contours(XHR.p,XHR.gui);',...
                                                        'clear G; ',...
                                                    'else, ',...
                                                        'XHR.p = eeg_contours_engine(XHR.p);',...
                                                    'end;',...
                                                'else ',...
                                                    '[G,XHR.p] = gui_eeg_contours('''',XHR.gui);',...
                                                    'clear G; ',...
                                                'end; p = XHR.p;',...
                                                'set(XHR.gui,''userdata'',XHR); clear XHR;'));                                            
    H.handles.topo_opt    = uicontrol(H.gui,'Style','checkbox', 'Units','Normalized',Font,...
                              'Position',[.92 .30 .08 .05],...
                              'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                              'Tag','TOPO_OPT',...
                              'String','GUI','Value',0,...
                              'TooltipString','View/Modify Topography Parameters');
                          
    H.handles.peaks       = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.92 .25 .08 .05],...
                              'String','Peaks',...
                              'Tag','PEAKS',...
                              'TooltipString','Calculate Peaks for All Channels (RunOnce)', ...
                              'CallBack',strcat('XHR = get(gcbf,''userdata'');',...
                                                'if isfield(XHR,''p''), ',...
                                                    'XHR.p = eeg_peaks(XHR.p);',...
                                                    'set(XHR.handles.peaksView,''Value'',1); ',...
                                                'else, ',...
                                                    'XHR.p.volt.data = XHR.data.ydata;',...
                                                    'XHR.p.volt.timeArray = XHR.data.xdata;',...
                                                    'XHR.p = eeg_peaks(XHR.p);',...
                                                    'set(XHR.handles.peaksView,''Value'',1); ',...
                                                'end; ',...
                                                'set(XHR.gui,''userdata'',XHR); clear XHR;',...
                                                '[Xpoint,Ypoint] = eeg_crosshair(''viewpeaks''); '));
    H.handles.pprev       = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.92 .20 .04 .05],...
                              'String','<',...
                              'Tag','PPREV',...
                              'TooltipString','Goto Previous Peak of Current Channel',...
                              'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''prevpeak'');');                          
    H.handles.pnext       = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.96 .20 .04 .05],...
                              'String','>',...
                              'Tag','PNEXT',...
                              'TooltipString','Goto Next Peak of Current Channel',...
                              'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''nextpeak'');');
    H.handles.peaksView   = uicontrol(H.gui,'Style','checkbox','Units','Normalized',Font,...
                               'Position',[.92 .15 .08 .05],...
                               'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                               'String','View','Value',0,...
                               'Tag','VIEWPEAK',...
                               'TooltipString','View peaks for current channel.',...
                               'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''viewpeaks'');');
    H.handles.peaksMove   = uicontrol(H.gui,'Style','checkbox','Units','Normalized',Font,...
                               'Position',[.92 .10 .08 .05],...
                               'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                               'String','Move','Value',0,...
                               'Tag','MOVEPEAK','Visible','off',...
                               'TooltipString','Auto move to nearest peak for current channel.',...
                               'CallBack',strcat('[Xpoint,Ypoint] = eeg_crosshair(''nearpeak'');'));
    
    %%%%%%%%%%%%%%%%%%%%%%%%%
    % Get Line Data from Plot
    
    % Lines are referenced as axis children, among other
    % axis children; so first get all axis children
    sibs = get(H.handles.axis,'Children');
    
    % Now search axis children for any line types.
    % Because the columns of the y data matrix in a plot
    % command seem to be reversed in the axis children, 
    % count down from max sibs to the first sib.
    lines = 0;
    H.data.xdata = [];
    H.data.ydata = [];
    H.data.xpoint = [];
    H.data.ypoint = [];
    H.data.xindex = 1;
    H.data.yindex = 1;
    i = max(size(sibs));
    while i >= 1
        if strcmp(get(sibs(i),'Type'),'line')
            % Found a line child, but check its size
            getline = 1;
            if ~isempty(H.data.xdata),
                if isequal(size(get(sibs(i),'XData').',1),size(H.data.xdata,1)),
                    getline = 1;
                else
                    getline = 0;
                end
            end
            if getline,
                % OK, found a line among the axis children.
                lines = lines + 1;
                H.handles.datalines(lines) = sibs(i);
                
                % put line data into a column of data.xdata|data.ydata
                H.data.xdata(:,lines) = get(sibs(i),'XData').';
                H.data.ydata(:,lines) = get(sibs(i),'YData').';
            end
        end
        i = i - 1;
    end
    
    % Switch off||on Trace GUI controls
    Vis = 'Off';
    if lines > 1,
        Vis = 'On';
    elseif lines == 0,
        error('No lines found in the current plot window\n');
    end
    
    % REMOVING THE FOLLOWING, AS NOW EFFECTIVELY AVAILABLE FROM YINDEX edit box
    
%     % 'traces' string variable must be in ascending order
%     traces  = '';
%     i = 1;
%     while i <= lines;
%         if i < lines
%             tracelabel = sprintf('Channel %4d|',i);            
%         else
%             tracelabel = sprintf('Channel %4d',i);
%         end
%         traces = strcat(traces,tracelabel);
%         i = i + 1;
%     end
%     
%     % If more than one line, provide GUI for line selection
%     
%     
%     % Create Trace Index GUI
%     H.handles.traceLabel   = uicontrol(H.gui,'Style','Edit', 'Units','Normalized',Font,...
%                                'Position',[.00 .00 .09 .05],...
%                                'Tag','TRACELABEL',...
%                                'Visible',Vis,'String','Select :',...
%                                'TooltipString','Select channel to follow with crosshairs.');
%     H.handles.trace        = uicontrol(H.gui,'Style','Popup','Units','Normalized',Font,...
%                                'Position',[.10 .00 .19 .05],...
%                                'Tag','TRACESWITCH',...
%                                'BackGroundColor','w','String',traces,...
%                                'Visible',Vis,...
%                                'CallBack',strcat('XHR = get(gcbf,''userdata'');',...
%                                                  'XHR.data.yindex = get(XHR.handles.trace,''Value'');',...
%                                                  'set(XHR.gui,''userdata'',XHR); clear XHR; ',...
%                                                  '[Xpoint,Ypoint] = eeg_crosshair(''changey'');'));
    
    
    H.handles.traceNearest = uicontrol(H.gui,'Style','checkbox', 'Units','Normalized',Font,...
                               'Position',[.30 .00 .14 .05],...
                               'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                               'Tag','TRACENEAREST',...
                               'Visible',Vis,'String','Nearest','Value',1,...
                               'TooltipString','Channel nearest to mouse click selection. Switch off for fixed channel.');
    H.handles.traceView    = uicontrol(H.gui,'Style','checkbox','Units','Normalized',Font,...
                               'Position',[.45 .00 .19 .05],...
                               'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                               'String','View Channel','Value',0,...
                               'Tag','VIEW','Visible',Vis,...
                               'TooltipString','View only selected channel (on) or all channels (off).', ...
                               'CallBack',strcat('XHR = get(gcbf,''userdata'');',...
                                                 'if (get(XHR.handles.traceView,''Value'')),',...
                                                     'set(XHR.handles.datalines,''Visible'',''off''); ',...
                                                     'set(XHR.handles.datalines(XHR.data.yindex),''Visible'',''on''); ',...
                                                 'else, ',...
                                                     'set(XHR.handles.datalines,''Visible'',''on''); ',...
                                                 'end; ',...
                                                 'figure(XHR.gui); clear XHR;'));
    H.handles.traceAdd    = uicontrol(H.gui,'Style','checkbox', 'Units','Normalized',Font,...
                               'Position',[.65 .00 .19 .05],...
                               'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,...
                               'Tag','TRACEADD',...
                               'Visible',Vis,'String','Add Channel','Value',0,...
                               'TooltipString','Add channels when using ''view channel'' rather than replace them.');
    
    Font.FontWeight = 'bold';
    
    % ASCII Parameters
    H.handles.Bparam      = uicontrol(H.gui,'Style','pushbutton','Units','Normalized',Font,...
                              'Position',[.69 .95 .1 .05],'BusyAction','queue',...
                              'String','PARAM',...
                              'TooltipString','Define ERP sample rate, epoch, etc.',...
                              'BackgroundColor',[0.0 0.0 0.75],...
                              'ForegroundColor',[1 1 1], 'HorizontalAlignment', 'center',...
                              'Callback',strcat('XHR = get(gcbf,''userdata'');',...
                                                'tempgui = gui_eeg_ascii_parameters(XHR.gui); clear tempgui; ',...
                                                'XHR = get(gcbf,''userdata'');',...
                                                'figure(XHR.gui); [Xpoint,Ypoint] = eeg_crosshair(''done''); clf;',...
                                                'plot(XHR.p.volt.timeArray,XHR.p.volt.data);',...
                                                '[Xpoint,Ypoint] = eeg_crosshair(''init'',XHR.p,XHR.parent.gui); clear XHR; '));
    % Interface to electrodes
    H.handles.Belec       = uicontrol(H.gui,'Style','pushbutton','Units','Normalized',Font,...
                              'Position',[.79 .95 .1 .05],...
                              'String','ELEC','HorizontalAlignment','center',...
                              'TooltipString','Load associated electrode coordinates.',...
                              'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
                              'Callback',strcat('XHR = get(gcbf,''userdata'');',...
                                                'p = gui_elec_open(XHR.p,''init'',XHR.gui);',...
                                                'clear XHR;'));
    % Interface to meshes
    H.handles.Bmesh       = uicontrol(H.gui,'Style','pushbutton','Units','Normalized',Font,...
                              'Position',[.89 .95 .1 .05],...
                              'String','MESH','HorizontalAlignment','center',...
                              'visible','on',...
                              'TooltipString','Load associated MRI tesselations.',...
                              'BackgroundColor',[0.0 0.0 0.75],'ForegroundColor', [1 1 1],...
                              'Callback',strcat('XHR = get(gcbf,''userdata'');',...
                                                'XHR.p = gui_mesh_open(XHR.p,''init'',XHR.gui);',...
                                                'clear XHR;'));
    
    
    H.handles.done        = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.84 .00 .08 .05],...
                              'BackgroundColor',[0.7 0 0],'ForegroundColor', [1 1 1],...
                              'String','Done',...
                              'Tag','DONE',...
                              'TooltipString','Close eeg_crosshair', ...
                              'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''done'');');
    H.handles.exit        = uicontrol(H.gui,'Style','Push','Units','Normalized',Font,...
                              'Position',[.92 .00 .08 .05],...
                              'BackgroundColor',[0.8 0 0],'ForegroundColor', [1 1 1],...
                              'String','Exit',...
                              'Tag','EXIT',...
                              'TooltipString','Close eeg_crosshair and Figure', ...
                              'CallBack','[Xpoint,Ypoint] = eeg_crosshair(''exit'');');
                          

    % Set X,Y cross hair lines
    % Do this after finding all the line axis children
    % to avoid confusing these lines with those of the
    % plot itself (counted above).
    x_rng = get(H.handles.axis,'Xlim');
    y_rng = get(H.handles.axis,'Ylim');
    axes(H.handles.axis);
    H.handles.xline = line(x_rng,[y_rng(1) y_rng(1)]);
    H.handles.yline = line(x_rng,[y_rng(1) y_rng(1)]);
    set(H.handles.xline,'Color','r','EraseMode','xor','Tag','XLINE');
    set(H.handles.yline,'Color','r','EraseMode','xor','Tag','YLINE');
    
    %set(H.gui,'HandleVisibility','callback'); % hide fig from other commands
    
return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -