Home > fcn > DIVA_GUI_callbacks > gui_expctrl_noise.m

gui_expctrl_noise

PURPOSE ^

Callback function for Experimental Control -> Model Noise menu item

SYNOPSIS ^

function gui_expctrl_noise(src,eventdata)

DESCRIPTION ^

 Callback function for Experimental Control -> Model Noise menu item

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function gui_expctrl_noise(src,eventdata)
0002 % Callback function for Experimental Control -> Model Noise menu item
0003 
0004 % TODO % Timing noise for auditory/somatosensory error calculation and
0005 % feedforward motor cmd
0006 
0007   h=figure('name','Experimental Control: Noise Specification',...
0008     'numbertitle','off','units','pixels','position',[100 100 640 480],...
0009     'menu','none','doublebuffer','on','color',[0.5 0.5 0.5]);
0010     
0011   % Split figure/frame into thirds: Acoustic Error noise, Somato Error
0012   % noise and FFcmd Amplitude noise
0013   %
0014   
0015   
0016   panel.border = [0.05 0.05]; % side and top borders
0017   panel.width = (1-4*panel.border(1))/3;
0018   panel.height = (1-2*panel.border(2));
0019   
0020   frames = {'AUDnoise','SOMnoise','FFnoise'};
0021   motorVar = {'ErrorNoise_sound','ErrorNoise_somatosensory','ErrorNoise_ffAmplitude'};
0022   frameTitle = {'Auditory Error','Somatosensory Error','Feedforward Command'};
0023   
0024   for n=1:3, % 3 sections
0025     distPar = DIVA('MotorCortex',motorVar{n});
0026     setappdata(h,frames{n},distPar);
0027     
0028     pos(1) = n*panel.border(1)+(n-1)*panel.width;
0029     pos(2) = panel.border(2)+2*panel.border(2);
0030     pos(3) = panel.width;
0031     pos(4) = panel.height-2*panel.border(2);
0032     
0033     panel.(frames{n}).main = uicontrol('style','frame','units','norm',...
0034       'position',[pos(1)+0.01*pos(3) pos(2)+0.825*pos(4) 0.98*pos(3) 0.15*pos(4)],...
0035       'backgroundcolor',[0.7 0.7 0.7]);
0036     panel.(frames{n}).title = uicontrol('style','text','parent',h,...
0037       'string',frameTitle{n},'FontUnits','pixels','FontSize',16,...
0038       'FontWeight','bold','Units','norm','position',...
0039       [pos(1)+0.05*pos(3) pos(2)+0.85*pos(4) 0.9*pos(3) 0.1*pos(4)],...
0040       'backgroundcolor',[0.7 0.7 0.7]);
0041     panel.(frames{n}).axes = axes('units','norm','parent',h, ...
0042       'position',[pos(1)+0.05*pos(3) pos(2)+0.25*pos(4) 0.9*pos(3) 0.5*pos(4)]);      
0043     %%% just plot N(0,1/4) for now
0044     if(distPar(2)==0)
0045       panel.(frames{n}).noiseDist = line(-1:0.001:1,((-1:0.001:1)==distPar(2))*3,...
0046         'tag',frames{n});
0047     else
0048       panel.(frames{n}).noiseDist = line(-1:0.001:1,normpdf(-1:0.001:1,distPar(1),distPar(2)),...
0049         'tag',frames{n});
0050     end
0051     axis off
0052       
0053     line([0 0],[-0.1 normpdf(0,0,1/10)],'color','k','linestyle','--');
0054     line([-1 -1],[-0.1 normpdf(0,0,1/10)],'color','k','linestyle',':');
0055     line([1 1],[-0.1 normpdf(0,0,1/10)],'color','k','linestyle',':');
0056     set(gca,'xlim',[-1 1],'ylim',[-0.1 3]);
0057     
0058     panel.(frames{n}).slideframe = uicontrol('style','frame','units','norm',...
0059       'position',[pos(1) pos(2) pos(3) 0.2*pos(4)],...
0060       'backgroundcolor',[0.7 0.7 0.7]);
0061     
0062     panel.(frames{n}).sliderBias = uicontrol('style','slider','units','norm',...
0063       'position',[pos(1)+0.05*pos(3) pos(2)+(0.2/3)*pos(4)+0.05*pos(4) ...
0064                   0.9*pos(3) 0.05*pos(4)],'min',-1,'max',1,'sliderstep',[0.01,0.1],...
0065                   'tag','bias','value',distPar(1),...%'tooltipstring',num2str(distPar(1)),...
0066                   'callback',{@slider_cbk,panel.(frames{n}).noiseDist});
0067     panel.(frames{n}).sliderVar = uicontrol('style','slider','units','norm',...
0068       'position',[pos(1)+0.05*pos(3) pos(2)+(0.1/3)*pos(4) ...
0069                   0.9*pos(3) 0.05*pos(4)],'min',0,'max',2,'sliderstep',[0.01,0.1],...
0070                   'tag','var','value',distPar(2),...
0071                   'callback',{@slider_cbk,panel.(frames{n}).noiseDist});
0072                 
0073   % labels for sliders
0074     if(n==1)
0075       panel.labelBias = uicontrol('style','text','units','norm',...
0076         'position',[0 pos(2)+(0.2/3)*pos(4)+0.05*pos(4) ...
0077                     pos(1) 0.05*pos(4)],...
0078         'string','Bias','parent',h,'backgroundcolor',[0.5 0.5 0.5],...
0079         'FontSize',10);
0080       panel.labelVar = uicontrol('style','text','units','norm',...
0081         'position',[0 pos(2)+(0.1/3)*pos(4) pos(1) 0.05*pos(4)],...
0082         'string','Var','parent',h,'backgroundcolor',[0.5 0.5 0.5],...
0083         'FontSize',10);
0084     end
0085   end
0086   
0087   
0088   %----------------------------Set/cancel-------------------------------------%
0089 
0090   btn.ok=uicontrol('parent',h,'style','pushbutton','units','norm',...
0091     'position',[.8 .05 .05 .05],'FontUnits','norm',...
0092     'FontSize',.45,'String','OK',...
0093     'callback',{@ok_cbk,frames,motorVar});
0094   btn.cancel=uicontrol('parent',h,'style','pushbutton','units','norm',...
0095     'position',[.85 .05 .1 .05],'FontUnits','norm',...
0096     'FontSize',.45,'String','Cancel',...
0097     'callback',@cancel_cbk);
0098 
0099   %************************************************************%
0100   function ok_cbk(src,eventdata,frames,motorVar)    
0101     for n=1:length(frames),      
0102       distPar = getappdata(gcf,frames{n});
0103       DIVA('MotorCortex',motorVar{n},distPar);
0104     end      
0105     close(get(src,'parent'));
0106   
0107   %************************************************************%
0108   function cancel_cbk(src,eventdata)
0109     close(get(src,'parent'));
0110 
0111   %************************************************************%
0112   function slider_cbk(src,eventdata,handles)
0113     distPar = getappdata(gcf,get(handles,'tag'));
0114     switch(get(src,'tag'))
0115       case 'bias',
0116         distPar(1)=get(src,'value');
0117         %set(src,'tooltipstring',num2str(distPar(1)));
0118       case 'var',
0119         distPar(2)=get(src,'value');
0120     end
0121     if(distPar(2)==0)
0122       set(handles,'visible','on','ydata',(fix(1000*(-1:0.001:1))==fix(1000*distPar(1)))*3);
0123     else
0124       set(handles,'visible','on','ydata',normpdf(-1:0.001:1,distPar(1),distPar(2)));
0125     end
0126     setappdata(gcf,get(handles,'tag'),distPar);

Generated on Tue 27-Mar-2007 12:06:24 by m2html © 2003