Home > vbmeg > external > mne > mne_read_stc_file.m

mne_read_stc_file

PURPOSE ^

SYNOPSIS ^

function [stc] = mne_read_stc_file(filename)

DESCRIPTION ^

 [stc] = mne_read_stc_file(filename)
 
 Reads an stc file. The returned structure has the following fields

     tmin           The first time point of the data in seconds
     tstep          Time between frames in seconds
     vertices       vertex indices (0 based)
     data           The data matrix (nvert * ntime)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [stc] = mne_read_stc_file(filename)
0002 %
0003 % [stc] = mne_read_stc_file(filename)
0004 %
0005 % Reads an stc file. The returned structure has the following fields
0006 %
0007 %     tmin           The first time point of the data in seconds
0008 %     tstep          Time between frames in seconds
0009 %     vertices       vertex indices (0 based)
0010 %     data           The data matrix (nvert * ntime)
0011 %
0012 %
0013 
0014 %
0015 %
0016 %   Author : Matti Hamalainen, MGH Martinos Center
0017 %   License : BSD 3-clause
0018 %
0019 %   Revision 1.7  2006/04/23 15:29:41  msh
0020 %   Added MGH to the copyright
0021 %
0022 %   Revision 1.6  2006/04/10 23:26:54  msh
0023 %   Added fiff reading routines
0024 %
0025 %   Revision 1.5  2005/12/05 20:23:21  msh
0026 %   Added fiff_save_evoked. Improved error handling.
0027 %
0028 %   Revision 1.4  2005/11/21 05:40:24  msh
0029 %   Required number of arguments was wrong.
0030 %
0031 %   Revision 1.3  2005/11/21 03:19:12  msh
0032 %   Improved error handling
0033 %
0034 %   Revision 1.2  2005/11/21 02:15:51  msh
0035 %   Added more routines
0036 %
0037 %   Revision 1.1  2005/11/21 01:41:57  msh
0038 %   Introduced structures and start all function names with mne_
0039 %
0040 %
0041 me='MNE:mne_read_stc_file';
0042 if(nargin ~= 1)
0043    error(me,'usage: [stc] = mne_read_stc_file(filename)');
0044 end
0045 
0046 [fid,message] = fopen(filename,'r','ieee-be');
0047 if fid == -1
0048     error(me,message)
0049 end
0050 
0051 STATUS = fseek(fid, 0, 'eof');
0052 filelen= ftell(fid);
0053 STATUS = fseek(fid, 0, 'bof');
0054 
0055 % read tmin in ms
0056 [stc.tmin count]=fread(fid,1,'float32');
0057 stc.tmin=stc.tmin/1000.0;
0058 % read sampling rate in ms
0059 [stc.tstep count]=fread(fid,1,'float32');
0060 stc.tstep=stc.tstep/1000.0;
0061 % read number of vertices/sources
0062 [vertices_n count]=fread(fid,1,'uint32');
0063 % read the source vector
0064 [stc.vertices count]=fread(fid,vertices_n,'uint32');
0065 stc.vertices=uint32(stc.vertices);
0066 % read the number of timepts
0067 [data_n count]=fread(fid,1,'uint32');
0068 
0069 if (mod((filelen/4-4-vertices_n),data_n*vertices_n) ~= 0) 
0070    error(me,'incorrect stc file size')
0071 end
0072 
0073 
0074 % read the data matrix
0075 [stc.data count]=fread(fid,vertices_n*data_n,'float32');
0076 stc.data=squeeze(reshape(stc.data,vertices_n,data_n));
0077 % close the file
0078 fclose(fid);
0079 return;
0080

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