Home > vbmeg > external > mne > mne_read_label_file.m

mne_read_label_file

PURPOSE ^

SYNOPSIS ^

function [label] = mne_read_label_file(filename)

DESCRIPTION ^

 [label] = mne_read_label_file(filename)
 
 Reads a label file. The returned structure has the following fields

     comment        comment from the first line of the label file
     vertices       vertex indices (0 based, column 1)
     pos            locations in meters (columns 2 - 4 divided by 1000)
     values         values at the vertices (column 5)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [label] = mne_read_label_file(filename)
0002 %
0003 % [label] = mne_read_label_file(filename)
0004 %
0005 % Reads a label file. The returned structure has the following fields
0006 %
0007 %     comment        comment from the first line of the label file
0008 %     vertices       vertex indices (0 based, column 1)
0009 %     pos            locations in meters (columns 2 - 4 divided by 1000)
0010 %     values         values at the vertices (column 5)
0011 %
0012 
0013 %
0014 %
0015 %   Author : Matti Hamalainen, MGH Martinos Center
0016 %   License : BSD 3-clause
0017 %
0018 
0019 %
0020 % This is based on the FreeSurfer read_label routine
0021 % SUBJECTS_DIR environment variable is not consulted for the standard location
0022 %
0023 
0024 me='MNE:mne_read_label_file';
0025 if(nargin ~= 1)
0026    error(me,'usage: mne_read_label_file(filename)');
0027 end
0028 
0029 [fid,message] = fopen(filename,'r');
0030 if (fid < 0)
0031    error(me,'Cannot open file %s (%s)', filename,message);
0032 end
0033 
0034 comment = fgets(fid) ;
0035 line = fgets(fid) ;
0036 nv = sscanf(line, '%d') ;
0037 data = fscanf(fid, '%d %f %f %f %f\n') ;
0038 data = reshape(data, 5, nv);
0039 
0040 for k = 2:length(comment)
0041    if comment(k) ~= ' '
0042       break;
0043    end
0044 end
0045 if comment(length(comment)) == 10
0046    comment = comment(1:end-1);
0047 end
0048 label.comment  = comment(k:end);
0049 label.vertices = int32(data(1,:));
0050 label.pos      = 1e-3*data(2:4,:)';
0051 label.values   = data(5,:);
0052 fclose(fid);
0053 
0054

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