0001 function [result] = vb_posfile_replace_label(src_file, dst_file, rpl_type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 func_ = mfilename;
0024 result = 0;
0025
0026
0027 if ~exist('src_file', 'var'), src_file = ''; end
0028 if ~exist('dst_file', 'var'), dst_file = ''; end
0029 if ~exist('rpl_type', 'var'), rpl_type = []; end
0030
0031 [src_file, dst_file, rpl_type] = ...
0032 inner_check_arguments(src_file, dst_file, rpl_type);
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 pos = load(src_file);
0047 if ~isfield(pos, 'name')
0048 fprintf('(%s) cannot find name field\n', func_);
0049 result = 1;
0050 return;
0051 end
0052
0053 switch rpl_type
0054 case 0
0055 new_labels = inner_sub_64_fp1_to_a1(pos.name);
0056
0057 case 1
0058 new_labels = inner_sub_64_a1_to_fp1(pos.name);
0059
0060 otherwise
0061 fprintf('(%s) unknown replace type : %d\n', func_, rpl_type);
0062 result = 1;
0063 return;
0064 end
0065
0066
0067 pos.name = new_labels;
0068 vb_save_struct(dst_file, pos);
0069 return;
0070
0071
0072
0073
0074
0075
0076
0077 function [src_file, dst_file, rpl_type] = ...
0078 inner_check_arguments(src_file, dst_file, rpl_type)
0079 func_ = mfilename;
0080
0081 if isempty(src_file)
0082 error('(%s) src_file is a required parameter', func_);
0083 end
0084
0085 if exist(src_file, 'file') ~= 2
0086 error('(%s) cannot find src_file : %s\n', func_, src_file);
0087 end
0088
0089 if isempty(dst_file)
0090 error('(%s) dst_file is a required parameter', func_);
0091 end
0092
0093 if isempty(rpl_type)
0094 rpl_type = 0;
0095 end
0096 return;
0097
0098
0099
0100
0101
0102
0103 function new_labels = inner_sub_64_fp1_to_a1(old_labels)
0104
0105 n_old = length(old_labels);
0106 new_labels = cell(64,1);
0107 i_new = 1;
0108
0109 for i_old = 1:n_old
0110 if strcmp(old_labels{i_old}, 'Fp1'), new_labels{i_new} = 'A1';
0111 elseif strcmp(old_labels{i_old}, 'Fpz'), new_labels{i_new} = 'B1';
0112 elseif strcmp(old_labels{i_old}, 'Fp2'), new_labels{i_new} = 'B2';
0113
0114 elseif strcmp(old_labels{i_old}, 'AF7'), new_labels{i_new} = 'A2';
0115 elseif strcmp(old_labels{i_old}, 'AF3'), new_labels{i_new} = 'A3';
0116 elseif strcmp(old_labels{i_old}, 'AFz'), new_labels{i_new} = 'B5';
0117 elseif strcmp(old_labels{i_old}, 'AF4'), new_labels{i_new} = 'B4';
0118 elseif strcmp(old_labels{i_old}, 'AF8'), new_labels{i_new} = 'B3';
0119
0120 elseif strcmp(old_labels{i_old}, 'F7' ), new_labels{i_new} = 'A7';
0121 elseif strcmp(old_labels{i_old}, 'F5' ), new_labels{i_new} = 'A6';
0122 elseif strcmp(old_labels{i_old}, 'F3' ), new_labels{i_new} = 'A5';
0123 elseif strcmp(old_labels{i_old}, 'F1' ), new_labels{i_new} = 'A4';
0124 elseif strcmp(old_labels{i_old}, 'Fz' ), new_labels{i_new} = 'B6';
0125 elseif strcmp(old_labels{i_old}, 'F2' ), new_labels{i_new} = 'B7';
0126 elseif strcmp(old_labels{i_old}, 'F4' ), new_labels{i_new} = 'B8';
0127 elseif strcmp(old_labels{i_old}, 'F6' ), new_labels{i_new} = 'B9';
0128 elseif strcmp(old_labels{i_old}, 'F8' ), new_labels{i_new} = 'B10';
0129
0130 elseif strcmp(old_labels{i_old}, 'FT7'), new_labels{i_new} = 'A8';
0131 elseif strcmp(old_labels{i_old}, 'FC5'), new_labels{i_new} = 'A9';
0132 elseif strcmp(old_labels{i_old}, 'FC3'), new_labels{i_new} = 'A10';
0133 elseif strcmp(old_labels{i_old}, 'FC1'), new_labels{i_new} = 'A11';
0134 elseif strcmp(old_labels{i_old}, 'FCz'), new_labels{i_new} = 'B15';
0135 elseif strcmp(old_labels{i_old}, 'FC2'), new_labels{i_new} = 'B14';
0136 elseif strcmp(old_labels{i_old}, 'FC4'), new_labels{i_new} = 'B13';
0137 elseif strcmp(old_labels{i_old}, 'FC6'), new_labels{i_new} = 'B12';
0138 elseif strcmp(old_labels{i_old}, 'FT8'), new_labels{i_new} = 'B11';
0139
0140 elseif strcmp(old_labels{i_old}, 'T7' ), new_labels{i_new} = 'A15';
0141 elseif strcmp(old_labels{i_old}, 'C5' ), new_labels{i_new} = 'A14';
0142 elseif strcmp(old_labels{i_old}, 'C3' ), new_labels{i_new} = 'A13';
0143 elseif strcmp(old_labels{i_old}, 'C1' ), new_labels{i_new} = 'A12';
0144 elseif strcmp(old_labels{i_old}, 'Cz' ), new_labels{i_new} = 'B16';
0145 elseif strcmp(old_labels{i_old}, 'C2' ), new_labels{i_new} = 'B17';
0146 elseif strcmp(old_labels{i_old}, 'C4' ), new_labels{i_new} = 'B18';
0147 elseif strcmp(old_labels{i_old}, 'C6' ), new_labels{i_new} = 'B19';
0148 elseif strcmp(old_labels{i_old}, 'T8' ), new_labels{i_new} = 'B20';
0149
0150 elseif strcmp(old_labels{i_old}, 'TP7'), new_labels{i_new} = 'A16';
0151 elseif strcmp(old_labels{i_old}, 'CP5'), new_labels{i_new} = 'A17';
0152 elseif strcmp(old_labels{i_old}, 'CP3'), new_labels{i_new} = 'A18';
0153 elseif strcmp(old_labels{i_old}, 'CP1'), new_labels{i_new} = 'A19';
0154 elseif strcmp(old_labels{i_old}, 'CPz'), new_labels{i_new} = 'A32';
0155 elseif strcmp(old_labels{i_old}, 'CP2'), new_labels{i_new} = 'B24';
0156 elseif strcmp(old_labels{i_old}, 'CP4'), new_labels{i_new} = 'B23';
0157 elseif strcmp(old_labels{i_old}, 'CP6'), new_labels{i_new} = 'B22';
0158 elseif strcmp(old_labels{i_old}, 'TP8'), new_labels{i_new} = 'B21';
0159
0160 elseif strcmp(old_labels{i_old}, 'P9' ), new_labels{i_new} = 'A24';
0161 elseif strcmp(old_labels{i_old}, 'P7' ), new_labels{i_new} = 'A23';
0162 elseif strcmp(old_labels{i_old}, 'P5' ), new_labels{i_new} = 'A22';
0163 elseif strcmp(old_labels{i_old}, 'P3' ), new_labels{i_new} = 'A21';
0164 elseif strcmp(old_labels{i_old}, 'P1' ), new_labels{i_new} = 'A20';
0165 elseif strcmp(old_labels{i_old}, 'Pz' ), new_labels{i_new} = 'A31';
0166 elseif strcmp(old_labels{i_old}, 'P2' ), new_labels{i_new} = 'B25';
0167 elseif strcmp(old_labels{i_old}, 'P4' ), new_labels{i_new} = 'B26';
0168 elseif strcmp(old_labels{i_old}, 'P6' ), new_labels{i_new} = 'B27';
0169 elseif strcmp(old_labels{i_old}, 'P8' ), new_labels{i_new} = 'B28';
0170 elseif strcmp(old_labels{i_old}, 'P10'), new_labels{i_new} = 'B29';
0171
0172 elseif strcmp(old_labels{i_old}, 'PO7'), new_labels{i_new} = 'A25';
0173 elseif strcmp(old_labels{i_old}, 'PO3'), new_labels{i_new} = 'A26';
0174 elseif strcmp(old_labels{i_old}, 'POz'), new_labels{i_new} = 'A30';
0175 elseif strcmp(old_labels{i_old}, 'PO4'), new_labels{i_new} = 'B31';
0176 elseif strcmp(old_labels{i_old}, 'PO8'), new_labels{i_new} = 'B30';
0177
0178 elseif strcmp(old_labels{i_old}, 'O1' ), new_labels{i_new} = 'A27';
0179 elseif strcmp(old_labels{i_old}, 'Oz' ), new_labels{i_new} = 'A29';
0180 elseif strcmp(old_labels{i_old}, 'O2' ), new_labels{i_new} = 'B32';
0181
0182 elseif strcmp(old_labels{i_old}, 'Iz' ), new_labels{i_new} = 'A28';
0183 end
0184
0185 i_new = i_new + 1;
0186 end
0187 return;
0188
0189
0190
0191
0192
0193
0194 function new_labels = inner_sub_64_a1_to_fp1(old_labels)
0195
0196 n_old = length(old_labels);
0197 new_labels = cell(64,1);
0198 i_new = 1;
0199
0200 for i_old = 1:n_old
0201 if strcmp(old_labels{i_old}, 'A1'), new_labels{i_new} = 'Fp1';
0202 elseif strcmp(old_labels{i_old}, 'B1'), new_labels{i_new} = 'Fpz1';
0203 elseif strcmp(old_labels{i_old}, 'B2'), new_labels{i_new} = 'Fp2';
0204
0205 elseif strcmp(old_labels{i_old}, 'A2'), new_labels{i_new} = 'AF7';
0206 elseif strcmp(old_labels{i_old}, 'A3'), new_labels{i_new} = 'AF3';
0207 elseif strcmp(old_labels{i_old}, 'B5'), new_labels{i_new} = 'AFz';
0208 elseif strcmp(old_labels{i_old}, 'B4'), new_labels{i_new} = 'AF4';
0209 elseif strcmp(old_labels{i_old}, 'B3'), new_labels{i_new} = 'AF8';
0210
0211 elseif strcmp(old_labels{i_old}, 'A7' ), new_labels{i_new} = 'F7';
0212 elseif strcmp(old_labels{i_old}, 'A6' ), new_labels{i_new} = 'F5';
0213 elseif strcmp(old_labels{i_old}, 'A5' ), new_labels{i_new} = 'F3';
0214 elseif strcmp(old_labels{i_old}, 'A4' ), new_labels{i_new} = 'F1';
0215 elseif strcmp(old_labels{i_old}, 'B6' ), new_labels{i_new} = 'Fz';
0216 elseif strcmp(old_labels{i_old}, 'B7' ), new_labels{i_new} = 'F2';
0217 elseif strcmp(old_labels{i_old}, 'B8' ), new_labels{i_new} = 'F4';
0218 elseif strcmp(old_labels{i_old}, 'B9' ), new_labels{i_new} = 'F6';
0219 elseif strcmp(old_labels{i_old}, 'B10' ), new_labels{i_new} = 'F8';
0220
0221 elseif strcmp(old_labels{i_old}, 'A8'), new_labels{i_new} = 'FT7';
0222 elseif strcmp(old_labels{i_old}, 'A9'), new_labels{i_new} = 'FC5';
0223 elseif strcmp(old_labels{i_old}, 'A10'), new_labels{i_new} = 'FC3';
0224 elseif strcmp(old_labels{i_old}, 'A11'), new_labels{i_new} = 'FC1';
0225 elseif strcmp(old_labels{i_old}, 'B15'), new_labels{i_new} = 'FCz';
0226 elseif strcmp(old_labels{i_old}, 'B14'), new_labels{i_new} = 'FC2';
0227 elseif strcmp(old_labels{i_old}, 'B13'), new_labels{i_new} = 'FC4';
0228 elseif strcmp(old_labels{i_old}, 'B12'), new_labels{i_new} = 'FC6';
0229 elseif strcmp(old_labels{i_old}, 'B11'), new_labels{i_new} = 'FT8';
0230
0231 elseif strcmp(old_labels{i_old}, 'A15' ), new_labels{i_new} = 'T7';
0232 elseif strcmp(old_labels{i_old}, 'A14' ), new_labels{i_new} = 'C5';
0233 elseif strcmp(old_labels{i_old}, 'A13' ), new_labels{i_new} = 'C3';
0234 elseif strcmp(old_labels{i_old}, 'A12' ), new_labels{i_new} = 'C1';
0235 elseif strcmp(old_labels{i_old}, 'B16' ), new_labels{i_new} = 'Cz';
0236 elseif strcmp(old_labels{i_old}, 'B17' ), new_labels{i_new} = 'C2';
0237 elseif strcmp(old_labels{i_old}, 'B18' ), new_labels{i_new} = 'C4';
0238 elseif strcmp(old_labels{i_old}, 'B19' ), new_labels{i_new} = 'C6';
0239 elseif strcmp(old_labels{i_old}, 'B20' ), new_labels{i_new} = 'T8';
0240
0241 elseif strcmp(old_labels{i_old}, 'A16'), new_labels{i_new} = 'TP7';
0242 elseif strcmp(old_labels{i_old}, 'A17'), new_labels{i_new} = 'CP5';
0243 elseif strcmp(old_labels{i_old}, 'A18'), new_labels{i_new} = 'CP3';
0244 elseif strcmp(old_labels{i_old}, 'A19'), new_labels{i_new} = 'CP1';
0245 elseif strcmp(old_labels{i_old}, 'A32'), new_labels{i_new} = 'CPz';
0246 elseif strcmp(old_labels{i_old}, 'B24'), new_labels{i_new} = 'CP2';
0247 elseif strcmp(old_labels{i_old}, 'B23'), new_labels{i_new} = 'CP4';
0248 elseif strcmp(old_labels{i_old}, 'B22'), new_labels{i_new} = 'CP6';
0249 elseif strcmp(old_labels{i_old}, 'B21'), new_labels{i_new} = 'TP8';
0250
0251 elseif strcmp(old_labels{i_old}, 'A24' ), new_labels{i_new} = 'P9';
0252 elseif strcmp(old_labels{i_old}, 'A23' ), new_labels{i_new} = 'P7';
0253 elseif strcmp(old_labels{i_old}, 'A22' ), new_labels{i_new} = 'P5';
0254 elseif strcmp(old_labels{i_old}, 'A21' ), new_labels{i_new} = 'P3';
0255 elseif strcmp(old_labels{i_old}, 'A20' ), new_labels{i_new} = 'P1';
0256 elseif strcmp(old_labels{i_old}, 'A31' ), new_labels{i_new} = 'Pz';
0257 elseif strcmp(old_labels{i_old}, 'B25' ), new_labels{i_new} = 'P2';
0258 elseif strcmp(old_labels{i_old}, 'B26' ), new_labels{i_new} = 'P4';
0259 elseif strcmp(old_labels{i_old}, 'B27' ), new_labels{i_new} = 'P6';
0260 elseif strcmp(old_labels{i_old}, 'B28' ), new_labels{i_new} = 'P8';
0261 elseif strcmp(old_labels{i_old}, 'B29'), new_labels{i_new} = 'P10';
0262
0263 elseif strcmp(old_labels{i_old}, 'A25'), new_labels{i_new} = 'PO7';
0264 elseif strcmp(old_labels{i_old}, 'A26'), new_labels{i_new} = 'PO3';
0265 elseif strcmp(old_labels{i_old}, 'A30'), new_labels{i_new} = 'POz';
0266 elseif strcmp(old_labels{i_old}, 'B31'), new_labels{i_new} = 'PO4';
0267 elseif strcmp(old_labels{i_old}, 'B30'), new_labels{i_new} = 'PO8';
0268
0269 elseif strcmp(old_labels{i_old}, 'A27' ), new_labels{i_new} = 'O1';
0270 elseif strcmp(old_labels{i_old}, 'A29' ), new_labels{i_new} = 'Oz';
0271 elseif strcmp(old_labels{i_old}, 'B32' ), new_labels{i_new} = 'O2';
0272
0273 elseif strcmp(old_labels{i_old}, 'A28' ), new_labels{i_new} = 'Iz';
0274 end
0275
0276 i_new = i_new + 1;
0277 end
0278 return;
0279
0280
0281
0282
0283
0284