Skip to content

Commit 05f497b

Browse files
committed
update in doc and reorganize files
1 parent 9ae1304 commit 05f497b

File tree

13 files changed

+311
-153
lines changed

13 files changed

+311
-153
lines changed

README.md

Lines changed: 30 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919
* 3.2. [Add as a submodule](#Addasasubmodule)
2020
* 3.2.1. [Example for submodule usage](#Exampleforsubmoduleusage)
2121
* 3.3. [Direct download](#Directdownload)
22-
* 4. [Setting up keyboards](#Settingupkeyboards)
23-
* 5. [Structure](#Structure)
24-
* 6. [Annexes](#Annexes)
25-
* 6.1. [Experiment template [ WIP ]](#ExperimenttemplateWIP)
26-
* 6.2. [devSandbox (stand-alone)](#devSandboxstand-alone)
27-
* 7. [Contributors ✨](#Contributors)
22+
* 4. [Documentation](#Documentation)
23+
* 5. [Content](#Content)
24+
* 6. [Contributors ✨](#Contributors)
2825

2926
<!-- vscode-markdown-toc-config
3027
numbering=true
@@ -35,7 +32,7 @@
3532

3633
This is the Crossmodal Perception and Plasticity lab (CPP) PsychToolBox (PTB) toolbox.
3734

38-
Those functions are mostly wrappers around some PTB functions to facilitate their use and to have a codebase to facilitate their reuse.
35+
Those functions are mostly wrappers around some PTB functions to facilitate their use and their reuse (#DontRepeatYourself)
3936

4037
## 1. <a name='Requirements'></a>Requirements
4138

@@ -49,17 +46,20 @@ For instructions see the following links:
4946
| [Matlab](https://www.mathworks.com/products/matlab.html) | >=2015b |
5047
| or [octave](https://www.gnu.org/software/octave/) | 4.? |
5148

52-
The exact version required for this to work but it is known to work with:
49+
Tested:
5350
- matlab 2015b or octave 4.2.2 and PTB 3.0.14.
5451

5552
## 2. <a name='Codeguidestyle'></a>Code guidestyle
5653

5754
We use the `camelCase` to more easily differentiates our functions from the ones from PTB that use a `PascalCase`.
58-
We use the following regular expression for function names: `[a-z]+(([A-Z]|[0-9]){1}[a-z]+)*`.
5955

60-
We keep the McCabe complexity as reported by the [check_my_code function](https://github.com/Remi-Gau/check_my_code) below 15.
56+
In practice, we use the following regular expression for function names: `[a-z]+(([A-Z]|[0-9]){1}[a-z]+)*`.
6157

62-
We use the [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_checker.html) to automatically fix some linting issues. The code style and quality is also checked during the continuous integration.
58+
We keep the McCabe complexity as reported by the [check_my_code function](https://github.com/Remi-Gau/check_my_code) below 15 or the [MISS_HIT code checker](https://florianschanda.github.io/miss_hit)
59+
60+
We use the [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_checker.html) to automatically fix some linting issues.
61+
62+
The code style and quality is also checked during the [continuous integration](./.travis.yml).
6363

6464
## 3. <a name='Howtoinstall'></a>How to install
6565

@@ -84,7 +84,7 @@ git pull origin master
8484
To work with a specific version, create a branch at a specific version tag number
8585
```bash
8686
# creating and checking out a branch that will be calle version1 at the version tag v0.0.1
87-
git checkout -b version1 v0.0.1
87+
git checkout -b version1 v1.0.0
8888
```
8989

9090
### 3.2. <a name='Addasasubmodule'></a>Add as a submodule
@@ -145,112 +145,30 @@ Or take the latest commit (NOT RECOMMENDED):
145145

146146
https://github.com/cpp-lln-lab/CPP_PTB/archive/master.zip
147147

148-
## 4. <a name='Settingupkeyboards'></a>Setting up keyboards
149-
150-
To select a specific keyboard to be used by the experimenter or the participant, you need to know
151-
the value assigned by PTB to each keyboard device.
152148

153-
To know this copy-paste this on the command window:
149+
## 4. <a name='Documentation'></a>Documentation
154150

155-
``` matlab
156-
[keyboardNumbers, keyboardNames] = GetKeyboardIndices;
151+
All the documentation is accessible [here](./docs/00_index.md).
157152

158-
disp(keyboardNumbers);
159-
disp(keyboardNames);
160-
```
153+
## 5. <a name='Content'></a>Content
161154

162-
You can then assign a specific device number to the main keyboard or the response box in the `cfg` structure
163-
164-
- `cfg.keyboard.responseBox` would be the device number of the device used by the participant to give his/her
165-
response: like the button box in the scanner or a separate keyboard for a behavioral experiment
166-
- `cfg.keyboard.keyboard` would be the device number of the keyboard on which the experimenter will type or
167-
press the keys necessary to start or abort the experiment.
168-
169-
`cfg.keyboard.responseBox` and `cfg.keyboard.keyboard` can be different or the same.
170-
171-
Using empty vectors (ie `[]`) or a negative value for those means that you will let PTB find and use the default device.
172-
173-
## 5. <a name='Structure'></a>Structure
174-
175-
The `cfg` structure is where most of the information about your experiment will be defined.
176-
177-
Below we try to outline what it contains.
178-
179-
```matlab
180-
181-
cfg.testingDevice = 'pc';
182-
183-
% cfg.color
184-
cfg.keyboard.keyboard = [];
185-
cfg.keyboard.responseBox = [];
186-
cfg.keyboard.responseKey = {};
187-
cfg.keyboard.escapeKey = 'ESCAPE';
188-
189-
% cfg.debug
190-
cfg.debug.do = true;
191-
cfg.debug.transpWin = true;
192-
cfg.debug.smallWin = true;
193-
194-
% cfg.text
195-
cfg.text.font
196-
cfg.text.size
197-
cfg.text.style
198-
199-
% cfg.color
200-
cfg.color.background
201-
202-
% cfg.screen
203-
cfg.screen.monitorWidth
204-
cfg.screen.monitorDistance
205-
cfg.screen.idx
206-
cfg.screen.win
207-
cfg.screen.winRect
208-
cfg.screen.winWidth
209-
cfg.screen.winHeight
210-
cfg.screen.center
211-
cfg.screen.FOV
212-
cfg.screen.ppd
213-
cfg.screen.ifi
214-
cfg.screen.monRefresh
215-
216-
% cfg.audio
217-
cfg.audio.do
218-
cfg.audio.pahandle
219-
cfg.audio.devIdx
220-
cfg.audio.playbackMode
221-
cfg.audio.requestedLatency
222-
cfg.audio.fs
223-
cfg.audio.channels
224-
cfg.audio.initVolume
225-
cfg.audio.pushSize
226-
cfg.audio.requestOffsetTime
227-
cfg.audio.reqsSampleOffset
228-
229-
% cfg.mri
230-
cfg.mri.repetitionTime
231-
cfg.mri.triggerNb
232-
cfg.mri.triggerKey
155+
```bash
156+
├── demos # quick demo of how to use some functions
157+
├── dev # templates for experiment (will be moved out soon)
158+
├── docs # documentation
159+
├── manualTests # all the tests that cannot be automated (yet)
160+
├── src # actual code of the CPP_PTB
161+
│ ├── aperture # function related to create apertur (circle, wedge, bar...)
162+
│ ├── dot # functions to simplify the creations of RDK
163+
│ ├── errors # all error functions
164+
│ ├── fixation # to create fixation cross, dots
165+
│ ├── keyboard # to collect responses, abort experiment...
166+
│ ├── randomization # functions to help with trial randomization
167+
│ └── utils # set of general functions
168+
└── tests # all the tests that that can be run by github actions
233169
```
234170

235-
## 6. <a name='Annexes'></a>Annexes
236-
237-
### 6.1. <a name='ExperimenttemplateWIP'></a>Experiment template [ WIP ]
238-
239-
### 6.2. <a name='devSandboxstand-alone'></a>devSandbox (stand-alone)
240-
241-
This script is a stand-alone function that can be useful as a sandbox to develop the PTB audio/visual stimulation of your experiment. No input/output required.
242-
243-
Here, a tutorial from https://peterscarfe.com/contrastgratingdemo.html is provided for illustrative purpose (notice that some variable names are updated to our code style). For your use, you will delete that part.
244-
245-
It is composed of two parts:
246-
- a fixed structure that will initialize and close PTB in 'debug mode'
247-
(`PsychDebugWindowConfiguration`, `SkipSyncTests`)
248-
- the actual sandbox where to set your dynamic variables (the stimulation
249-
parameters) and the 'playground' where to develop the stimulation code
250-
251-
When you are happy with it, ideally you will move the vars in `setParameters.m` and the stimulation code in a separate function in `my-experiment-folder/subfun`. The code style and variable names are the same used in `cpp-lln-lab/CPP_PTB` github repo, therefore it should be easy to move everything in your experiment scripts (see the template that is annexed in `cpp-lln-lab/CPP_PTB`).
252-
253-
## 7. <a name='Contributors'></a>Contributors ✨
171+
## 6. <a name='Contributors'></a>Contributors ✨
254172

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

docs/00_index.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# CPP_PTB documentation
2+
3+
<!-- vscode-markdown-toc -->
4+
* 1. [the CFG gtructure](#theCFGgtructure)
5+
* 2. [Setting up keyboards](#Settingupkeyboards)
6+
* 3. [functions descriptions](#functionsdescriptions)
7+
* 4. [Annexes](#Annexes)
8+
* 4.1. [Experiment template [ WIP ]](#ExperimenttemplateWIP)
9+
* 4.2. [devSandbox (stand-alone)](#devSandboxstand-alone)
10+
11+
<!-- vscode-markdown-toc-config
12+
numbering=true
13+
autoSave=true
14+
/vscode-markdown-toc-config -->
15+
<!-- /vscode-markdown-toc -->
16+
17+
## 1. <a name='theCFGgtructure'></a>the CFG gtructure
18+
19+
The `cfg` structure is where most of the information about your experiment will be defined.
20+
21+
Below we try to outline what it contains.
22+
23+
Some of those fields you can set yourself while some others will be created and filled after running `initPTB.m`.
24+
25+
If no value is provided here, it means that there is no set default (or that the `initPTB` takes care of it).
26+
27+
```matlab
28+
%% -------------------------------------------------------------------------- %%
29+
cfg.testingDevice = 'pc'; % could be 'mri', 'eeg', 'meg'
30+
31+
32+
%% -------------------------------------------------------------------------- %%
33+
% cfg.keyboard
34+
cfg.keyboard.keyboard = []; % device index for the main keyboard (that of the experimenter)
35+
cfg.keyboard.responseBox = []; % device index used by the participants
36+
cfg.keyboard.responseKey = {}; % list the keys that PTB should "listen" to when
37+
% using KbQueue to collect responses ; if empty PTB will listen to all key presses
38+
cfg.keyboard.escapeKey = 'ESCAPE'; % key to press to escape
39+
40+
41+
%% -------------------------------------------------------------------------- %%
42+
% cfg.debug
43+
cfg.debug.do = true; % if true this will make less PTB tolerant with bad synchronisation
44+
cfg.debug.transpWin = true; % makes the stimulus windows semi-transparent: useful when designing your experiment
45+
cfg.debug.smallWin = true; % open a small window and not a full screen window ; can be useful for debugging
46+
47+
%% -------------------------------------------------------------------------- %%
48+
% cfg.text
49+
cfg.text.font = 'Courier New';
50+
cfg.text.size = 18;
51+
cfg.text.style = 1; ???
52+
53+
54+
%% -------------------------------------------------------------------------- %%
55+
% cfg.color
56+
cfg.color.background % [r g b] each in 0-255
57+
58+
59+
%% -------------------------------------------------------------------------- %%
60+
% cfg.screen
61+
cfg.screen.monitorWidth = 42;% in cm
62+
cfg.screen.monitorDistance = 134;% in cm
63+
64+
% all the following will be initialised by initPTB
65+
cfg.screen.idx % screen index
66+
cfg.screen.win % window index
67+
cfg.screen.winRect % rectangle definition of the window
68+
cfg.screen.winWidth
69+
cfg.screen.winHeight
70+
cfg.screen.center % [x y] ; pixel coordinate of the window center
71+
cfg.screen.FOV % width of the field of view in degrees of visual angle
72+
cfg.screen.ppd % pixel per degree
73+
cfg.screen.ifi % inter frame interval
74+
cfg.screen.monRefresh % monitor refresh rate ; 1 / ifi
75+
76+
77+
%% -------------------------------------------------------------------------- %%
78+
% fixation
79+
cfg.fixation.type = 'cross'; % can also be 'dot' or 'bestFixation'
80+
cfg.fixation.xDisplacement = 0; % horizontal offset from window center
81+
cfg.fixation.yDisplacement = 0; % vertical offset from window center
82+
cfg.fixation.color = [255 255 255];
83+
cfg.fixation.width = 1; % in degrees of visual angle
84+
cfg.fixation.lineWidthPix = 5; % width of the lines in pixel
85+
86+
87+
%% -------------------------------------------------------------------------- %%
88+
% aperture
89+
% mostly relevant for retinotopy scripts but can be reused for other types of
90+
% experiments where an aperture is needed
91+
cfg.aperture.type = 'none'; % 'bar', 'wedge', 'ring', 'circle'
92+
93+
94+
%% -------------------------------------------------------------------------- %%
95+
% cfg.audio
96+
cfg.audio.do = false; % set to true if you are going to play some sounds
97+
cfg.audio.pahandle
98+
cfg.audio.devIdx = [ ];
99+
cfg.audio.playbackMode = 1;
100+
cfg.audio.requestedLatency = 3;
101+
cfg.audio.fs 44800; % sampling frequency
102+
cfg.audio.channels = 2; % number of auditory channels
103+
cfg.audio.initVolume = 1;
104+
cfg.audio.pushSize
105+
cfg.audio.requestOffsetTime = 1;
106+
cfg.audio.reqsSampleOffset
107+
cfg.audio.repeat = 1;
108+
cfg.audio.startCue = 0;
109+
cfg.audio.waitForDevice = 1;
110+
111+
112+
%% -------------------------------------------------------------------------- %%
113+
% eyetracker
114+
cfg.eyeTracker.do = false; % set to true if you are using an eyelink eyetracker
115+
cfg.eyeTracker.defaultCalibration = true;
116+
cfg.eyeTracker.backgroundColor = [192 192 192];
117+
cfg.eyeTracker.fontColor = [0 0 0];
118+
cfg.eyeTracker.calibrationTargetColor = [0 0 0];
119+
cfg.eyeTracker.calibrationTargetSize = 1;
120+
cfg.eyeTracker.calibrationTargetWidth = 0.5;
121+
cfg.eyeTracker.displayCalResults = 1;
122+
123+
124+
%% -------------------------------------------------------------------------- %%
125+
% cfg.mri
126+
cfg.mri.repetitionTime
127+
128+
129+
%% -------------------------------------------------------------------------- %%
130+
% operating system information collected by initPTB
131+
cfg.software.os
132+
cfg.software.name = 'Psychtoolbox';
133+
cfg.software.RRID = 'SCR_002881';
134+
cfg.software.version % psychtoolbox version
135+
cfg.software.runsOn % matlab or octave and version number
136+
```
137+
138+
## 2. <a name='Settingupkeyboards'></a>Setting up keyboards
139+
140+
To select a specific keyboard to be used by the experimenter or the participant, you need to know
141+
the value assigned by PTB to each keyboard device.
142+
143+
To know this copy-paste this on the command window:
144+
145+
``` matlab
146+
[keyboardNumbers, keyboardNames] = GetKeyboardIndices;
147+
148+
disp(keyboardNumbers);
149+
disp(keyboardNames);
150+
```
151+
152+
You can then assign a specific device number to the main keyboard or the response box in the `cfg` structure
153+
154+
- `cfg.keyboard.responseBox` would be the device number of the device used by the participant to give his/her
155+
response: like the button box in the scanner or a separate keyboard for a behavioral experiment
156+
- `cfg.keyboard.keyboard` would be the device number of the keyboard on which the experimenter will type or
157+
press the keys necessary to start or abort the experiment.
158+
159+
`cfg.keyboard.responseBox` and `cfg.keyboard.keyboard` can be different or the same.
160+
161+
Using empty vectors (ie `[]`) or a negative value for those means that you will let PTB find and use the default device.
162+
163+
## 3. <a name='functionsdescriptions'></a>functions descriptions
164+
165+
The main functions of the toolbox are described [here](./10_functions_descriptions.md).
166+
167+
## 4. <a name='Annexes'></a>Annexes
168+
169+
### 4.1. <a name='ExperimenttemplateWIP'></a>Experiment template [ WIP ]
170+
171+
Will be moved to a different repository
172+
173+
### 4.2. <a name='devSandboxstand-alone'></a>devSandbox (stand-alone)
174+
175+
Will be moved to a different repository
176+
177+
This script is a stand-alone function that can be useful as a sandbox to develop the PTB audio/visual stimulation of your experiment. No input/output required.
178+
179+
Here, a tutorial from https://peterscarfe.com/contrastgratingdemo.html is provided for illustrative purpose (notice that some variable names are updated to our code style). For your use, you will delete that part.
180+
181+
It is composed of two parts:
182+
- a fixed structure that will initialize and close PTB in 'debug mode'
183+
(`PsychDebugWindowConfiguration`, `SkipSyncTests`)
184+
- the actual sandbox where to set your dynamic variables (the stimulation
185+
parameters) and the 'playground' where to develop the stimulation code
186+
187+
When you are happy with it, ideally you will move the vars in `setParameters.m` and the stimulation code in a separate function in `my-experiment-folder/subfun`. The code style and variable names are the same used in `cpp-lln-lab/CPP_PTB` github repo, therefore it should be easy to move everything in your experiment scripts (see the template that is annexed in `cpp-lln-lab/CPP_PTB`).

0 commit comments

Comments
 (0)