Home > functions > gui > bayes_parm_editor_dir > bayes_parm_editor_callback.m

bayes_parm_editor_callback

PURPOSE ^

callback function for bayes_parm editor gui.

SYNOPSIS ^

function bayes_parm_editor_callback(fig, hObj)

DESCRIPTION ^

 callback function for bayes_parm editor gui.
 [USAGE]
    bayes_parm_editor_callback(<fig>, <hObj>);
 [IN]
     fig : figure handle of fmri gui.
    hObj : component handle.
 [OUT]
    none

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function bayes_parm_editor_callback(fig, hObj)
0002 % callback function for bayes_parm editor gui.
0003 % [USAGE]
0004 %    bayes_parm_editor_callback(<fig>, <hObj>);
0005 % [IN]
0006 %     fig : figure handle of fmri gui.
0007 %    hObj : component handle.
0008 % [OUT]
0009 %    none
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0018     error('invalid figure is specified.');
0019 end
0020 if ~exist('hObj', 'var')
0021     error('hObj is a required parameter.');
0022 end
0023 
0024 %
0025 % --- Main Procedure
0026 %
0027 global vbmeg_inst;
0028 define = vbmeg_inst.const;
0029 
0030 % load data(@see pa_fmri_create)
0031 data = guidata(fig);
0032 H = data.H;
0033 
0034 meg_info = bayes_parm_editor(data.main_obj,'get_megfile_info');
0035 
0036 switch( hObj )
0037  case H.Rfilt_edit
0038   Rfilt = str2num(get(H.Rfilt_edit,'String'));
0039   if ~isempty(Rfilt), 
0040     if Rfilt<0, Rfilt = 0; end
0041     bayes_parm.Rfilt = Rfilt*1e-3;
0042     bayes_parm.Rfilt_global = Rfilt*1e-3;
0043     bayes_parm_editor(data.main_obj,'merge_bayes_parm',bayes_parm);
0044   end
0045   
0046  case H.reduce_edit
0047   reduce = str2num(get(H.reduce_edit,'String'));
0048   if ~isempty(reduce), 
0049     if reduce<0.001, reduce = 0.001; 
0050     elseif reduce>1, reduce = 1; end
0051     bayes_parm.reduce = reduce;
0052     bayes_parm.reduce_global = reduce;
0053     bayes_parm_editor(data.main_obj,'merge_bayes_parm',bayes_parm);
0054   end
0055   
0056  case H.duration_check_push
0057   % Display durations
0058   [start_pos, end_pos, err] = get_interval(H,meg_info);
0059   if err
0060     return;
0061   end
0062 
0063   time_window_string = [num2str(start_pos, '%-8.2f'),...
0064                       repmat(' - ', length(start_pos), 1),...
0065                       num2str(end_pos, '%-8.2f')];
0066   % set to listbox
0067   set(H.duration_listbox, 'String', time_window_string);
0068   % set listbox line
0069   set(H.duration_listbox, 'Value', 1);
0070 end
0071 
0072 function [start_pos, end_pos, err] = get_interval(H,meg_info)
0073 % This function gets small window start points and end points.
0074 % [IN]
0075 %      H : GUI component handle.
0076 % [OUT]
0077 %      start_pos : time window start positions
0078 %      end_pos   : time window end positions
0079 %      err       : return true when time window is invalid.
0080 
0081 start_pos = [];
0082 end_pos = [];
0083 err = false;
0084 
0085 sample_freq = vb_meginfo_get_sampling_frequency(meg_info);
0086 
0087 if get(H.time_shift_manual_radiobutton, 'Value')
0088   % manual Shift
0089   command = ['[' get(H.time_shift_start_pos_edit, 'String') ']']; 
0090   start_pos = eval(command);
0091   start_pos = start_pos(:);
0092   command = ['[' get(H.time_shift_end_pos_edit, 'String') ']']; 
0093   end_pos = eval(command);
0094   end_pos = end_pos(:);
0095 
0096   if length(start_pos) ~= length(end_pos)
0097     errordlg('Check Start positions and End positions.', 'Error');
0098     err = true;
0099   end
0100 else
0101   % equally Shift
0102   window_size = str2double(...
0103       get(H.time_shift_window_size_edit, 'String'));
0104   shift_length = str2double(...
0105       get(H.time_shift_shift_length_edit, 'String'));
0106   begin = str2double( ...
0107       get(H.whole_time_window_from_edit, 'String'));
0108   last  = str2double(...
0109       get(H.whole_time_window_to_edit, 'String'));
0110 
0111   st = clock;
0112   w_start_pos = begin;
0113   w_end_pos = 0;  
0114   one_time_point_sec = vb_numsamp_to_time(1, sample_freq);
0115   while( (w_end_pos <= last) && (w_start_pos < last) )
0116     loop_out = false;
0117     w_end_pos = w_start_pos + window_size - one_time_point_sec;
0118     if w_end_pos >= last
0119       w_end_pos = last;
0120       loop_out = true;
0121     end
0122 
0123     % add small window start_pos, end_pos
0124     start_pos = [start_pos; w_start_pos];
0125     end_pos = [end_pos; w_end_pos];
0126 
0127     w_start_pos = w_start_pos + shift_length;
0128     if loop_out || etime(clock, st) >= 3
0129       break;
0130     end
0131   end
0132 end

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