Home > bioelectromagnetism > gui_mesh_write.m

gui_mesh_write

PURPOSE ^

gui_mesh_write - Save a mesh (triangulation) file

SYNOPSIS ^

function [p] = gui_mesh_write(p)

DESCRIPTION ^

 gui_mesh_write - Save a mesh (triangulation) file
 
 Usage: [p] = gui_mesh_write(p)

 p is a structure, generated by 'eeg_toolbox_defaults'

 See also mesh_write

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [p] = gui_mesh_write(p)
0002 
0003 % gui_mesh_write - Save a mesh (triangulation) file
0004 %
0005 % Usage: [p] = gui_mesh_write(p)
0006 %
0007 % p is a structure, generated by 'eeg_toolbox_defaults'
0008 %
0009 % See also mesh_write
0010 %
0011 
0012 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0013 
0014 % Licence:  GNU GPL, no express or implied warranties
0015 % History:  02/02 Darren.Weber_at_radiology.ucsf.edu
0016 %
0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0018 
0019 if ~exist('p','var'),
0020     fprintf('GUI_MESH_WRITE: No input p struct.\n');
0021     return
0022 elseif isempty(p),
0023     fprintf('GUI_MESH_WRITE: Input p struct is empty.\n');
0024     return
0025 elseif isempty(p.mesh.data),
0026     fprintf('GUI_MESH_WRITE: Input p struct has no mesh data.\n');
0027     return
0028 end
0029 
0030 
0031 MESHWrite = INIT(p);
0032 
0033 
0034 return
0035 
0036 
0037 
0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0039 function [MESHWrite] = INIT(p),
0040     
0041     % GUI General Parameters
0042     
0043     GUIwidth  = 500;
0044     GUIheight = 120;
0045     
0046     GUI = figure('Name','MESH File Write','Tag','MESH_WRITE',...
0047                  'NumberTitle','off',...
0048                  'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0049     movegui(GUI,'center');
0050     
0051     MESHWrite.gui = GUI;
0052     
0053     Font.FontName   = 'Helvetica';
0054     Font.FontUnits  = 'Pixels';
0055     Font.FontSize   = 12;
0056     Font.FontWeight = 'normal';
0057     Font.FontAngle  = 'normal';
0058     
0059     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060     % Mesh Data Selection and Parameters
0061 
0062     G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0063         'Position',[.01 .75 .17 .2],...
0064         'TooltipString','Mesh/Tesselation Formats (see, ''help mesh_write'')',...
0065         'String','Mesh Type:','HorizontalAlignment','left');
0066     
0067     switch p.mesh.type
0068         case 'BrainStorm',      meshType = 1;
0069         case 'EMSE',            meshType = 2;
0070         otherwise,              meshType = 1;
0071     end
0072     
0073     G.PmeshType = uicontrol('Tag','PmeshType','Parent',GUI,'Style','popupmenu',...
0074         'Units','Normalized',Font,  ...
0075         'Position',[.20 .75 .28 .2],...
0076         'String',{'BrainStorm' 'EMSE'},'Value',meshType,...
0077         'TooltipString','Mesh/Tesselation Formats (see, ''help mesh_write'')',...
0078         'Callback',strcat('MESHWrite = get(gcbf,''Userdata'');',...
0079                           'MESHWrite.p.mesh.type = popupstr(MESHWrite.handles.PmeshType);',...
0080                           'set(gcbf,''Userdata'',MESHWrite); clear MESHWrite;'));
0081                       
0082     G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0083         'Position',[.01 .50 .17 .2],...
0084         'String','Path','HorizontalAlignment','left');
0085     G.EmeshPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0086         'Position',[.20 .50 .58 .2], 'String',p.mesh.path,...
0087         'Callback',strcat('MESHWrite = get(gcbf,''Userdata'');',...
0088                           'MESHWrite.p.mesh.path = get(MESHWrite.handles.EmeshPath,''String'');',...
0089                           'set(gcbf,''Userdata'',MESHWrite); clear MESHWrite;'));
0090     
0091     G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0092         'Position',[.01 .25 .17 .2],...
0093         'String','File','HorizontalAlignment','left');
0094     G.EmeshFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font,  ...
0095         'Position',[.20 .25 .58 .2], 'String',p.mesh.file,...
0096         'Callback',strcat('MESHWrite = get(gcbf,''Userdata'');',...
0097                           'MESHWrite.p.mesh.file = get(MESHWrite.handles.EmeshFile,''String'');',...
0098                           'set(gcbf,''Userdata'',MESHWrite); clear MESHWrite;'));
0099     
0100     Font.FontWeight = 'bold';
0101     
0102     % BROWSE: Look for the data
0103     browsecommand = strcat('MESHWrite = get(gcbf,''Userdata'');',...
0104         'cd(MESHWrite.p.mesh.path);',...
0105         '[file, path] = uigetfile(',...
0106         '{''*.mat'', ''BrainStorm Tesselations (*.mat)'';', ...
0107         '*.wfr'', ''EMSE Tesselations (*.wfr)'';', ...
0108         ' ''*.*'',   ''All Files (*.*)''},', ...
0109         '''Select Mesh/Tesselation File'');',...
0110         'if ~isequal(path,0), MESHWrite.p.mesh.path = path; end;',...
0111         'if ~isequal(file,0), MESHWrite.p.mesh.file = file; end;',...
0112         'if ~isempty(findstr(file,''.dat'')) | ~isempty(findstr(file,''.txt'')), ',...
0113             'MESHWrite.p.mesh.file = strcat(file,''.subjecttess.mat'');',...
0114             'set(MESHWrite.handles.PmeshType,''Value'',1); ',...
0115             'MESHWrite.p.mesh.type = popupstr(MESHWrite.handles.PmeshType);',...
0116         'elseif ~isempty(findstr(file,''.asc'')) | ~isempty(findstr(file,''.tri'')), ',...
0117             'MESHWrite.p.mesh.file = strcat(file,''.subjecttess.mat'');',...
0118             'set(MESHWrite.handles.PmeshType,''Value'',1); ',...
0119             'MESHWrite.p.mesh.type = popupstr(MESHWrite.handles.PmeshType);',...
0120         'elseif findstr(file,''.wfr''), ',...
0121             'set(MESHWrite.handles.PmeshType,''Value'',2); ',...
0122             'MESHWrite.p.mesh.type = popupstr(MESHWrite.handles.PmeshType);',...
0123         'else, ',...
0124             'set(MESHWrite.handles.PmeshType,''Value'',1); ',...
0125             'MESHWrite.p.mesh.type = popupstr(MESHWrite.handles.PmeshType);',...
0126         'end;',...
0127         'set(MESHWrite.handles.EmeshPath,''String'',MESHWrite.p.mesh.path);',...
0128         'set(MESHWrite.handles.EmeshFile,''String'',MESHWrite.p.mesh.file);',...
0129         'set(gcbf,''Userdata'',MESHWrite); clear MESHWrite;');
0130     G.BmeshFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0131         'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0132         'BackgroundColor',[0.8 0.8 0.0],...
0133         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0134         'Callback', browsecommand );
0135     
0136     % SAVE AS: convert the current mesh data!
0137     G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0138         'Position',[.40 .01 .18 .2],...
0139         'String','SAVE AS','BusyAction','queue',...
0140         'TooltipString','Save the current mesh (only BrainStorm format at present).',...
0141         'BackgroundColor',[0.0 0.6 0.0],...
0142         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0143         'Callback',strcat('MESHWrite = get(gcbf,''Userdata'');',...
0144                           'set(MESHWrite.gui,''pointer'',''watch'');',...
0145                           'tmp = mesh_write(MESHWrite.p);',...
0146                           'clear tmp MESHWrite; close gcbf;'));
0147     
0148     % Cancel
0149     G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0150         'Position',[.80 .01 .18 .2],...
0151         'String','CANCEL','BusyAction','queue',...
0152         'TooltipString','Close, do not save the mesh.',...
0153         'BackgroundColor',[0.75 0.0 0.0],...
0154         'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0155         'Callback','close gcbf;');
0156     
0157     % Store userdata
0158     MESHWrite.handles = G;
0159     MESHWrite.p = p;
0160     set(GUI,'HandleVisibility','callback');
0161     set(GUI,'Userdata',MESHWrite);
0162     
0163 return

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