0001 function [curv] = freesurfer_write_curv(fname, curv, fnum, ver)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if(nargin < 3),
0017 fprintf('USAGE: curv = freesurfer_write_curv(fname, curv, fnum, [ver])\n');
0018 return;
0019 end
0020
0021 if ~exist('ver','var'), ver = 'new'; end
0022 if isempty(ver), ver = 'new'; end
0023
0024
0025
0026
0027 vnum = length(curv) ;
0028
0029
0030 fid = fopen(fname, 'wb', 'b') ;
0031
0032 switch lower(ver),
0033
0034 case 'new',
0035
0036 fprintf('...writing new curv version (float)\n');
0037
0038 NEW_VERSION_MAGIC_NUMBER = 16777215;
0039 freesurfer_fwrite3(fid, NEW_VERSION_MAGIC_NUMBER ) ;
0040
0041 fwrite(fid, vnum,'int32');
0042 fwrite(fid, fnum,'int32');
0043 fwrite(fid, 1,'int32');
0044 fwrite(fid, curv,'float');
0045 fclose(fid) ;
0046
0047 case 'old',
0048
0049 fprintf('...writing old curv version (int16)\n');
0050
0051 freesurfer_fwrite3(fid,vnum) ;
0052 freesurfer_fwrite3(fid,fnum) ;
0053 fwrite(fid, curv .* 100, 'int16') ;
0054 end
0055
0056 return