Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_setting_dlg.m

job_plot_cmap_setting_dlg

PURPOSE ^

[USAGE]

SYNOPSIS ^

function [property_list] = job_plot_cmap_setting_dlg(properties, mode)

DESCRIPTION ^

 [USAGE]
  property_list = job_plot_cmap_setting_dlg(properties, mode);
 
 [IN]
   properties : dialog initial properties <<struct array>> [Nx1]
   properties(k).key : property name [string]
                    = 'brain_file'        : Set cortical model file.
                    = 'area_file'         : Set cortical area file.
                    = 'act_file'          : Set cortical act file.
                    = 'current_file'      : Set cortical current file.
                    = 'current_load_mode' : Set load mode.
                    = 'current_trial'     : Set trial number.
                    = 'tf_file'           : Set time frequency file.
                .value :  property value
                    when key = '*_file'            : fullpath filename. [string]
                    when key = 'current_load_mode' : 'ave' or 'raw'     [string]
                    when key = 'current_trial'     : trial number       [integer]
                .update_flag  : update checkbox status  [boolean]
                                  =  true : check.
                                  = false : uncheck.

   mode : determines required file(s) on this dialog
          <<integer>> : optional [default=1]
          set *SUMMATION* value of bits by *DECIMAL* number.
          = 1 (bit:001) : current/timefrequency file is required. 
          = 2 (bit:010) : area file is required.
          = 4 (bit:100) : act file is required.
          e.g.
          = 7 (bit:111) : (current/timefrequency + area + act)file is required.
          - You can set "OR value of bits" by decimal notation.
          * note: brain_file is always required.

 [OUT]
  property_list : dialog input values.     <<struct array>> [Mx1] 
                  The meaning of key, value, update_flags are same as input spec.
  property_list(k).key         : property name  [string]
                  .value       : property value [string]
                  .update_flag : update flag    [boolean]
                                   =  true : want to update.
                                   = false : don't want to update.

  GUI is closed by CANCEL or x button, property_list = [].

 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 [property_list] = job_plot_cmap_setting_dlg(properties, mode)
0002 % [USAGE]
0003 %  property_list = job_plot_cmap_setting_dlg(properties, mode);
0004 %
0005 % [IN]
0006 %   properties : dialog initial properties <<struct array>> [Nx1]
0007 %   properties(k).key : property name [string]
0008 %                    = 'brain_file'        : Set cortical model file.
0009 %                    = 'area_file'         : Set cortical area file.
0010 %                    = 'act_file'          : Set cortical act file.
0011 %                    = 'current_file'      : Set cortical current file.
0012 %                    = 'current_load_mode' : Set load mode.
0013 %                    = 'current_trial'     : Set trial number.
0014 %                    = 'tf_file'           : Set time frequency file.
0015 %                .value :  property value
0016 %                    when key = '*_file'            : fullpath filename. [string]
0017 %                    when key = 'current_load_mode' : 'ave' or 'raw'     [string]
0018 %                    when key = 'current_trial'     : trial number       [integer]
0019 %                .update_flag  : update checkbox status  [boolean]
0020 %                                  =  true : check.
0021 %                                  = false : uncheck.
0022 %
0023 %   mode : determines required file(s) on this dialog
0024 %          <<integer>> : optional [default=1]
0025 %          set *SUMMATION* value of bits by *DECIMAL* number.
0026 %          = 1 (bit:001) : current/timefrequency file is required.
0027 %          = 2 (bit:010) : area file is required.
0028 %          = 4 (bit:100) : act file is required.
0029 %          e.g.
0030 %          = 7 (bit:111) : (current/timefrequency + area + act)file is required.
0031 %          - You can set "OR value of bits" by decimal notation.
0032 %          * note: brain_file is always required.
0033 %
0034 % [OUT]
0035 %  property_list : dialog input values.     <<struct array>> [Mx1]
0036 %                  The meaning of key, value, update_flags are same as input spec.
0037 %  property_list(k).key         : property name  [string]
0038 %                  .value       : property value [string]
0039 %                  .update_flag : update flag    [boolean]
0040 %                                   =  true : want to update.
0041 %                                   = false : don't want to update.
0042 %
0043 %  GUI is closed by CANCEL or x button, property_list = [].
0044 %
0045 % Copyright (C) 2011, ATR All Rights Reserved.
0046 % License : New BSD License(see VBMEG_LICENSE.txt)
0047 
0048 %
0049 % --- Previous check
0050 %
0051 if ~exist('properties', 'var')
0052     error('properties is a required parameter.');
0053 end
0054 if ~exist('mode', 'var')
0055     mode = 1; % current/timefrequency display mode.
0056 end
0057 
0058 %
0059 % --- Main Procedure
0060 %
0061 fig = openfig(mfilename);
0062 H = guihandles(fig);
0063 property_list = [];
0064 
0065 
0066 % set default to current-file
0067 job_plot_cmap_setting_dlg_callback(H,...
0068                                    H.data_file_current_radiobutton);
0069 
0070 % set description text
0071 desc = vb_define_description_table;
0072 setappdata(H.brain_file_text, 'description', ...
0073            vb_table_query_value(desc, 'brain_file'));
0074 setappdata(H.area_file_text, 'description', ...
0075            vb_table_query_value(desc, 'area_file'));
0076 setappdata(H.act_file_text, 'description', ...
0077            vb_table_query_value(desc, 'act_file'));
0078 setappdata(H.current_file_text, 'description', ...
0079            vb_table_query_value(desc, 'current_file'));
0080 setappdata(H.load_mode_text, 'description', ...
0081            vb_table_query_value(desc, 'current_load_mode'));
0082 setappdata(H.tf_file_text, 'description', ...
0083            vb_table_query_value(desc, 'tf_file'));
0084 
0085 % Check file read status of callee application
0086 file_on_app = 0;     % file read status on application which calls this dialog.
0087                      % set value by bitset.(bit number)
0088                      %  bit1:brain_file
0089                      %  bit2:area_file
0090                      %  bit3:act_file
0091                      %  bit4:current_file
0092                      %  bit5:time frequency file
0093 
0094 %
0095 % --- set given properties to GUI
0096 %
0097 keys = vb_table_get_keys(properties);
0098 for k=1:length(keys)
0099     prop = keys{k};
0100     val  = vb_table_query_value(properties, keys{k});
0101     flag = vb_table_query_update_flag(properties, keys{k});
0102 
0103     switch(prop)
0104         case 'brain_file'
0105             str = get(H.brain_file_text, 'String');
0106             set(H.brain_file_text, 'String', ['*', str]);
0107             job_plot_cmap_setting_dlg_set_file(H, val, 'brain_file');
0108             set(H.brain_file_update_checkbox, 'Value', flag);
0109             if exist(val, 'file') == 2 && flag == 0
0110                 file_on_app = bitset(file_on_app, 1);
0111             end
0112         case 'area_file'
0113             if bitget(mode, 2)
0114                 str = get(H.area_file_text, 'String');
0115                 set(H.area_file_text, 'String', ['*', str]);
0116             end
0117             job_plot_cmap_setting_dlg_set_file(H, val, 'area_file');
0118             set(H.area_file_update_checkbox, 'Value', flag);
0119             if exist(val, 'file') == 2 && flag == 0
0120                 file_on_app = bitset(file_on_app, 2);
0121             end
0122         case 'act_file'
0123             if bitget(mode, 3)
0124                 str = get(H.act_file_text, 'String');
0125                 set(H.act_file_text, 'String', ['*', str]);
0126             end
0127             job_plot_cmap_setting_dlg_set_file(H, val, 'act_file');
0128             set(H.act_file_update_checkbox, 'Value', flag);
0129             if exist(val, 'file') == 2 && flag == 0
0130                 file_on_app = bitset(file_on_app, 3);
0131             end
0132         case 'current_file'
0133             if bitget(mode, 1)
0134                 str = get(H.current_file_text, 'String');
0135                 set(H.current_file_text, 'String', ['*', str]);
0136             end
0137             job_plot_cmap_setting_dlg_callback(H,...
0138                                     H.data_file_current_radiobutton);
0139             set(H.current_file_edit, 'String', val);
0140 
0141             % Current mode( 'ave' or 'raw' )
0142             cur_mode  = vb_table_query_value(properties, 'current_load_mode');
0143             if isempty(cur_mode)
0144                 cur_mode = 'ave';
0145             end
0146             % Current trial number
0147             cur_trial = vb_table_query_value(properties, 'current_trial');
0148             if isempty(cur_trial)
0149                 cur_trial = 1;
0150             end
0151             job_plot_cmap_setting_dlg_set_current_file(H, val, cur_mode, cur_trial);
0152 
0153             % Upate state
0154             set(H.current_file_update_checkbox, 'Value', flag);
0155             
0156             if exist(val, 'file') == 2 && flag == 0
0157                 file_on_app = bitset(file_on_app, 4);
0158             end
0159         case 'current_load_mode'
0160             % This fields are used at current_file.
0161         case 'current_trial'
0162             % This fields are used at current_file.
0163         case 'tf_file'
0164             if bitget(mode, 1)
0165                 str = get(H.tf_file_text, 'String');
0166                 set(H.tf_file_text, 'String', ['*', str]);
0167             end
0168             if ~isempty(val)
0169                 job_plot_cmap_setting_dlg_callback(H,...
0170                                     H.data_file_tf_radiobutton);
0171             end
0172             job_plot_cmap_setting_dlg_set_file(H, val, 'tf_file');
0173             set(H.tf_file_update_checkbox, 'Value', flag);
0174 
0175             if exist(val, 'file') == 2 && flag == 0
0176                 file_on_app = bitset(file_on_app, 5);
0177             end
0178         otherwise
0179             delete(fig);
0180             error('unknown property : %s', prop);
0181     end
0182 end
0183 
0184 % Private data for this dialog.
0185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0186 private_data = struct;
0187 private_data.mode        = mode;
0188 private_data.file_on_app = file_on_app;
0189 private_data.input_properties = properties;
0190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0191 guidata(fig, private_data);
0192 ret = job_plot_cmap_setting_dlg_is_requirement_filled(fig);
0193 if ret
0194     set(H.ok_push, 'Enable', 'on');
0195 else
0196     set(H.ok_push, 'Enable', 'off');
0197 end
0198 
0199 %
0200 % --- Wait for user input
0201 %
0202 set(fig, 'WindowStyle', 'modal');
0203 waitfor(fig, 'Visible', 'off');
0204 
0205 if ~ishandle(fig)
0206     % GUI is closed by cancel/close push
0207     % disp('cancel/close push');
0208     return;
0209 end
0210 
0211 %
0212 % --- Create return value
0213 %
0214 if ishandle(fig)
0215     props = {'brain_file', 'area_file', 'act_file', 'current_file', 'tf_file'};
0216     % get value from figure
0217     for k=1:length(props)
0218         % get(H.brain_file_edit, 'String')
0219         cmd_get_file        = ['get(H.' props{k}, '_edit, ''String'');'];
0220         % get(H.brain_file_update_checkbox, 'Value')
0221         cmd_get_update      = ['get(H.', props{k}, '_update_checkbox, ''Value'');'];
0222 
0223         key         = props{k};
0224         value       = eval(cmd_get_file);
0225         update_flag = eval(cmd_get_update);
0226         
0227         record = vb_key_value_pair(key, value);
0228         record.update_flag = update_flag;
0229         
0230         property_list = vb_table_insert(property_list, record);
0231     end
0232     if get(H.data_file_current_radiobutton, 'Value')
0233         % 'current file', tf_file is removed.
0234         property_list = vb_table_delete(property_list, 'tf_file');
0235         % 'current_load_mode'
0236         if(get(H.current_file_mode_average_radiobutton, 'Value'))
0237             load_mode = 'ave';
0238         else
0239             load_mode = 'raw';
0240         end
0241         key   = 'current_load_mode';
0242         value = load_mode;
0243         update_flag = false;
0244 
0245         record = vb_key_value_pair(key, value);
0246         record.update_flag = update_flag;
0247         property_list = vb_table_insert(property_list, record);
0248         % 'current_trial'
0249         key = 'current_trial';
0250         value = 1;
0251         update_flag = false;
0252         if strcmp(load_mode, 'raw')
0253             value = str2double(...
0254                 get(H.current_file_mode_raw_edit, 'String'));
0255         end
0256         record = vb_key_value_pair(key, value);
0257         record.update_flag = update_flag;
0258         property_list = vb_table_insert(property_list, record);
0259     else
0260         % 'tf_file', current_file is removed.
0261         property_list = vb_table_delete(property_list, 'current_file');
0262     end
0263     delete(fig);
0264 end

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