Home > vbmeg > external > mne > mne_write_stc_file.m

mne_write_stc_file

PURPOSE ^

SYNOPSIS ^

function mne_write_stc_file(filename,stc)

DESCRIPTION ^

 mne_write_stc_file(filename,stc)
 
 writes an stc file

     filename      output file
     stc           a stucture containing the stc data with fields:

     tmin          The time of the first frame 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 mne_write_stc_file(filename,stc)
0002 %
0003 % mne_write_stc_file(filename,stc)
0004 %
0005 % writes an stc file
0006 %
0007 %     filename      output file
0008 %     stc           a stucture containing the stc data with fields:
0009 %
0010 %     tmin          The time of the first frame in seconds
0011 %     tstep         Time between frames in seconds
0012 %     vertices      Vertex indices (0 based)
0013 %     data          The data matrix nvert * ntime
0014 %
0015 
0016 %
0017 %
0018 %   Author : Matti Hamalainen, MGH Martinos Center
0019 %   License : BSD 3-clause
0020 %
0021 %
0022 %     $Id: mne_write_stc_file.m 8776 2013-11-14 09:04:48Z roboos $
0023 %
0024 %     Revision 1.7  2006/05/05 03:50:40  msh
0025 %     Added routines to compute L2-norm inverse solutions.
0026 %     Added mne_write_inverse_sol_stc to write them in stc files
0027 %     Several bug fixes in other files
0028 %
0029 %     Revision 1.6  2006/04/23 15:29:41  msh
0030 %     Added MGH to the copyright
0031 %
0032 %     Revision 1.5  2006/04/10 23:26:54  msh
0033 %     Added fiff reading routines
0034 %
0035 %     Revision 1.4  2005/12/05 20:23:21  msh
0036 %     Added fiff_save_evoked. Improved error handling.
0037 %
0038 %     Revision 1.3  2005/11/21 03:19:12  msh
0039 %     Improved error handling
0040 %
0041 %     Revision 1.2  2005/11/21 02:15:51  msh
0042 %     Added more routines
0043 %
0044 %     Revision 1.1  2005/11/21 01:41:57  msh
0045 %     Introduced structures and start all function names with mne_
0046 %
0047 %
0048 me='MNE:mne_write_stc_file';
0049 if(nargin ~= 2)
0050    error(me,'usage: mne_write_stc_file(filename, stc)');
0051 end
0052 
0053 [fid,message] = fopen(filename,'w','ieee-be');
0054 if fid == -1
0055    error(me,message);
0056 end
0057 
0058 % write starttime in ms
0059 fwrite(fid,1000*stc.tmin,'float32');
0060 % write sampling rate in ms
0061 fwrite(fid,1000*stc.tstep,'float32');
0062 % write number of vertices
0063 fwrite(fid,length(stc.vertices),'uint32');
0064 % write the vertex indices
0065 for i=1:length(stc.vertices)
0066     fwrite(fid,stc.vertices(i),'uint32');
0067 end
0068 
0069 % write the number of timepts
0070 fwrite(fid,size(stc.data,2),'uint32');
0071 %
0072 % write the data
0073 %
0074 fwrite(fid,stc.data,'float32');
0075 
0076 % close the file
0077 fclose(fid);

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