tracker_CK.m 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  1. function varargout = tracker_CK(varargin)
  2. % TRACKER_CK M-file for tracker_CK.fig
  3. % TRACKER_CK, by itself, creates a new TRACKER_CK or raises the existing
  4. % singleton*.
  5. %
  6. % H = TRACKER_CK returns the handle to a new TRACKER_CK or the handle to
  7. % the existing singleton*.
  8. %
  9. % TRACKER_CK('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in TRACKER_CK.M with the given input arguments.
  11. %
  12. % TRACKER_CK('Property','Value',...) creates a new TRACKER_CK or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before tracker_OpeningFunction gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to tracker_CK_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help tracker_CK
  23. % Last Modified by GUIDE v2.5 20-Sep-2019 13:11:53
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @tracker_CK_OpeningFcn, ...
  29. 'gui_OutputFcn', @tracker_CK_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before tracker_CK is made visible.
  42. function tracker_CK_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to tracker_CK (see VARARGIN)
  48. % X = varargin{1};
  49. % Y = varargin{2};
  50. % line(X, Y)
  51. % Choose default command line output for tracker_CK
  52. handles.output = hObject;
  53. Init(hObject, handles)
  54. % ht = uitoolbar(hObject)
  55. % a(:,:,1) = rand(20);
  56. % a(:,:,2) = rand(20);
  57. % a(:,:,3) = rand(20);
  58. % htt = uitoggletool(ht,'CData',a,'TooltipString','Hello')
  59. % Update handles structure
  60. %guidata(hObject, handles);
  61. % UIWAIT makes tracker_CK wait for user response (see UIRESUME)
  62. % uiwait(handles.figure1);
  63. % --- Outputs from this function are returned to the command line.
  64. function varargout = tracker_CK_OutputFcn(hObject, eventdata, handles)
  65. % varargout cell array for returning output args (see VARARGOUT);
  66. % hObject handle to figure
  67. % eventdata reserved - to be defined in a future version of MATLAB
  68. % handles structure with handles and user data (see GUIDATA)
  69. % Get default command line output from handles structure
  70. varargout{1} = handles.output;
  71. % --- Executes on button press in Init.
  72. function Init(hObject, handles)
  73. % hObject handle to Init (see GCBO)
  74. % eventdata reserved - to be defined in a future version of MATLAB
  75. % handles structure with handles and user data (see GUIDATA)
  76. % prestim %initial values, startup of das, startup of cogent
  77. prestim_ptb %initial values, startup of das, startup of ptb
  78. if isfield(Par,'DasOn') && Par.DasOn %defined in prestim
  79. handles.DasOn = true;
  80. end
  81. % initialize paramaterfields
  82. %timing
  83. set(handles.ToFixTime, 'String', num2str(Par.Times.ToFix, 4))
  84. set(handles.FixT, 'String', num2str(Par.Times.Fix, 4))
  85. set(handles.StimT, 'String', num2str(Par.Times.Stim, 4))
  86. if numel(Par.Times.Targ)==1
  87. set(handles.TargT, 'String', num2str(Par.Times.Targ, 4))
  88. else
  89. set(handles.TargT, 'String', num2str(Par.Times.Targ(1,2), 4))
  90. end
  91. set(handles.ReactionT, 'String', num2str(Par.Times.Rt, 4))
  92. set(handles.InterTT, 'String', num2str(Par.Times.InterTrial, 4))
  93. set(handles.e_RndFix, 'String', num2str(Par.Times.RndFix, 4))
  94. set(handles.e_RndStim, 'String', num2str(Par.Times.RndStim, 4))
  95. set(handles.e_RndTarg, 'String', num2str(Par.Times.RndTarg, 4))
  96. set(handles.e_Sacc, 'String', num2str(Par.Times.Sacc, 4))
  97. set(handles.e_Err, 'String', num2str(Par.Times.Err, 4))
  98. if numel(Par.RewardTime)==1
  99. set(handles.Lbl_Rwtime, 'String', num2str(Par.RewardTime, 5))
  100. set(handles.slider1, 'Value', Par.RewardTime)
  101. else
  102. set(handles.Lbl_Rwtime, 'String', num2str(Par.RewardTime(1,2), 5))
  103. set(handles.slider1, 'Value', Par.RewardTime(1,2))
  104. end
  105. set(handles.rb_Drum, 'Value', Par.Drum)
  106. set(handles.E_RGB, 'String', [ num2str(Par.BG(1)) ' ' num2str(Par.BG(2)) ' ' num2str(Par.BG(2))])
  107. Updatetimeaxes(handles)
  108. %scale eyeinput to pixels
  109. set(handles.lblScx, 'String', num2str(Par.SCx, 4))
  110. set(handles.lblScy, 'String', num2str(Par.SCy, 4))
  111. set(handles.TB_x, 'String', ['x*' num2str(Par.xdir, 1)])
  112. set(handles.TB_y, 'String', ['y*' num2str(Par.ydir, 1)])
  113. %control window dimensions
  114. set(handles.LFixWd, 'String', num2str(Par.FixWdDeg) )
  115. set(handles.LTargWd, 'String', num2str(Par.TargWdDeg) )
  116. set(handles.LFixHt, 'String', num2str(Par.FixHtDeg) )
  117. set(handles.LTargHt, 'String', num2str(Par.TargHtDeg) )
  118. set(handles.ScrDist, 'String', num2str(Par.DistanceToScreen));
  119. set(handles.ScrWid, 'String', num2str(Par.ScreenWidthD2 * 2));
  120. set(handles.PixDeg, 'String', num2str(Par.PixPerDeg, 4));
  121. % some hand control and fix parameters
  122. set(handles.RewHIB,'Value',Par.RewNeeds.HandIsIn);
  123. set(handles.StimHIB,'Value',Par.StimNeeds.HandIsIn);
  124. set(handles.FixHIB,'Value',Par.FixNeeds.HandIsIn);
  125. set(handles.SecFixCol,'Value',Par.RewardFixFeedBack);
  126. set(handles.AutoDim,'Value',Par.HandOutDimsScreen);
  127. set(handles.AutoDimPerc,'Value',Par.HandOutDimsScreen_perc);
  128. handles.RUNFUNC = @runstim;
  129. set(handles.T_RUN, 'String', ['Runfunction : ' Par.RUNFUNC]);
  130. % Update handles structure
  131. guidata(hObject, handles);
  132. % --- Executes on button press in Stop.
  133. function Stop_Callback(hObject, eventdata, handles)
  134. % hObject handle to Stop (see GCBO)
  135. % eventdata reserved - to be defined in a future version of MATLAB
  136. % handles structure with handles and user data (see GUIDATA)
  137. global Par
  138. Par.ESC = true;
  139. % if Par.isRunning == true
  140. % return
  141. % end
  142. % poststim
  143. % --- Executes on button press in Run.
  144. function Run_Callback(hObject, eventdata, handles)
  145. % hObject handle to Run (see GCBO)
  146. % eventdata reserved - to be defined in a future version of MATLAB
  147. % handles structure with handles and user data (see GUIDATA)
  148. global Par
  149. if isfield(handles, 'DasOn') && handles.DasOn
  150. set(hObject, 'BackgroundColor', [0.5 0.6 0.9])
  151. Par.isRunning = true;
  152. axes(handles.axes1);
  153. %the runfunction is now a handle, don't change!!!!!
  154. handles.RUNFUNC([handles.T_Trl handles.T_Sd]) %gets a handle to update trial numbers and noise value
  155. end %IS_RUNNING%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  156. Par.isRunning = false;
  157. set(hObject, 'BackgroundColor', [0.925 0.914 0.847])
  158. % --- Executes on button press in ZoomUp.
  159. function ZoomUp_Callback(hObject, eventdata, handles)
  160. % hObject handle to ZoomUp (see GCBO)
  161. % eventdata reserved - to be defined in a future version of MATLAB
  162. % handles structure with handles and user data (see GUIDATA)
  163. global Par
  164. Par.ZOOM = Par.ZOOM * 1.25;
  165. cla
  166. refreshtracker( 1)
  167. % --- Executes on button press in ZoomDown.
  168. function ZoomDown_Callback(hObject, eventdata, handles)
  169. % hObject handle to ZoomDown (see GCBO)
  170. % eventdata reserved - to be defined in a future version of MATLAB
  171. % handles structure with handles and user data (see GUIDATA)
  172. global Par
  173. Par.ZOOM = Par.ZOOM * 0.8;
  174. cla
  175. refreshtracker( 1)
  176. % --- Executes on key press over figure1 with no controls selected.
  177. function figure1_KeyPressFcn(hObject, eventdata, handles)
  178. % hObject handle to figure1 (see GCBO)
  179. % eventdata reserved - to be defined in a future version of MATLAB
  180. % handles structure with handles and user data (see GUIDATA)
  181. global Par
  182. Par.KeyDetectedInTrackerWindow = true;
  183. KP = double(get(hObject, 'CurrentCharacter'));
  184. %ST = get(hObject, 'SelectionType');
  185. %disp(ST) %works with mouse buttons!!!!left = 'normal', middle = 'extend',
  186. %right = 'alt'
  187. % if strcmp(ST,'normal')
  188. % Par.MousePress = 0;
  189. % set(handles.rb_SCALE, 'Value', 1.0);
  190. % elseif strcmp(ST,'alt')
  191. % Par.MousePress = 2;
  192. % set(handles.rb_SHIFT, 'Value', 1.0);
  193. % end
  194. if ~isempty(KP)
  195. switch KP
  196. case 28 %left arrow was pressed
  197. if Par.MousePress == 2
  198. %Par.OFFx = Par.OFFx - 1 * Par.xdir;
  199. %calllib(Par.Dll, 'ShiftOffset', -1, 0);
  200. Par.ScaleOff = dasoffset( -1, 0);
  201. else
  202. Par.SCx = Par.SCx * 1/1.1;
  203. set(handles.lblScx, 'String', num2str(Par.SCx, 4))
  204. Par.ScaleOff(3) = Par.SCx;
  205. end
  206. %disp('keypress left')
  207. case 29 %Right arrow was pressed
  208. if Par.MousePress == 2
  209. %Par.OFFx = Par.OFFx + 1 * Par.xdir;
  210. %calllib(Par.Dll, 'ShiftOffset', 1, 0);
  211. Par.ScaleOff = dasoffset( 1, 0);
  212. else
  213. Par.SCx = Par.SCx * 1.1;
  214. set(handles.lblScx, 'String', num2str(Par.SCx, 4))
  215. Par.ScaleOff(3) = Par.SCx;
  216. end
  217. % disp('keypress right')
  218. case 30 %up arrow was pressed
  219. if Par.MousePress == 2
  220. %Par.OFFy = Par.OFFy + 1 * Par.ydir;
  221. %calllib(Par.Dll, 'ShiftOffset', 0, 1);
  222. Par.ScaleOff = dasoffset( 0, 1);
  223. else
  224. Par.SCy = Par.SCy * 1.1;
  225. set(handles.lblScy, 'String', num2str(Par.SCy, 4))
  226. Par.ScaleOff(4) = Par.SCy;
  227. end
  228. %disp('keypress up')
  229. case 31 %down arrow was pressed
  230. if Par.MousePress == 2
  231. % Par.OFFy = Par.OFFy - 1 * Par.ydir;
  232. %calllib(Par.Dll, 'ShiftOffset', 0, -1);
  233. Par.ScaleOff = dasoffset( 0, -1);
  234. else
  235. Par.SCy = Par.SCy * 1/1.1;
  236. set(handles.lblScy, 'String', num2str(Par.SCy, 4))
  237. Par.ScaleOff(4) = Par.SCy;
  238. end
  239. % disp('keypress down')
  240. case 27 %escape key was pressed
  241. Par.ESC = 1;
  242. % disp('keypress ESC')
  243. case 122 %Z key was pressed
  244. % Par.SetZero = true;
  245. % disp('keypress ZERO')
  246. if Par.Mouserun
  247. % LPM = calllib(Par.Dll, 'Use_Mouse', Par.Mouserun );
  248. % setdatatype(LPM, 'int32Ptr', 2, 1);
  249. Par.MOff = dasusemouse( 1 );
  250. else
  251. %calllib(Par.Dll,'SetZero');
  252. Par.ScaleOff = daszero();
  253. end
  254. %case 106 %j key was pressed , give juice reward
  255. % % calllib(Par.Dll, 'DO_Bit', Par.RewardB, 1);
  256. % % calllib(Par.Dll, 'Juice', 3.5);
  257. % dasbit( Par.RewardB, 1);
  258. % dasjuice( 4 );
  259. % pause(Par.RewardTime)
  260. % % calllib(Par.Dll, 'DO_Bit', Par.RewardB, 0);
  261. % % calllib(Par.Dll, 'Juice', 0.0);
  262. % dasbit( Par.RewardB, 0);
  263. % dasjuice( 0 );
  264. % disp('Reward')
  265. otherwise
  266. %disp(KP)
  267. end
  268. end
  269. % --- Executes on slider movement.
  270. function slider1_Callback(hObject, eventdata, handles)
  271. % hObject handle to slider1 (see GCBO)
  272. % eventdata reserved - to be defined in a future version of MATLAB
  273. % handles structure with handles and user data (see GUIDATA)
  274. % Hints: get(hObject,'Value') returns position of slider
  275. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  276. global Par
  277. Par.RewardTime = get(hObject,'Value');
  278. set(handles.Lbl_Rwtime, 'String', num2str(Par.RewardTime, '% -5.3f'));
  279. % --- Executes during object creation, after setting all properties.
  280. function slider1_CreateFcn(hObject, eventdata, handles)
  281. % hObject handle to slider1 (see GCBO)
  282. % eventdata reserved - to be defined in a future version of MATLAB
  283. % handles empty - handles not created until after all CreateFcns called
  284. % Hint: slider controls usually have a light gray background.
  285. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  286. set(hObject,'BackgroundColor',[.9 .9 .9]);
  287. end
  288. % --------------------------------------------------------------------
  289. function READ_Callback(hObject, eventdata, handles)
  290. % hObject handle to READ (see GCBO)
  291. % eventdata reserved - to be defined in a future version of MATLAB
  292. % handles structure with handles and user data (see GUIDATA)
  293. global Par
  294. RUNFUNC = '';
  295. [FileName,PathName] = uigetfile('PAR.mat','Select a parameter Mat-file','PAR.mat');
  296. Pf = fullfile(PathName,FileName);
  297. if exist(Pf)
  298. load(Pf)
  299. Par.Times = Times;
  300. Par.Drum = Drum;
  301. Par.SCx = SCx;
  302. Par.SCy = SCy;
  303. Par.DistanceToScreen = DistanceToScreen;
  304. Par.ScreenWidthD2 = ScreenWidthD2;
  305. Par.PixPerDeg = PixPerDeg;
  306. Par.FixWdDeg = FixWdDeg;
  307. Par.TargWdDeg = TargWdDeg;
  308. Par.FixHtDeg = FixHtDeg;
  309. Par.TargHtDeg = TargHtDeg;
  310. Par.xdir = xdir;
  311. Par.ydir = ydir;
  312. Par.BG = BG;
  313. if exist(RUNFUNC, 'var')
  314. Par.RUNFUNC = RUNFUNC;
  315. handles.RUNFUNC = str2fun(Par.RUNFUNC);
  316. set(handles.T_RUN, 'String', ['Runfunction : ' Par.RUNFUNC]);
  317. end
  318. set(handles.ToFixTime, 'String', num2str(Times.ToFix, 4));
  319. set(handles.FixT, 'String', num2str(Times.Fix, 4));
  320. set(handles.StimT, 'String', num2str(Times.Stim, 4));
  321. %set(handles.TargT, 'String', num2str(Times.Targ, 4));
  322. if numel(Par.Times.Targ)==1
  323. set(handles.TargT, 'String', num2str(Par.Times.Targ, 4))
  324. else
  325. set(handles.TargT, 'String', num2str(Par.Times.Targ(1,2), 4))
  326. end
  327. set(handles.ReactionT, 'String', num2str(Par.Times.Rt, 4))
  328. set(handles.InterTT, 'String', num2str(Times.InterTrial, 4));
  329. Updatetimeaxes(handles) %update axes showing control times
  330. set(handles.e_RndFix, 'String', num2str(Par.Times.RndFix, 4))
  331. set(handles.e_RndStim, 'String', num2str(Par.Times.RndStim, 4))
  332. set(handles.e_RndTarg, 'String', num2str(Par.Times.RndTarg, 4))
  333. set(handles.e_Sacc, 'String', num2str(Par.Times.Sacc, 4))
  334. set(handles.e_Err, 'String', num2str(Par.Times.Err, 4))
  335. set(handles.rb_Drum, 'Value', Par.Drum)
  336. set(handles.E_RGB, 'String', [ num2str(Par.BG(1)) ' ' num2str(Par.BG(2)) ' ' num2str(Par.BG(2))])
  337. set(handles.lblScx, 'String', num2str(Par.SCx, 4));
  338. set(handles.lblScy, 'String', num2str(Par.SCy, 4));
  339. set(handles.TB_x, 'String', ['x*' num2str(Par.xdir, 1)])
  340. set(handles.TB_y, 'String', ['y*' num2str(Par.ydir, 1)])
  341. %control window dimensions
  342. set(handles.LFixWd, 'String', num2str(Par.FixWdDeg) )
  343. set(handles.LTargWd, 'String', num2str(Par.TargWdDeg) )
  344. set(handles.LFixHt, 'String', num2str(Par.FixHtDeg) )
  345. set(handles.LTargHt, 'String', num2str(Par.TargHtDeg) )
  346. set(handles.ScrDist, 'String', num2str(Par.DistanceToScreen));
  347. set(handles.ScrWid, 'String', num2str(Par.ScreenWidthD2 * 2));
  348. set(handles.PixDeg, 'String', num2str(Par.PixPerDeg, 4));
  349. % some hand control and fix parameters
  350. set(handles.RewHIB,'Value',Par.RewNeeds.HandIsIn);
  351. set(handles.StimHIB,'Value',Par.StimNeeds.HandIsIn);
  352. set(handles.FixHIB,'Value',Par.FixNeeds.HandIsIn);
  353. set(handles.SecFixCol,'Value',Par.RewardFixFeedBack);
  354. set(handles.AutoDim,'Value',Par.HandOutDimsScreen);
  355. set(handles.AutoDimPerc,'Value',Par.HandOutDimsScreen_perc);
  356. % FixSz = Par.FixSzDeg * Par.PixPerDeg;
  357. % TargSz = Par.TargSzDeg * Par.PixPerDeg;
  358. for i = 1:size(Par.WIN,2)
  359. if Par.WIN(5,i) == 0 %fix window == 0
  360. Par.WIN(3,i) = Par.FixHtDeg * Par.PixPerDeg; %width
  361. Par.WIN(4,i) = Par.FixWdDeg * Par.PixPerDeg; %height
  362. elseif Par.WIN(5,i) == 1 || Par.WIN(5,i) == 2 %target window == 2
  363. Par.WIN(3,i) = Par.TargHtDeg * Par.PixPerDeg; %width
  364. Par.WIN(4,i) = Par.TargWdDeg * Par.PixPerDeg; %height
  365. end
  366. end
  367. guidata(hObject, handles);
  368. else
  369. errordlg('No saved Parameters to retrieve')
  370. end
  371. % --------------------------------------------------------------------
  372. function SAVE_Callback(hObject, eventdata, handles)
  373. % hObject handle to SAVE (see GCBO)
  374. % eventdata reserved - to be defined in a future version of MATLAB
  375. % handles structure with handles and user data (see GUIDATA)
  376. global Par
  377. save( 'PAR.mat', '-struct', 'Par')
  378. % --------------------------------------------------------------------
  379. function SAVEAS_Callback(hObject, eventdata, handles)
  380. % hObject handle to SAVEAS (see GCBO)
  381. % eventdata reserved - to be defined in a future version of MATLAB
  382. % handles structure with handles and user data (see GUIDATA)
  383. global Par
  384. [file,path] = uiputfile('PAR.mat','Save PAR as');
  385. if file ~= 0
  386. save([path file], '-struct', 'Par')
  387. else
  388. errormsg('No filename supplied')
  389. end
  390. % --------------------------------------------------------------------
  391. function CHANGE_Callback(hObject, eventdata, handles)
  392. % hObject handle to CHANGE (see GCBO)
  393. % eventdata reserved - to be defined in a future version of MATLAB
  394. % handles structure with handles and user data (see GUIDATA)
  395. set(handles.axes1, 'Visible', 'off')
  396. CHILD = get(handles.axes1, 'Children');
  397. for i = 1:length(CHILD)
  398. set(CHILD(i), 'Visible', 'off')
  399. end
  400. set(handles.ParmPanel, 'Visible', 'on')
  401. Updatetimeaxes(handles) %update axes showing control times
  402. % --- Executes on button press in ParmClose.
  403. function ParmClose_Callback(hObject, eventdata, handles)
  404. % hObject handle to ParmClose (see GCBO)
  405. % eventdata reserved - to be defined in a future version of MATLAB
  406. % handles structure with handles and user data (see GUIDATA)
  407. set(handles.ParmPanel, 'Visible', 'off')
  408. refreshtracker( 1)
  409. set(handles.axes1, 'Visible', 'on')
  410. % CHILD = get(handles.axes1, 'Children');
  411. % for i = 1:length(CHILD)
  412. % set(CHILD(i), 'Visible', 'on')
  413. % end
  414. function ToFixTime_Callback(hObject, eventdata, handles)
  415. % hObject handle to ToFixTime (see GCBO)
  416. % eventdata reserved - to be defined in a future version of MATLAB
  417. % handles structure with handles and user data (see GUIDATA)
  418. % Hints: get(hObject,'String') returns contents of ToFixTime as text
  419. % str2double(get(hObject,'String')) returns contents of ToFixTime as a double
  420. global Par
  421. time = str2double(get(hObject,'String'));
  422. if isnan(time) || time == 0
  423. errordlg('Enter valid time')
  424. else
  425. Par.Times.ToFix = time;
  426. end
  427. Updatetimeaxes(handles)
  428. % --- Executes during object creation, after setting all properties.
  429. function ToFixTime_CreateFcn(hObject, eventdata, handles)
  430. % hObject handle to ToFixTime (see GCBO)
  431. % eventdata reserved - to be defined in a future version of MATLAB
  432. % handles empty - handles not created until after all CreateFcns called
  433. % Hint: edit controls usually have a white background on Windows.
  434. % See ISPC and COMPUTER.
  435. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  436. set(hObject,'BackgroundColor','white');
  437. end
  438. function FixT_Callback(hObject, eventdata, handles)
  439. % hObject handle to FixT (see GCBO)
  440. % eventdata reserved - to be defined in a future version of MATLAB
  441. % handles structure with handles and user data (see GUIDATA)
  442. % Hints: get(hObject,'String') returns contents of FixT as text
  443. % str2double(get(hObject,'String')) returns contents of FixT as a double
  444. global Par
  445. time = str2double(get(hObject,'String'));
  446. if isnan(time) || time == 0
  447. errordlg('Enter valid time')
  448. else
  449. Par.Times.Fix = time;
  450. end
  451. Updatetimeaxes(handles)
  452. % --- Executes during object creation, after setting all properties.
  453. function FixT_CreateFcn(hObject, eventdata, handles)
  454. % hObject handle to FixT (see GCBO)
  455. % eventdata reserved - to be defined in a future version of MATLAB
  456. % handles empty - handles not created until after all CreateFcns called
  457. % Hint: edit controls usually have a white background on Windows.
  458. % See ISPC and COMPUTER.
  459. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  460. set(hObject,'BackgroundColor','white');
  461. end
  462. function StimT_Callback(hObject, eventdata, handles)
  463. % hObject handle to StimT (see GCBO)
  464. % eventdata reserved - to be defined in a future version of MATLAB
  465. % handles structure with handles and user data (see GUIDATA)
  466. % Hints: get(hObject,'String') returns contents of StimT as text
  467. % str2double(get(hObject,'String')) returns contents of StimT as a double
  468. global Par
  469. time = str2double(get(hObject,'String'));
  470. if isnan(time) || time <= 0
  471. errordlg('Enter valid time')
  472. else
  473. Par.Times.Stim = round(round(time/Par.fliptime)*Par.fliptime);
  474. set(hObject,'String', num2str(Par.Times.Stim) )
  475. end
  476. Updatetimeaxes(handles)
  477. % --- Executes during object creation, after setting all properties.
  478. function StimT_CreateFcn(hObject, eventdata, handles)
  479. % hObject handle to StimT (see GCBO)
  480. % eventdata reserved - to be defined in a future version of MATLAB
  481. % handles empty - handles not created until after all CreateFcns called
  482. % Hint: edit controls usually have a white background on Windows.
  483. % See ISPC and COMPUTER.
  484. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  485. set(hObject,'BackgroundColor','white');
  486. end
  487. function TargT_Callback(hObject, eventdata, handles)
  488. % hObject handle to TargT (see GCBO)
  489. % eventdata reserved - to be defined in a future version of MATLAB
  490. % handles structure with handles and user data (see GUIDATA)
  491. % Hints: get(hObject,'String') returns contents of TargT as text
  492. % str2double(get(hObject,'String')) returns contents of TargT as a double
  493. global Par
  494. time = str2double(get(hObject,'String'));
  495. if isnan(time) || time < 0
  496. errordlg('Enter valid time')
  497. else
  498. Par.Times.Targ = round(round(time/Par.fliptime)*Par.fliptime);
  499. set(hObject,'String', num2str(Par.Times.Targ) )
  500. end
  501. Updatetimeaxes(handles)
  502. % --- Executes during object creation, after setting all properties.
  503. function TargT_CreateFcn(hObject, eventdata, handles)
  504. % hObject handle to TargT (see GCBO)
  505. % eventdata reserved - to be defined in a future version of MATLAB
  506. % handles empty - handles not created until after all CreateFcns called
  507. % Hint: edit controls usually have a white background on Windows.
  508. % See ISPC and COMPUTER.
  509. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  510. set(hObject,'BackgroundColor','white');
  511. end
  512. function ReactionT_Callback(hObject, eventdata, handles)
  513. % hObject handle to ReactionT (see GCBO)
  514. % eventdata reserved - to be defined in a future version of MATLAB
  515. % handles structure with handles and user data (see GUIDATA)
  516. % Hints: get(hObject,'String') returns contents of ReactionT as text
  517. % str2double(get(hObject,'String')) returns contents of ReactionT as a double
  518. global Par
  519. time = str2double(get(hObject,'String'));
  520. if isnan(time) || time <= 0
  521. errordlg('Enter valid time')
  522. else
  523. Par.Times.Rt = time;
  524. end
  525. Updatetimeaxes(handles)
  526. % --- Executes during object creation, after setting all properties.
  527. function ReactionT_CreateFcn(hObject, eventdata, handles)
  528. % hObject handle to ReactionT (see GCBO)
  529. % eventdata reserved - to be defined in a future version of MATLAB
  530. % handles empty - handles not created until after all CreateFcns called
  531. % Hint: edit controls usually have a white background on Windows.
  532. % See ISPC and COMPUTER.
  533. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  534. set(hObject,'BackgroundColor','white');
  535. end
  536. function InterTT_Callback(hObject, eventdata, handles)
  537. % hObject handle to InterTT (see GCBO)
  538. % eventdata reserved - to be defined in a future version of MATLAB
  539. % handles structure with handles and user data (see GUIDATA)
  540. % Hints: get(hObject,'String') returns contents of InterTT as text
  541. % str2double(get(hObject,'String')) returns contents of InterTT as a double
  542. global Par
  543. time = str2double(get(hObject,'String'));
  544. if isnan(time) || time < 0
  545. errordlg('Enter valid time')
  546. else
  547. Par.Times.InterTrial = time;
  548. end
  549. Updatetimeaxes(handles)
  550. % --- Executes during object creation, after setting all properties.
  551. function InterTT_CreateFcn(hObject, eventdata, handles)
  552. % hObject handle to InterTT (see GCBO)
  553. % eventdata reserved - to be defined in a future version of MATLAB
  554. % handles empty - handles not created until after all CreateFcns called
  555. % Hint: edit controls usually have a white background on Windows.
  556. % See ISPC and COMPUTER.
  557. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  558. set(hObject,'BackgroundColor','white');
  559. end
  560. % --- Executes on button press in juiceradio.
  561. function juiceradio_Callback(hObject, eventdata, handles)
  562. % hObject handle to juiceradio (see GCBO)
  563. % eventdata reserved - to be defined in a future version of MATLAB
  564. % handles structure with handles and user data (see GUIDATA)
  565. % Hint: get(hObject,'Value') returns toggle state of juiceradio
  566. global Par
  567. Par.Reward = get(hObject,'Value');
  568. function lblScx_Callback(hObject, eventdata, handles)
  569. % hObject handle to lblScx (see GCBO)
  570. % eventdata reserved - to be defined in a future version of MATLAB
  571. % handles structure with handles and user data (see GUIDATA)
  572. % Hints: get(hObject,'String') returns contents of lblScx as text
  573. % str2double(get(hObject,'String')) returns contents of lblScx as a double
  574. % --- Executes during object creation, after setting all properties.
  575. function lblScx_CreateFcn(hObject, eventdata, handles)
  576. % hObject handle to lblScx (see GCBO)
  577. % eventdata reserved - to be defined in a future version of MATLAB
  578. % handles empty - handles not created until after all CreateFcns called
  579. % Hint: edit controls usually have a white background on Windows.
  580. % See ISPC and COMPUTER.
  581. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  582. set(hObject,'BackgroundColor','white');
  583. end
  584. function LblScy_Callback(hObject, eventdata, handles)
  585. % hObject handle to LblScy (see GCBO)
  586. % eventdata reserved - to be defined in a future version of MATLAB
  587. % handles structure with handles and user data (see GUIDATA)
  588. % Hints: get(hObject,'String') returns contents of LblScy as text
  589. % str2double(get(hObject,'String')) returns contents of LblScy as a double
  590. % --- Executes during object creation, after setting all properties.
  591. function LblScy_CreateFcn(hObject, eventdata, handles)
  592. % hObject handle to LblScy (see GCBO)
  593. % eventdata reserved - to be defined in a future version of MATLAB
  594. % handles empty - handles not created until after all CreateFcns called
  595. % Hint: edit controls usually have a white background on Windows.
  596. % See ISPC and COMPUTER.
  597. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  598. set(hObject,'BackgroundColor','white');
  599. end
  600. function lblScy_Callback(hObject, eventdata, handles)
  601. % hObject handle to lblScy (see GCBO)
  602. % eventdata reserved - to be defined in a future version of MATLAB
  603. % handles structure with handles and user data (see GUIDATA)
  604. % Hints: get(hObject,'String') returns contents of lblScy as text
  605. % str2double(get(hObject,'String')) returns contents of lblScy as a double
  606. % --- Executes during object creation, after setting all properties.
  607. function lblScy_CreateFcn(hObject, eventdata, handles)
  608. % hObject handle to lblScy (see GCBO)
  609. % eventdata reserved - to be defined in a future version of MATLAB
  610. % handles empty - handles not created until after all CreateFcns called
  611. % Hint: edit controls usually have a white background on Windows.
  612. % See ISPC and COMPUTER.
  613. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  614. set(hObject,'BackgroundColor','white');
  615. end
  616. function LFixx_Callback(hObject, eventdata, handles)
  617. % hObject handle to LFixx (see GCBO)
  618. % eventdata reserved - to be defined in a future version of MATLAB
  619. % handles structure with handles and user data (see GUIDATA)
  620. % Hints: get(hObject,'String') returns contents of LFixx as text
  621. % str2double(get(hObject,'String')) returns contents of LFixx as a double
  622. % --- Executes during object creation, after setting all properties.
  623. function LFixx_CreateFcn(hObject, eventdata, handles)
  624. % hObject handle to LFixx (see GCBO)
  625. % eventdata reserved - to be defined in a future version of MATLAB
  626. % handles empty - handles not created until after all CreateFcns called
  627. % Hint: edit controls usually have a white background on Windows.
  628. % See ISPC and COMPUTER.
  629. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  630. set(hObject,'BackgroundColor','white');
  631. end
  632. function LTargx_Callback(hObject, eventdata, handles)
  633. % hObject handle to LTargx (see GCBO)
  634. % eventdata reserved - to be defined in a future version of MATLAB
  635. % handles structure with handles and user data (see GUIDATA)
  636. % Hints: get(hObject,'String') returns contents of LTargx as text
  637. % str2double(get(hObject,'String')) returns contents of LTargx as a double
  638. % --- Executes during object creation, after setting all properties.
  639. function LTargx_CreateFcn(hObject, eventdata, handles)
  640. % hObject handle to LTargx (see GCBO)
  641. % eventdata reserved - to be defined in a future version of MATLAB
  642. % handles empty - handles not created until after all CreateFcns called
  643. % Hint: edit controls usually have a white background on Windows.
  644. % See ISPC and COMPUTER.
  645. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  646. set(hObject,'BackgroundColor','white');
  647. end
  648. function LFixy_Callback(hObject, eventdata, handles)
  649. % hObject handle to LFixy (see GCBO)
  650. % eventdata reserved - to be defined in a future version of MATLAB
  651. % handles structure with handles and user data (see GUIDATA)
  652. % Hints: get(hObject,'String') returns contents of LFixy as text
  653. % str2double(get(hObject,'String')) returns contents of LFixy as a double
  654. % --- Executes during object creation, after setting all properties.
  655. function LFixy_CreateFcn(hObject, eventdata, handles)
  656. % hObject handle to LFixy (see GCBO)
  657. % eventdata reserved - to be defined in a future version of MATLAB
  658. % handles empty - handles not created until after all CreateFcns called
  659. % Hint: edit controls usually have a white background on Windows.
  660. % See ISPC and COMPUTER.
  661. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  662. set(hObject,'BackgroundColor','white');
  663. end
  664. function LTargy_Callback(hObject, eventdata, handles)
  665. % hObject handle to LTargy (see GCBO)
  666. % eventdata reserved - to be defined in a future version of MATLAB
  667. % handles structure with handles and user data (see GUIDATA)
  668. % Hints: get(hObject,'String') returns contents of LTargy as text
  669. % str2double(get(hObject,'String')) returns contents of LTargy as a double
  670. % --- Executes during object creation, after setting all properties.
  671. function LTargy_CreateFcn(hObject, eventdata, handles)
  672. % hObject handle to LTargy (see GCBO)
  673. % eventdata reserved - to be defined in a future version of MATLAB
  674. % handles empty - handles not created until after all CreateFcns called
  675. % Hint: edit controls usually have a white background on Windows.
  676. % See ISPC and COMPUTER.
  677. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  678. set(hObject,'BackgroundColor','white');
  679. end
  680. function LFixWd_Callback(hObject, eventdata, handles)
  681. % hObject handle to LFixWd (see GCBO)
  682. % eventdata reserved - to be defined in a future version of MATLAB
  683. % handles structure with handles and user data (see GUIDATA)
  684. % Hints: get(hObject,'String') returns contents of LFixWd as text
  685. global Par
  686. Val = str2double(get(hObject,'String')); %returns contents of LFixSz as a double
  687. if ~isnan(Val) && Val > 0
  688. Par.FixWdDeg = Val;
  689. FixWd = Val * Par.PixPerDeg;
  690. for i = 1:size(Par.WIN,2)
  691. if Par.WIN(5,i) == 0 %fix window == 0
  692. Par.WIN(3,i) = FixWd; %width
  693. end
  694. end
  695. end
  696. % --- Executes during object creation, after setting all properties.
  697. function LFixWd_CreateFcn(hObject, eventdata, handles)
  698. % hObject handle to LFixWd (see GCBO)
  699. % eventdata reserved - to be defined in a future version of MATLAB
  700. % handles empty - handles not created until after all CreateFcns called
  701. % Hint: edit controls usually have a white background on Windows.
  702. % See ISPC and COMPUTER.
  703. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  704. set(hObject,'BackgroundColor','white');
  705. end
  706. function LTargWd_Callback(hObject, eventdata, handles)
  707. % hObject handle to LTargWd (see GCBO)
  708. % eventdata reserved - to be defined in a future version of MATLAB
  709. % handles structure with handles and user data (see GUIDATA)
  710. % Hints: get(hObject,'String') returns contents of LTargWd as text
  711. % str2double(get(hObject,'String')) returns contents of LTargWd as a double
  712. global Par
  713. Val = str2double(get(hObject,'String')); %returns contents of LFixSz as a double
  714. if ~isnan(Val) && Val > 0
  715. Par.TargWdDeg = Val;
  716. TargWd = Val * Par.PixPerDeg;
  717. for i = 1:size(Par.WIN,2)
  718. if Par.WIN(5,i) == 1 || Par.WIN(5,i) == 2 %target window == 2
  719. Par.WIN(3,i) = TargWd; %width
  720. end
  721. end
  722. end
  723. % --- Executes during object creation, after setting all properties.
  724. function LTargWd_CreateFcn(hObject, eventdata, handles)
  725. % hObject handle to LTargWd (see GCBO)
  726. % eventdata reserved - to be defined in a future version of MATLAB
  727. % handles empty - handles not created until after all CreateFcns called
  728. % Hint: edit controls usually have a white background on Windows.
  729. % See ISPC and COMPUTER.
  730. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  731. set(hObject,'BackgroundColor','white');
  732. end
  733. function LFixHt_Callback(hObject, eventdata, handles)
  734. % hObject handle to LFixHt (see GCBO)
  735. % eventdata reserved - to be defined in a future version of MATLAB
  736. % handles structure with handles and user data (see GUIDATA)
  737. % Hints: get(hObject,'String') returns contents of LFixHt as text
  738. % str2double(get(hObject,'String')) returns contents of LFixHt as a double
  739. global Par
  740. Val = str2double(get(hObject,'String')); %returns contents of LFixSz as a double
  741. if ~isnan(Val) && Val > 0
  742. Par.FixHtDeg = Val;
  743. FixHt = Val * Par.PixPerDeg;
  744. for i = 1:size(Par.WIN,2)
  745. if Par.WIN(5,i) == 0 %fix window == 0
  746. Par.WIN(4,i) = FixHt; %width
  747. end
  748. end
  749. end
  750. % --- Executes during object creation, after setting all properties.
  751. function LFixHt_CreateFcn(hObject, eventdata, handles)
  752. % hObject handle to LFixHt (see GCBO)
  753. % eventdata reserved - to be defined in a future version of MATLAB
  754. % handles empty - handles not created until after all CreateFcns called
  755. % Hint: edit controls usually have a white background on Windows.
  756. % See ISPC and COMPUTER.
  757. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  758. set(hObject,'BackgroundColor','white');
  759. end
  760. function LTargHt_Callback(hObject, eventdata, handles)
  761. % hObject handle to LTargHt (see GCBO)
  762. % eventdata reserved - to be defined in a future version of MATLAB
  763. % handles structure with handles and user data (see GUIDATA)
  764. % Hints: get(hObject,'String') returns contents of LTargHt as text
  765. % str2double(get(hObject,'String')) returns contents of LTargHt as a double
  766. global Par
  767. Val = str2double(get(hObject,'String')); %returns contents of LFixSz as a double
  768. if ~isnan(Val) && Val > 0
  769. Par.TargHtDeg = Val;
  770. TargHt = Val * Par.PixPerDeg;
  771. for i = 1:size(Par.WIN,2)
  772. if Par.WIN(5,i) == 1 || Par.WIN(5,i) == 2 %target window == 2
  773. Par.WIN(4,i) = TargHt; %width
  774. end
  775. end
  776. end
  777. % --- Executes during object creation, after setting all properties.
  778. function LTargHt_CreateFcn(hObject, eventdata, handles)
  779. % hObject handle to LTargHt (see GCBO)
  780. % eventdata reserved - to be defined in a future version of MATLAB
  781. % handles empty - handles not created until after all CreateFcns called
  782. % Hint: edit controls usually have a white background on Windows.
  783. % See ISPC and COMPUTER.
  784. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  785. set(hObject,'BackgroundColor','white');
  786. end
  787. function ScrDist_Callback(hObject, eventdata, handles)
  788. % hObject handle to ScrDist (see GCBO)
  789. % eventdata reserved - to be defined in a future version of MATLAB
  790. % handles structure with handles and user data (see GUIDATA)
  791. % Hints: get(hObject,'String') returns contents of ScrDist as text
  792. % str2double(get(hObject,'String')) returns contents of ScrDist as a double
  793. global Par
  794. Val = str2double(get(hObject,'String')); %returns contents as a double
  795. if ~isnan(Val) && Val > 0
  796. Par.DistanceToScreen = Val;
  797. Par.PixPerDeg = Par.HW/atand(Par.ScreenWidthD2/Val);
  798. set(handles.PixDeg, 'String', num2str(Par.PixPerDeg) )
  799. % TargSz = Par.TargSzDeg * Par.PixPerDeg;
  800. % FixSz = Par.FixSzDeg * Par.PixPerDeg;
  801. for i = 1:size(Par.WIN,2)
  802. if Par.WIN(5,i) == 0 %fix window == 0
  803. Par.WIN(3,i) = Par.FixWdDeg * Par.PixPerDeg; %width
  804. Par.WIN(4,i) = Par.FixHtDeg * Par.PixPerDeg; %height
  805. elseif Par.WIN(5,i) == 1 || Par.WIN(5,i) == 2 %target window == 2
  806. Par.WIN(3,i) = Par.TargWdDeg * Par.PixPerDeg; %width
  807. Par.WIN(4,i) = Par.TargHtDeg * Par.PixPerDeg; %heigth
  808. end
  809. end
  810. else
  811. errordlg('Invalid input');
  812. end
  813. % --- Executes during object creation, after setting all properties.
  814. function ScrDist_CreateFcn(hObject, eventdata, handles)
  815. % hObject handle to ScrDist (see GCBO)
  816. % eventdata reserved - to be defined in a future version of MATLAB
  817. % handles empty - handles not created until after all CreateFcns called
  818. % Hint: edit controls usually have a white background on Windows.
  819. % See ISPC and COMPUTER.
  820. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  821. set(hObject,'BackgroundColor','white');
  822. end
  823. function ScrWid_Callback(hObject, eventdata, handles)
  824. % hObject handle to ScrWid (see GCBO)
  825. % eventdata reserved - to be defined in a future version of MATLAB
  826. % handles structure with handles and user data (see GUIDATA)
  827. % Hints: get(hObject,'String') returns contents of ScrWid as text
  828. % str2double(get(hObject,'String')) returns contents of ScrWid as a double
  829. global Par
  830. Val = str2double(get(hObject,'String')); %returns contents as a double
  831. if ~isnan(Val) && Val > 0
  832. Par.ScreenWidthD2 = Val/2;
  833. Par.PixPerDeg = Par.HW/atand(Par.ScreenWidthD2/Par.DistanceToScreen);
  834. set(handles.PixDeg, 'String', num2str(Par.PixPerDeg) )
  835. % TargSz = Par.TargSzDeg * Par.PixPerDeg;
  836. % FixSz = Par.FixWdDeg * Par.PixPerDeg;
  837. for i = 1:size(Par.WIN,2)
  838. if Par.WIN(5,i) == 0 %fix window == 0
  839. Par.WIN(3,i) = Par.FixWdDeg * Par.PixPerDeg; %width
  840. Par.WIN(4,i) = Par.FixHtDeg * Par.PixPerDeg;%height
  841. elseif Par.WIN(5,i) == 1 || Par.WIN(5,i) == 2 %target window == 2
  842. Par.WIN(3,i) = Par.TargWdDeg * Par.PixPerDeg; %width
  843. Par.WIN(4,i) = Par.TargHtDeg * Par.PixPerDeg;
  844. end
  845. end
  846. else
  847. errordlg('Invalid input');
  848. end
  849. % --- Executes during object creation, after setting all properties.
  850. function ScrWid_CreateFcn(hObject, eventdata, handles)
  851. % hObject handle to ScrWid (see GCBO)
  852. % eventdata reserved - to be defined in a future version of MATLAB
  853. % handles empty - handles not created until after all CreateFcns called
  854. % Hint: edit controls usually have a white background on Windows.
  855. % See ISPC and COMPUTER.
  856. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  857. set(hObject,'BackgroundColor','white');
  858. end
  859. % --- Executes during object creation, after setting all properties.
  860. function PixDeg_CreateFcn(hObject, eventdata, handles)
  861. % hObject handle to PixDeg (see GCBO)
  862. % eventdata reserved - to be defined in a future version of MATLAB
  863. % handles empty - handles not created until after all CreateFcns called
  864. % Hint: edit controls usually have a white background on Windows.
  865. % See ISPC and COMPUTER.
  866. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  867. set(hObject,'BackgroundColor','white');
  868. end
  869. function Updatetimeaxes(handles)
  870. global Par
  871. axes(handles.axes_timing);
  872. cla
  873. Times = Par.Times;
  874. plot([-(Times.ToFix + Times.Fix) -Times.Fix], [0 0], 'Color', [0.75 0.75 0.75], 'LineWidth', 10)
  875. hold on
  876. if numel(Par.Times.Targ)==1
  877. set(handles.TargT, 'String', num2str(Par.Times.Targ, 4))
  878. else
  879. set(handles.TargT, 'String', num2str(Par.Times.Targ(1,2), 4))
  880. end
  881. if numel(Par.Times.Targ)==1
  882. plot([ -Times.Fix Times.Targ], [0 0], 'LineWidth', 10, 'Color', [0 0.75 0.75])
  883. plot([Times.Targ Times.Targ + Par.Times.Rt], [0 0], 'LineWidth', 10, 'Color', [0.75 0.75 0])
  884. plot([Times.Targ + Par.Times.Rt Times.Targ + Par.Times.Rt+Times.InterTrial], ...
  885. [0 0], 'Color', [0.5 0.5 0.5], 'LineWidth', 10)
  886. else
  887. plot([ -Times.Fix Times.Targ(1,2)], [0 0], 'LineWidth', 10, 'Color', [0 0.75 0.75])
  888. plot([Times.Targ(1,2) Times.Targ(1,2) + Par.Times.Rt], [0 0], 'LineWidth', 10, 'Color', [0.75 0.75 0])
  889. plot([Times.Targ(1,2) + Par.Times.Rt Times.Targ(1,2) + Par.Times.Rt+Times.InterTrial], ...
  890. [0 0], 'Color', [0.5 0.5 0.5], 'LineWidth', 10)
  891. end
  892. plot([ 0 Times.Stim], [0 0], 'k', 'LineWidth', 5)
  893. line([-Times.Fix -Times.Fix], [-0.1 1])
  894. text(-Times.Fix, 0.2, 'Fix')
  895. line([0 0], [-0.1 1])
  896. text(0, 0.4, 'Stim')
  897. if numel(Par.Times.Targ)==1
  898. line([Times.Targ Times.Targ], [-0.1 1])
  899. text(Times.Targ, 0.6, 'Targ')
  900. else
  901. line([Times.Targ(1,2) Times.Targ(1,2)], [-0.1 1])
  902. text(Times.Targ(1,2), 0.6, 'Targ')
  903. end
  904. % POS = get(handles.figure1, 'Position');
  905. lgnd1 = legend('Fix\_wait duration', 'Fixation time', 'Reaction time', 'Intertrial time', 'Stim\_on time');
  906. set(lgnd1,'Units','characters','Position', [5 14 30 8]);
  907. xlabel('time(ms)')
  908. set(handles.axes_timing, 'YLim', [-0.1 1])
  909. set(handles.axes_timing, 'YTick', [], 'YTickLabel', '')
  910. axes(handles.axes1);
  911. % --------------------------------------------------------------------
  912. function M_Con_Callback(hObject, eventdata, handles)
  913. % hObject handle to M_Con (see GCBO)
  914. % eventdata reserved - to be defined in a future version of MATLAB
  915. % handles structure with handles and user data (see GUIDATA)
  916. % --------------------------------------------------------------------
  917. function I_Bezier_Callback(hObject, eventdata, handles)
  918. % hObject handle to I_Bezier (see GCBO)
  919. % eventdata reserved - to be defined in a future version of MATLAB
  920. % handles structure with handles and user data (see GUIDATA)
  921. % --- Executes on button press in RB_Sqr.
  922. function RB_Sqr_Callback(hObject, eventdata, handles)
  923. % hObject handle to RB_Sqr (see GCBO)
  924. % eventdata reserved - to be defined in a future version of MATLAB
  925. % handles structure with handles and user data (see GUIDATA)
  926. % Hint: get(hObject,'Value') returns toggle state of RB_Sqr
  927. global Par
  928. Par.Bsqr = get(hObject,'Value');
  929. function e_RndFix_Callback(hObject, eventdata, handles)
  930. % hObject handle to e_RndFix (see GCBO)
  931. % eventdata reserved - to be defined in a future version of MATLAB
  932. % handles structure with handles and user data (see GUIDATA)
  933. % Hints: get(hObject,'String') returns contents of e_RndFix as text
  934. % str2double(get(hObject,'String')) returns contents of e_RndFix as a double
  935. global Par
  936. Val = str2double(get(hObject,'String'));
  937. if ~isnan(Val)
  938. Par.Times.RndFix = Val;
  939. else
  940. errordlg('Invalid input');
  941. end
  942. % --- Executes during object creation, after setting all properties.
  943. function e_RndFix_CreateFcn(hObject, eventdata, handles)
  944. % hObject handle to e_RndFix (see GCBO)
  945. % eventdata reserved - to be defined in a future version of MATLAB
  946. % handles empty - handles not created until after all CreateFcns called
  947. % Hint: edit controls usually have a white background on Windows.
  948. % See ISPC and COMPUTER.
  949. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  950. set(hObject,'BackgroundColor','white');
  951. end
  952. function e_RndStim_Callback(hObject, eventdata, handles)
  953. % hObject handle to e_RndStim (see GCBO)
  954. % eventdata reserved - to be defined in a future version of MATLAB
  955. % handles structure with handles and user data (see GUIDATA)
  956. % Hints: get(hObject,'String') returns contents of e_RndStim as text
  957. % str2double(get(hObject,'String')) returns contents of e_RndStim as a double
  958. global Par
  959. Val = str2double(get(hObject,'String'));
  960. if ~isnan(Val) && Val >= 0
  961. Par.Times.RndStim = Val;
  962. else
  963. errordlg('Invalid input');
  964. end
  965. % --- Executes during object creation, after setting all properties.
  966. function e_RndStim_CreateFcn(hObject, eventdata, handles)
  967. % hObject handle to e_RndStim (see GCBO)
  968. % eventdata reserved - to be defined in a future version of MATLAB
  969. % handles empty - handles not created until after all CreateFcns called
  970. % Hint: edit controls usually have a white background on Windows.
  971. % See ISPC and COMPUTER.
  972. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  973. set(hObject,'BackgroundColor','white');
  974. end
  975. function e_RndTarg_Callback(hObject, eventdata, handles)
  976. % hObject handle to e_RndTarg (see GCBO)
  977. % eventdata reserved - to be defined in a future version of MATLAB
  978. % handles structure with handles and user data (see GUIDATA)
  979. % Hints: get(hObject,'String') returns contents of e_RndTarg as text
  980. % str2double(get(hObject,'String')) returns contents of e_RndTarg as a double
  981. global Par
  982. Val = str2double(get(hObject,'String'));
  983. if ~isnan(Val) && Val >= 0
  984. Par.Times.RndTarg = Val;
  985. else
  986. errordlg('Invalid input');
  987. end
  988. % --- Executes during object creation, after setting all properties.
  989. function e_RndTarg_CreateFcn(hObject, eventdata, handles)
  990. % hObject handle to e_RndTarg (see GCBO)
  991. % eventdata reserved - to be defined in a future version of MATLAB
  992. % handles empty - handles not created until after all CreateFcns called
  993. % Hint: edit controls usually have a white background on Windows.
  994. % See ISPC and COMPUTER.
  995. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  996. set(hObject,'BackgroundColor','white');
  997. end
  998. function e_Err_Callback(hObject, eventdata, handles)
  999. % hObject handle to e_Err (see GCBO)
  1000. % eventdata reserved - to be defined in a future version of MATLAB
  1001. % handles structure with handles and user data (see GUIDATA)
  1002. % Hints: get(hObject,'String') returns contents of e_Err as text
  1003. % str2double(get(hObject,'String')) returns contents of e_Err as a double
  1004. global Par
  1005. Val = str2double(get(hObject,'String'));
  1006. if ~isnan(Val)
  1007. Par.Times.Err = Val;
  1008. else
  1009. errordlg('Invalid input');
  1010. end
  1011. % --- Executes during object creation, after setting all properties.
  1012. function e_Err_CreateFcn(hObject, eventdata, handles)
  1013. % hObject handle to e_Err (see GCBO)
  1014. % eventdata reserved - to be defined in a future version of MATLAB
  1015. % handles empty - handles not created until after all CreateFcns called
  1016. % Hint: edit controls usually have a white background on Windows.
  1017. % See ISPC and COMPUTER.
  1018. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1019. set(hObject,'BackgroundColor','white');
  1020. end
  1021. function e_Sacc_Callback(hObject, eventdata, handles)
  1022. % hObject handle to e_Sacc (see GCBO)
  1023. % eventdata reserved - to be defined in a future version of MATLAB
  1024. % handles structure with handles and user data (see GUIDATA)
  1025. % Hints: get(hObject,'String') returns contents of e_Sacc as text
  1026. % str2double(get(hObject,'String')) returns contents of e_Sacc as a double
  1027. global Par
  1028. Val = str2double(get(hObject,'String'));
  1029. if ~isnan(Val)
  1030. Par.Times.Sacc = Val;
  1031. else
  1032. errordlg('Invalid input');
  1033. end
  1034. % --- Executes during object creation, after setting all properties.
  1035. function e_Sacc_CreateFcn(hObject, eventdata, handles)
  1036. % hObject handle to e_Sacc (see GCBO)
  1037. % eventdata reserved - to be defined in a future version of MATLAB
  1038. % handles empty - handles not created until after all CreateFcns called
  1039. % Hint: edit controls usually have a white background on Windows.
  1040. % See ISPC and COMPUTER.
  1041. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1042. set(hObject,'BackgroundColor','white');
  1043. end
  1044. % --- Executes on button press in rb_Drum.
  1045. function rb_Drum_Callback(hObject, eventdata, handles)
  1046. % hObject handle to rb_Drum (see GCBO)
  1047. % eventdata reserved - to be defined in a future version of MATLAB
  1048. % handles structure with handles and user data (see GUIDATA)
  1049. global Par
  1050. Par.Drum = get(hObject,'Value'); %returns toggle state of rb_Drum
  1051. % --- Executes on button press in PB_Test.
  1052. function PB_Test_Callback(hObject, eventdata, handles)
  1053. % hObject handle to PB_Test (see GCBO)
  1054. % eventdata reserved - to be defined in a future version of MATLAB
  1055. % handles structure with handles and user data (see GUIDATA)
  1056. global Par
  1057. if isfield(handles, 'DasOn') && handles.DasOn
  1058. set(hObject, 'BackgroundColor', [0.5 0.6 0.9])
  1059. Par.isRunning = true;
  1060. axes( handles.axes1);
  1061. Par.ESC = false; %escape has not been pressed
  1062. Par.Updatxy = 1;
  1063. while ~Par.ESC
  1064. pause(0.05)
  1065. DasCheck; %retrieve position values and plot on Control display
  1066. end
  1067. Par.Updatxy = 0;
  1068. end
  1069. Par.isRunning = false;
  1070. set(hObject, 'BackgroundColor', [0.925 0.914 0.847])
  1071. % --- Executes on button press in TB_x.
  1072. function TB_x_Callback(hObject, eventdata, handles)
  1073. % hObject handle to TB_x (see GCBO)
  1074. % eventdata reserved - to be defined in a future version of MATLAB
  1075. % handles structure with handles and user data (see GUIDATA)
  1076. % Hint: get(hObject,'Value') returns toggle state of TB_x
  1077. global Par
  1078. if Par.xdir == 1
  1079. Par.xdir = -1;
  1080. else
  1081. Par.xdir = 1;
  1082. end
  1083. set(hObject, 'String', ['x*' num2str(Par.xdir, 1)])
  1084. % --- Executes on button press in TB_y.
  1085. function TB_y_Callback(hObject, eventdata, handles)
  1086. % hObject handle to TB_y (see GCBO)
  1087. % eventdata reserved - to be defined in a future version of MATLAB
  1088. % handles structure with handles and user data (see GUIDATA)
  1089. % Hint: get(hObject,'Value') returns toggle state of TB_y
  1090. global Par
  1091. if Par.ydir == 1
  1092. Par.ydir = -1;
  1093. else
  1094. Par.ydir = 1;
  1095. end
  1096. set(hObject, 'String', ['y*' num2str(Par.ydir, 1)])
  1097. function E_RGB_Callback(hObject, eventdata, handles)
  1098. % hObject handle to E_RGB (see GCBO)
  1099. % eventdata reserved - to be defined in a future version of MATLAB
  1100. % handles structure with handles and user data (see GUIDATA)
  1101. % Hints: get(hObject,'String') returns contents of E_RGB as text
  1102. % str2double(get(hObject,'String')) returns contents of E_RGB as a double
  1103. global Par
  1104. STR = get(hObject,'String');
  1105. strexp = '\d\.\d|\d(?!\d)';
  1106. RGBSTR = regexp(STR, strexp, 'match');
  1107. RGB = zeros(3,1);
  1108. if length(RGBSTR) == 3
  1109. for i = 1:3
  1110. RGB(i) = str2double(RGBSTR{i});
  1111. if RGB(i) > 1.0 || RGB(i) < 0.0
  1112. errordlg('Invalid input')
  1113. return
  1114. end
  1115. end
  1116. Par.BG = RGB;
  1117. else
  1118. errordlg('Invalid input')
  1119. end
  1120. % --- Executes during object creation, after setting all properties.
  1121. function E_RGB_CreateFcn(hObject, eventdata, handles)
  1122. % hObject handle to E_RGB (see GCBO)
  1123. % eventdata reserved - to be defined in a future version of MATLAB
  1124. % handles empty - handles not created until after all CreateFcns called
  1125. % Hint: edit controls usually have a white background on Windows.
  1126. % See ISPC and COMPUTER.
  1127. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1128. set(hObject,'BackgroundColor','white');
  1129. end
  1130. % --- Executes on button press in rb_SCALE.
  1131. function rb_SCALE_Callback(hObject, eventdata, handles)
  1132. % hObject handle to rb_SCALE (see GCBO)
  1133. % eventdata reserved - to be defined in a future version of MATLAB
  1134. % handles structure with handles and user data (see GUIDATA)
  1135. % Hint: get(hObject,'Value') returns toggle state of rb_SCALE
  1136. global Par
  1137. Par.MousePress = 0;
  1138. % --- Executes on button press in rb_SHIFT.
  1139. function rb_SHIFT_Callback(hObject, eventdata, handles)
  1140. % hObject handle to rb_SHIFT (see GCBO)
  1141. % eventdata reserved - to be defined in a future version of MATLAB
  1142. % handles structure with handles and user data (see GUIDATA)
  1143. % Hint: get(hObject,'Value') returns toggle state of rb_SHIFT
  1144. global Par
  1145. Par.MousePress = 2;
  1146. % --------------------------------------------------------------------
  1147. function EXIT_Callback(hObject, eventdata, handles)
  1148. % hObject handle to EXIT (see GCBO)
  1149. % eventdata reserved - to be defined in a future version of MATLAB
  1150. % handles structure with handles and user data (see GUIDATA)
  1151. global Par
  1152. global Control
  1153. if Par.isRunning == true
  1154. button = questdlg('Did your runstim crash','Alert','Yes');
  1155. if strcmp(button, 'Yes')
  1156. Par.isRunning = false;
  1157. %poststim
  1158. poststim_ptb
  1159. delete(handles.figure1);
  1160. end
  1161. else
  1162. poststim_ptb
  1163. %delete(handles.figure1);
  1164. %poststim
  1165. end
  1166. % --------------------------------------------------------------------
  1167. function MI_Stim_Callback(hObject, eventdata, handles)
  1168. % hObject handle to MI_Stim (see GCBO)
  1169. % eventdata reserved - to be defined in a future version of MATLAB
  1170. % handles structure with handles and user data (see GUIDATA)
  1171. SG = Stimgui;
  1172. PS = get(SG, 'Position');
  1173. FPos = get(handles.figure1, 'Position');
  1174. % SPos = get(handles.figure1, 'Position');
  1175. PS = [FPos(1)+10 PS(2:4)];
  1176. set(SG, 'Position', PS);
  1177. % --------------------------------------------------------------------
  1178. function MI_MonkeName_Callback(hObject, eventdata, handles)
  1179. % hObject handle to MI_MonkeyName (see GCBO)
  1180. % eventdata reserved - to be defined in a future version of MATLAB
  1181. % handles structure with handles and user data (see GUIDATA)
  1182. global Par
  1183. FSTR = uigetfile('*.m');
  1184. StrPth = which(FSTR);
  1185. if strcmp(StrPth, '')
  1186. errordlg('This function is not in the matlab path')
  1187. else
  1188. button = questdlg({StrPth, '', 'Is this the function you want to use.?'},'Confirm');
  1189. if strcmp(button, 'Yes')
  1190. Str = regexp(FSTR, '\w*', 'match');
  1191. Par.RUNFUNC = Str{1};
  1192. handles.RUNFUNC = str2func(Par.RUNFUNC);
  1193. % Update handles structure
  1194. guidata(hObject, handles);
  1195. set(handles.T_RUN, 'String', Par.RUNFUNC);
  1196. end
  1197. end
  1198. % --------------------------------------------------------------------
  1199. function MI_ExpFolder_Callback(hObject, eventdata, handles)
  1200. % hObject handle to MI_ExpFolder (see GCBO)
  1201. % eventdata reserved - to be defined in a future version of MATLAB
  1202. % handles structure with handles and user data (see GUIDATA)
  1203. global Par
  1204. % go to root folder
  1205. cd(Par.StartFolder);
  1206. % remove current folders from path
  1207. OldExpFolder = Par.ExpFolder;
  1208. Par.ExpFolder=0;
  1209. % carryover the current monkey name
  1210. CurrMonkey = Par.MONKEY;
  1211. % get new folder
  1212. cd TRACKER_PTB
  1213. while ~Par.ExpFolder
  1214. Par.ExpFolder=uigetdir(pwd,...
  1215. 'Choose your experiment root-folder (contains Engine & Experiment folders)');
  1216. end
  1217. warning off
  1218. rmpath(genpath(OldExpFolder));
  1219. warning on
  1220. % close tracker
  1221. close(Par.hTracker);
  1222. % Add stuff to the path
  1223. addpath(genpath(Par.ExpFolder));
  1224. % Go to folder
  1225. cd(Par.ExpFolder);
  1226. % Run tracker
  1227. Par.hTracker = tracker_CK;
  1228. Par.hTracker_ax = findobj(Par.hTracker,'Tag','axes1');
  1229. if strcmp(Par.tracker_version, 'tracker_dark')
  1230. set(Par.hTracker_ax,'Color','k');
  1231. end
  1232. Par.MONKEY = CurrMonkey;
  1233. % --------------------------------------------------------------------
  1234. function MI_StimSettings_Callback(hObject, eventdata, handles)
  1235. % hObject handle to MI_ExpFolder (see GCBO)
  1236. % eventdata reserved - to be defined in a future version of MATLAB
  1237. % handles structure with handles and user data (see GUIDATA)
  1238. global Par
  1239. % go to Exp folder
  1240. cd Experiment
  1241. cd StimSettings
  1242. % get StimSettings file
  1243. StimSetSel=false;
  1244. while ~exist('FSTR') || ~StimSetSel
  1245. FSTR = uigetfile('*.m','Choose a StimSettings file');
  1246. if FSTR
  1247. StimSetSel=true;
  1248. end
  1249. end
  1250. StrPth = which(FSTR);
  1251. cd ..
  1252. cd ..
  1253. if strcmp(StrPth, '')
  1254. errordlg('This file is not in the matlab path')
  1255. else
  1256. button = questdlg({StrPth, '', 'Is this the file you want to use?'},'Confirm');
  1257. if strcmp(button, 'Yes')
  1258. Str = regexp(FSTR, '\w*', 'match');
  1259. Par.STIMSETFILE = Str{1};
  1260. end
  1261. end
  1262. % --------------------------------------------------------------------
  1263. function MI_MonkeyName_Callback(hObject, eventdata, handles)
  1264. % hObject handle to MI_ExpFolder (see GCBO)
  1265. % eventdata reserved - to be defined in a future version of MATLAB
  1266. % handles structure with handles and user data (see GUIDATA)
  1267. global Par
  1268. %get the monkeyname
  1269. FSTR = inputdlg('Specify monkey name','Monkey Name',1,{Par.MONKEY});
  1270. Par.MONKEY = FSTR{1};
  1271. % --------------------------------------------------------------------
  1272. function MI_ParSettings_Callback(hObject, eventdata, handles)
  1273. % hObject handle to MI_ExpFolder (see GCBO)
  1274. % eventdata reserved - to be defined in a future version of MATLAB
  1275. % handles structure with handles and user data (see GUIDATA)
  1276. global Par
  1277. % go to Exp folder
  1278. cd Experiment
  1279. cd ParSettings
  1280. % get ParSettings file
  1281. ParSetSel=false;
  1282. while ~exist('FSTR') || ~ParSetSel
  1283. FSTR = uigetfile('*.m','Choose a ParSettings file');
  1284. if FSTR
  1285. ParSetSel=true;
  1286. end
  1287. end
  1288. StrPth = which(FSTR);
  1289. cd ..
  1290. cd ..
  1291. if strcmp(StrPth, '')
  1292. errordlg('This file is not in the matlab path')
  1293. else
  1294. button = questdlg({StrPth, '', 'Is this the file you want to use?'},'Confirm');
  1295. if strcmp(button, 'Yes')
  1296. Str = regexp(FSTR, '\w*', 'match');
  1297. Par.PARSETFILE = Str{1};
  1298. end
  1299. end
  1300. % --------------------------------------------------------------------
  1301. function UPDATE_Callback(hObject, eventdata, handles)
  1302. % hObject handle to UPDATE (see GCBO)
  1303. % eventdata reserved - to be defined in a future version of MATLAB
  1304. % handles structure with handles and user data (see GUIDATA)
  1305. pad = which( 'Trackerupdates.html');
  1306. web(pad)
  1307. % --- Executes on button press in Mouse.
  1308. function Mouse_Callback(hObject, eventdata, handles)
  1309. % hObject handle to Mouse (see GCBO)
  1310. % eventdata reserved - to be defined in a future version of MATLAB
  1311. % handles structure with handles and user data (see GUIDATA)
  1312. global Par
  1313. val = get(hObject, 'Value');
  1314. if(val >= 1)
  1315. Par.Mouserun = 1;
  1316. % set(hObject, 'Value', 0);
  1317. else
  1318. Par.Mouserun = 0;
  1319. % calllib(Par.Dll, 'Use_Mouse', 0);
  1320. dasusemouse( 0 );
  1321. % set(hObject, 'Value', 1);
  1322. end
  1323. % --- Executes when user attempts to close figure1.
  1324. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  1325. % hObject handle to figure1 (see GCBO)
  1326. % eventdata reserved - to be defined in a future version of MATLAB
  1327. % handles structure with handles and user data (see GUIDATA)
  1328. % Hint: delete(hObject) closes the figure
  1329. %delete(hObject);
  1330. % global Par
  1331. %
  1332. % if Par.isRunning == true
  1333. % errordlg('Please stop running first')
  1334. % return
  1335. % end
  1336. % poststim
  1337. % delete(hObject);
  1338. % --- Executes during object deletion, before destroying properties.
  1339. function figure1_DeleteFcn(hObject, eventdata, handles)
  1340. % hObject handle to figure1 (see GCBO)
  1341. % eventdata reserved - to be defined in a future version of MATLAB
  1342. % handles structure with handles and user data (see GUIDATA)
  1343. % global Par
  1344. %
  1345. % if Par.isRunning == true
  1346. % errordlg('Please stop running first')
  1347. % return
  1348. % end
  1349. % poststim
  1350. % delete(hObject);
  1351. % --- Executes on button press in OnOFF_noise.
  1352. function OnOFF_noise_Callback(hObject, eventdata, handles)
  1353. % hObject handle to OnOFF_noise (see GCBO)
  1354. % eventdata reserved - to be defined in a future version of MATLAB
  1355. % handles structure with handles and user data (see GUIDATA)
  1356. global Par
  1357. if Par.NoiseUpdate == 1
  1358. Par.NoiseUpdate = 0;
  1359. dassetnoise(0)
  1360. set(hObject, 'BackgroundColor', [0.83 0.82 0.78])
  1361. else
  1362. Par.NoiseUpdate = 1;
  1363. dassetnoise(1)
  1364. set(hObject, 'BackgroundColor', [1.0 0.95 0.87])
  1365. end
  1366. % --- Executes on button press in RewHIB.
  1367. function RewHIB_Callback(hObject, eventdata, handles)
  1368. % hObject handle to RewHIB (see GCBO)
  1369. % eventdata reserved - to be defined in a future version of MATLAB
  1370. % handles structure with handles and user data (see GUIDATA)
  1371. global Par
  1372. % Hint: get(hObject,'Value') returns toggle state of RewHIB
  1373. if get(hObject,'Value') == true
  1374. Par.RewNeedsHandInBox = true;
  1375. else
  1376. Par.RewNeedsHandInBox = false;
  1377. end
  1378. % --- Executes on button press in StimHIB.
  1379. function StimHIB_Callback(hObject, eventdata, handles)
  1380. % hObject handle to StimHIB (see GCBO)
  1381. % eventdata reserved - to be defined in a future version of MATLAB
  1382. % handles structure with handles and user data (see GUIDATA)
  1383. global Par
  1384. % Hint: get(hObject,'Value') returns toggle state of StimHIB
  1385. if get(hObject,'Value') == true
  1386. Par.StimNeedsHandInBox = true;
  1387. else
  1388. Par.StimNeedsHandInBox = false;
  1389. end
  1390. % --- Executes on button press in FixHIB.
  1391. function FixHIB_Callback(hObject, eventdata, handles)
  1392. % hObject handle to FixHIB (see GCBO)
  1393. % eventdata reserved - to be defined in a future version of MATLAB
  1394. % handles structure with handles and user data (see GUIDATA)
  1395. global Par
  1396. % Hint: get(hObject,'Value') returns toggle state of FixHIB
  1397. if get(hObject,'Value') == true
  1398. Par.FixNeedsHandInBox = true;
  1399. else
  1400. Par.FixNeedsHandInBox = false;
  1401. end
  1402. % --- Executes on button press in SecFixCol.
  1403. function SecFixCol_Callback(hObject, eventdata, handles)
  1404. % hObject handle to SecFixCol (see GCBO)
  1405. % eventdata reserved - to be defined in a future version of MATLAB
  1406. % handles structure with handles and user data (see GUIDATA)
  1407. global Par
  1408. % Hint: get(hObject,'Value') returns toggle state of SecFixCol
  1409. if get(hObject,'Value') == true
  1410. Par.RewardFixFeedBack = true;
  1411. else
  1412. Par.RewardFixFeedBack = false;
  1413. end
  1414. % --- Executes on button press in AutoDim.
  1415. function AutoDim_Callback(hObject, eventdata, handles)
  1416. % hObject handle to AutoDim (see GCBO)
  1417. % eventdata reserved - to be defined in a future version of MATLAB
  1418. % handles structure with handles and user data (see GUIDATA)
  1419. global Par
  1420. % Hint: get(hObject,'Value') returns toggle state of SecFixCol
  1421. if get(hObject,'Value') == true
  1422. Par.HandOutDimsScreen = true;
  1423. else
  1424. Par.HandOutDimsScreen = false;
  1425. end
  1426. function AutoDimPerc_Callback(hObject, eventdata, handles)
  1427. % hObject handle to AutoDimPerc (see GCBO)
  1428. % eventdata reserved - to be defined in a future version of MATLAB
  1429. % handles structure with handles and user data (see GUIDATA)
  1430. global Par
  1431. % Hints: get(hObject,'String') returns contents of AutoDimPerc as text
  1432. % str2double(get(hObject,'String')) returns contents of AutoDimPerc as a double
  1433. Val = str2double(get(hObject,'String'));
  1434. Par.HandOutDimsScreen_perc = Val;
  1435. % --- Executes during object creation, after setting all properties.
  1436. function AutoDimPerc_CreateFcn(hObject, eventdata, handles)
  1437. % hObject handle to AutoDimPerc (see GCBO)
  1438. % eventdata reserved - to be defined in a future version of MATLAB
  1439. % handles empty - handles not created until after all CreateFcns called
  1440. % Hint: edit controls usually have a white background on Windows.
  1441. % See ISPC and COMPUTER.
  1442. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1443. set(hObject,'BackgroundColor','white');
  1444. end
  1445. % --------------------------------------------------------------------
  1446. function view_Callback(hObject, eventdata, handles)
  1447. % hObject handle to view (see GCBO)
  1448. % eventdata reserved - to be defined in a future version of MATLAB
  1449. % handles structure with handles and user data (see GUIDATA)
  1450. % --------------------------------------------------------------------
  1451. function darkmode_Callback(hObject, eventdata, handles)
  1452. % hObject handle to darkmode (see GCBO)
  1453. % eventdata reserved - to be defined in a future version of MATLAB
  1454. % handles structure with handles and user data (see GUIDATA)
  1455. global Par
  1456. set(Par.hTracker_ax,'Color','k');
  1457. Par.tracker_version = 'tracker_dark';
  1458. recolortracker;
  1459. % --------------------------------------------------------------------
  1460. function lightmode_Callback(hObject, eventdata, handles)
  1461. % hObject handle to lightmode (see GCBO)
  1462. % eventdata reserved - to be defined in a future version of MATLAB
  1463. % handles structure with handles and user data (see GUIDATA)
  1464. global Par
  1465. set(Par.hTracker_ax,'Color','w');
  1466. Par.tracker_version = 'default';
  1467. recolortracker;