Home > vbmeg > functions > job > job_edit_area_dir > job_edit_area.m

job_edit_area

PURPOSE ^

---

SYNOPSIS ^

function job_edit_area(brainfile, areafile)

DESCRIPTION ^

---
 function job_edit_area(brainfile, areafile)

 Edit area data. 

 Input parameters
 - brainfile  : Cortex model file (.brain.mat)
 - areafile   : Area file (.area.mat)

 Example
 job_edit_area('./data/10000fb.brain.mat',...
               './data/10000fb.area.mat'); 

 2006-02-24 Taku Yoshioka
---

 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_area(brainfile, areafile)
0002 %---
0003 % function job_edit_area(brainfile, areafile)
0004 %
0005 % Edit area data.
0006 %
0007 % Input parameters
0008 % - brainfile  : Cortex model file (.brain.mat)
0009 % - areafile   : Area file (.area.mat)
0010 %
0011 % Example
0012 % job_edit_area('./data/10000fb.brain.mat',...
0013 %               './data/10000fb.area.mat');
0014 %
0015 % 2006-02-24 Taku Yoshioka
0016 %---
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 inst_id = create_instance;
0022 if isempty(inst_id), return; end; 
0023 create_GUI(inst_id,areafile,brainfile);
0024 job_edit_area_update_spatialpattern(inst_id);
0025 
0026 %%%
0027 %%% Inner functions
0028 %%%
0029 
0030 %
0031 % Create instance of GUI
0032 % i: Instance ID of job_edit_area
0033 %
0034 function inst_id = create_instance
0035 
0036 global vbmeg_inst
0037 
0038 if isfield(vbmeg_inst,'editarea'),
0039   for inst_id=1:vbmeg_inst.const.EDITAREA_MAX
0040     if isempty(vbmeg_inst.editarea{inst_id}), return; end;
0041   end
0042   fprintf(['The number of instances of ''job_edit_area''' ...
0043        ' GUIs reaches the maximum number.\n']);
0044   inst_id = [];
0045 elseif isfield(vbmeg_inst,'const'), 
0046   vbmeg_inst.editarea = cell(vbmeg_inst.const.EDITAREA_MAX,1);
0047   inst_id = 1;
0048 else
0049   fprintf(['''vbmeg_inst'' was not correct. You have to invoke' ...
0050        '''vbmeg'' to create an instance of VBMEG.\n']); 
0051   inst_id = []; 
0052 end
0053 
0054 %
0055 % Create GUI
0056 %
0057 function create_GUI(inst_id,areafile,brainfile)
0058 
0059 global vbmeg_inst;
0060 
0061 % GUI open
0062 h_fig = open('job_edit_area.fig');
0063 set(h_fig,'HandleVisibility','on');
0064 drawnow; 
0065 set(h_fig,'Pointer','watch');
0066 
0067 % Load folded and inflated cortical models
0068 [V,F] = vb_load_cortex(brainfile); 
0069 editarea.V0 = V; 
0070 editarea.F0 = F;
0071 [V,F,xx,inf_C] = vb_load_cortex(brainfile,'Inflate');
0072 editarea.V = V;
0073 editarea.F = F;
0074 editarea.inf_C = inf_C;
0075 
0076 % Load neighbour data for morphological operations
0077 [nextDD,nextIX] = vb_load_cortex_neighbour(brainfile); 
0078 editarea.nextDD = nextDD;
0079 editarea.nextIX = nextIX;
0080 
0081 % Area file
0082 editarea.areafile = areafile;
0083 
0084 % Area data
0085 editarea.Iextract = cell(30,1); 
0086 
0087 % Handles of GUI components
0088 editarea.h_fig = h_fig;
0089 editarea.h_space = get_child_handle(h_fig,'plot_brain');
0090 editarea.ed1 = get_child_handle(h_fig,'dilation_radius');
0091 editarea.ed2 = get_child_handle(h_fig,'erosion_radius');
0092 editarea.ed3 = get_child_handle(h_fig,'vertex_number');
0093 editarea.ed4 = get_child_handle(h_fig,'area_file');
0094 editarea.lb1 = get_child_handle(h_fig,'area_list');
0095 editarea.pb1 = get_child_handle(h_fig,'dilation');
0096 editarea.pb2 = get_child_handle(h_fig,'erosion');
0097 editarea.pb4 = get_child_handle(h_fig,'clear');
0098 editarea.pb5 = get_child_handle(h_fig,'delete');
0099 editarea.pb6 = get_child_handle(h_fig,'overwrite');
0100 editarea.pb7 = get_child_handle(h_fig,'registration');
0101 editarea.pb8 = get_child_handle(h_fig,'undo');
0102 editarea.pb9 = get_child_handle(h_fig,'reverse');
0103 editarea.pb10 = get_child_handle(h_fig,'remove_corpus');
0104 editarea.zt  = get_child_handle(h_fig, 'zoom_toggle');
0105 editarea.operation_text = get_child_handle(h_fig, 'operation_text');
0106 
0107 % Set GUI value
0108 set(editarea.ed1,'String','6');
0109 set(editarea.ed2,'String','6');
0110 set(editarea.ed3,'String','0');
0111 set(editarea.ed4,'String',areafile);
0112 
0113 % Area list
0114 keyset = vb_get_keyset_area(areafile);
0115 set(editarea.lb1,'String',keyset); 
0116 set(editarea.lb1,'Value',1);
0117 
0118 % Cortex plot parameters
0119 editarea.plot_parm = vb_set_plot_parm;
0120 editarea.plot_parm.index = [];
0121 editarea.plot_parm.LRflag = 'LR';
0122 
0123 %
0124 % Set callback functions
0125 %
0126 inst_str = num2str(inst_id); 
0127 editarea_str = ['vbmeg_inst.editarea{' inst_str '}'];
0128 
0129 % Change filter radius
0130 command = ['job_edit_area_change_radius(' inst_str ');']; 
0131 set(editarea.ed1,'Callback',command);
0132 set(editarea.ed2,'Callback',command);
0133 
0134 % Dilation
0135 command = ['job_edit_area_dilation(' inst_str ');'];
0136 set(editarea.pb1,'Callback',command);
0137 
0138 % Erosion
0139 command = ['job_edit_area_erosion(' inst_str ');'];
0140 set(editarea.pb2,'Callback',command);
0141 
0142 % Clear current area
0143 command = ['job_edit_area_clear(' inst_str ');'];
0144 set(editarea.pb4,'Callback',command);
0145 
0146 % Delete area
0147 command = ['job_edit_area_delete(' inst_str ');'];
0148 set(editarea.pb5,'Callback',command);
0149 
0150 % Overwrite area
0151 command = ['job_edit_area_overwrite(' inst_str ');'];
0152 set(editarea.pb6,'Callback',command);
0153 
0154 % Area registration
0155 command = ['job_edit_area_registration(' inst_str ');'];
0156 set(editarea.pb7,'Callback',command);
0157 
0158 % Undo
0159 command = ['job_edit_area_undo(' inst_str ');'];
0160 set(editarea.pb8,'Callback',command);
0161 
0162 % Reverse
0163 command = ['job_edit_area_reverse(' inst_str ');'];
0164 set(editarea.pb9,'Callback',command);
0165 
0166 % Remove corpus
0167 command = ['job_edit_area_remove_corpus(' inst_str ');'];
0168 set(editarea.pb10,'Callback',command);
0169 
0170 % Close window
0171 command = ['global vbmeg_inst; '...
0172        'vbmeg_inst.editarea{' inst_str '}=[];'];
0173 set(h_fig,'DeleteFcn',command);
0174 
0175 % Zoom on/off button
0176 command = ['job_edit_area_change_zoom(' inst_str ');'];
0177 set(editarea.zt, 'Callback', command);
0178 if vb_matlab_version('<=', '7.5.0')
0179     set(editarea.zt, 'Visible', 'on');
0180 else
0181     str       = get(editarea.operation_text, 'String');
0182     zoom_help = '   Zoom: mouse wheel';
0183     set(editarea.operation_text, 'String', [str, zoom_help]);
0184     set(editarea.zt, 'Visible', 'off');
0185 end
0186 
0187 %
0188 % Properties of axis for cortex plot
0189 set(h_fig,'Renderer','zbuffer');
0190 set(h_fig,'CurrentAxes',editarea.h_space);
0191 axis off;
0192 %axis tight; % 2006/11/24 hayashi delete
0193 %axis equal; % These commands causes axes LimMode change(auto-->manual)
0194              % after MATLAB 7.0.1. and brain model is not displayed.
0195 
0196 % Set instance
0197 vbmeg_inst.editarea{inst_id} = editarea; 
0198 
0199 % Set pointer to arrow
0200 set(h_fig,'Pointer','arrow');
0201 
0202 % not to show colorbar warning
0203 warning('off', 'MATLAB:colorbar:DeprecatedV6Argument');

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005