Home > 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)
 [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

 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 % [output]
0011 %     result : ==0) success
0012 %            : ~=0) error occured
0013 % [note]
0014 %   support only the case of 64 channel EEG default, for now
0015 % [history]
0016 %   2010-05-07 (Sako) initial version
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 func_ = mfilename;
0022 result = 0; % success
0023 
0024 % --- define the type of replace
0025 RPLTYPE_DEFAULT = 0;
0026 
0027 % --- CHECK ARGUMENTS --- %
0028 if ~exist('src_file', 'var'), src_file = ''; end
0029 if ~exist('dst_file', 'var'), dst_file = ''; end
0030 if ~exist('rpl_type', 'var'), rpl_type = []; end
0031 
0032 [src_file, dst_file, rpl_type] = ...
0033   inner_check_arguments(src_file, dst_file, rpl_type);
0034 
0035 % --- MAIN PROCEDURE --------------------------------------------------------- %
0036 %
0037 
0038 % --- a sample of fields of POS-MAT file ------------------------------ *
0039 %            mri_key: '2378239763b93c4c66ce9acde6d0ecb8'
0040 %                pos: [64x3 double]
0041 %               name: {64x1 cell}
0042 %         coord_type: 'SPM_Right_m'
0043 %     spherical_info: [1x1 struct]
0044 %         trans_info: [1x1 struct]
0045 %             header: [1x1 struct]
0046 % ------------------------------------------------------------- *
0047 pos = load(src_file);
0048 if ~isfield(pos, 'name')
0049   fprintf('(%s) cannot find name field\n', func_);
0050   result = 1; % failure
0051   return;
0052 end
0053 
0054 switch rpl_type
0055   case RPLTYPE_DEFAULT
0056     new_labels = inner_sub_64_fp1_to_a1(pos.name);
0057   otherwise
0058     fprintf('(%s) unknown replace type : %d\n', func_, rpl_type);
0059     result = 1;
0060     return;
0061 end
0062 
0063 % overwrite labels
0064 pos.name = new_labels;
0065 vb_save_struct(dst_file, pos);
0066 return;
0067 %
0068 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0069 
0070 % --- INNER FUNCTIONS -------------------------------------------------------- %
0071 %
0072 % --- inner_check_arguments()
0073 %
0074 function [src_file, dst_file, rpl_type] = ...
0075   inner_check_arguments(src_file, dst_file, rpl_type)
0076 func_ = mfilename;
0077 
0078 if isempty(src_file)
0079   error('(%s) src_file is a required parameter', func_);
0080 end
0081 
0082 if exist(src_file, 'file') ~= 2
0083   error('(%s) cannot find src_file : %s\n', func_, src_file);
0084 end
0085 
0086 if isempty(dst_file)
0087   error('(%s) dst_file is a required parameter', func_);
0088 end
0089 
0090 if isempty(rpl_type)
0091   rpl_type = 0;
0092 end
0093 return;
0094 %
0095 % --- end of inner_check_arguments()
0096 
0097 
0098 % --- inner_sub_fp1_to_a1()
0099 %
0100 function new_labels = inner_sub_64_fp1_to_a1(old_labels)
0101 
0102 n_old = length(old_labels);
0103 new_labels = cell(64,1);
0104 i_new = 1;
0105 
0106 for i_old = 1:n_old
0107   if strcmp(old_labels{i_old}, 'Fp1'), new_labels{i_new} = 'A1';
0108   elseif strcmp(old_labels{i_old}, 'Fpz'), new_labels{i_new} = 'B1';
0109   elseif strcmp(old_labels{i_old}, 'Fp2'), new_labels{i_new} = 'B2';
0110 
0111   elseif strcmp(old_labels{i_old}, 'AF7'), new_labels{i_new} = 'A2';
0112   elseif strcmp(old_labels{i_old}, 'AF3'), new_labels{i_new} = 'A3';
0113   elseif strcmp(old_labels{i_old}, 'AFz'), new_labels{i_new} = 'B5';
0114   elseif strcmp(old_labels{i_old}, 'AF4'), new_labels{i_new} = 'B4';
0115   elseif strcmp(old_labels{i_old}, 'AF8'), new_labels{i_new} = 'B3';
0116   
0117   elseif strcmp(old_labels{i_old}, 'F7' ), new_labels{i_new} = 'A7';
0118   elseif strcmp(old_labels{i_old}, 'F5' ), new_labels{i_new} = 'A6';
0119   elseif strcmp(old_labels{i_old}, 'F3' ), new_labels{i_new} = 'A5';
0120   elseif strcmp(old_labels{i_old}, 'F1' ), new_labels{i_new} = 'A4';
0121   elseif strcmp(old_labels{i_old}, 'Fz' ), new_labels{i_new} = 'B6';
0122   elseif strcmp(old_labels{i_old}, 'F2' ), new_labels{i_new} = 'B7';
0123   elseif strcmp(old_labels{i_old}, 'F4' ), new_labels{i_new} = 'B8';
0124   elseif strcmp(old_labels{i_old}, 'F6' ), new_labels{i_new} = 'B9';
0125   elseif strcmp(old_labels{i_old}, 'F8' ), new_labels{i_new} = 'B10';
0126   
0127   elseif strcmp(old_labels{i_old}, 'FT7'), new_labels{i_new} = 'A8';
0128   elseif strcmp(old_labels{i_old}, 'FC5'), new_labels{i_new} = 'A9';
0129   elseif strcmp(old_labels{i_old}, 'FC3'), new_labels{i_new} = 'A10';
0130   elseif strcmp(old_labels{i_old}, 'FC1'), new_labels{i_new} = 'A11';
0131   elseif strcmp(old_labels{i_old}, 'FCz'), new_labels{i_new} = 'B15';
0132   elseif strcmp(old_labels{i_old}, 'FC2'), new_labels{i_new} = 'B14';
0133   elseif strcmp(old_labels{i_old}, 'FC4'), new_labels{i_new} = 'B13';
0134   elseif strcmp(old_labels{i_old}, 'FC6'), new_labels{i_new} = 'B12';
0135   elseif strcmp(old_labels{i_old}, 'FT8'), new_labels{i_new} = 'B11';
0136   
0137   elseif strcmp(old_labels{i_old}, 'T7' ), new_labels{i_new} = 'A15';
0138   elseif strcmp(old_labels{i_old}, 'C5' ), new_labels{i_new} = 'A14';
0139   elseif strcmp(old_labels{i_old}, 'C3' ), new_labels{i_new} = 'A13';
0140   elseif strcmp(old_labels{i_old}, 'C1' ), new_labels{i_new} = 'A12';
0141   elseif strcmp(old_labels{i_old}, 'Cz' ), new_labels{i_new} = 'B16';
0142   elseif strcmp(old_labels{i_old}, 'C2' ), new_labels{i_new} = 'B17';
0143   elseif strcmp(old_labels{i_old}, 'C4' ), new_labels{i_new} = 'B18';
0144   elseif strcmp(old_labels{i_old}, 'C6' ), new_labels{i_new} = 'B19';
0145   elseif strcmp(old_labels{i_old}, 'T8' ), new_labels{i_new} = 'B20';
0146   
0147   elseif strcmp(old_labels{i_old}, 'TP7'), new_labels{i_new} = 'A16';
0148   elseif strcmp(old_labels{i_old}, 'CP5'), new_labels{i_new} = 'A17';
0149   elseif strcmp(old_labels{i_old}, 'CP3'), new_labels{i_new} = 'A18';
0150   elseif strcmp(old_labels{i_old}, 'CP1'), new_labels{i_new} = 'A19';
0151   elseif strcmp(old_labels{i_old}, 'CPz'), new_labels{i_new} = 'A32';
0152   elseif strcmp(old_labels{i_old}, 'CP2'), new_labels{i_new} = 'B24';
0153   elseif strcmp(old_labels{i_old}, 'CP4'), new_labels{i_new} = 'B23';
0154   elseif strcmp(old_labels{i_old}, 'CP6'), new_labels{i_new} = 'B22';
0155   elseif strcmp(old_labels{i_old}, 'TP8'), new_labels{i_new} = 'B21';
0156   
0157   elseif strcmp(old_labels{i_old}, 'P9' ), new_labels{i_new} = 'A24';
0158   elseif strcmp(old_labels{i_old}, 'P7' ), new_labels{i_new} = 'A23';
0159   elseif strcmp(old_labels{i_old}, 'P5' ), new_labels{i_new} = 'A22';
0160   elseif strcmp(old_labels{i_old}, 'P3' ), new_labels{i_new} = 'A21';
0161   elseif strcmp(old_labels{i_old}, 'P1' ), new_labels{i_new} = 'A20';
0162   elseif strcmp(old_labels{i_old}, 'Pz' ), new_labels{i_new} = 'A31';
0163   elseif strcmp(old_labels{i_old}, 'P2' ), new_labels{i_new} = 'B25';
0164   elseif strcmp(old_labels{i_old}, 'P4' ), new_labels{i_new} = 'B26';
0165   elseif strcmp(old_labels{i_old}, 'P6' ), new_labels{i_new} = 'B27';
0166   elseif strcmp(old_labels{i_old}, 'P8' ), new_labels{i_new} = 'B28';
0167   elseif strcmp(old_labels{i_old}, 'P10'), new_labels{i_new} = 'B29';
0168   
0169   elseif strcmp(old_labels{i_old}, 'PO7'), new_labels{i_new} = 'A25';
0170   elseif strcmp(old_labels{i_old}, 'PO3'), new_labels{i_new} = 'A26';
0171   elseif strcmp(old_labels{i_old}, 'POz'), new_labels{i_new} = 'A30';
0172   elseif strcmp(old_labels{i_old}, 'PO4'), new_labels{i_new} = 'B31';
0173   elseif strcmp(old_labels{i_old}, 'PO8'), new_labels{i_new} = 'B30';
0174 
0175   elseif strcmp(old_labels{i_old}, 'O1' ), new_labels{i_new} = 'A27';
0176   elseif strcmp(old_labels{i_old}, 'Oz' ), new_labels{i_new} = 'A29';
0177   elseif strcmp(old_labels{i_old}, 'O2' ), new_labels{i_new} = 'B32';
0178 
0179   elseif strcmp(old_labels{i_old}, 'Iz' ), new_labels{i_new} = 'A28';
0180   end
0181   
0182   i_new = i_new + 1;
0183 end
0184 return;
0185 %
0186 % --- end of inner_sub_fp1_to_a1()
0187 %
0188 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0189 
0190 % --- END OF FILE --- %

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005