Home > vbmeg > functions > device > acqdata > vb_posfile_replace_label.m

vb_posfile_replace_label

PURPOSE ^

replace channel labels of posfile

SYNOPSIS ^

function [result] = vb_posfile_replace_label(src_file, dst_file, rpl_type)

DESCRIPTION ^

 replace channel labels of posfile
 [usage]
   [result] = vb_posfile_replace_label(src_file, dst_file, rpl_type)
 [input]
   src_file : <required> POS-MAT file that will be converted
   dst_file : <required> POS-MAT file that will be newly made
   rpl_type : <optional> replace type
            :  [0]) EEG from Fp1 series to A1 series (Biosemi 64 ch default)
            :   1 ) EEG from A1 series to Fp1 series
 [output]
     result : ==0) success
            : ~=0) error occured
 [note]
   support only the case of 64 channel EEG default, for now
 [history]
   2010-05-07 (Sako) initial version
   2012-11-14 (Sako) added conversion A1 to Fp1

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [result] = vb_posfile_replace_label(src_file, dst_file, rpl_type)
0002 % replace channel labels of posfile
0003 % [usage]
0004 %   [result] = vb_posfile_replace_label(src_file, dst_file, rpl_type)
0005 % [input]
0006 %   src_file : <required> POS-MAT file that will be converted
0007 %   dst_file : <required> POS-MAT file that will be newly made
0008 %   rpl_type : <optional> replace type
0009 %            :  [0]) EEG from Fp1 series to A1 series (Biosemi 64 ch default)
0010 %            :   1 ) EEG from A1 series to Fp1 series
0011 % [output]
0012 %     result : ==0) success
0013 %            : ~=0) error occured
0014 % [note]
0015 %   support only the case of 64 channel EEG default, for now
0016 % [history]
0017 %   2010-05-07 (Sako) initial version
0018 %   2012-11-14 (Sako) added conversion A1 to Fp1
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 func_ = mfilename;
0024 result = 0; % success
0025 
0026 % --- CHECK ARGUMENTS --- %
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 % --- MAIN PROCEDURE --------------------------------------------------------- %
0035 %
0036 
0037 % --- a sample of fields of POS-MAT file ------------------------------ *
0038 %            mri_key: '2378239763b93c4c66ce9acde6d0ecb8'
0039 %                pos: [64x3 double]
0040 %               name: {64x1 cell}
0041 %         coord_type: 'SPM_Right_m'
0042 %     spherical_info: [1x1 struct]
0043 %         trans_info: [1x1 struct]
0044 %             header: [1x1 struct]
0045 % ------------------------------------------------------------- *
0046 pos = load(src_file);
0047 if ~isfield(pos, 'name')
0048   fprintf('(%s) cannot find name field\n', func_);
0049   result = 1; % failure
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 % overwrite labels
0067 pos.name = new_labels;
0068 vb_save_struct(dst_file, pos);
0069 return;
0070 %
0071 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0072 
0073 % --- INNER FUNCTIONS -------------------------------------------------------- %
0074 %
0075 % --- inner_check_arguments()
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 % --- end of inner_check_arguments()
0099 
0100 
0101 % --- inner_sub_fp1_to_a1()
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 % --- end of inner_sub_fp1_to_a1()
0190 
0191 
0192 % --- inner_sub_a1_to_fp1()
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 % --- end of inner_sub_a1_to_fp1()
0281 %
0282 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0283 
0284 % --- END OF FILE --- %

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