Home > vbmeg > external > mne > mne_pick_channels_forward.m

mne_pick_channels_forward

PURPOSE ^

SYNOPSIS ^

function [fwd] = mne_pick_channels_forward(orig,include,exclude)

DESCRIPTION ^

 [fwd] = mne_pick_channels_forward(orig,include,exclude)

 Pick desired channels from a forward solution

 orig      - The original forward solution
 include   - Channels to include (if empty, include all available)
 exclude   - Channels to exclude (if empty, do not exclude any)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fwd] = mne_pick_channels_forward(orig,include,exclude)
0002 %
0003 % [fwd] = mne_pick_channels_forward(orig,include,exclude)
0004 %
0005 % Pick desired channels from a forward solution
0006 %
0007 % orig      - The original forward solution
0008 % include   - Channels to include (if empty, include all available)
0009 % exclude   - Channels to exclude (if empty, do not exclude any)
0010 %
0011 %
0012 
0013 %
0014 %
0015 %   Author : Matti Hamalainen, MGH Martinos Center
0016 %   License : BSD 3-clause
0017 %
0018 %   Revision 1.2  2009/03/04 22:04:31  msh
0019 %   Fixed typos in comments
0020 %
0021 %   Revision 1.1  2009/02/11 22:04:02  msh
0022 %   New routine to pick selected channels from the forward solution
0023 %
0024 %
0025 
0026 me='MNE:mne_pick_channels_forward';
0027 
0028 if nargin == 1
0029     fwd = orig;
0030     return;
0031 elseif nargin == 2
0032     exclude = [];
0033 elseif nargin ~= 3
0034     error(me,'Incorrect number of arguments');
0035 end
0036 
0037 if isempty(include) && isempty(exclude)
0038     fwd = orig;
0039     return;
0040 end
0041 
0042 if isempty(orig.sol.row_names) 
0043     error(me,'Cannot pick from a forward solution without channel names');
0044 end
0045 
0046 fwd = orig;
0047 %
0048 %   First do the channels to be included
0049 %
0050 sel = fiff_pick_channels(orig.sol.row_names, include, exclude);
0051 if isempty(sel)
0052    error(me, 'Nothing remains after picking');
0053 end
0054 fwd.sol.data = fwd.sol.data(sel,:);
0055 fwd.chs = fwd.chs(sel);
0056 %
0057 %   Select the desired stuff
0058 %
0059 for p = 1:length(sel)
0060    names{p} = fwd.sol.row_names{sel(p)};
0061 end
0062 fwd.sol.row_names = names;
0063 fwd.sol.nrow      = length(sel);
0064 fwd.nchan         = length(sel);
0065 %
0066 return;

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