This function reads yokogawa data file and set extra channel information to the meg_info [usage] [meg_info] = vb_ykgwfile_load_extra_channel_info(ykgwfile, meg_info) [input] ykgwfile : <required> <<file>> yokogawa data file (.con, .raw, .avw) meg_info : <required> <<struct>> MEG information which will be updated [output] meg_info : <<struct>> updated by adding ExtraChannelInfo struct : .ExtraChannelinfo <<struct>> : .Channel_active [N_ex_ch x 1] : active or not : .Channel_name [N_ex_ch x 1] : name (label) - string : .Channel_type [N_ex_ch x 1] : kind of channel : .Channel_id [N_ex_ch x 1] : index number (1 start) [note] substitute this function for load_yokogawa_eeg_header See also vb_yokogawa_get_channel_type getYkgwHdrChannel [history] 2008-02-07 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [meg_info] = vb_ykgwfile_load_extra_channel_info(ykgwfile, meg_info) 0002 % This function reads yokogawa data file and set extra channel information 0003 % to the meg_info 0004 % 0005 % [usage] 0006 % [meg_info] = vb_ykgwfile_load_extra_channel_info(ykgwfile, meg_info) 0007 % 0008 % [input] 0009 % ykgwfile : <required> <<file>> yokogawa data file (.con, .raw, .avw) 0010 % meg_info : <required> <<struct>> MEG information which will be updated 0011 % 0012 % [output] 0013 % meg_info : <<struct>> updated by adding ExtraChannelInfo struct 0014 % : .ExtraChannelinfo <<struct>> 0015 % : .Channel_active [N_ex_ch x 1] : active or not 0016 % : .Channel_name [N_ex_ch x 1] : name (label) - string 0017 % : .Channel_type [N_ex_ch x 1] : kind of channel 0018 % : .Channel_id [N_ex_ch x 1] : index number (1 start) 0019 % 0020 % [note] 0021 % substitute this function for load_yokogawa_eeg_header 0022 % 0023 % See also 0024 % vb_yokogawa_get_channel_type 0025 % getYkgwHdrChannel 0026 % 0027 % [history] 0028 % 2008-02-07 (Sako) initial version 0029 % 0030 % Copyright (C) 2011, ATR All Rights Reserved. 0031 % License : New BSD License(see VBMEG_LICENSE.txt) 0032 0033 % --- CHECK ARGUMENTS --- % 0034 if ~exist('meg_info', 'var'), meg_info = []; end 0035 if ~exist('ykgwfile', 'var'), ykgwfile = []; end 0036 [meg_info, ExChInfo] = inner_check_arguments(ykgwfile, meg_info); 0037 0038 % --- MAIN PROCEDURE --------------------------------------------------------- % 0039 % 0040 0041 % get extra channel type 0042 % 2) EXTRA 0043 % 3) REFERENCE 0044 ex_ch_types = vb_yokogawa_get_channel_type(bitor(2,4)); 0045 % [N_extra_ch x ] 0046 0047 % load channel information from yokogawa file 0048 channel_info = getYkgwHdrChannel(ykgwfile); 0049 0050 % --- extract extra channels 0051 Channel_active = []; 0052 Channel_name = []; 0053 Channel_type = []; 0054 Channel_id = []; 0055 0056 ch_info_list = channel_info.channel; 0057 ch_type_list = [ch_info_list(:).type]; 0058 0059 ch_start = 1; 0060 0061 for i_type = 1:length(ex_ch_types) 0062 cur_type = ex_ch_types(i_type).id; 0063 cur_idx = find(ch_type_list(:) == cur_type); 0064 0065 if isempty(cur_idx) 0066 continue; 0067 end 0068 0069 % --- <<data structure>> 0070 %{ 0071 % ----- EegChannel or EcgChannel 0072 % .type 0073 % .id 0074 % .name : abbreviation name 0075 % .gain 0076 % 0077 % ----- TriggerChannel or EtcChannel 0078 % .type 0079 % .id 0080 % .name : abbreviation name 0081 %} 0082 0083 num_ch = length(cur_idx); 0084 0085 % active or not (NullChannel or not) 0086 if cur_type == 0 % NullChannel 0087 Channel_active = [Channel_active; zeros(num_ch,1)]; 0088 else 0089 Channel_active = [Channel_active; ones(num_ch,1)]; 0090 end 0091 Channel_name = [Channel_name; (cur_idx-1)]; 0092 Channel_type = [Channel_type; ch_type_list(cur_idx)']; 0093 Channel_id = [Channel_id; cur_idx]; 0094 0095 ch_end = ch_start + num_ch - 1; 0096 ch_start = ch_end + 1; 0097 end 0098 0099 % convert to string - Channel_name 0100 Nch = length(Channel_id); 0101 Channel_name_str = cell(Nch,1); 0102 for i_ch = 1:Nch 0103 Channel_name_str(i_ch) = {num2str(Channel_name(i_ch))}; 0104 end 0105 0106 ExChInfo.Channel_active = Channel_active; 0107 ExChInfo.Channel_name = Channel_name_str; 0108 ExChInfo.Channel_type = Channel_type; 0109 ExChInfo.Channel_id = Channel_id; 0110 0111 meg_info.ExtraChannelInfo = ExChInfo; 0112 return; 0113 % 0114 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0115 0116 0117 % --- INNER FUNCTIONS -------------------------------------------------------- % 0118 % 0119 % --- inner_check_arguments() 0120 % 0121 function [meg_info, ex_info] = inner_check_arguments(ykgwfile, meg_info) 0122 0123 func_ = mfilename; 0124 0125 ex_info = []; 0126 0127 if isempty(meg_info) 0128 % require no action 0129 else 0130 if isfield(meg_info, 'ExtraChannelInfo') 0131 ex_info = meg_info.ExtraChannelInfo; 0132 end 0133 end 0134 0135 if isempty(ykgwfile) 0136 error('(%s)ykgwfile is a required parameter', func_); 0137 end 0138 0139 % --- check as a file 0140 if exist(ykgwfile, 'file') ~= 2 0141 error('(%s)cannot find yokogawa file : %s', func_, ykgwfile); 0142 end 0143 return; 0144 % 0145 % --- end of inner_check_arguments() 0146 % 0147 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0148 0149 % --- END OF FILE --- %