mesh_write_brainstorm - Save eeg toolbox meshes to brainstorm format USEAGE: mesh_write_brainstorm(p) This routine saves each mesh in p.mesh.data into the correct structure format required in brainstorm. The workspace variables created are saved, in the brainstorm file format, into p.mesh.file with a '.mat' extension. The variables from this file can be loaded using the matlab 'load' command. To plot the default cortex, skull & scalp BrainStorm data: Hpatch1 = patch('Vertices',Vertices{1}','Faces',Faces{1},... 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); Hpatch2 = patch('Vertices',Vertices{2}','Faces',Faces{2},... 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); Hpatch3 = patch('Vertices',Vertices{3}','Faces',Faces{3},... 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); See the BrainStorm website at http://neuroimage.usc.edu/brainstorm/ for more information about the BrainStorm toolbox and the format and content of the subjecttess variables.
0001 function mesh_write_brainstorm(p) 0002 0003 % mesh_write_brainstorm - Save eeg toolbox meshes to brainstorm format 0004 % 0005 % USEAGE: mesh_write_brainstorm(p) 0006 % 0007 % This routine saves each mesh in p.mesh.data into the correct 0008 % structure format required in brainstorm. 0009 % 0010 % The workspace variables created are saved, in the brainstorm 0011 % file format, into p.mesh.file with a '.mat' extension. 0012 % 0013 % The variables from this file can be loaded using the matlab 'load' 0014 % command. To plot the default cortex, skull & scalp BrainStorm data: 0015 % 0016 % Hpatch1 = patch('Vertices',Vertices{1}','Faces',Faces{1},... 0017 % 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); 0018 % Hpatch2 = patch('Vertices',Vertices{2}','Faces',Faces{2},... 0019 % 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); 0020 % Hpatch3 = patch('Vertices',Vertices{3}','Faces',Faces{3},... 0021 % 'EdgeColor',[.6 .6 .6],'FaceColor',[0.9 0.9 0.9]); 0022 % 0023 % See the BrainStorm website at http://neuroimage.usc.edu/brainstorm/ 0024 % for more information about the BrainStorm toolbox and the format 0025 % and content of the subjecttess variables. 0026 % 0027 0028 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0029 0030 % Licence: GNU GPL, no implied or express warranties 0031 % History: 04/2002, Darren.Weber_at_radiology.ucsf.edu 0032 % 0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0034 0035 fprintf('\nMESH_WRITE_BRAINSTORM...\n'); 0036 0037 if ~exist('p','var'), 0038 error('...no input p struct.\n'); 0039 else 0040 if isempty(p.mesh.data), 0041 error('...input p.mesh.data is empty.\n'); 0042 end 0043 end 0044 0045 [path,name,ext] = fileparts(strcat(p.mesh.path,filesep,p.mesh.file)); 0046 ext = '.mat'; 0047 brainstormfile = fullfile(path,[name ext]); 0048 0049 if ~exist('brainstormfile','var'), 0050 error('...no input brainstormfile.\n'); 0051 end 0052 0053 tic; 0054 0055 Comment = p.mesh.data.meshtype; 0056 Faces = cell(size(Comment)); 0057 Vertices = cell(size(Comment)); 0058 0059 for i=1:size(Comment,2), 0060 fprintf('...converting tesselation: %s\n',Comment{i}); 0061 Vertices{i} = p.mesh.data.vertices{i}'; % transpose vertices 0062 Faces{i} = p.mesh.data.faces{i}; 0063 end 0064 0065 fprintf('...saving BrainStorm data to:\n\t%s\n',brainstormfile); 0066 save(brainstormfile, 'Comment', 'Faces', 'Vertices'); 0067 0068 t=toc; fprintf('...done (%5.2f sec).\n\n',t); 0069 0070 return