Home > bioelectromagnetism > mesh_write_fs_overlay.m

mesh_write_fs_overlay

PURPOSE ^

mesh_write_fs_overlay - Save mesh CData to FreeSurfer overlay file

SYNOPSIS ^

function mesh_write_fs_overlay(p)

DESCRIPTION ^

 mesh_write_fs_overlay - Save mesh CData to FreeSurfer overlay file

 USEAGE: mesh_write_fs_overlay(p)

 Write a binary overlay file (*.w) for each mesh in p.mesh.data.  
 If any cells of p.mesh.data.meshtype are empty, they are skipped.
 
 This function outputs an *.w overlay file from the
 vertex scalar data contained in p.mesh.data.Cdata - if it 
 contains a timeseries, the output values are taken from 
 the column specified in p.mesh.samplePoint.
 
 All output is handled by fs_write_wfile.
 
 See the FreeSurfer website at http://surfer.nmr.mgh.harvard.edu/
 for more information.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mesh_write_fs_overlay(p)
0002 
0003 % mesh_write_fs_overlay - Save mesh CData to FreeSurfer overlay file
0004 %
0005 % USEAGE: mesh_write_fs_overlay(p)
0006 %
0007 % Write a binary overlay file (*.w) for each mesh in p.mesh.data.
0008 % If any cells of p.mesh.data.meshtype are empty, they are skipped.
0009 %
0010 % This function outputs an *.w overlay file from the
0011 % vertex scalar data contained in p.mesh.data.Cdata - if it
0012 % contains a timeseries, the output values are taken from
0013 % the column specified in p.mesh.samplePoint.
0014 %
0015 % All output is handled by fs_write_wfile.
0016 %
0017 % See the FreeSurfer website at http://surfer.nmr.mgh.harvard.edu/
0018 % for more information.
0019 %
0020 
0021 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0022 
0023 % Licence:  GNU GPL, no implied or express warranties
0024 % History:  10/2002, Darren.Weber_at_radiology.ucsf.edu
0025 %           01/2003, Darren.Weber_at_radiology.ucsf.edu
0026 %                    now using fs_write_surf and fs_write_wfile
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 
0029 fprintf('\nMESH_WRITE_FS_OVERLAY...\n');
0030 
0031 if ~exist('p','var'),
0032     error('...no input p struct.\n');
0033 elseif isempty(p),
0034     error('...input p struct is empty.\n');
0035 elseif isempty(p.mesh.data),
0036     error('...input p struct has no mesh data.\n');
0037 end
0038 
0039 [path,name,ext] = fileparts(strcat(p.mesh.path,filesep,p.mesh.file));
0040 file = fullfile(path,[name ext]);
0041 
0042 fprintf('...writing FreeSurfer overlays to:\n\t%s\n',path);
0043 
0044 tic;
0045 
0046 Meshes = p.mesh.data.meshtype;
0047 
0048 [path,name,ext] = fileparts(file);
0049 
0050 for i=1:size(Meshes,2),
0051     
0052     if Meshes{i},
0053         
0054         % check for mesh Cdata
0055         if size(p.mesh.data.Cdata,2) >= i,
0056             if ~isempty(p.mesh.data.Cdata{i}),
0057                 if size(p.mesh.data.Cdata{i},2) > 1,
0058                     % Obtain the Cdata at the selected time point
0059                     w = p.mesh.data.Cdata{i}(:,p.mesh.samplePoint);
0060                 else
0061                     w = p.mesh.data.Cdata{i};
0062                 end
0063                 
0064                 outputExt = [ext, '.w'];
0065                 outputName = strcat(name,'.',Meshes{i});
0066                 outputFile = fullfile(path,[outputName outputExt]);
0067                 
0068                 fprintf('...writing overlay: %s\n',[outputName outputExt]);
0069                 fs_write_wfile(outputFile,w);
0070             else
0071                 msg = sprintf('\np.mesh.data.Cdata{%d} is empty\n',i);
0072                 warning(msg);
0073             end
0074         else
0075             msg = sprintf('\nno p.mesh.data.Cdata{%d}\n',i);
0076             warning(msg);
0077         end
0078     end
0079 end
0080 
0081 t=toc; fprintf('...done (%5.2f sec).\n\n',t);
0082 
0083 return

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