mesh_write_fs_surf - Save mesh to FreeSurfer (.asc) file USEAGE: mesh_write_fs_surf(p) Write a binary surface file for each mesh in p.mesh.data. If any cells of p.mesh.data.meshtype are empty, they will be skipped. All output is handled by fs_write_surf. This is just a wrapper to ouput all p.mesh.data, converting from meters into mm. See also fs_write_surf, fs_read_surf, and the FreeSurfer website at http://surfer.nmr.mgh.harvard.edu/.
0001 function mesh_write_fs_surf(p) 0002 0003 % mesh_write_fs_surf - Save mesh to FreeSurfer (.asc) file 0004 % 0005 % USEAGE: mesh_write_fs_surf(p) 0006 % 0007 % Write a binary surface file for each mesh in p.mesh.data. If any 0008 % cells of p.mesh.data.meshtype are empty, they will be skipped. 0009 % 0010 % All output is handled by fs_write_surf. This is just a wrapper 0011 % to ouput all p.mesh.data, converting from meters into mm. 0012 % 0013 % See also fs_write_surf, fs_read_surf, and 0014 % the FreeSurfer website at http://surfer.nmr.mgh.harvard.edu/. 0015 % 0016 0017 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0018 0019 % Licence: GNU GPL, no implied or express warranties 0020 % History: 10/2002, Darren.Weber_at_radiology.ucsf.edu 0021 % 01/2003, Darren.Weber_at_radiology.ucsf.edu 0022 % now using fs_write_surf 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 fprintf('\nMESH_WRITE_FS_SURF...\n'); 0026 0027 if ~exist('p','var'), 0028 error('...no input p struct.\n'); 0029 elseif isempty(p), 0030 error('...input p struct is empty.\n'); 0031 elseif isempty(p.mesh.data), 0032 error('...input p struct has no mesh data.\n'); 0033 end 0034 0035 [path,name,ext] = fileparts(strcat(p.mesh.path,filesep,p.mesh.file)); 0036 file = fullfile(path,[name ext]); 0037 0038 fprintf('...writing FreeSurfer binary surfaces to:\n\t%s\n',path); 0039 0040 tic; 0041 0042 Meshes = p.mesh.data.meshtype; 0043 0044 [path,name,ext] = fileparts(file); 0045 0046 for i=1:size(Meshes,2), 0047 0048 if Meshes{i}, 0049 0050 % Convert vertices from meters to mm 0051 fprintf('...converting vertices from meters to mm.\n'); 0052 vertices = p.mesh.data.vertices{i} .* 1000; 0053 faces = p.mesh.data.faces{i}; 0054 0055 outputName = strcat(name,'.',Meshes{i}); 0056 outputFile = fullfile(path,outputName); 0057 0058 fprintf('...writing tesselation: %s\n',outputName); 0059 fs_write_surf(outputFile,vertices,faces); 0060 0061 end 0062 end 0063 0064 t=toc; fprintf('...done (%5.2f sec).\n\n',t); 0065 0066 return