Home > functions > job > job_plot_meg_dir > job_plot_meg_load_meg.m

job_plot_meg_load_meg

PURPOSE ^

Load MEG data (callback function of job_plot_meg).

SYNOPSIS ^

function job_plot_meg_load_meg(inst_id,megfile,mode,twin_lim,twin_ini)

DESCRIPTION ^

 Load MEG data (callback function of job_plot_meg).

 [syntax]
 job_plot_meg_load_meg(inst_id,megfile,mode,twin_lim,twin_ini)
 [input]
 - inst_id       : instance id of gui.
 - megfile       : MEG data file (.meg.mat)
 - mode          : = 0 % loading average data
                   = 1 % loading all trials
                   = 2 % intaraction mode(default)
 - twin_lim      : Time window selection limit(meg data index)
                   e.g. twin_lim = [300, 500];
 - twin_ini      : Initial Time window selection(meg data index)
                   (default:[Pretrigger, Pretrigger] from 0msec to 0msec)
                   e.g. twin_ini = [300, 500];

 [history]
 2008-09-02 Taku Yoshioka
 2008-10-24 Taku Yoshioka
   Support EEG data
 2011-02-10 taku-y
  [debug] Channelinfo correctly loaded.
 2011-06-01 (Sako) converted return values of vb_load_device to upper case
 2012-06-12 taku-y
  [minor] Not invoke confirmation dialog for trial averaging when
  MEG-MAT file contains single trial. 

 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:

SOURCE CODE ^

0001 function job_plot_meg_load_meg(inst_id,megfile,mode,twin_lim,twin_ini)
0002 % Load MEG data (callback function of job_plot_meg).
0003 %
0004 % [syntax]
0005 % job_plot_meg_load_meg(inst_id,megfile,mode,twin_lim,twin_ini)
0006 % [input]
0007 % - inst_id       : instance id of gui.
0008 % - megfile       : MEG data file (.meg.mat)
0009 % - mode          : = 0 % loading average data
0010 %                   = 1 % loading all trials
0011 %                   = 2 % intaraction mode(default)
0012 % - twin_lim      : Time window selection limit(meg data index)
0013 %                   e.g. twin_lim = [300, 500];
0014 % - twin_ini      : Initial Time window selection(meg data index)
0015 %                   (default:[Pretrigger, Pretrigger] from 0msec to 0msec)
0016 %                   e.g. twin_ini = [300, 500];
0017 %
0018 % [history]
0019 % 2008-09-02 Taku Yoshioka
0020 % 2008-10-24 Taku Yoshioka
0021 %   Support EEG data
0022 % 2011-02-10 taku-y
0023 %  [debug] Channelinfo correctly loaded.
0024 % 2011-06-01 (Sako) converted return values of vb_load_device to upper case
0025 % 2012-06-12 taku-y
0026 %  [minor] Not invoke confirmation dialog for trial averaging when
0027 %  MEG-MAT file contains single trial.
0028 %
0029 % Copyright (C) 2011, ATR All Rights Reserved.
0030 % License : New BSD License(see VBMEG_LICENSE.txt)
0031 
0032 global vbmeg_inst;
0033 define_job_plot_meg_const;
0034 
0035 %
0036 % Input parameters
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 % Check file and switch average/raw data
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 % Load MEG data
0070 %
0071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0072 set(vbmeg_inst.plotmeg{inst_id}.h_fig,'Pointer','watch');
0073 drawnow;
0074 
0075 % MEG data
0076 pick = vb_load_sensor(megfile);
0077 measurement_str = vb_load_device(megfile);
0078 Measurement_str = upper(measurement_str);
0079 
0080 % if strcmp(vb_load_device(megfile),'MEG'),
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 % Channel type information
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 % Measurement_str = vb_load_device(megfile);
0101 switch Measurement_str
0102  case 'MEG', 
0103   vbmeg_inst.plotmeg{inst_id}.bexp = bexp*1e15; % T -> fT
0104   vbmeg_inst.plotmeg{inst_id}.ylabel_str = 'MEG signal [fT]';
0105  case 'EEG',
0106   vbmeg_inst.plotmeg{inst_id}.bexp = bexp*1e6; % V -> micro V
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 % Display parameters
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 % Delete old menu for sensor type
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 % Create new menu for sensor type
0134 %
0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0136 
0137 % Sensor type information for Yokogawa MEG (@ATR)
0138 sensor_type_list = [2 3 -1];
0139 sensor_type_string = {'Axial gradiometer','Planer gradiometer','All'};
0140 
0141 % Create menu
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 % Set sensor type (default: -1, all sensors)
0155 vbmeg_inst.plotmeg{inst_id}.sensor_type = -1;
0156 set(vbmeg_inst.plotmeg{inst_id}.h_sensortype(end),'Checked','on');
0157 
0158 %
0159 % Update plots
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 % Change figure title
0169 %
0170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0171 [tmp,fname,ext] = fileparts(megfile);
0172 set(vbmeg_inst.plotmeg{inst_id}.h_fig,'Name', ...
0173                   ['job_plot_meg: ' fname ext]);

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