0001 function mesh_write_fs_curv(p)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 fprintf('\nMESH_WRITE_FS_CURV...\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 curvatures 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
0055 if size(p.mesh.data.Cdata,2) >= i,
0056 if ~isempty(p.mesh.data.Cdata{1}),
0057 if size(p.mesh.data.Cdata{i},2) > 1,
0058
0059 curv = p.mesh.data.Cdata{i}(:,p.mesh.samplePoint);
0060 else
0061 curv = p.mesh.data.Cdata{i};
0062 end
0063
0064 Nfaces = size(p.mesh.data.faces{i},1);
0065
0066 outputExt = [ext,'.curv'];
0067 outputName = strcat(name,'.',Meshes{i});
0068 outputFile = fullfile(path,[outputName outputExt]);
0069
0070 fprintf('...writing curvature: %s\n',[outputName outputExt]);
0071 fs_write_curv(outputFile,curv,Nfaces);
0072 else
0073 msg = sprintf('\np.mesh.data.Cdata{%d} is empty\n',i);
0074 warning(msg);
0075 end
0076 else
0077 msg = sprintf('\nno p.mesh.data.Cdata{%d}\n',i);
0078 warning(msg);
0079 end
0080 end
0081 end
0082
0083 t=toc; fprintf('...done (%5.2f sec).\n\n',t);
0084
0085 return