0001 function [info, info_type] = vb_load_measurement_info(acq_file, info_type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 if ~exist('acq_file', 'var'), acq_file = ''; end
0050 if ~exist('info_type', 'var'), info_type = ''; end
0051 [acq_file, info_type] = inner_check_arguments(acq_file, info_type);
0052
0053
0054
0055 func_ = mfilename;
0056 info = [];
0057
0058
0059 TYPE_EEGINFO = 'EEGINFO';
0060 TYPE_MEGINFO = 'MEGINFO';
0061
0062 [measurement] = vb_load_device(acq_file);
0063 Measurement = upper(measurement);
0064
0065 switch Measurement
0066 case 'MEG'
0067 load(acq_file, 'MEGinfo');
0068
0069 if ~isfield(MEGinfo, 'Measurement')
0070 MEGinfo.Measurement = Measurement;
0071 end
0072 info = MEGinfo;
0073
0074 switch info_type
0075 case TYPE_EEGINFO
0076
0077 warning('not be implemented yet (MEGinfo-->EEGinfo)');
0078 return;
0079 case TYPE_MEGINFO
0080
0081 return;
0082 otherwise
0083 error('(%s)unknown info_type: %s', func_, info_type);
0084 end
0085
0086 case 'EEG'
0087 load(acq_file, 'EEGinfo');
0088 if isempty(EEGinfo)
0089 error('invalid acq_file - no EEGinfo : %s', acq_file);
0090 end
0091
0092 switch info_type
0093 case TYPE_EEGINFO
0094 info = EEGinfo;
0095 return;
0096
0097 case TYPE_MEGINFO
0098 info = inner_convert_EEGinfo2MEGinfo(EEGinfo);
0099 return;
0100
0101 otherwise
0102 error('(%s)unknown info_type: %s', func_, info_type);
0103 end
0104
0105 case 'INFO'
0106 load(acq_file, 'fileinfo');
0107 info = vb_load_measurement_info(fileinfo.filename{1}, info_type);
0108
0109 otherwise
0110 error('unknown Measurement : %s - maybe invalid measurement_file: %s', ...
0111 Measurement, measurement_file);
0112 end
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 function MEGinfo = inner_convert_EEGinfo2MEGinfo(EEGinfo)
0138 if ~isfield(EEGinfo, 'Nchannel'), EEGinfo.Nchannel = []; end
0139 if ~isfield(EEGinfo, 'Nsample'), EEGinfo.Nsample = []; end
0140 if ~isfield(EEGinfo, 'Pretrigger'), EEGinfo.Pretrigger = []; end
0141 if ~isfield(EEGinfo, 'SampleFrequency'), EEGinfo.SampleFrequency = []; end
0142 if ~isfield(EEGinfo, 'Nrepeat'), EEGinfo.Nrepeat = []; end
0143 if ~isfield(EEGinfo, 'Trial'), EEGinfo.Trial = []; end
0144 if ~isfield(EEGinfo, 'Vcenter'), EEGinfo.Vcenter = []; end
0145 if ~isfield(EEGinfo, 'Vradius'), EEGinfo.Vradius = []; end
0146 if ~isfield(EEGinfo, 'ChannelName'), EEGinfo.ChannelName = []; end
0147 if ~isfield(EEGinfo, 'ChannelID'), EEGinfo.ChannelID = []; end
0148 if ~isfield(EEGinfo, 'ActiveChannel'), EEGinfo.ActiveChannel = []; end
0149 if ~isfield(EEGinfo, 'ActiveTrial'), EEGinfo.ActiveTrial = []; end
0150 if ~isfield(EEGinfo, 'Device'), EEGinfo.Device = []; end
0151 if ~isfield(EEGinfo, 'Measurement'), EEGinfo.Measurement = []; end
0152 if ~isfield(EEGinfo, 'MRI_ID'), EEGinfo.MRI_ID = []; end
0153 if ~isfield(EEGinfo, 'ChannelInfo'), EEGinfo.ChannelInfo = []; end
0154 if ~isfield(EEGinfo, 'ExtraChannelInfo'),EEGinfo.ExtraChannelInfo = []; end
0155 if ~isfield(EEGinfo, 'File'), EEGinfo.File = []; end
0156 if ~isfield(EEGinfo, 'DataType'), EEGinfo.DataType = []; end
0157
0158 MEGinfo.Nchannel = EEGinfo.Nchannel;
0159 MEGinfo.Nsample = EEGinfo.Nsample;
0160 MEGinfo.Pretrigger = EEGinfo.Pretrigger;
0161 MEGinfo.SampleFreq = EEGinfo.SampleFrequency;
0162 MEGinfo.Nrepeat = EEGinfo.Nrepeat;
0163 MEGinfo.Trial = EEGinfo.Trial;
0164 if isfield(EEGinfo, 'cond_id')
0165 MEGinfo.cond_id = EEGinfo.cond_id;
0166 end
0167 MEGinfo.Vcenter = EEGinfo.Vcenter;
0168 MEGinfo.Vradius = EEGinfo.Vradius;
0169 MEGinfo.MEGch_name = EEGinfo.ChannelName;
0170 MEGinfo.MEGch_id = EEGinfo.ChannelID;
0171 MEGinfo.ActiveChannel = EEGinfo.ActiveChannel;
0172 MEGinfo.ActiveTrial = EEGinfo.ActiveTrial;
0173 MEGinfo.device = EEGinfo.Device;
0174 MEGinfo.Measurement = EEGinfo.Measurement;
0175 MEGinfo.MRI_ID = EEGinfo.MRI_ID;
0176 MEGinfo.ChannelInfo = EEGinfo.ChannelInfo;
0177 MEGinfo.ExtraChannelInfo = EEGinfo.ExtraChannelInfo;
0178 if ~isempty(EEGinfo.File)
0179 MEGinfo.saveman.data_dir = ...
0180 [EEGinfo.File.OutputDir '/' EEGinfo.File.DataDir];
0181 else
0182 MEGinfo.saveman.data_dir = '';
0183 end
0184
0185 if ~isempty(EEGinfo.DataType)
0186 MEGinfo.saveman.precision = EEGinfo.DataType(1);
0187 else
0188 MEGinfo.saveman.precision = '';
0189 end
0190 return;
0191
0192
0193
0194
0195
0196 function [acq_file, info_type] = inner_check_arguments(acq_file, info_type)
0197 func_ = mfilename;
0198 if isempty(acq_file)
0199 error('(%s)acq_file is a required parameter', func_);
0200 end
0201
0202 if isempty(info_type)
0203 [measurement] = vb_load_device(acq_file);
0204 Measurement = upper(measurement);
0205
0206 switch Measurement
0207 case 'MEG'
0208 info_type = 'MEGINFO';
0209 case 'EEG'
0210 info_type = 'EEGINFO';
0211 case 'INFO'
0212 load(acq_file, 'fileinfo');
0213 [Measurement2] = vb_load_device(fileinfo.filename{1});
0214 switch Measurement2
0215 case 'MEG'
0216 info_type = 'MEGINFO';
0217 case 'EEG'
0218 info_type = 'EEGINFO';
0219 end
0220 otherwise
0221 error('(%s)unexpected Measurement : %s', func_, Measurement);
0222 end
0223 else
0224 info_type = upper(info_type);
0225 end
0226 return;
0227
0228
0229
0230