0001 function channel_info = vb_eeginfo_make_channel_info(eeginfo, ch_labels, ch_type)
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
0027
0028
0029
0030
0031
0032
0033 if ~exist('eeginfo', 'var'), eeginfo = ''; end
0034 if ~exist('ch_labels', 'var'), ch_labels = []; end
0035 if ~exist('ch_type', 'var'), ch_type = []; end
0036 [eeginfo, ch_labels, ch_type] = ...
0037 inner_check_arguments(eeginfo, ch_labels, ch_type);
0038
0039
0040
0041 org_eeg_label = vb_eeginfo_get_channel_label(eeginfo);
0042 org_ext_label = vb_eeginfo_get_channel_label_extra(eeginfo, false);
0043
0044
0045
0046
0047 target_eeg_labels = [];
0048 if ch_type ~= 2 && ~isempty(org_eeg_label) && ~isempty(ch_labels)
0049 [eeg_idx] = vb_util_get_index(org_eeg_label, ch_labels);
0050 if ~isempty(eeg_idx)
0051 target_eeg_labels = org_eeg_label(eeg_idx);
0052 end
0053 else
0054 eeg_idx = [];
0055 end
0056
0057
0058 target_ext_labels = [];
0059 if ch_type ~= 1 && ~isempty(org_ext_label) && ~isempty(ch_labels)
0060 [ext_idx] = vb_util_get_index(org_ext_label, ch_labels);
0061 if ~isempty(ext_idx)
0062 target_ext_labels = org_ext_label(ext_idx);
0063 end
0064 else
0065 ext_idx = [];
0066 end
0067
0068 extra_info = eeginfo.ExtraChannelInfo;
0069
0070
0071 if vb_info_active_channel_is_valid(eeginfo)
0072 active_ch = vb_info_get_active_channel(eeginfo);
0073 eeg_active = active_ch(eeg_idx);
0074
0075 if ~isempty(extra_info.Channel_active)
0076 ext_active = extra_info.Channel_active(ext_idx);
0077 else
0078
0079 Nch = length(ext_idx);
0080 ext_active = ones(Nch,1);
0081 end
0082 channel_info.Active = [eeg_active;ext_active];
0083 else
0084 Nch = length(target_eeg_labels)+length(target_ext_labels);
0085 channel_info.Active = ones(Nch,1);
0086 end
0087
0088
0089 channel_info.Name = [target_eeg_labels;target_ext_labels];
0090
0091
0092
0093 len_eeg_ch = length(target_eeg_labels);
0094 eeg_type = ones(len_eeg_ch, 1);
0095
0096 if ~isempty(extra_info.Channel_type)
0097 ext_type = extra_info.Channel_type(ext_idx);
0098 else
0099
0100
0101
0102 ext_type = [];
0103 end
0104 channel_info.Type = [eeg_type;ext_type];
0105
0106
0107 eeg_id = eeginfo.ChannelID(eeg_idx);
0108 ext_id = extra_info.Channel_id(ext_idx);
0109 channel_info.ID = [eeg_id;ext_id];
0110 return;
0111
0112
0113
0114
0115
0116
0117
0118 function [eeginfo, ch_labels, ch_type] = ...
0119 inner_check_arguments(eeginfo, ch_labels, ch_type)
0120
0121 func_ = mfilename;
0122 if isempty(eeginfo)
0123 error('(%s)eeginfo is a required parameter', func_);
0124 end
0125
0126 if isempty(ch_type)
0127 ch_type = 0;
0128 end
0129 return;
0130
0131
0132
0133
0134
0135