Home > vbmeg > external > mne > mne_read_curvature.m

mne_read_curvature

PURPOSE ^

SYNOPSIS ^

function [curv] = mne_read_curvature(fname)

DESCRIPTION ^

 [curf] = mne_read_surface(fname)

 Reads a FreeSurfer curvature file

 fname       - The file to read
 curv        - The curvature values

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [curv] = mne_read_curvature(fname)
0002 %
0003 % [curf] = mne_read_surface(fname)
0004 %
0005 % Reads a FreeSurfer curvature file
0006 %
0007 % fname       - The file to read
0008 % curv        - The curvature values
0009 %
0010 
0011 %
0012 %
0013 %   Author : Matti Hamalainen, MGH Martinos Center
0014 %   License : BSD 3-clause
0015 %
0016 %
0017 %   Revision 1.4  2006/07/31 05:12:39  msh
0018 %   fread3 was still called instead of mne_fread3
0019 %
0020 %   Revision 1.3  2006/05/22 11:01:47  msh
0021 %   Deleted superfluous text from the comments.
0022 %
0023 %   Revision 1.2  2006/05/22 10:55:02  msh
0024 %   Fixed help text.
0025 %
0026 %   Revision 1.1  2006/05/22 10:44:44  msh
0027 %   Added surface and curvature reading routines.
0028 %   Fixed error in mne_read_source_spaces: triangle normals were not normalized
0029 %
0030 
0031 me='MNE:mne_read_curvature';
0032 
0033 %
0034 %   The input file is big endian
0035 %
0036 fid = fopen(fname,'rb','ieee-be');
0037 
0038 if (fid < 0)
0039    error(me,'Cannot open file %s', fname);
0040 end;
0041 
0042 magic = mne_fread3(fid) ;
0043 NEW_VERSION_MAGIC_NUMBER = 16777215;
0044 if (magic == NEW_VERSION_MAGIC_NUMBER)
0045     nvert = fread(fid, 1, 'int32');
0046     nface = fread(fid, 1, 'int32');
0047     val_per_vertex = fread(fid, 1, 'int32');
0048     if val_per_vertex ~= 1
0049         fclose(fid);
0050         error(me,'Values per vertex not equal to one');
0051     end
0052     curv = fread(fid, nvert, 'float') ;
0053     fprintf(1,'\t%d values read from a new style curvature file.\n',nvert);
0054 else
0055     nvert = magic;
0056     nface = mne_fread3(fid);
0057     curv = fread(fid, nvert, 'int16') ./ 100 ;
0058     fprintf(1,'\t%d values read from an old style curvature file.\n',nvert);
0059 end
0060 
0061 fclose(fid);
0062 
0063 return;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005