Home > vbmeg > external > mne > mne_write_inverse_sol_w.m

mne_write_inverse_sol_w

PURPOSE ^

SYNOPSIS ^

function mne_write_inverse_sol_w(stem,inv,sol)

DESCRIPTION ^

 function mne_write_inverse_sol_w(stem,inv,sol)

 Save static inverse solution data into stc files

 stem      - Stem for the w files
 inv       - The inverse operator structure (can be the forward operator as well)
 sol       - The solution matrix (number of locations)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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