0001 function [fwd] = mne_pick_channels_forward(orig,include,exclude)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
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
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
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;