0001 function gui_all_params_cbk(src,eventdata)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 h=figure('name','DIVA Parameter Editor','numbertitle','off',...
0012 'units','pixels','position',[100 100 800 600],'menu','none',...
0013 'doublebuffer','on','color',[0.5 0.5 0.5]);
0014
0015
0016
0017
0018 diva_area = [0.025 0.675 0.45 0.975-0.675];
0019
0020 diva_panel=uicontrol('style','frame','units','norm',...
0021 'position',diva_area,...
0022 'backgroundcolor',[0.7 0.7 0.7]);
0023
0024
0025
0026 height = (0.8*diva_area(4))/4;
0027
0028 spacer = (0.8*diva_area(4)-2*height)/3;
0029
0030 width = (2/3)*diva_area(3)/2;
0031
0032 labels.diva_title=...
0033 uicontrol('style','text',...
0034 'parent',h,'string','DIVA',...
0035 'FontUnits','pixels','FontSize',16,...
0036 'FontWeight','bold','Units','norm','position',...
0037 [diva_area(1)+0.0075 diva_area(2)+0.85*diva_area(4) ...
0038 3*diva_area(3)/5 0.1*diva_area(4)]);
0039
0040 labels.diva_timestep=...
0041 uicontrol('style','text',...
0042 'parent',h,'string','Time Step',...
0043 'FontUnits','points','FontSize',13,...
0044 'Units','norm','Position',...
0045 [diva_area(1)+0.001 diva_area(2)+(2*spacer+1*height) width height]);
0046
0047 labels.diva_plotstep=...
0048 uicontrol('style','text',...
0049 'parent',h,'string','Plot Step',...
0050 'FontUnits','points','FontSize',13,...
0051 'Units','norm','Position',...
0052 [diva_area(1)+0.001 diva_area(2)+(1*spacer+0*height) width height]);
0053
0054 labels.diva_storagetime=...
0055 uicontrol('style','text',...
0056 'parent',h,'string',...
0057 sprintf('%s\n%s','Storage', 'Time'),...
0058 'FontUnits','points','FontSize',13,...
0059 'Units','norm','Position',...
0060 [diva_area(1)+0.001+diva_area(3)*.5 ...
0061 diva_area(2)+(2*spacer+1*height-height/2) ...
0062 width 2*height]);
0063
0064 checkbox.diva_blockmode=...
0065 uicontrol('style','checkbox',...
0066 'min',0,'max',1,...
0067 'UserData',{'DIVA','BlockMode',[0 1]},...
0068 'parent',h,'string','Block Mode',...
0069 'FontUnits','points','FontSize',13,...
0070 'units','norm','Position',...
0071 [diva_area(1)+0.001+diva_area(3)*.5 diva_area(2)+(1*spacer+0*height) ...
0072 diva_area(3)/2-0.002 height],...
0073 'BackgroundColor',[0.7 0.7 0.7]);
0074
0075 edits.diva_timestep=...
0076 uicontrol('style','edit','UserData',...
0077 {'DIVA','TimeStep',[1 5]},...
0078 'parent',h,'FontUnits','norm',...
0079 'callback',@verify,'units','norm',...
0080 'Position',...
0081 [diva_area(1)+width+0.001 ...
0082 diva_area(2)+2*spacer+1*height+0.25*height ...
0083 diva_area(3)*0.5-width-0.01 height]);
0084
0085 edits.diva_plotstep=...
0086 uicontrol('style','edit','UserData',{'DIVA','PlotStep',[1 50]},...
0087 'parent',h,'FontUnits','norm',...
0088 'callback',@verify,'units','norm',...
0089 'Position',...
0090 [diva_area(1)+width+0.001 ...
0091 diva_area(2)+1*spacer+0*height+0.25*height...
0092 diva_area(3)*0.5-width-0.01 height]);
0093
0094 edits.diva_storagetime=...
0095 uicontrol('style','edit','UserData',{'DIVA','StorageTime',[1 25]},...
0096 'parent',h,'FontUnits','norm',...
0097 'callback',@verify,'units','norm',...
0098 'Position',...
0099 [diva_area(1)+diva_area(3)*.5+width+0.001 ...
0100 diva_area(2)+2*spacer+1*height+0.25*height ...
0101 diva_area(3)*0.5-width-0.01 height]);
0102
0103
0104
0105 somato_area=[0.525 0.75 0.45 0.975-0.75];
0106
0107 somato_panel=uicontrol('style','frame','parent',h,...
0108 'units','norm','position',somato_area,...
0109 'backgroundcolor',[0.7 0.7 0.7]);
0110
0111 labels.somato_title=...
0112 uicontrol('style','text',...
0113 'parent',h,'string','Somatosensory Cortex',...
0114 'FontUnits','points','FontSize',12,...
0115 'FontWeight','bold','units','norm','position',...
0116 [somato_area(1)+0.0075 somato_area(2)+0.825*somato_area(4) ...
0117 17*somato_area(3)/19 0.15*somato_area(4)]);
0118
0119 labels.somato_eps_learn=...
0120 uicontrol('style','text',...
0121 'parent',h,...
0122 'string',sprintf('%s\n%s','Learning','Rate'),...
0123 'FontUnits','points',...
0124 'Units','norm','FontSize',13,...
0125 'Position',...
0126 [somato_area(1)+0.002 diva_area(2)+(2*spacer+1*height-height/2) ...
0127 width 2*height]);
0128
0129 edits.somato_eps_learn=...
0130 uicontrol('style','edit','parent',h,...
0131 'UserData',...
0132 {'SomatosensoryCortex','eps_learn',[0 1]},...
0133 'FontUnits','norm','callback',@verify,...
0134 'units','norm','position',...
0135 [somato_area(1)+width+0.0025 ...
0136 diva_area(2)+(2*spacer+1*height)+0.25*height ...
0137 somato_area(3)*0.5-width-0.01 height]);
0138
0139
0140
0141
0142
0143
0144 motor_ff_area=[0.025 0.175 0.45 0.45];
0145 motor_ff_panel=uicontrol('style','frame','parent',h,...
0146 'units','norm','position',motor_ff_area,...
0147 'backgroundcolor',[0.7 0.7 0.7]);
0148
0149 labels.motor_ff_title=...
0150 uicontrol('style','text','parent',h,...
0151 'string','Motor Cortex: Feedforward Command',...
0152 'fontunits','points','fontsize',13,...
0153 'fontweight','bold','units','norm','position',...
0154 [motor_ff_area(1)+0.0075 motor_ff_area(2)+0.85*motor_ff_area(4) ...
0155 motor_ff_area(3)-0.015 0.1*motor_ff_area(4)]);
0156
0157 height = (motor_ff_area(4)-.2*motor_ff_area(4))/8;
0158 spacer = (motor_ff_area(4)-.2*motor_ff_area(4)-4*height)/5;
0159 width = motor_ff_area(3)*(3/4);
0160
0161 labels.motor_ff_learn=...
0162 uicontrol('style','text','parent',h,...
0163 'string','Learning Weight',...
0164 'Fontunits','points','fontsize',13,...
0165 'units','norm','position',...
0166 [motor_ff_area(1)+0.0075 motor_ff_area(2)+4*spacer+3*height ...
0167 width-0.0075 height]);
0168
0169 labels.motor_ff_learn_a=...
0170 uicontrol('style','text','parent',h,...
0171 'string','Auditory',...
0172 'Fontunits','points','fontsize',12,...
0173 'units','norm','position',...
0174 [motor_ff_area(1)+0.0075*3 ...
0175 motor_ff_area(2)+3*spacer+2*height ...
0176 (2/3)*(0.45*motor_ff_area(3)) height]);
0177
0178 labels.motor_ff_learn_s=...
0179 uicontrol('style','text','parent',h,...
0180 'string','Somatosensory',...
0181 'Fontunits','points','fontsize',12,...
0182 'units','norm','position',...
0183 [motor_ff_area(1)+0.45*motor_ff_area(3) ...
0184 motor_ff_area(2)+3*spacer+2*height ...
0185 0.55*motor_ff_area(3)*(3/4) height]);
0186
0187 edits.motor_ff_learn=...
0188 uicontrol('style','edit','parent',h,...
0189 'userdata',{'MotorCortex','WeightLearn',[0,1]},...
0190 'fontunits','norm',...
0191 'callback',@verify,'units','norm',...
0192 'position',...
0193 [motor_ff_area(1)+0.45*motor_ff_area(3)+0.55*motor_ff_area(3)*(3/4) ...
0194 motor_ff_area(2)+(4*spacer+3*height) ...
0195 0.55*motor_ff_area(3)*(1/4)-0.005 ...
0196 1.25*height-0.005]);
0197
0198 edits.motor_ff_learn_a=...
0199 uicontrol('style','edit','parent',h,...
0200 'userdata',{'MotorCortex','WeightLearn_sound',[0,1]},...
0201 'fontunits','norm',...
0202 'callback',@verify,'units','norm',...
0203 'position',...
0204 [motor_ff_area(1)+(2/3)*(0.45*motor_ff_area(3)) ...
0205 motor_ff_area(2)+(3*spacer+2*height) ...
0206 (1/3)*(0.45*motor_ff_area(3))-0.005 ...
0207 1.25*height-0.005]);
0208
0209 edits.motor_ff_learn_s=...
0210 uicontrol('style','edit','parent',h,...
0211 'userdata',{'MotorCortex','WeightLearn_somatosensory',[0,1]},...
0212 'fontunits','norm',...
0213 'callback',@verify,'units','norm',...
0214 'position',...
0215 [motor_ff_area(1)+0.45*motor_ff_area(3)+0.55*motor_ff_area(3)*(3/4) ...
0216 motor_ff_area(2)+(3*spacer+2*height) ...
0217 0.55*motor_ff_area(3)*(1/4)-0.005 ...
0218 1.25*height-0.005]);
0219
0220
0221
0222 motor_cmd_area=[0.525 0.175 0.45 0.45];
0223 motor_cmd_panel=uicontrol('style','frame','parent',h,...
0224 'units','norm','position',motor_cmd_area,...
0225 'backgroundcolor',[0.7 0.7 0.7]);
0226 labels.motor_cmd_title=...
0227 uicontrol('style','text','parent',h,...
0228 'string','Motor Cortex: Instantaneous Motor Command',...
0229 'fontunits','points','fontsize',13,...
0230 'fontweight','bold','units','norm','position',...
0231 [motor_cmd_area(1)+0.0075 motor_cmd_area(2)+0.825*motor_cmd_area(4) ...
0232 motor_cmd_area(3)-0.015 0.15*motor_cmd_area(4)]);
0233
0234 height = (motor_cmd_area(4)-.2*motor_cmd_area(4))/8;
0235 spacer = (motor_cmd_area(4)-.2*motor_cmd_area(4)-4*height)/5;
0236 width = (9/16)*motor_cmd_area(3)*(3/4);
0237
0238 labels.motor_contrib_ff=...
0239 uicontrol('style','text',...
0240 'parent',h,'string','FeedForward',...
0241 'FontUnits','points','FontSize',13,...
0242 'Units','norm','Position',...
0243 [motor_cmd_area(1)+0.0075 motor_cmd_area(2)+(4*spacer+3*height) ...
0244 width-0.0075 height]);
0245
0246 labels.motor_contrib_fb=...
0247 uicontrol('style','text',...
0248 'parent',h,'string','FeedBack',...
0249 'FontUnits','points','FontSize',13,...
0250 'Units','norm','Position',...
0251 [motor_cmd_area(1)+0.0075 motor_cmd_area(2)+(3*spacer+2*height) ...
0252 width-0.0075 height]);
0253
0254 labels.motor_contrib_fba=...
0255 uicontrol('style','text',...
0256 'parent',h,'string','Auditory',...
0257 'FontUnits','points','FontSize',12,...
0258 'Units','norm','Position',...
0259 [motor_cmd_area(1)+0.0075*3 motor_cmd_area(2)+(2*spacer+1*height) ...
0260 width-.0075*3 height]);
0261
0262 labels.motor_contrib_fbs=...
0263 uicontrol('style','text',...
0264 'parent',h,'string','Somatosensory',...
0265 'FontUnits','points','FontSize',12,...
0266 'Units','norm','Position',...
0267 [motor_cmd_area(1)+0.0075*3 motor_cmd_area(2)+(1*spacer+0*height) ...
0268 width-0.0075*3 height]);
0269
0270 edits.motor_contrib_ff=...
0271 uicontrol('style','edit','userdata',...
0272 {'MotorCortex','WeightFeedForward',[0 1]},...
0273 'parent',h,'fontunits','norm',...
0274 'callback',@verify,'units','norm',...
0275 'Position',...
0276 [motor_cmd_area(1)+width ...
0277 motor_cmd_area(2)+(4*spacer+3*height) ...
0278 (9/16)*motor_cmd_area(3)-width 1.25*height-0.005]);
0279
0280 edits.motor_contrib_fb=...
0281 uicontrol('style','edit','userdata',...
0282 {'MotorCortex','WeightFeedBack',[0 1]},...
0283 'parent',h,'fontunits','norm',...
0284 'callback',@verify,'units','norm',...
0285 'Position',...
0286 [motor_cmd_area(1)+width ...
0287 motor_cmd_area(2)+(3*spacer+2*height) ...
0288 (9/16)*motor_cmd_area(3)-width 1.25*height-0.005]);
0289
0290 edits.motor_contrib_fba=...
0291 uicontrol('style','edit','userdata',...
0292 {'MotorCortex','WeightFeedBack_sound',[0 1]},...
0293 'parent',h,'fontunits','norm',...
0294 'callback',@verify,'units','norm',...
0295 'Position',...
0296 [motor_cmd_area(1)+width ...
0297 motor_cmd_area(2)+(2*spacer+1*height) ...
0298 (9/16)*motor_cmd_area(3)-width 1.25*height-0.005]);
0299
0300 edits.motor_contrib_fbs=...
0301 uicontrol('style','edit','userdata',...
0302 {'MotorCortex','WeightFeedBack_somatosensory',[0 1]},...
0303 'parent',h,'fontunits','norm',...
0304 'callback',@verify,'units','norm',...
0305 'Position',...
0306 [motor_cmd_area(1)+width ...
0307 motor_cmd_area(2)+(1*spacer+0*height) ...
0308 (9/16)*motor_cmd_area(3)-width 1.25*height-0.005]);
0309
0310 width = (6/16)*motor_cmd_area(3)*(2/3);
0311
0312 labels.motor_integrate=...
0313 uicontrol('style','text',...
0314 'parent',h,'string','Int. Rate',...
0315 'Fontunits','points','fontsize',13,...
0316 'units','norm','position',...
0317 [motor_cmd_area(1)+(9/16)*motor_cmd_area(3)+0.001 ...
0318 motor_cmd_area(2)+(4*spacer+3*height) ...
0319 width height]);
0320
0321 labels.motor_decay=...
0322 uicontrol('style','text',...
0323 'parent',h,'string','Decay Rate',...
0324 'Fontunits','points','fontsize',13,...
0325 'units','norm','position',...
0326 [motor_cmd_area(1)+(9/16)*motor_cmd_area(3)+0.001 ...
0327 motor_cmd_area(2)+(3*spacer+2*height) ...
0328 width height]);
0329
0330 edits.motor_integrate=...
0331 uicontrol('style','edit','userdata',...
0332 {'MotorCortex','eps_motor',[0 1]},...
0333 'parent',h,'fontunits','norm',...
0334 'callback',@verify,'units','norm',...
0335 'position',...
0336 [motor_cmd_area(1)+(9/16)*motor_cmd_area(3)+width+0.005 ...
0337 motor_cmd_area(2)+(4*spacer+3*height) ...
0338 (6/16)*motor_cmd_area(3)*(1/3) ...
0339 1.25*height-0.005]);
0340
0341 edits.motor_decay=...
0342 uicontrol('style','edit','userdata',...
0343 {'MotorCortex','eps_decay',[0 1]},...
0344 'parent',h,'fontunits','norm',...
0345 'callback',@verify,'units','norm',...
0346 'position',...
0347 [motor_cmd_area(1)+(9/16)*motor_cmd_area(3)+width+0.005 ...
0348 motor_cmd_area(2)+(3*spacer+2*height) ...
0349 (6/16)*motor_cmd_area(3)*(1/3) ...
0350 1.25*height-0.005]);
0351
0352
0353
0354 btn.ok=uicontrol('parent',h,'style','pushbutton','units','norm',...
0355 'position',[.8 .1 .05 .05],'FontUnits','norm',...
0356 'FontSize',.45,'String','OK',...
0357 'callback',{@ok_cbk,edits,checkbox});
0358 btn.cancel=uicontrol('parent',h,'style','pushbutton','units','norm',...
0359 'position',[.85 .1 .1 .05],'FontUnits','norm',...
0360 'FontSize',.45,'String','Cancel',...
0361 'callback',@cancel_cbk);
0362
0363
0364
0365 set(h,'resize','off');
0366
0367 fnames=fieldnames(labels);
0368 for i=1:length(fnames)
0369 set(labels.(fnames{i}),'BackgroundColor',[0.7 0.7 0.7],...
0370 'HorizontalAlignment','left');
0371 end
0372
0373
0374
0375 fnames=fieldnames(edits);
0376 for i=1:length(fnames)
0377 set(edits.(fnames{i}),'FontSize',0.4,'callback',@verify);
0378 out=get(edits.(fnames{i}),'UserData');
0379 if(~isempty(out) && length(out)>=2),
0380 setParamsGUI(edits.(fnames{i}),out);
0381 end
0382 end
0383
0384 fnames=fieldnames(checkbox);
0385 for i=1:length(fnames)
0386 set(checkbox.(fnames{i}),'callback',@verify);
0387 out=get(checkbox.(fnames{i}),'UserData');
0388 if(~isempty(out) && length(out)>=2),
0389 setParamsGUI(checkbox.(fnames{i}),out);
0390 end
0391 end
0392
0393
0394
0395 function verify(src,eventdata)
0396
0397
0398
0399 if(~isempty(get(src,'UserData')))
0400 out=get(src,'UserData');
0401 if(length(out)==3)
0402 range=out{3};
0403 if(strcmp(get(src,'style'),'checkbox')),
0404 else
0405 if(strcmp(out{2},'PlotStep') || strcmp(out{2},'StorageTime') || ...
0406 strcmp(out{2},'ntimepoints') || strcmp(out{2},'TimeStep'))
0407
0408 if((mod(str2double(get(src,'string')),10)<1 && ...
0409 mod(str2double(get(src,'string')),10)>0) ||...
0410 str2double(get(src,'string'))==0)
0411 errordlg(sprintf('Entered value must be integer'),'Warning...');
0412 setParamsGUI(src,out);
0413 return;
0414 end
0415 end
0416
0417 if(any(mod(range*100,100)<1 & mod(range*100,100)>0))
0418 rangestr=sprintf('[%1.3f %1.3f]',range(1),range(2));
0419 elseif(any(mod(range*10,10)<1 & mod(range*10,10)>0))
0420 rangestr=sprintf('[%1.2f %1.2f]',range(1),range(2));
0421 elseif(any(mod(range,1)<1 & mod(range,1)>0))
0422 rangestr=sprintf('[%1.1f %1.1f]',range(1),range(2));
0423 elseif(all(mod(range,1)==0))
0424 rangestr=sprintf('[%d %d]',range(1),range(2));
0425 end
0426 if(str2double(get(src,'string'))>range(2) || str2double(get(src,'string'))<range(1))
0427 errordlg(sprintf('Entered value must be in range %s',rangestr),...
0428 'Warning...','modal');
0429 setParamsGUI(src,out);
0430 end
0431 end
0432 end
0433 end
0434
0435
0436 function setParamsGUI(src,options)
0437 if(strcmp(get(src,'style'),'checkbox'))
0438 if(strcmp(options{1},'DIVA')),
0439 set(src,'value',DIVA(options{2}));
0440 else
0441 set(src,'value',DIVA(options{1},options{2}));
0442 end
0443 else
0444 if(strcmp(options{1},'DIVA'))
0445 set(src,'string',num2str(DIVA(options{2})));
0446 else
0447 set(src,'string',num2str(DIVA(options{1},options{2})));
0448 end
0449 end
0450
0451
0452 function setParamsDIVA(options,value)
0453 if(ischar(value))
0454 value=str2double(value);
0455 end
0456 if(strcmp(options{2},'TimeStep'))
0457 value=value/1000;
0458 end
0459 if(strcmp(options{1},'DIVA'))
0460 DIVA(options{2},value);
0461 else
0462 DIVA(options{1},options{2},value);
0463 end
0464
0465
0466 function ok_cbk(src,eventdata,edits,checkbox)
0467 fnames=fieldnames(edits);
0468 for i=1:length(fnames),
0469 setParamsDIVA(get(edits.(fnames{i}),'UserData'),get(edits.(fnames{i}),'string'));
0470 end
0471 fnames=fieldnames(checkbox);
0472 for i=1:length(fnames),
0473 setParamsDIVA(get(checkbox.(fnames{i}),'UserData'),get(checkbox.(fnames{i}),'value'));
0474 end
0475 close(get(src,'parent'));
0476
0477
0478 function cancel_cbk(src,eventdata)
0479 close(get(src,'parent'));
0480