0001 function [result] = job_plot_cmap_setting_dlg_set_file(H, file, file_type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ~exist('H', 'var')
0023 error('H is a required parameter.');
0024 end
0025 if ~exist('file', 'var')
0026 error('file is a required parameter.');
0027 end
0028 if ~exist('file_type', 'var')
0029 error('file_type is a required parameter.');
0030 end
0031
0032
0033
0034
0035 result = SUCCESS;
0036
0037 ext = '';
0038 d = vb_define_extension;
0039
0040 switch(file_type)
0041 case 'brain_file'
0042 ext = d.BRAIN_EXTENSION;
0043 comp_edit = H.brain_file_edit;
0044 comp_check = H.brain_file_update_checkbox;
0045 case 'area_file'
0046 ext = d.AREA_EXTENSION;
0047 comp_edit = H.area_file_edit;
0048 comp_check = H.area_file_update_checkbox;
0049 case 'act_file'
0050 ext = d.FMRI_EXTENSION;
0051 comp_edit = H.act_file_edit;
0052 comp_check = H.act_file_update_checkbox;
0053 case 'current_file'
0054 ext = d.CURRENT_EXTENSION;
0055 comp_edit = H.current_file_edit;
0056 comp_check = H.current_file_update_checkbox;
0057 case 'tf_file'
0058 ext = '.tf.mat';
0059 comp_edit = H.tf_file_edit;
0060 comp_check = H.tf_file_update_checkbox;
0061 otherwise
0062 error('Specified file_type is unknown.');
0063 end
0064
0065
0066
0067
0068 if isempty(file)
0069 file = getappdata(comp_edit, 'prev');
0070 set(comp_edit, 'String', file);
0071 return;
0072 end
0073
0074 if exist(file, 'file') ~= 2
0075
0076 result = FAILURE;
0077 return;
0078 end
0079
0080
0081 if length(file) < length(ext)
0082 result = FAILURE;
0083 return;
0084 end
0085
0086
0087 if ~strcmpi(file(end-length(ext)+1:end), ext)
0088 result = FAILURE;
0089 return;
0090 end
0091
0092
0093 set(comp_edit, 'String', file);
0094
0095 setappdata(comp_edit, 'prev', file);
0096
0097 set(comp_check, 'Value', 1);