Home > bioelectromagnetism > gui_mesh_save.m

gui_mesh_save

PURPOSE ^

GUI_MESH_OPEN: Load an emse mesh (wfr) file into matlab workspace

SYNOPSIS ^

function [p] = gui_mesh_save(p,mesh_save_command,parent)

DESCRIPTION ^

 GUI_MESH_OPEN: Load an emse mesh (wfr) file into matlab workspace
 
 Usage: [p] = gui_mesh_save(p,[command],[parent])

 p is a structure, generated by 'eeg_toolbox_defaults'
 command is either 'init' or 'save'
 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [p] = gui_mesh_save(p,mesh_save_command,parent)
0002 % GUI_MESH_OPEN: Load an emse mesh (wfr) file into matlab workspace
0003 %
0004 % Usage: [p] = gui_mesh_save(p,[command],[parent])
0005 %
0006 % p is a structure, generated by 'eeg_toolbox_defaults'
0007 % command is either 'init' or 'save'
0008 % parent is a handle to the gui that calls this gui, useful
0009 % for updating the UserData field of the parent from this gui.
0010 % The p structure is returned to the parent when the parent
0011 % handle is given.
0012 %
0013 
0014 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0015 
0016 % Licence:  GNU GPL, no express or implied warranties
0017 % History:  02/02 Darren.Weber_at_radiology.ucsf.edu
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 if ~exist('p','var'),
0022    [p] = eeg_toolbox_defaults;
0023 elseif isempty(p),
0024    [p] = eeg_toolbox_defaults;
0025 end
0026 
0027 if ~exist('mesh_save_command','var'), mesh_save_command = 'init'; end
0028 
0029 switch mesh_save_command,
0030     
0031 case 'init',
0032     
0033     if exist('parent','var'),
0034         MESHSave = INIT(p,parent);
0035     else
0036         MESHSave = INIT(p);
0037     end
0038     
0039 case 'save',
0040     
0041     MESHSave = get(gcbf,'Userdata');
0042     gui_mesh_save(MESHSave.p,'init',MESHSave.gui);
0043     
0044     if isequal(get(MESHSave.handles.Bhold,'Value'),1),
0045        [p] = gui_updateparent(MESHSave,0);
0046     else
0047        [p] = gui_updateparent(MESHSave);
0048         close gcbf;
0049     end
0050     
0051     fprintf('GUI_MESH_OPEN: Save As not yet implemented\n');
0052     
0053     
0054 otherwise,
0055     
0056     close gcbf;
0057     
0058 end
0059 
0060 return
0061 
0062 
0063 
0064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0065 function [MESHSave] = INIT(p,parent),
0066     
0067     % GUI General Parameters
0068     
0069     GUIwidth  = 500;
0070     GUIheight = 120;
0071     
0072     GUI = figure('Name','MESH File Load','Tag','MESH_OPEN',...
0073                  'NumberTitle','off',...
0074                  'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0075     movegui(GUI,'center');
0076     
0077     MESHSave.gui = GUI;
0078     
0079     Font.FontName   = 'Helvetica';
0080     Font.FontUnits  = 'Pixels';
0081     Font.FontSize   = 12;
0082     Font.FontWeight = 'normal';
0083     Font.FontAngle  = 'normal';
0084     
0085     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0086     % Mesh Data Selection and Parameters
0087 
0088     G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0089         'Position',[.01 .75 .17 .2],...
0090         'TooltipString','Mesh/Tesselation Formats (see, ''help mesh_open'')',...
0091         'String','Mesh Type:','HorizontalAlignment','left');
0092     
0093     switch p.mesh.type
0094         case 'BrainStorm',       meshType = 1;
0095         otherwise,               meshType = 1;
0096     end
0097     G.PmeshType = uicontrol('Tag','PmeshType','Parent',GUI,'Style','popupmenu',...
0098         'Units','Normalized',Font,  ...
0099         'Position',[.20 .75 .28 .2],...
0100         'String',{'BrainStorm'},'Value',meshType,...
0101         'TooltipString','Mesh/Tesselation Formats (see, ''help mesh_save'')',...
0102         'Callback',strcat('MESHSave = get(gcbf,''Userdata'');',...
0103                           'MESHSave.p.mesh.type = popupstr(MESHSave.handles.PmeshType);',...
0104                           'set(gcbf,''Userdata'',MESHSave); clear MESHSave;'));
0105                       
0106     G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0107         'Position',[.01 .50 .17 .2],...
0108         'String','Path','HorizontalAlignment','left');
0109     G.EmeshPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0110         'Position',[.20 .50 .58 .2], 'String',p.mesh.path,...
0111         'Callback',strcat('MESHSave = get(gcbf,''Userdata'');',...
0112                           'MESHSave.p.mesh.path = get(MESHSave.handles.EmeshPath,''String'');',...
0113                           'set(gcbf,''Userdata'',MESHSave); clear MESHSave;'));
0114     
0115     G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0116         'Position',[.01 .25 .17 .2],...
0117         'String','File','HorizontalAlignment','left');
0118     G.EmeshFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0119         'Position',[.20 .25 .58 .2], 'String',p.mesh.file,...
0120         'Callback',strcat('MESHSave = get(gcbf,''Userdata'');',...
0121                           'MESHSave.p.mesh.file = get(MESHSave.handles.EmeshFile,''String'');',...
0122                           'set(gcbf,''Userdata'',MESHSave); clear MESHSave;'));
0123     
0124     Font.FontWeight = 'bold';
0125     
0126     % BROWSE: Look for the data
0127     browsecommand = strcat('MESHSave = get(gcbf,''Userdata'');',...
0128         'cd(MESHSave.p.mesh.path);',...
0129         '[file, path] = uigetfile(',...
0130         '{''*.dat;*.txt'', ''ASCII Tesselations (*.dat,*.txt)'';', ...
0131         ' ''*.asc;*.tri'', ''FreeSurfer Tesselations (*.asc,*.tri)'';', ...
0132         ' ''*.wfr'', ''EMSE Tesselations (*.wfr)'';', ...
0133         ' ''*.mat'', ''BrainStorm Tesselations (*.mat)'';', ...
0134         ' ''*.*'',   ''All Files (*.*)''},', ...
0135         '''Select Mesh/Tesselation File'');',...
0136         'if ~isequal(path,0), MESHSave.p.mesh.path = path; end;',...
0137         'if ~isequal(file,0), MESHSave.p.mesh.file = file; end;',...
0138         'set(MESHSave.handles.EmeshPath,''String'',MESHSave.p.mesh.path);',...
0139         'set(MESHSave.handles.EmeshFile,''String'',MESHSave.p.mesh.file);',...
0140         'if ~isempty(findstr(file,''.dat'')) | ~isempty(findstr(file,''.txt'')), ',...
0141             'set(MESHSave.handles.PmeshType,''Value'',1); ',...
0142             'MESHSave.p.mesh.type = popupstr(MESHSave.handles.PmeshType);',...
0143         'elseif ~isempty(findstr(file,''.asc'')) | ~isempty(findstr(file,''.tri'')), ',...
0144             'set(MESHSave.handles.PmeshType,''Value'',2); ',...
0145             'MESHSave.p.mesh.type = popupstr(MESHSave.handles.PmeshType);',...
0146         'elseif findstr(file,''.wfr''), ',...
0147             'set(MESHSave.handles.PmeshType,''Value'',3); ',...
0148             'MESHSave.p.mesh.type = popupstr(MESHSave.handles.PmeshType);',...
0149         'else, ',...
0150             'set(MESHSave.handles.PmeshType,''Value'',4); ',...
0151             'MESHSave.p.mesh.type = popupstr(MESHSave.handles.PmeshType);',...
0152         'end;',...
0153         'set(gcbf,''Userdata'',MESHSave); clear MESHSave;');
0154     G.BmeshFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0155         'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0156         'BackgroundColor',[0.8 0.8 0.0],...
0157         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0158         'Callback', browsecommand );
0159     
0160     % SAVE AS: Load & convert the data!
0161     G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0162         'Position',[.40 .01 .18 .2],...
0163         'String','SAVE AS','BusyAction','queue',...
0164         'TooltipString','Load and convert the mesh (not implemented yet).',...
0165         'BackgroundColor',[0.0 0.0 0.5],...
0166         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0167         'Callback',strcat('MESHSave = get(gcbf,''Userdata'');',...
0168                           'p = mesh_write(MESHSave.p,''save'');',...
0169                           'clear MESHSave;'));
0170     
0171     % Cancel
0172     G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0173         'Position',[.80 .01 .18 .2],...
0174         'String','CANCEL','BusyAction','queue',...
0175         'TooltipString','Close, do not return the p struct.',...
0176         'BackgroundColor',[0.75 0.0 0.0],...
0177         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0178         'Callback','gui_mesh_open([],''cancel'');');
0179     
0180     % Store userdata
0181     if exist('parent','var'), MESHSave.parent.gui = parent; end
0182     MESHSave.handles = G;
0183     MESHSave.p = p;
0184     set(GUI,'HandleVisibility','callback');
0185     set(GUI,'Userdata',MESHSave);
0186     
0187 return

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