freesurfer_write_wfile - FreeSurfer I/O function to write an overlay (*.w) file [w] = freesurfer_write_wfile(fname, w) writes a vector into a binary 'w' file fname - name of file to write to w - vector of values to be written, assumed sorted from vertex 1:N See also freesurfer_read_wfile, freesurfer_write_surf, freesurfer_write_curv
0001 function freesurfer_write_wfile(fname, w) 0002 0003 % freesurfer_write_wfile - FreeSurfer I/O function to write an overlay (*.w) file 0004 % 0005 % [w] = freesurfer_write_wfile(fname, w) 0006 % writes a vector into a binary 'w' file 0007 % fname - name of file to write to 0008 % w - vector of values to be written, 0009 % assumed sorted from vertex 1:N 0010 % 0011 % See also freesurfer_read_wfile, freesurfer_write_surf, freesurfer_write_curv 0012 0013 if(nargin ~= 2) 0014 msg = sprintf('USAGE: [w] = freesurfer_write_wfile(fname, w)\n'); 0015 error(msg); 0016 end 0017 0018 % open it as a big-endian file 0019 fid = fopen(fname, 'wb', 'b') ; 0020 0021 vnum = length(w) ; 0022 0023 fwrite(fid, 0, 'int16') ; % latency integer 0024 freesurfer_fwrite3(fid, vnum) ; % number of vertices 0025 for i=1:vnum, 0026 freesurfer_fwrite3(fid, i-1) ; % FS vertices start at zero 0027 fwrite(fid, w(i), 'float') ; 0028 end 0029 0030 fclose(fid) ; 0031 0032 return