freesurfer_read_curv - FreeSurfer I/O function to read a curvature file [curv, fnum] = freesurfer_read_curv(fname) reads a binary curvature file into a vector After reading an associated surface, with freesurfer_read_surf, try: patch('vertices',vert,'faces',face,... 'facecolor','interp','edgecolor','none',... 'FaceVertexCData',curv); light See also freesurfer_write_curv, freesurfer_read_surf, freesurfer_read_wfile
0001 function [curv, fnum] = freesurfer_read_curv(fname) 0002 0003 % freesurfer_read_curv - FreeSurfer I/O function to read a curvature file 0004 % 0005 % [curv, fnum] = freesurfer_read_curv(fname) 0006 % 0007 % reads a binary curvature file into a vector 0008 % 0009 % After reading an associated surface, with freesurfer_read_surf, try: 0010 % patch('vertices',vert,'faces',face,... 0011 % 'facecolor','interp','edgecolor','none',... 0012 % 'FaceVertexCData',curv); light 0013 % 0014 % See also freesurfer_write_curv, freesurfer_read_surf, freesurfer_read_wfile 0015 0016 0017 % $Revision: 1.2 $ $Date: 2005/05/18 23:07:42 $ 0018 0019 % Copyright (C) 2000 Darren L. Weber 0020 % 0021 % This program is free software; you can redistribute it and/or 0022 % modify it under the terms of the GNU General Public License 0023 % as published by the Free Software Foundation; either version 2 0024 % of the License, or (at your option) any later version. 0025 % 0026 % This program is distributed in the hope that it will be useful, 0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0029 % GNU General Public License for more details. 0030 % 0031 % You should have received a copy of the GNU General Public License 0032 % along with this program; if not, write to the Free Software 0033 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 0034 % USA. 0035 0036 % History: 08/2000, Developed at MGH, Boston 0037 % 01/2004, Darren.Weber_at_radiology.ucsf.edu 0038 % 0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0040 0041 0042 ver = '$Revision: 1.2 $ $Date: 2005/05/18 23:07:42 $'; 0043 fprintf('FREESURFER_READ_CURV [v %s]\n',ver(11:15)); 0044 0045 % open it as a big-endian file 0046 fid = fopen(fname, 'rb', 'b'); 0047 if (fid < 0), 0048 str = sprintf('could not open file: %s', fname); 0049 error(str); 0050 end 0051 0052 fprintf('...reading surface file: %s\n', fname); 0053 tic; 0054 0055 vnum = freesurfer_fread3(fid); 0056 NEW_VERSION_MAGIC_NUMBER = 16777215; 0057 if (vnum == NEW_VERSION_MAGIC_NUMBER), 0058 fprintf('...reading new version (float)\n'); 0059 vnum = fread(fid, 1, 'int32'); 0060 fnum = fread(fid, 1, 'int32'); 0061 vals_per_vertex = fread(fid, 1, 'int32'); 0062 curv = fread(fid, vnum, 'float'); 0063 else 0064 fprintf('...reading old version (int16)\n'); 0065 fnum = freesurfer_fread3(fid); 0066 curv = fread(fid, vnum, 'int16') ./ 100; 0067 end 0068 0069 fclose(fid); 0070 t=toc; fprintf('...done (%6.2f sec)\n\n',t); 0071 0072 return