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

📄 gui_mesh_open.m

📁 Matlab下的EEG处理程序库
💻 M
字号:
function [p] = gui_mesh_open(p,mesh_open_command,parent)

% GUI_MESH_OPEN - GUI to mesh_open
% 
% Useage: [p] = gui_mesh_open(p,[command],[parent])
%
% p        - struct, generated by 'eeg_toolbox_defaults'
% command  - either 'init' or 'load'
% parent   - a handle to the gui that calls this gui, used
%            to update the UserData of the parent. The p 
%            struct is returned to the parent in this way.
% 
% See command line version, MESH_OPEN
% 

% $Revision: 1.3 $ $Date: 2003/04/07 06:12:02 $

% Licence:  GNU GPL, no express or implied warranties
% History:  02/2002, Darren.Weber@flinders.edu.au
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~exist('p','var'),
    p = eeg_toolbox_defaults;
elseif isempty(p),
    p = eeg_toolbox_defaults;
end

if ~exist('mesh_open_command','var'), mesh_open_command = 'init'; end

switch mesh_open_command,
    
case 'init',
    
    if exist('parent','var'),
        MESHOpen = INIT(p,parent);
    else
        MESHOpen = INIT(p);
    end
    
case 'plot',

    MESHOpen = get(gcbf,'Userdata');
    
    MESHOpen.p.mesh.plot = 0;
    MESHOpen.p = mesh_open(MESHOpen.p);
    
    set(MESHOpen.gui,'Userdata',MESHOpen);
    
    if isequal(get(MESHOpen.handles.Bhold,'Value'),1),
        
        p = gui_updateparent(MESHOpen,0);
        p = gui_mesh_plot(p,'init',MESHOpen.gui);
        
    else
        p = gui_updateparent(MESHOpen);
        if isfield(MESHOpen,'parent'),
            if ~isempty(MESHOpen.parent),
                gui_mesh_plot(MESHOpen.p,'init',MESHOpen.parent.gui);
            end
        else
            gui_mesh_plot(MESHOpen.p,'init','');
        end
        close gcbf;
    end
    
case 'save',
    
    MESHOpen = get(gcbf,'Userdata');
    gui_mesh_write(MESHOpen.p);
    
    if isequal(get(MESHOpen.handles.Bhold,'Value'),1),
        p = gui_updateparent(MESHOpen,0);
    else
        p = gui_updateparent(MESHOpen);
        close gcbf;
    end
    
    %fprintf('GUI_MESH_OPEN: Save As not yet implemented\n');
    
    
case 'return',
    
    MESHOpen = get(gcbf,'Userdata');
    
    set(MESHOpen.gui,'Pointer','watch');
    
    MESHOpen.p.mesh.plot = 0;
    MESHOpen.p = mesh_open(MESHOpen.p);
    
    set(MESHOpen.gui,'Userdata',MESHOpen);
    
    set(MESHOpen.gui,'Pointer','arrow');
    
    if isequal(get(MESHOpen.handles.Bhold,'Value'),1),
        p = gui_updateparent(MESHOpen,0);
    else
        p = gui_updateparent(MESHOpen);
        close gcbf;
    end
    
otherwise,
    
    close gcbf;
    
end

return



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [MESHOpen] = INIT(p,parent),
    
    % GUI General Parameters
    
    GUIwidth  = 500;
    GUIheight = 120;
    
    GUI = figure('Name','MESH File Open','Tag','MESH_OPEN',...
                 'NumberTitle','off',...
                 'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
    movegui(GUI,'center');
    
    MESHOpen.gui = GUI;
    
    Font.FontName   = 'Helvetica';
    Font.FontUnits  = 'Pixels';
    Font.FontSize   = 12;
    Font.FontWeight = 'normal';
    Font.FontAngle  = 'normal';
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Mesh Data Selection and Parameters

    G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
        'Position',[.01 .75 .17 .2],...
        'TooltipString','Mesh/Tesselation Formats (see, ''help mesh_open'')',...
        'String','Mesh Type:','HorizontalAlignment','left');
    
    switch lower(p.mesh.type),
        case 'brainstorm',  meshType = 1;
        case 'emse',        meshType = 2;
        case 'ascii',       meshType = 3;
        case 'fs_ascii',    meshType = 4;
        case 'fs_surf',     meshType = 5;
        case 'fs_curv',     meshType = 6;
        case 'fs_overlay',  meshType = 7;
        otherwise,          meshType = 1;
    end
    meshtypes = {'BrainStorm' 'EMSE' 'ASCII' ...
                 'FS_ascii' 'FS_surf' 'FS_curv' 'FS_overlay' };
    G.PmeshType = uicontrol('Tag','PmeshType','Parent',GUI,'Style','popupmenu',...
        'Units','Normalized',Font,  ...
        'Position',[.20 .75 .28 .2],...
        'String',meshtypes,'Value',meshType,...
        'TooltipString','Mesh/Triangulation Formats (see, ''help mesh_open'', FS = FreeSurfer)',...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'MESHOpen.p.mesh.type = popupstr(MESHOpen.handles.PmeshType);',...
                          'set(gcbf,''Userdata'',MESHOpen); clear MESHOpen;'));
    
    G.BmeshReplace = uicontrol('Tag','BmeshReplace','Parent',GUI,'Style','checkbox',...
        'Units','Normalized',Font,...
        'Position',[.40 .75 .18 .2],...
        'String','Replace','Value',1,...
        'TooltipString','Reload current mesh, if any?',...
        'Visible','off',...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'MESHOpen.p.mesh.reload = get(MESHOpen.handles.BmeshReplace,''Value'');',...
                          'set(gcbf,''Userdata'',MESHOpen); clear MESHOpen;'));
    
    G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
        'Position',[.01 .50 .17 .2],...
        'String','Path','HorizontalAlignment','left');
    G.EmeshPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
    	'Position',[.20 .50 .58 .2], 'String',p.mesh.path,...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'MESHOpen.p.mesh.path = get(MESHOpen.handles.EmeshPath,''String'');',...
                          'set(gcbf,''Userdata'',MESHOpen); clear MESHOpen;'));
    
    G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
        'Position',[.01 .25 .17 .2],...
        'String','File','HorizontalAlignment','left');
    G.EmeshFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
    	'Position',[.20 .25 .58 .2], 'String',p.mesh.file,...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'MESHOpen.p.mesh.file = get(MESHOpen.handles.EmeshFile,''String'');',...
                          'set(gcbf,''Userdata'',MESHOpen); clear MESHOpen;'));
    
    Font.FontWeight = 'bold';
    
    % BROWSE: Look for the data
    browsecommand = strcat('MESHOpen = get(gcbf,''Userdata'');',...
        'cd(MESHOpen.p.mesh.path);',...
        '[file, path] = uigetfile(',...
        '{''*.dat;*.txt'', ''ASCII Tesselations (*.dat,*.txt)'';', ...
        ' ''*.asc;*.tri'', ''FreeSurfer Tesselations (*.asc,*.tri)'';', ...
        ' ''*.wfr'', ''EMSE Tesselations (*.wfr)'';', ...
        ' ''*.mat'', ''BrainStorm Tesselations (*.mat)'';', ...
        ' ''*.*'',   ''All Files (*.*)''},', ...
        '''Select Mesh/Tesselation File'');',...
        'if ~isequal(path,0), MESHOpen.p.mesh.path = path; end;',...
        'if ~isequal(file,0), MESHOpen.p.mesh.file = file; end;',...
        'set(MESHOpen.handles.EmeshPath,''String'',MESHOpen.p.mesh.path);',...
        'set(MESHOpen.handles.EmeshFile,''String'',MESHOpen.p.mesh.file);',...
        'if     findstr(file,''.mat''), value = 1; ',...
        'elseif findstr(file,''.wfr''), value = 2; ',...
        'elseif findstr(file,''.dat''), value = 3; ',...
        'elseif findstr(file,''.txt''), value = 3; ',...
        'elseif findstr(file,''.asc''), value = 3; ',...
        'elseif findstr(file,''.tri''), value = 4; ',...
        'elseif findstr(file,''.orig''),     value = 5; ',...
        'elseif findstr(file,''.smoothwm''), value = 5; ',...
        'elseif findstr(file,''.white''),    value = 5; ',...
        'elseif findstr(file,''.pial''),     value = 5; ',...
        'else, value = 3; ',...
        'end;',...
        'set(MESHOpen.handles.PmeshType,''Value'',value); ',...
        'MESHOpen.p.mesh.type = popupstr(MESHOpen.handles.PmeshType);',...
        'set(gcbf,''Userdata'',MESHOpen); clear value file path MESHOpen;');
    G.BmeshFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
        'Position',[.01 .01 .17 .2], 'String','BROWSE',...
        'BackgroundColor',[0.8 0.8 0.0],...
        'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
        'Callback', browsecommand );
    
    % PLOT: Load & plot the data!
    G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
        'Position',[.20 .01 .18 .2],...
        'String','PLOT','BusyAction','queue',...
        'TooltipString','Plot the mesh and return the file parameters.',...
        'BackgroundColor',[0.0 0.5 0.0],...
        'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'p = gui_mesh_open(MESHOpen.p,''plot'');',...
                          'clear MESHOpen;'));

    % SAVE AS: Load & convert the data!
    G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
        'Position',[.40 .01 .18 .2],...
        'String','SAVE AS','BusyAction','queue',...
        'TooltipString','Load and convert the mesh (not implemented yet).',...
        'BackgroundColor',[0.0 0.0 0.5],...
        'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'p = gui_mesh_open(MESHOpen.p,''save'');',...
                          'clear MESHOpen;'));

    % Return file parameters
    G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
        'Position',[.60 .01 .18 .2],...
        'String','RETURN','BusyAction','queue',...
        'TooltipString','Close and return the file parameters.',...
        'BackgroundColor',[0.75 0.0 0.0],...
        'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
        'Callback',strcat('MESHOpen = get(gcbf,''Userdata'');',...
                          'p = gui_mesh_open(MESHOpen.p,''return'');',...
                          'clear MESHOpen;'));
    
    % Cancel, do not return parameters
    G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
        'Position',[.80 .01 .18 .2],...
        'String','CANCEL','BusyAction','queue',...
        'TooltipString','Close, do not return the p struct.',...
        'BackgroundColor',[0.75 0.0 0.0],...
        'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
        'Callback','gui_mesh_open([],''cancel'');');
    
	% Help
	G.Bhelp = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
        'Position',[.80 .25 .18 .2],'String','Help','BusyAction','queue',...
        'BackgroundColor',[1 1 0],...
        'ForegroundColor',[0 0 0], 'HorizontalAlignment', 'center',...
        'Callback','doc mesh_open;');
    
	% Hold GUI Open checkbox
	G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
        'Position',[.80 .50 .18 .2],'String','Hold GUI','BusyAction','queue',...
        'TooltipString','MESH File Load GUI remains open after ''Plot'' and ''Return'' commands.',...
        'Value',p.hold,'HorizontalAlignment', 'center');
        
    % Store userdata
    if exist('parent','var'), MESHOpen.parent.gui = parent; end
    MESHOpen.handles = G;
    MESHOpen.p = p;
    set(GUI,'HandleVisibility','callback');
    set(GUI,'Userdata',MESHOpen);
    
return

⌨️ 快捷键说明

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