0001 function bayes_parm_editor_callback(fig, hObj)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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
0026
0027 global vbmeg_inst;
0028 define = vbmeg_inst.const;
0029
0030
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
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
0067 set(H.duration_listbox, 'String', time_window_string);
0068
0069 set(H.duration_listbox, 'Value', 1);
0070 end
0071
0072 function [start_pos, end_pos, err] = get_interval(H,meg_info)
0073
0074
0075
0076
0077
0078
0079
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
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
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
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