0001 function [cond] = job_plot_cmap_setting_dlg_is_requirement_filled(fig)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 cond = false;
0019 if ~ishandle(fig) || isempty(fig)
0020 error('Specified figure is invalid.');
0021 end
0022
0023
0024
0025
0026 private_data = guidata(fig);
0027 if isempty(private_data), return, end
0028
0029 H = guihandles(fig);
0030
0031
0032 if get(H.data_file_current_radiobutton, 'Value')
0033 view_mode = 'current';
0034 elseif get(H.data_file_tf_radiobutton, 'Value')
0035 view_mode = 'tf';
0036 else
0037 error('Specified view mode is unknown.');
0038 end
0039
0040
0041 mode = private_data.mode;
0042
0043
0044 file_on_app = private_data.file_on_app;
0045
0046
0047 cond = true;
0048
0049
0050 brain_is_required = true;
0051 brain_update = get(H.brain_file_update_checkbox, 'Value');
0052 brain_already_read = bitget(file_on_app, 1);
0053 brain_file = get(H.brain_file_edit, 'String');
0054 set_error_msg_to_info_msgbox(H.info_edit, 'brain_file', OFF);
0055 if brain_is_required
0056 if brain_update && is_file_exist(brain_file)
0057
0058 elseif brain_already_read && brain_update == false
0059
0060 else
0061
0062 cond = false;
0063 set_error_msg_to_info_msgbox(H.info_edit, 'brain_file', ON, brain_file);
0064 end
0065 end
0066
0067
0068 curr_tf_mode = bitget(mode, 1);
0069 current_is_required = curr_tf_mode && strcmp(view_mode, 'current');
0070
0071 current_update = get(H.current_file_update_checkbox, 'Value');
0072 current_already_read = bitget(file_on_app, 4);
0073 current_file = get(H.current_file_edit, 'String');
0074
0075
0076 tf_is_required = curr_tf_mode && strcmp(view_mode, 'tf');
0077 tf_update = get(H.tf_file_update_checkbox, 'Value');
0078 tf_already_read = bitget(file_on_app, 5);
0079 tf_file = get(H.tf_file_edit, 'String');
0080
0081 set_error_msg_to_info_msgbox(H.info_edit, 'current_file', OFF);
0082 set_error_msg_to_info_msgbox(H.info_edit, 'tf_file', OFF);
0083 if current_is_required
0084 if current_update && is_file_exist(current_file)
0085
0086 elseif current_already_read && current_update == false
0087
0088 else
0089
0090 cond = false;
0091 set_error_msg_to_info_msgbox(H.info_edit, 'current_file', ON, current_file);
0092 end
0093 elseif tf_is_required
0094 if tf_update && is_file_exist(tf_file)
0095
0096 elseif tf_already_read && tf_update == false
0097
0098 else
0099
0100 cond = false;
0101 set_error_msg_to_info_msgbox(H.info_edit, 'tf_file', ON, tf_file);
0102 end
0103 end
0104
0105
0106 area_is_required = bitget(mode, 2);
0107 area_update = get(H.area_file_update_checkbox, 'Value');
0108 area_already_read = bitget(file_on_app, 2);
0109 area_file = get(H.area_file_edit, 'String');
0110 set_error_msg_to_info_msgbox(H.info_edit, 'area_file', OFF);
0111 if area_is_required
0112 if area_update && is_file_exist(area_file)
0113
0114 elseif area_already_read && area_update == false
0115
0116 else
0117
0118 cond = false;
0119 set_error_msg_to_info_msgbox(H.info_edit, 'area_file', ON, area_file);
0120 end
0121 elseif area_update && ~is_file_exist(area_file)
0122
0123 cond = false;
0124 set_error_msg_to_info_msgbox(H.info_edit, 'area_file', ON, area_file);
0125 end
0126
0127
0128 act_is_required = bitget(mode, 3);
0129 act_update = get(H.act_file_update_checkbox, 'Value');
0130 act_already_read = bitget(file_on_app, 3);
0131 act_file = get(H.act_file_edit, 'String');
0132 set_error_msg_to_info_msgbox(H.info_edit, 'act_file', OFF);
0133 if act_is_required
0134 if act_update && is_file_exist(act_file)
0135
0136 elseif act_already_read && act_update == false
0137
0138 else
0139
0140 cond = false;
0141 set_error_msg_to_info_msgbox(H.info_edit, 'act_file', ON, act_file);
0142 end
0143 elseif act_update && ~is_file_exist(act_file)
0144
0145 cond = false;
0146 set_error_msg_to_info_msgbox(H.info_edit, 'act_file', ON, act_file);
0147 end
0148
0149 function ret = is_file_exist(file)
0150 ret = false;
0151 if exist(file, 'file') == 2
0152 ret = true;
0153 end
0154
0155 function set_error_msg_to_info_msgbox(comp_desc, file_type, on_off, file)
0156
0157 if ~exist('on_off', 'var'), on_off = ON; end;
0158
0159 str = get(comp_desc, 'String');
0160 if isempty(str)
0161 str = cell(0);
0162 else
0163 str = cellstr(str);
0164 end
0165
0166 switch(file_type)
0167 case 'brain_file'
0168 msg = '- Cortical model file';
0169 case 'area_file'
0170 msg = '- Cortical area file';
0171 case 'act_file'
0172 msg = '- Cortical act file';
0173 case 'current_file'
0174 msg = '- Current file';
0175 case 'tf_file'
0176 msg = '- Time frequency file';
0177 otherwise
0178 error('Unknown file_type was specified.');
0179 end
0180
0181 ix = strmatch(msg, str);
0182 if on_off == ON
0183
0184 if isempty(file)
0185 reason = ' is required.';
0186 elseif exist(file, 'file') == 2
0187 reason = ' should be applied.';
0188 else
0189 reason = ' is invalid.';
0190 end
0191 if isempty(ix)
0192 str{end+1} = [msg, reason];
0193 end
0194 else
0195
0196 if ~isempty(ix)
0197
0198 str(ix) = [];
0199 end
0200 end
0201 set(comp_desc, 'String', str);