return MEGinfo type data from MEG-MAT file or EEG-MAT file [usage] [meginfo] = vb_load_meg_info(megfile, info_type); [input] megfile : <required> <<file>> measurement file : meg-mat file(.meg.mat) or eeg-mat file(.eeg.mat) info_type : <optional> (bit sequence) type code you want [1] : 1) (0001) basic : .SampleFreq : .Nchannel : .Nsample : .Nrepeat : .Pretrigger : .device : .sensor_weight (MEG) : .Coord (EEG) : .Measurement : 2) (0010) for brain sphere model : .Vcenter : .Vradius : 4) (0100) channel data : .MEGch_id : .MEGch_name : .ChannelInfo : .ExtraChannelInfo : .saveman : 8) (1000) active conditions : .ActiveChannel : .ActiveTrial : .Trial : [NOTICE] : You have to set *SUMMATION* value of bits by *DECIMAL* number. : (combination example) : 3 (0011) --> basic + brain sphere model : 5 (0101) --> basic + channel data : 6 (0110) --> brain sphere model + channel data : 7 (0111) --> basic + brain sphere model + channel data : 9 (1001) --> basic + active conditions : 13 (1101) --> basic + channel_data + active conditions : 15 (1111) --> all [output] meginfo : newest format - sbi @ see make_sbi_meg_data() - yokogawa @ see make_yokogawa_data() [note] standard format: meginfo .Measurement % measurement type .device % meg device type .Nchannel % number of active gradiometers .Nsample % sampling number of measurement .Nrepeat % repeat number .Pretrigger % sampling number for pre-trigger .SampleFreq % sampling frequency .Vcenter % origin of sphere model [m] .Vradius % radius of sphere model [m] .ActiveChannel % [Nchannel x 1 boolean] list of active channel flag .ActiveTrial % [Ntrial x 1 boolean] list of active trial flag .MEGch_id .MEGch_name .MEG_ID .MRI_ID .Trial .ChannelInfo .ExtraChannelInfo .saveman measurement-dependent members are: .sensor_weight % for MEG .Coord % for EEG if given is an eeg-mat file, convert EEGinfo to MEGinfo See also vb_load_measurement_info [history] 2006-12-13 (Sako) modified for EEG 2008-03-10 (Sako) renamed fields 2008-04-15 (Sako) added Trial, Active* 2009-08-03 (Sako) added info_type and changed the set of fields 2010-01-22 (Sako) modified bug of INFOTYPE_ACTIVE 2010-09-16 (Sako) modified to inherit info_type when 'INFO' type file 2011-03-08 (Sako) added 'sensor_weight' for MEG and 'Coord' for EEG 2011-06-01 (Sako) converted return values of vb_load_device to upper case 2011-06-02 (Sako) modified according to the new data format 2012-07-13 (Sako) supported an MEG-MAT file which has 'Pretriger' field. Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [meginfo] = vb_load_meg_info(megfile, info_type) 0002 % return MEGinfo type data from MEG-MAT file or EEG-MAT file 0003 % 0004 % [usage] 0005 % [meginfo] = vb_load_meg_info(megfile, info_type); 0006 % 0007 % [input] 0008 % megfile : <required> <<file>> measurement file 0009 % : meg-mat file(.meg.mat) or eeg-mat file(.eeg.mat) 0010 % 0011 % info_type : <optional> (bit sequence) type code you want [1] 0012 % : 1) (0001) basic 0013 % : .SampleFreq 0014 % : .Nchannel 0015 % : .Nsample 0016 % : .Nrepeat 0017 % : .Pretrigger 0018 % : .device 0019 % : .sensor_weight (MEG) 0020 % : .Coord (EEG) 0021 % : .Measurement 0022 % : 2) (0010) for brain sphere model 0023 % : .Vcenter 0024 % : .Vradius 0025 % : 4) (0100) channel data 0026 % : .MEGch_id 0027 % : .MEGch_name 0028 % : .ChannelInfo 0029 % : .ExtraChannelInfo 0030 % : .saveman 0031 % : 8) (1000) active conditions 0032 % : .ActiveChannel 0033 % : .ActiveTrial 0034 % : .Trial 0035 % : [NOTICE] 0036 % : You have to set *SUMMATION* value of bits by *DECIMAL* number. 0037 % : (combination example) 0038 % : 3 (0011) --> basic + brain sphere model 0039 % : 5 (0101) --> basic + channel data 0040 % : 6 (0110) --> brain sphere model + channel data 0041 % : 7 (0111) --> basic + brain sphere model + channel data 0042 % : 9 (1001) --> basic + active conditions 0043 % : 13 (1101) --> basic + channel_data + active conditions 0044 % : 15 (1111) --> all 0045 % 0046 % [output] 0047 % meginfo : newest format - sbi @ see make_sbi_meg_data() 0048 % - yokogawa @ see make_yokogawa_data() 0049 % 0050 % [note] 0051 % standard format: 0052 % meginfo 0053 % .Measurement % measurement type 0054 % .device % meg device type 0055 % .Nchannel % number of active gradiometers 0056 % .Nsample % sampling number of measurement 0057 % .Nrepeat % repeat number 0058 % .Pretrigger % sampling number for pre-trigger 0059 % .SampleFreq % sampling frequency 0060 % .Vcenter % origin of sphere model [m] 0061 % .Vradius % radius of sphere model [m] 0062 % .ActiveChannel % [Nchannel x 1 boolean] list of active channel flag 0063 % .ActiveTrial % [Ntrial x 1 boolean] list of active trial flag 0064 % .MEGch_id 0065 % .MEGch_name 0066 % .MEG_ID 0067 % .MRI_ID 0068 % .Trial 0069 % .ChannelInfo 0070 % .ExtraChannelInfo 0071 % .saveman 0072 % 0073 % measurement-dependent members are: 0074 % .sensor_weight % for MEG 0075 % .Coord % for EEG 0076 % 0077 % if given is an eeg-mat file, convert EEGinfo to MEGinfo 0078 % 0079 % See also 0080 % vb_load_measurement_info 0081 % 0082 % [history] 0083 % 2006-12-13 (Sako) modified for EEG 0084 % 2008-03-10 (Sako) renamed fields 0085 % 2008-04-15 (Sako) added Trial, Active* 0086 % 2009-08-03 (Sako) added info_type and changed the set of fields 0087 % 2010-01-22 (Sako) modified bug of INFOTYPE_ACTIVE 0088 % 2010-09-16 (Sako) modified to inherit info_type when 'INFO' type file 0089 % 2011-03-08 (Sako) added 'sensor_weight' for MEG and 'Coord' for EEG 0090 % 2011-06-01 (Sako) converted return values of vb_load_device to upper case 0091 % 2011-06-02 (Sako) modified according to the new data format 0092 % 2012-07-13 (Sako) supported an MEG-MAT file which has 'Pretriger' field. 0093 % 0094 % Copyright (C) 2011, ATR All Rights Reserved. 0095 % License : New BSD License(see VBMEG_LICENSE.txt) 0096 0097 % --- CHECK ARGUMENTS --- % 0098 if ~exist('megfile', 'var'), megfile = ''; end 0099 if ~exist('info_type', 'var'), info_type = []; end 0100 [megfile, info_type] = inner_check_arguments(megfile, info_type); 0101 0102 % --- MAIN PROCEDURE --------------------------------------------------------- % 0103 % 0104 [measurement] = vb_load_device(megfile); 0105 Measurement = upper(measurement); 0106 0107 switch Measurement 0108 0109 case 'MEG' 0110 % this script is in original vb_load_meg_info 0111 load(megfile, 'MEGinfo'); 0112 0113 case 'EEG' 0114 MEGinfo = vb_load_measurement_info(megfile, 'meginfo'); 0115 0116 case 'INFO' 0117 load(megfile, 'fileinfo'); 0118 MEGinfo = vb_load_meg_info(fileinfo.filename{1}, info_type); 0119 0120 ActiveChannel = zeros(fileinfo.Nchannel,1); 0121 ActiveChannel(fileinfo.channel_id) = 1; 0122 MEGinfo.ActiveChannel = ActiveChannel; 0123 0124 ActiveTrial = zeros(fileinfo.Ntotal,1); 0125 ActiveTrial(fileinfo.act_trial) = 1; 0126 MEGinfo.ActiveTrial = ActiveTrial; 0127 0128 MEGinfo.Nrepeat = fileinfo.Ntotal; 0129 otherwise 0130 error('unknown Measurement : %s', Measurement); 0131 end 0132 0133 meginfo = inner_read_meg_info(MEGinfo, Measurement, info_type, megfile); 0134 return; 0135 % 0136 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0137 0138 % --- INNER FUNCTIONS -------------------------------------------------------- % 0139 % 0140 % --- inner_check_arguments() 0141 % 0142 function [megfile, info_type] = inner_check_arguments(megfile, info_type) 0143 func_ = mfilename; 0144 0145 if isempty(megfile) 0146 error('(%s) megfile is a required parameter', func_); 0147 end 0148 0149 if isempty(info_type) 0150 info_type = 1; % basic 0151 end 0152 return; 0153 % 0154 % --- end of inner_check_arguments() 0155 0156 0157 % --- inner_read_meg_info() 0158 % 0159 function [meginfo] = ... 0160 inner_read_meg_info(MEGinfo, Measurement, info_type, megfile) 0161 func_ = mfilename; 0162 0163 meginfo = []; 0164 0165 % --- constants 0166 INFOTYPE_BASIC = 1; % 0001 0167 INFOTYPE_SPHERE = 2; % 0010 0168 INFOTYPE_CHANNEL = 4; % 0100 0169 INFOTYPE_ACTIVE = 8; % 1000 0170 0171 % --- BASIC TYPE 0172 if bitand(info_type, INFOTYPE_BASIC) == INFOTYPE_BASIC 0173 % --- .SampleFreq 0174 if isfield(MEGinfo, 'SampleFreq') 0175 meginfo.SampleFreq = MEGinfo.SampleFreq; 0176 else 0177 warning('(%s) megfile(%s) does not have SampleFreq\n', func_, megfile); 0178 end 0179 0180 % --- .Nchannel 0181 if isfield(MEGinfo, 'Nchannel') 0182 meginfo.Nchannel = MEGinfo.Nchannel; 0183 else 0184 warning('(%s) megfile(%s) does not have Nchannel\n', func_, megfile); 0185 end 0186 0187 % --- .Nsample 0188 if isfield(MEGinfo, 'Nsample') 0189 meginfo.Nsample = MEGinfo.Nsample; 0190 else 0191 warning('(%s) megfile(%s) does not have Nsample\n', func_, megfile); 0192 end 0193 0194 % --- .Nrepeat 0195 if isfield(MEGinfo, 'Nrepeat') 0196 meginfo.Nrepeat = MEGinfo.Nrepeat; 0197 else 0198 warning('(%s) megfile(%s) does not have Nrepeat\n', func_, megfile); 0199 end 0200 0201 % --- .Pretrigger 0202 meginfo.Pretrigger = vb_meginfo_get_pre_trigger(MEGinfo); 0203 0204 % --- .Measurement 0205 if isfield(MEGinfo, 'Measurement') 0206 meginfo.Measurement = MEGinfo.Measurement; 0207 else 0208 % warning('(%s) megfile(%s) does not have Measurement\n', func_, megfile); 0209 end 0210 0211 % --- .device 0212 if isfield(MEGinfo, 'device') 0213 meginfo.device = MEGinfo.device; 0214 else 0215 warning('(%s) megfile(%s) does not have device\n', func_, megfile); 0216 end 0217 0218 % --- (MEG) .sensor_weight 0219 if strcmp(Measurement, 'MEG') == 1 0220 if isfield(MEGinfo, 'sensor_weight') 0221 meginfo.sensor_weight = MEGinfo.sensor_weight; 0222 else 0223 warning('(%s) megfile(%s) does not have sensor_weight\n', func_, megfile); 0224 end 0225 end 0226 0227 % --- (EEG) .Coord 0228 if strcmp(Measurement, 'EEG') == 1 0229 EEGinfo = vb_eegfile_load_eeginfo(megfile); 0230 if isfield(EEGinfo, 'Coord') 0231 meginfo.Coord = EEGinfo.Coord; 0232 else 0233 warning('(%s) megfile(%s) does not have Coord\n', func_, megfile); 0234 end 0235 end 0236 end 0237 0238 if bitand(info_type, INFOTYPE_SPHERE) == INFOTYPE_SPHERE 0239 % --- .Vcenter 0240 if isfield(MEGinfo, 'Vcenter') 0241 meginfo.Vcenter = MEGinfo.Vcenter; 0242 else 0243 warning('(%s) megfile(%s) does not have Vcenter\n', func_, megfile); 0244 end 0245 0246 % --- .Vradius 0247 if isfield(MEGinfo, 'Vradius') 0248 meginfo.Vradius = MEGinfo.Vradius; 0249 else 0250 warning('(%s) megfile(%s) does not have Vradius\n', func_, megfile); 0251 end 0252 end 0253 0254 if bitand(info_type, INFOTYPE_CHANNEL) == INFOTYPE_CHANNEL 0255 % --- .MEGch_id 0256 if isfield(MEGinfo, 'MEGch_id') 0257 meginfo.MEGch_id = MEGinfo.MEGch_id; 0258 else 0259 warning('(%s) megfile(%s) does not have MEGch_id\n', func_, megfile); 0260 end 0261 0262 % --- .MEGch_name 0263 if isfield(MEGinfo, 'MEGch_name') 0264 meginfo.MEGch_name = MEGinfo.MEGch_name; 0265 else 0266 warning('(%s) megfile(%s) does not have MEGch_name\n', func_, megfile); 0267 end 0268 0269 % --- .ChannelInfo 0270 if isfield(MEGinfo, 'ChannelInfo') 0271 meginfo.ChannelInfo = MEGinfo.ChannelInfo; 0272 else 0273 warning('(%s) megfile(%s) does not have ChannelInfo\n', func_, megfile); 0274 end 0275 0276 % --- .ExtraChannelInfo 0277 if isfield(MEGinfo, 'ExtraChannelInfo') 0278 meginfo.ExtraChannelInfo = MEGinfo.ExtraChannelInfo; 0279 else 0280 warning('(%s) megfile(%s) does not have ExtraChannelInfo\n', ... 0281 func_, megfile); 0282 end 0283 0284 % --- .saveman 0285 if isfield(MEGinfo, 'saveman') 0286 meginfo.saveman = MEGinfo.saveman; 0287 else 0288 warning('(%s) megfile(%s) does not have saveman\n', func_, megfile); 0289 end 0290 end 0291 0292 if bitand(info_type, INFOTYPE_ACTIVE) == INFOTYPE_ACTIVE 0293 % --- .ActiveChannel 0294 if isfield(MEGinfo, 'ActiveChannel') 0295 meginfo.ActiveChannel = MEGinfo.ActiveChannel; 0296 else 0297 warning('(%s) megfile(%s) does not have ActiveChannel\n', func_, megfile); 0298 end 0299 0300 % --- .ActiveTrial 0301 if isfield(MEGinfo, 'ActiveTrial') 0302 meginfo.ActiveTrial = MEGinfo.ActiveTrial; 0303 else 0304 warning('(%s) megfile(%s) does not have ActiveTrial\n', func_, megfile); 0305 end 0306 0307 % --- .Trial 0308 if isfield(MEGinfo, 'Trial') 0309 meginfo.Trial = MEGinfo.Trial; 0310 else 0311 warning('(%s) megfile(%s) does not have Trial\n', func_, megfile); 0312 end 0313 end 0314 return; 0315 % 0316 % --- enf of inner_read_meg_info() 0317 % 0318 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0319 0320 %%% END OF FILE %%%