Skip to content

Commit 9b1948e

Browse files
committed
update dependency check and doc
- fxing remi's drunk coding
1 parent 3f43dae commit 9b1948e

File tree

3 files changed

+81
-69
lines changed

3 files changed

+81
-69
lines changed

CPP_getResponseDemo.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
jk%% Demo showing how to use the getResponse function
1+
%% Demo showing how to use the getResponse function
22

3-
% This small script shows how to use the getReponse function
3+
% This small script shows how to use the getReponse function
44
% (a wrapper around the KbQueue function from PTB)
55

66
% start with a clean slate
7-
clear; clc;
7+
clear; clc;
88
if IsOctave
99
more off % for a better display experience
1010
end
1111

1212
%% set parameters
1313

14-
% cfg.responseBox would be the device number of the device used by the participant to give his/her
14+
% cfg.responseBox would be the device number of the device used by the participant to give his/her
1515
% response: like the button box in the scanner or a separate keyboard for a behavioral experiment
1616
%
17-
% cfg.keyboard would be the device number of the keyboard on which the experimenter will type or
17+
% cfg.keyboard would be the device number of the keyboard on which the experimenter will type or
1818
% press the keys necessary to start or abort the experiment.
1919

2020
% cfg.responseBox and cfg.keyboard can be different or the same.
@@ -57,10 +57,10 @@
5757

5858
fprintf('\nDuring the next 5 seconds we will collect responses on the following keys: \n\n');
5959
if isempty(expParameters.responseKey)
60-
fprintf('\nALL KEYS\n\n');
60+
fprintf('\nALL KEYS\n\n');
6161
else
6262
for iKey=1:numel(expParameters.responseKey)
63-
fprintf('\n%s', expParameters.responseKey{iKey});
63+
fprintf('\n%s', expParameters.responseKey{iKey});
6464
end
6565
fprintf('\n\n');
6666
end

README.md

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# CPP_PTB
2+
23
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4+
35
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
6+
47
<!-- ALL-CONTRIBUTORS-BADGE:END -->
58

69
This is List of Crossmodal Perpeption and Plasticity lab (CPP) PsychToolBox (PTB) toolbox.
@@ -16,7 +19,7 @@ For instructions see the following links:
1619

1720
| Requirements | Used version |
1821
|----------------------------------------------------------|--------------|
19-
| [PsychToolBox](http://psychtoolbox.org/) Duuuuhh | >3.0.13 |
22+
| [PsychToolBox](http://psychtoolbox.org/) Duuuuhh | >=3.0.14 |
2023
| [Matlab](https://www.mathworks.com/products/matlab.html) | 201?? |
2124
| or [octave](https://www.gnu.org/software/octave/) | 4.? |
2225

@@ -36,40 +39,37 @@ We keep the McCabe complexity as reported by the [check_my_code function](https:
3639
This repository can be added as a dependencies by listing it in a [mpm-requirements.txt file](.mpm-requirements.txt)
3740
as follows:
3841

39-
```
40-
CPP_PTB -u https://github.com/cpp-lln-lab/CPP_PTB.git
41-
```
42+
CPP_PTB -u https://github.com/cpp-lln-lab/CPP_PTB.git
4243

4344
You can then use the [matlab package manager](https://github.com/mobeets/mpm), to simply download the appropriate version of those dependencies and add them to your path by running a `getDependencies` function like the one below where you just need to replace `YOUR_EXPERIMENT_NAME` by the name of your experiment.
4445

45-
4646
```matlab
47-
function getDependencies(action)
48-
% Will install on your computer the matlab dependencies specified in the mpm-requirements.txt
49-
% and add them to the matlab path. The path is never saved so you need to run getDependencies() when
50-
% you start matlab.
51-
%
52-
% getDependencies('update') will force the update and overwrite previous version of the dependencies.
53-
%
54-
% getDependencies() If you only already have the appropriate version but just want to add them to the matlab path.
55-
56-
experimentName = YOUR_EXPERIMENT_NAME;
57-
58-
if nargin<1
59-
action = '';
60-
end
61-
62-
switch action
63-
case 'update'
64-
% install dependencies
65-
mpm install -i mpm-requirements.txt -f -c YOUR_EXPERIMENT_NAME
66-
end
67-
68-
% adds them to the path
69-
mpm_folder = fileparts(which('mpm'));
70-
addpath(genpath(fullfile(mpm_folder, 'mpm-packages', 'mpm-collections', experimentName)));
71-
72-
end
47+
function getDependencies(action)
48+
% Will install on your computer the matlab dependencies specified in the mpm-requirements.txt
49+
% and add them to the matlab path. The path is never saved so you need to run getDependencies() when
50+
% you start matlab.
51+
%
52+
% getDependencies('update') will force the update and overwrite previous version of the dependencies.
53+
%
54+
% getDependencies() If you only already have the appropriate version but just want to add them to the matlab path.
55+
56+
experimentName = YOUR_EXPERIMENT_NAME;
57+
58+
if nargin<1
59+
action = '';
60+
end
61+
62+
switch action
63+
case 'update'
64+
% install dependencies
65+
mpm install -i mpm-requirements.txt -f -c YOUR_EXPERIMENT_NAME
66+
end
67+
68+
% adds them to the path
69+
mpm_folder = fileparts(which('mpm'));
70+
addpath(genpath(fullfile(mpm_folder, 'mpm-packages', 'mpm-collections', experimentName)));
71+
72+
end
7373
```
7474

7575

@@ -80,22 +80,25 @@ end
8080
### initPTB
8181

8282
This will initialize PsychToolBox
83+
8384
- screen
84-
- the windon opened takes the whole screen by default
85-
- set in debug mode with window transparency if necessary
86-
- can skip synch test if you ask for it (nicely)
87-
- gets the flip interval
88-
- computes the pixel per degree of visual angle
89-
- set font details
85+
- the windon opened takes the whole screen by default
86+
- set in debug mode with window transparency if necessary
87+
- can skip synch test if you ask for it (nicely)
88+
- gets the flip interval
89+
- computes the pixel per degree of visual angle
90+
- set font details
9091
- keyboard
9192
- sound
9293

9394
### testKeyboards
95+
9496
Checks that the keyboards asked for properly connected.
9597

9698
If no key is pressed on the correct keyboard after the timeOut time this exits with an error.
9799

98100
### cleanUp
101+
99102
A wrapper function to close all windows, ports, show mouse cursor, close keyboard queues
100103
and give access back to the keyboards.
101104

@@ -118,12 +121,10 @@ the value assigned by PTB to each keyboard device.
118121

119122
To know this copy-paste this on the command window:
120123

121-
```
122-
[keyboardNumbers, keyboardNames] = GetKeyboardIndices;
124+
[keyboardNumbers, keyboardNames] = GetKeyboardIndices;
123125

124-
keyboardNumbers
125-
keyboardNames
126-
```
126+
keyboardNumbers
127+
keyboardNames
127128

128129
### deg2Pix
129130

@@ -139,22 +140,16 @@ Define the parameters of the fixation cross in `cfg` and `expParameters` and thi
139140

140141
Use that to stop your script and only restart when the space bar is pressed.
141142

142-
143-
144-
145-
146-
147-
148-
149-
150-
151143
## Contributors ✨
152144

153145
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
154146

155147
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
148+
156149
<!-- prettier-ignore-start -->
150+
157151
<!-- markdownlint-disable -->
152+
158153
<table>
159154
<tr>
160155
<td align="center"><a href="https://remi-gau.github.io/"><img src="https://avatars3.githubusercontent.com/u/6961185?v=4" width="100px;" alt=""/><br /><sub><b>Remi Gau</b></sub></a><br /><a href="https://github.com/cpp-lln-lab/CPP_PTB/commits?author=Remi-Gau" title="Code">💻</a> <a href="#design-Remi-Gau" title="Design">🎨</a> <a href="https://github.com/cpp-lln-lab/CPP_PTB/commits?author=Remi-Gau" title="Documentation">📖</a></td>
@@ -163,7 +158,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
163158
</table>
164159

165160
<!-- markdownlint-enable -->
161+
166162
<!-- prettier-ignore-end -->
163+
167164
<!-- ALL-CONTRIBUTORS-LIST:END -->
168165

169166
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

checkDependencies.m

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,41 @@ function checkDependencies()
33

44
printCredits()
55

6-
7-
PTB = '3.0.16';
6+
PTB.major = 3;
7+
PTB.minor = 0;
8+
PTB.point = 14;
89

910
fprintf('Checking dependencies\n')
1011

1112
% check ptb version
1213
try
13-
a = PsychtoolboxVersion
14-
fprintf(' Using %s %s\n', a, b)
15-
if any(~strcmp(a, PTB))
16-
str = sprintf('%s %s %s.\n%s', ...
17-
'The current version PTB version is not', PTB,...
18-
'In case of problems (e.g json file related) consider updating.');
19-
warning(str); %#ok<*SPWRN>
20-
end
14+
15+
[~, versionStruc] = PsychtoolboxVersion;
16+
17+
fprintf(' Using PTB %i.%i.%i\n', ...
18+
versionStruc.major, ...
19+
versionStruc.minor, ...
20+
versionStruc.point)
21+
22+
if any( [...
23+
versionStruc.major < PTB.major, ...
24+
versionStruc.minor < PTB.minor, ...
25+
versionStruc.point < PTB.point, ...
26+
])
27+
28+
str = sprintf('%s %i.%i.%i %s.\n%s', ...
29+
'The current version PTB version is not', ...
30+
PTB.major, ...
31+
PTB.minor, ...
32+
PTB.point, ...
33+
'In case of problems (e.g json file related) consider updating.');
34+
warning(str); %#ok<*SPWRN>
35+
end
2136
catch
2237
error('Failed to check the PTB version: Are you sure that PTB is in the matlab path?')
2338
end
2439

2540

26-
fprintf(' We got all we need. Let''s get to work.\n')
41+
fprintf(' We got all we need. Let us get to work.\n')
2742

2843
end

0 commit comments

Comments
 (0)