Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_change_trial.m

job_plot_cmap_change_trial

PURPOSE ^

Callback function invoked when trial number changes.

SYNOPSIS ^

function job_plot_cmap_change_trial(inst_id)

DESCRIPTION ^

 Callback function invoked when trial number changes. 

 [syntax]
 job_plot_cmap_change_trial(inst_id);

 [input]
 inst_id: instance id of job_plot_currentmap gui.

 [history]
 ????-??-?? Taku Yoshioka
 2010-03-08 rhayashi
  Read single trial data at a one time when multiple trial current data
  is inputted
 2010-12-09 taku-y
  [minor change] If plotcmap.currfile is empty, nothing is done. 
 2012-01-26 sako
  [minor change] n_trial -> "n_trial" was replaced with "ix_trial"
 2012-02-17 taku-y
  [debug] Inward current as positive. 

 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_cmap_change_trial(inst_id)
0002 % Callback function invoked when trial number changes.
0003 %
0004 % [syntax]
0005 % job_plot_cmap_change_trial(inst_id);
0006 %
0007 % [input]
0008 % inst_id: instance id of job_plot_currentmap gui.
0009 %
0010 % [history]
0011 % ????-??-?? Taku Yoshioka
0012 % 2010-03-08 rhayashi
0013 %  Read single trial data at a one time when multiple trial current data
0014 %  is inputted
0015 % 2010-12-09 taku-y
0016 %  [minor change] If plotcmap.currfile is empty, nothing is done.
0017 % 2012-01-26 sako
0018 %  [minor change] n_trial -> "n_trial" was replaced with "ix_trial"
0019 % 2012-02-17 taku-y
0020 %  [debug] Inward current as positive.
0021 %
0022 % Copyright (C) 2011, ATR All Rights Reserved.
0023 % License : New BSD License(see VBMEG_LICENSE.txt)
0024 
0025 global vbmeg_inst; 
0026 
0027 object = vbmeg_inst.plotcmap{inst_id};
0028 max_trial = 0;
0029 
0030 if isempty(object.curr_file), 
0031   return;
0032 end
0033 
0034 h_fig = vbmeg_inst.plotcmap{inst_id}.h_fig;
0035 if exist(object.curr_file, 'file') == 2
0036     set(h_fig,'Pointer','watch');
0037     drawnow;
0038     Jinfo = vb_load_current_info(object.curr_file);
0039     if isfield(Jinfo, 'Ntrial')
0040         max_trial = Jinfo.Ntrial;
0041     elseif ~isempty(object.Jact)
0042         max_trial = size(object.Jact, 3);
0043     end
0044 else
0045     return;
0046 end
0047 
0048 % get trial index from GUI
0049 ix_trial = str2num(get(vbmeg_inst.plotcmap{inst_id}.ed1, 'String'));
0050 %if isempty(ix_trial)
0051   %vb_disp(['Trial index must be an integer value. Forced ix_trial to ' ...
0052   %         'be 1 (in job_plot_cmap_load_data.m). '], 'WARNING');
0053   %ix_trial = 1;
0054 %end
0055 ix_trial = ceil(ix_trial);
0056 
0057 % check trial index valid
0058 if isempty(ix_trial) | ix_trial > max_trial | ix_trial<1, 
0059   errordlg('Trial index is invalid.','Warning','modal');
0060   ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0061   set(vbmeg_inst.plotcmap{inst_id}.ed1,'String', num2str(ix_trial));
0062   set(h_fig,'Pointer', 'arrow');
0063   return;
0064 end
0065 
0066 % update trial index on GUI
0067 set(vbmeg_inst.plotcmap{inst_id}.ed1, 'String', num2str(ix_trial));
0068 ave_mode = vbmeg_inst.plotcmap{inst_id}.ave_mode;
0069 
0070 % update trial index in global variable
0071 vbmeg_inst.plotcmap{inst_id}.ix_trial = ix_trial;
0072 
0073 if size(vbmeg_inst.plotcmap{inst_id}.Jact, 3) > 1
0074   ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0075   vbmeg_inst.plotcmap{inst_id}.Jmax = ...
0076     max(max(abs(vbmeg_inst.plotcmap{inst_id}.Jact(:,:,ix_trial))));
0077 else
0078   [Jinfo, Jact] = vb_load_current(object.curr_file, 0, ave_mode, ix_trial);
0079   vbmeg_inst.plotcmap{inst_id}.Jact ...
0080       = -1*Jact; % inward current as positive
0081   vbmeg_inst.plotcmap{inst_id}.ix_trial = ix_trial;
0082   
0083   % physical unit of current
0084   if vbmeg_inst.plotcmap{inst_id}.patch_norm, % [pAm/mm^2]
0085     vbmeg_inst.plotcmap{inst_id}.Jact ...
0086         = vbmeg_inst.plotcmap{inst_id}.Jact*1e6; % (=1e12*1e-6);
0087     vbmeg_inst.plotcmap{inst_id}.Jbck ...
0088         = vbmeg_inst.plotcmap{inst_id}.Jbck*1e6; % (=1e12*1e-6);
0089   else                          % [nAm]
0090     vbmeg_inst.plotcmap{inst_id}.Jact ...
0091         = vbmeg_inst.plotcmap{inst_id}.Jact*1e9;
0092     vbmeg_inst.plotcmap{inst_id}.Jbck ...
0093         = vbmeg_inst.plotcmap{inst_id}.Jbck*1e9;
0094   end
0095 
0096   % scale of current amplitude
0097   if size(vbmeg_inst.plotcmap{inst_id}.Jact,3) > 1
0098     ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0099     Jmax = max(max(abs(vbmeg_inst.plotcmap{inst_id}.Jact(:,:,ix_trial))));
0100     Jmin = min(min(abs(vbmeg_inst.plotcmap{inst_id}.Jact(:,:,ix_trial))));
0101   else
0102     Jmax = max(max(abs(vbmeg_inst.plotcmap{inst_id}.Jact(:,:))));
0103     Jmin = min(min(abs(vbmeg_inst.plotcmap{inst_id}.Jact(:,:))));
0104   end
0105   
0106   vbmeg_inst.plotcmap{inst_id}.Jmax = Jmax;
0107   vbmeg_inst.plotcmap{inst_id}.Jmin = Jmin;
0108   vbmeg_inst.plotcmap{inst_id}.Jmax_plot = Jmax;
0109   vbmeg_inst.plotcmap{inst_id}.Jmin_plot = Jmax*0.1;
0110 end
0111 
0112 job_plot_cmap_update_timecourse(inst_id);
0113 job_plot_cmap_update_spatialpattern(inst_id);
0114 
0115 set(h_fig,'Pointer', 'arrow');
0116 return;

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