Skip to content

Commit 5eb29f8

Browse files
committed
improve help sections
1 parent f012d2a commit 5eb29f8

File tree

6 files changed

+51
-31
lines changed

6 files changed

+51
-31
lines changed

cleanUp.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function cleanUp
2+
% A wrapper function to close all windows, ports, show mouse cursor, close keyboard queues
3+
% and give access back to the keyboards.
24

35
WaitSecs(0.5);
46

@@ -24,5 +26,5 @@
2426

2527
close all
2628

27-
29+
2830
end

deg2Pix.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
function structure = deg2Pix(fieldName, structure, Cfg)
1+
function structure = deg2Pix(fieldName, structure, cfg)
2+
% For a given field value in degrees of visual angle in the structure,
3+
% this computes its value in pixel using the pixel per degree value of the cfg structure
4+
% and returns a structure with an additional field with Pix suffix holding that new value.
25

36
deg = getfield( structure, fieldName);
47

58
structure = setfield( structure, [fieldName 'Pix'], ...
6-
floor(Cfg.ppd * deg) ) ;
9+
floor(cfg.ppd * deg) ) ;
710

8-
end
11+
end

drawFixationCross.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
function drawFixationCross(Cfg, ExpParameters, color)
1+
function drawFixationCross(cfg, expParameters, color)
2+
% Define the parameters of the fixation cross in `cfg` and `expParameters` and this does the rest.
23

34
Screen('DrawLines', ...
4-
Cfg.win, ...
5-
Cfg.allCoords, ...
6-
ExpParameters.lineWidthPix, ...
5+
cfg.win, ...
6+
cfg.allCoords, ...
7+
expParameters.lineWidthPix, ...
78
color , ...
8-
[Cfg.center(1) Cfg.center(2)], 1);
9+
[cfg.center(1) cfg.center(2)], 1);
910

10-
end
11+
end

initPTB.m

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
function [cfg] = initPTB(cfg)
2-
% This seems a good candidate function to have as a common function across
3-
% experiments
4-
% We might want to add a couple of IF in case the experiment does not use
5-
% audio for example.
2+
% This will initialize PsychToolBox
3+
% - screen
4+
% - the windon opened takes the whole screen by default
5+
% - set in debug mode with window transparency if necessary
6+
% - can skip synch test if you ask for it (nicely)
7+
% - gets the flip interval
8+
% - computes the pixel per degree of visual angle
9+
% - set font details
10+
% - keyboard
11+
% - sound
12+
13+
14+
% TO DO
15+
% - We might want to add a couple of IF in case the experiment does not use audio for example.
16+
% - the computation for ppd assumes the windows takes the whole screenDistance
17+
% - refactor the window opening section (pass the window size as argument)
618

719
checkDependencies()
820

@@ -57,12 +69,12 @@
5769

5870
% init PTB with different options in concordance to the Debug Parameters
5971
if cfg.debug
60-
72+
6173
% set to one because we don not care about time
6274
Screen('Preference', 'SkipSyncTests', 2);
6375
Screen('Preference', 'Verbosity', 0);
6476
Screen('Preferences', 'SuppressAllWarnings', 2);
65-
77+
6678
if cfg.testingSmallScreen
6779
[cfg.win, cfg.winRect] = PsychImaging('OpenWindow', cfg.screen, cfg.backgroundColor, [0,0, 480, 270]);
6880
else
@@ -71,11 +83,11 @@
7183
end
7284
[cfg.win, cfg.winRect] = PsychImaging('OpenWindow', cfg.screen, cfg.backgroundColor);
7385
end
74-
86+
7587
else
7688
Screen('Preference','SkipSyncTests', 0);
7789
[cfg.win, cfg.winRect] = PsychImaging('OpenWindow', cfg.screen, cfg.backgroundColor);
78-
90+
7991
end
8092

8193

pressSpace4me.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
function pressSpace4me
2+
% Use that to stop your script and only restart when the space bar is pressed.
23

34
fprintf('\npress space to continue\n');
45

56
while 1
67

78
WaitSecs(0.1);
8-
9+
910
[~, keyCode, ~] = KbWait(-1);
10-
11+
1112
responseKey = KbName(find(keyCode));
12-
13+
1314
if strcmp(responseKey,'space')
1415
fprintf('starting the experiment....\n');
1516
break
1617
end
17-
18-
end
1918

2019
end
2120

21+
end

testKeyboards.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function testKeyboards(cfg)
2+
% Checks that the keyboards asked for properly connected.
3+
% If no key is pressed on the correct keyboard after the timeOut time this exits with an error.
24

35
timeOut = 5;
46

@@ -40,25 +42,25 @@ function throwError(keyCode, deviceNumber, keyboardType)
4042

4143

4244
if all(keyCode==0)
43-
45+
4446
% Give me my keyboard back... Pretty please.
4547
ListenChar();
46-
48+
4749
fprintf(text1);
48-
50+
4951
if isempty(deviceNumber)
5052
disp(' - no keyboard selected, default is the main keyboard')
5153
else
5254
disp(deviceNumber)
5355
end
54-
56+
5557
fprintf(text2);
56-
58+
5759
[keyboardNumbers, keyboardNames] = GetKeyboardIndices %#ok<*NOPRT,*ASGLU>
58-
60+
5961
error(errorText)
60-
62+
6163
end
6264

6365

64-
end
66+
end

0 commit comments

Comments
 (0)