0001 function job_plot_meg_load_meg(inst_id,megfile,mode,twin_lim,twin_ini)
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 global vbmeg_inst;
0033 define_job_plot_meg_const;
0034
0035
0036
0037
0038
0039 if nargin<5, twin_ini = []; end
0040 if nargin<4, twin_lim = []; end
0041 if nargin<3, mode = 2; end
0042
0043
0044
0045
0046
0047 if ~exist(megfile,'file'),
0048 warndlg(['File ' megfile ' does not exist.']);
0049 return;
0050 end
0051
0052 if mode == 2,
0053 MEGinfo = vb_load_meg_info(megfile);
0054 if MEGinfo.Nrepeat>1,
0055 button = questdlg(['Which of average or raw MEG/EEG data ' ...
0056 'do you want to load?'],'Load MEG/EEG data', ...
0057 'Average','Raw','Average');
0058 if strcmp(button,'Average'),
0059 mode = 0;
0060 else
0061 mode = 1;
0062 end
0063 else
0064 mode = 0;
0065 end
0066 end
0067
0068
0069
0070
0071
0072 set(vbmeg_inst.plotmeg{inst_id}.h_fig,'Pointer','watch');
0073 drawnow;
0074
0075
0076 pick = vb_load_sensor(megfile);
0077 measurement_str = vb_load_device(megfile);
0078 Measurement_str = upper(measurement_str);
0079
0080
0081 if strcmp(Measurement_str,'MEG'),
0082 pick = pick(1:size(pick,1)/2,:,:);
0083 end
0084 bexp = vb_load_meg_data(megfile);
0085 MEGinfo = vb_load_meg_info(megfile);
0086
0087
0088 ch_info = vb_load_channel_info(megfile);
0089 MEGinfo.ChannelInfo = ch_info;
0090
0091 if mode==0, bexp = mean(bexp,3); end
0092 pretrigger = vb_meginfo_get_pre_trigger(MEGinfo);
0093 if isempty(pretrigger), pretrigger = 0; end
0094 N = size(bexp,1);
0095 T = ((1:MEGinfo.Nsample)-pretrigger-1)*(1000/MEGinfo.SampleFreq);
0096 if isempty(twin_lim), twin_lim = [1, MEGinfo.Nsample]; end
0097 if isempty(twin_ini), twin_ini = [1, 1]; end
0098
0099 vbmeg_inst.plotmeg{inst_id}.megfile = megfile;
0100
0101 switch Measurement_str
0102 case 'MEG',
0103 vbmeg_inst.plotmeg{inst_id}.bexp = bexp*1e15;
0104 vbmeg_inst.plotmeg{inst_id}.ylabel_str = 'MEG signal [fT]';
0105 case 'EEG',
0106 vbmeg_inst.plotmeg{inst_id}.bexp = bexp*1e6;
0107 vbmeg_inst.plotmeg{inst_id}.ylabel_str = 'EEG signal [\mu V]';
0108 end
0109
0110 clear bexp;
0111 vbmeg_inst.plotmeg{inst_id}.pick = pick;
0112 vbmeg_inst.plotmeg{inst_id}.MEGinfo = MEGinfo;
0113 vbmeg_inst.plotmeg{inst_id}.N = N;
0114 vbmeg_inst.plotmeg{inst_id}.T = T;
0115 vbmeg_inst.plotmeg{inst_id}.twin_lim = twin_lim;
0116 vbmeg_inst.plotmeg{inst_id}.twin_ini = twin_ini;
0117
0118
0119 vbmeg_inst.plotmeg{inst_id}.n_trial = 1;
0120 vbmeg_inst.plotmeg{inst_id}.t = [T(min(twin_ini)) T(max(twin_ini))];
0121
0122
0123
0124
0125
0126 h = vbmeg_inst.plotmeg{inst_id}.sensor_type_menu;
0127 hh = get(h,'Children');
0128 for i=1:length(hh)
0129 delete(hh(i));
0130 end
0131
0132
0133
0134
0135
0136
0137
0138 sensor_type_list = [2 3 -1];
0139 sensor_type_string = {'Axial gradiometer','Planer gradiometer','All'};
0140
0141
0142 vbmeg_inst.plotmeg{inst_id}.sensor_type_list = sensor_type_list;
0143 h = vbmeg_inst.plotmeg{inst_id}.sensor_type_menu;
0144
0145 for i=1:length(sensor_type_list)
0146 command = ['job_plot_meg_change_sensor_type(' num2str(inst_id) ...
0147 ',' num2str(i) ');'];
0148 hh = uimenu(h,'Label',sensor_type_string{i},'Callback',command, ...
0149 'Tag',['submenu' num2str(i)]);
0150 vbmeg_inst.plotmeg{inst_id}.h_sensortype(i) = hh;
0151 set(hh,'Checked','off');
0152 end
0153
0154
0155 vbmeg_inst.plotmeg{inst_id}.sensor_type = -1;
0156 set(vbmeg_inst.plotmeg{inst_id}.h_sensortype(end),'Checked','on');
0157
0158
0159
0160
0161
0162 job_plot_meg_update_spatialpattern(inst_id);
0163 job_plot_meg_update_timecourse(inst_id,FORCE_UPDATE);
0164
0165 set(vbmeg_inst.plotmeg{inst_id}.h_fig,'Pointer','arrow');
0166
0167
0168
0169
0170
0171 [tmp,fname,ext] = fileparts(megfile);
0172 set(vbmeg_inst.plotmeg{inst_id}.h_fig,'Name', ...
0173 ['job_plot_meg: ' fname ext]);