Home > functions > job > job_edit_act_dir > job_edit_act.m

job_edit_act

PURPOSE ^

Start up GUI for editing activity information

SYNOPSIS ^

function job_edit_act(brainfile,actfile)

DESCRIPTION ^

 Start up GUI for editing activity information

 --- Syntax
 function job_edit_act(brainfile,actfile)

 --- History
 2007-02-15 Taku Yoshioka
 2008-09-04 Taku Yoshioka
 2009-05-01 Taku Yoshioka
   'Replace' button was added. 
 2009-05-22 Taku Yoshioka
   Several buttons were added. 

 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 job_edit_act(brainfile,actfile)
0002 % Start up GUI for editing activity information
0003 %
0004 % --- Syntax
0005 % function job_edit_act(brainfile,actfile)
0006 %
0007 % --- History
0008 % 2007-02-15 Taku Yoshioka
0009 % 2008-09-04 Taku Yoshioka
0010 % 2009-05-01 Taku Yoshioka
0011 %   'Replace' button was added.
0012 % 2009-05-22 Taku Yoshioka
0013 %   Several buttons were added.
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 %
0019 % Input parameter check
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 if nargin<2, actfile = []; end
0023 if nargin<1, brainfile = []; end
0024 
0025 inst_id = create_instance;
0026 if isempty(inst_id), return; end; 
0027 
0028 %
0029 % Create GUI and update plot
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 create_GUI(inst_id,brainfile,actfile);
0033 job_edit_act_update_spatialpattern(inst_id);
0034 
0035 %%%
0036 %%% Inner functions
0037 %%%
0038 
0039 function inst_id = create_instance
0040 % Create instance of GUI
0041 %
0042 % --- Syntax
0043 % inst_id = create_instance
0044 %
0045 % --- History
0046 % 2007-02-15 Taku Yoshioka
0047 
0048 global vbmeg_inst
0049 
0050 if isfield(vbmeg_inst,'editact'),
0051   for inst_id=1:vbmeg_inst.const.EDITACT_MAX
0052     if isempty(vbmeg_inst.editact{inst_id}), return; end;
0053   end
0054   fprintf(['The number of instances of ''job_edit_act''' ...
0055        ' GUIs reaches the maximum number.\n']);
0056   inst_id = [];
0057 elseif isfield(vbmeg_inst,'const'), 
0058   vbmeg_inst.editact = cell(vbmeg_inst.const.EDITACT_MAX,1);
0059   inst_id = 1;
0060 else
0061   fprintf(['''vbmeg_inst'' was not correct. You have to invoke' ...
0062        '''vbmeg'' to create an instance of VBMEG.\n']); 
0063   inst_id = []; 
0064 end
0065 
0066 function create_GUI(inst_id,brainfile,actfile)
0067 % Create GUI
0068 %
0069 % --- Syntax
0070 % create_GUI(inst_id,brainfile,actfile)
0071 %
0072 % --- History
0073 % 2007-02-15 Taku Yoshioka
0074 % 2008-09-04 Taku Yoshioka
0075 % 2009-05-01 Taku Yoshioka
0076 
0077 global vbmeg_inst;
0078 
0079 %
0080 % Initialize parameters
0081 %
0082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0083 
0084 % Cortical surface model
0085 editact.brainfile = [];
0086 editact.V = [];
0087 editact.Vinf = []; 
0088 editact.F = [];
0089 editact.inf_C = [];
0090 editact.Vtal = [];
0091 editact.Vmni = [];
0092 editact.nextDD = [];
0093 editact.nextID = [];
0094 
0095 % Load folded and inflated cortical models
0096 %[V,F] = vb_load_cortex(brainfile);
0097 %editact.V0 = V;
0098 %editact.F0 = F;
0099 %[V,F,xx,inf_C] = vb_load_cortex(brainfile,'Inflate');
0100 %editact.V = V;
0101 %editact.F = F;
0102 %editact.inf_C = inf_C;
0103 
0104 % Load neighbour data for morphological operations
0105 %[nextDD,nextIX] = vb_load_cortex_neighbour(brainfile);
0106 %editact.nextDD = nextDD;
0107 %editact.nextIX = nextIX;
0108 
0109 % Load standard brain coordinates
0110 % load(brainfile,'Vtal');
0111 % if ~exist('Vtal','var'), Vtal = zeros(size(V)); end
0112 % editact.Vtal = Vtal;
0113 %editact.Vtal = vb_load_cortex(brainfile, 'Talairach');
0114 %editact.Vtal = editact.Vtal*1e3;
0115 
0116 % Activity map
0117 editact.actfile = [];
0118 editact.xxP = []; 
0119 
0120 % Display parameters
0121 editact.ix = [];
0122 
0123 % Selected vertex
0124 %editact.ix = 1;
0125 
0126 %
0127 % GUI open
0128 %
0129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0130 h_fig = open('job_edit_act.fig');
0131 set(h_fig,'HandleVisibility','on');
0132 drawnow; 
0133 set(h_fig,'Pointer','watch');
0134 
0135 %
0136 % Handles of GUI components
0137 %
0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0139 editact.h_fig = h_fig;
0140 editact.h_space = get_child_handle(h_fig,'axes1');
0141 editact.h_cbar = get_child_handle(h_fig,'colorbar');
0142 editact.ed2 = get_child_handle(h_fig,'radius');
0143 editact.ed4 = get_child_handle(h_fig,'tal_coord');
0144 editact.ed5 = get_child_handle(h_fig,'vertex_index');
0145 editact.ed6 = get_child_handle(h_fig,'color_scale');
0146 editact.lb1 = get_child_handle(h_fig,'activity_map_list');
0147 editact.pb1 = get_child_handle(h_fig,'rotation');
0148 editact.pb2 = get_child_handle(h_fig,'clear');
0149 editact.pb3 = get_child_handle(h_fig,'average');
0150 editact.pb4 = get_child_handle(h_fig,'maximum');
0151 editact.pb5 = get_child_handle(h_fig,'histogram');
0152 editact.pb6 = get_child_handle(h_fig,'gaussian');
0153 editact.pb7 = get_child_handle(h_fig,'step_function');
0154 editact.pb8 = get_child_handle(h_fig,'registration');
0155 editact.pb9 = get_child_handle(h_fig,'delete');
0156 editact.pb11 = get_child_handle(h_fig,'normalize');
0157 editact.pb12 = get_child_handle(h_fig,'undo');
0158 editact.pb13 = get_child_handle(h_fig,'print');
0159 editact.pb14 = get_child_handle(h_fig,'vertex');
0160 editact.pb15 = get_child_handle(h_fig,'replace');
0161 editact.pb16 = get_child_handle(h_fig,'left_button');
0162 editact.pb17 = get_child_handle(h_fig,'right_button');
0163 editact.pb18 = get_child_handle(h_fig,'top_button');
0164 editact.pb19 = get_child_handle(h_fig,'bottom_button');
0165 editact.cb1 = get_child_handle(h_fig,'left_hemi');
0166 editact.cb2 = get_child_handle(h_fig,'right_hemi');
0167 editact.rb1 = get_child_handle(h_fig,'talairach');
0168 editact.rb2 = get_child_handle(h_fig,'mni');
0169 editact.model_type_inflate_rb = get_child_handle(h_fig,'inflate');
0170 editact.model_type_fold_rb = get_child_handle(h_fig,'folded');
0171 editact.load_cortex_menu ...
0172     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0173                        'load_cortex_menu');
0174 editact.load_actmap_menu ...
0175     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0176                        'load_actmap_menu');
0177 editact.loaded_files_menu ...
0178     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0179                        'loaded_files_menu');
0180 editact.close_menu ...
0181     = get_child_handle(get_child_handle(h_fig,'file_menu'), ...
0182                        'close_menu');
0183 % Set GUI values
0184 set(editact.ed2,'String','6');
0185 set(editact.lb1,'Value',1);
0186 
0187 editact.plot_parm = vb_set_plot_parm;
0188 editact.plot_parm.index = [];
0189 editact.plot_parm.LRflag = 'LR';
0190 
0191 % Initialize GUI components
0192 set(editact.h_space,'XTick',[],'YTick',[]);
0193 set(editact.h_cbar,'XTick',[],'YTick',[]);
0194 
0195 %
0196 % Callback functions
0197 %
0198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0199 inst_str = num2str(inst_id); 
0200 editact_str = ['vbmeg_inst.editact{' inst_str '}'];
0201 
0202 % Remove instance after window close
0203 command = ['global vbmeg_inst; '...
0204        'vbmeg_inst.editact{' inst_str '}=[];'];
0205 set(h_fig,'DeleteFcn',command);
0206 
0207 % Change filter radius
0208 command = ['job_edit_act_change_radius(' inst_str ');']; 
0209 set(editact.ed2,'Callback',command);
0210 
0211 % Change vertex index
0212 command = ['job_edit_act_change_vertex(' inst_str ');']; 
0213 set(editact.ed5,'Callback',command);
0214 
0215 % Rotation of cortex model
0216 command = ['job_edit_act_push_rotate_button(' inst_str ');'];
0217 set(editact.pb1,'Callback',command);
0218 
0219 % Clear activity map
0220 command = ['job_edit_act_clear(' inst_str ');'];
0221 set(editact.pb2,'Callback',command);
0222 
0223 % Replace activity map
0224 command = ['job_edit_act_replace(' inst_str ');'];
0225 set(editact.pb15,'Callback',command);
0226 
0227 % Average activity maps
0228 command = ['job_edit_act_average(' inst_str ');'];
0229 set(editact.pb3,'Callback',command);
0230 
0231 % Maximum activity maps
0232 command = ['job_edit_act_maximum(' inst_str ');'];
0233 set(editact.pb4,'Callback',command);
0234 
0235 % Display histogram
0236 command = ['job_edit_act_plot_histogram(' inst_str ');'];
0237 set(editact.pb5,'Callback',command);
0238 
0239 % Apply Gaussian filter
0240 command = ['job_edit_act_gauss_filter(' inst_str ');'];
0241 set(editact.pb6,'Callback',command);
0242 
0243 % Apply step function filter
0244 command = ['job_edit_act_step_filter(' inst_str ');'];
0245 set(editact.pb7,'Callback',command);
0246 
0247 % Activity map registration
0248 command = ['job_edit_act_registration(' inst_str ');'];
0249 set(editact.pb8,'Callback',command);
0250 
0251 % Delete activity map
0252 command = ['job_edit_act_delete(' inst_str ');'];
0253 set(editact.pb9,'Callback',command);
0254 
0255 % Normalize
0256 command = ['job_edit_act_normalize(' inst_str ');'];
0257 set(editact.pb11,'Callback',command);
0258 
0259 % Undo
0260 command = ['job_edit_act_undo(' inst_str ');'];
0261 set(editact.pb12,'Callback',command);
0262 
0263 % Print
0264 command = ['job_edit_act_print_spatialpattern(' inst_str ');'];
0265 set(editact.pb13,'Callback',command);
0266 
0267 % Select vertex
0268 command = ['job_edit_act_select_vertex(' inst_str ');'];
0269 set(editact.pb14,'Callback',command);
0270 
0271 % Change presented hemisphere
0272 command = ['job_edit_act_change_hemi(' inst_str ');'];
0273 set(editact.cb1,'Callback',command);
0274 set(editact.cb2,'Callback',command);
0275 
0276 % Model type
0277 model_type_group = [editact.model_type_inflate_rb,
0278                     editact.model_type_fold_rb];
0279 command = ['job_edit_act_change_modeltype(' inst_str ');'];
0280 set(model_type_group, 'Callback', command);
0281 set(model_type_group, 'Value', 0); % both off
0282 set(editact.model_type_inflate_rb,'Value',1);
0283 
0284 % Load cortical surface model
0285 command = ['[brain_dir,brain_file] = vb_file_select' ...
0286            '({''.brain.mat''},''Load cortical model'');' ...
0287            'if ~isempty(brain_file), ' ...
0288        'job_edit_act_load_cortex(' inst_str ',' ...
0289            '[brain_dir filesep brain_file{1}]); end'];
0290 set(editact.load_cortex_menu, 'Callback', command);
0291 
0292 % Load activity map file
0293 command = ['[act_dir,act_file] = vb_file_select' ...
0294            '({''.act.mat''},''Load activity map file'');' ...
0295            'if ~isempty(act_file), ' ...
0296        'job_edit_act_load_actfile(' inst_str ',' ...
0297            '[act_dir filesep act_file{1}]); end'];
0298 set(editact.load_actmap_menu, 'Callback', command);
0299 %command = ['job_edit_act_select_file(' inst_str ');'];
0300 %set(editact.pb10,'Callback',command);
0301 
0302 % Show loaded files
0303 command = ['job_edit_act_show_loaded_files(' inst_str ');']; 
0304 set(editact.loaded_files_menu, 'Callback', command);
0305 
0306 % Close window
0307 command = 'close'; 
0308 set(editact.close_menu,'Callback',command);
0309 
0310 % Angle
0311 command = ['job_edit_act_change_angle(' inst_str ',''left'');'];
0312 set(editact.pb16,'Callback',command);
0313 command = ['job_edit_act_change_angle(' inst_str ',''right'');'];
0314 set(editact.pb17,'Callback',command);
0315 command = ['job_edit_act_change_angle(' inst_str ',''top'');'];
0316 set(editact.pb18,'Callback',command);
0317 command = ['job_edit_act_change_angle(' inst_str ',''bottom'');'];
0318 set(editact.pb19,'Callback',command);
0319 
0320 % Radio button check
0321 command = ['job_edit_act_change_tal(' inst_str ');'];
0322 set(editact.rb1,'Callback',command);
0323 command = ['job_edit_act_change_mni(' inst_str ');'];
0324 set(editact.rb2,'Callback',command);
0325 
0326 % Color scale
0327 command = ['job_edit_act_change_color_scale(' inst_str ');'];
0328 set(editact.ed6,'Callback',command);
0329 
0330 %
0331 % Properties of axis for cortex plot
0332 %
0333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0334 set(h_fig,'Renderer','zbuffer');
0335 
0336 %
0337 % Set instance
0338 %
0339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0340 vbmeg_inst.editact{inst_id} = editact;
0341 
0342 % Set pointer to arrow
0343 set(h_fig,'Pointer','arrow');
0344 
0345 %
0346 % Load cortical surface model
0347 %
0348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0349 if ~isempty(brainfile),
0350   job_edit_act_load_cortex(inst_id,brainfile);
0351 end
0352 
0353 %
0354 % Load estimated current
0355 %
0356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0357 if ~isempty(actfile),
0358   job_edit_act_load_actfile(inst_id,actfile);
0359 end

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