Home > bioelectromagnetism > freesurfer_write_curv.m

freesurfer_write_curv

PURPOSE ^

freesurfer_write_curv - FreeSurfer I/O function to write a curvature file

SYNOPSIS ^

function [curv] = freesurfer_write_curv(fname, curv, fnum, ver)

DESCRIPTION ^

 freesurfer_write_curv - FreeSurfer I/O function to write a curvature file
 
 [curv] = freesurfer_write_curv(fname, curv, fnum, [ver])
 
 writes a curvature vector into a binary file
 fname - name of file to write
 curv  - vector of curvatures, one for each vertex
 fnum  - # of faces in surface.
 ver   - 'old' or 'new' version format (new by default)
 
 See also freesurfer_read_curv, freesurfer_write_surf, freesurfer_write_wfile

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [curv] = freesurfer_write_curv(fname, curv, fnum, ver)
0002 
0003 % freesurfer_write_curv - FreeSurfer I/O function to write a curvature file
0004 %
0005 % [curv] = freesurfer_write_curv(fname, curv, fnum, [ver])
0006 %
0007 % writes a curvature vector into a binary file
0008 % fname - name of file to write
0009 % curv  - vector of curvatures, one for each vertex
0010 % fnum  - # of faces in surface.
0011 % ver   - 'old' or 'new' version format (new by default)
0012 %
0013 % See also freesurfer_read_curv, freesurfer_write_surf, freesurfer_write_wfile
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 % curv array is one value per vertex,
0026 % so we get the number of vertices:
0027 vnum = length(curv) ;
0028 
0029 % open file as a big-endian file
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'); % vals_per_vertex
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

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