Home > vbmeg > external > mne > mne_write_inverse_sol_stc.m

mne_write_inverse_sol_stc

PURPOSE ^

SYNOPSIS ^

function mne_write_inverse_sol_stc(stem,inv,sol,tmin,tstep)

DESCRIPTION ^

 function mne_write_inverse_sol_stc(stem,inv,sol,tmin,tstep)

 Save dynamic inverse solution data into stc files

 stem      - Stem for the stc files
 inv       - The inverse operator structure (can be the forward operator as well)
 sol       - A solution matrix (locations x time)
 tmin      - Time of the first data point in seconds
 tstep     - Time between data points in seconds

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mne_write_inverse_sol_stc(stem,inv,sol,tmin,tstep)
0002 %
0003 % function mne_write_inverse_sol_stc(stem,inv,sol,tmin,tstep)
0004 %
0005 % Save dynamic inverse solution data into stc files
0006 %
0007 % stem      - Stem for the stc files
0008 % inv       - The inverse operator structure (can be the forward operator as well)
0009 % sol       - A solution matrix (locations x time)
0010 % tmin      - Time of the first data point in seconds
0011 % tstep     - Time between data points in seconds
0012 %
0013 
0014 %
0015 %
0016 %   Author : Matti Hamalainen, MGH Martinos Center
0017 %   License : BSD 3-clause
0018 %
0019 %   Revision 1.3  2009/03/04 03:47:15  msh
0020 %   Fixed comments and added a note that the source spaces can come from a forward operator as well
0021 %
0022 %   Revision 1.2  2006/09/14 22:12:48  msh
0023 %   Added output of the files written.
0024 %
0025 %   Revision 1.1  2006/05/05 03:50:40  msh
0026 %   Added routines to compute L2-norm inverse solutions.
0027 %   Added mne_write_inverse_sol_stc to write them in stc files
0028 %   Several bug fixes in other files
0029 %
0030 %
0031 
0032 me='MNE:mne_write_inverse_sol_stc';
0033 global FIFF;
0034 if isempty(FIFF)
0035    FIFF = fiff_define_constants();
0036 end
0037 
0038 if nargin ~= 5
0039     error(me,'Incorrect number of arguments');
0040 end
0041 
0042 if size(sol,1) ~= inv.nsource
0043     error(me,'The solution matrix cannot correspond to these source spaces');
0044 end
0045 
0046 off = 0;
0047 for k = 1:length(inv.src)
0048     off = off + inv.src(k).nuse;
0049     if (inv.src(k).id ~= FIFF.FIFFV_MNE_SURF_LEFT_HEMI && ...
0050             inv.src(k).id ~= FIFF.FIFFV_MNE_SURF_RIGHT_HEMI)
0051         error(me,'Source space hemispheres not properly assigned.');
0052     end
0053 end
0054 if off ~= inv.nsource
0055     error(me,'The source spaces are inconsistent with other inverse/forward operator data');
0056 end
0057 %
0058 %   Write a separate stc file for each source space
0059 %
0060 off = 0;
0061 for k = 1:length(inv.src)
0062     if (inv.src(k).id == FIFF.FIFFV_MNE_SURF_LEFT_HEMI)
0063         outname = sprintf('%s-lh.stc',stem);
0064     elseif (inv.src(k).id == FIFF.FIFFV_MNE_SURF_RIGHT_HEMI)
0065         outname = sprintf('%s-rh.stc',stem);
0066     end
0067     stc.tmin     = tmin;
0068     stc.tstep    = tstep;
0069     stc.vertices = inv.src(k).vertno - 1;
0070     stc.data     = sol(off+1:off+inv.src(k).nuse,:);
0071     mne_write_stc_file(outname,stc);
0072     off = off + inv.src(k).nuse;
0073     fprintf(1,'Wrote %s\n',outname);
0074 end
0075 
0076 return;
0077 
0078 
0079

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