Skip to content

Commit eb9a399

Browse files
committed
Merge remote-tracking branch 'cpp-lln-lab/master' into marco_refactor-ET
2 parents 8ebf7d9 + 558a247 commit eb9a399

23 files changed

+222
-125
lines changed

.travis.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
# Travis CI (https://travis-ci.org/)
2+
# This will only work on your repo if you have an account on travis and you
3+
# have set it up to run continuous integration on this this repo
24

3-
language: c
5+
# Linux distribution (bionic beaver)
46
dist: bionic
7+
8+
# Language and version
9+
language: python
10+
python:
11+
- "3.6" # current default Python on Travis CI
12+
513
cache:
614
apt: true # only works with Pro version
715

16+
# Install the miss_hit linter
817
before_install:
9-
- cd .. && git clone https://github.com/florianschanda/miss_hit.git && export PATH=$PATH:`pwd`/miss_hit && cd CPP_PTB
18+
- pip3 install miss_hit
1019

20+
# Lists all the tasks we will do
1121
jobs:
1222
include:
13-
- script: mh_style `pwd`
14-
name: "miss_hit linter" # names the second job
23+
- name: "miss_hit: checking code quality"
24+
script: mh_metric . --ci
25+
- name: "miss_hit: checking code style"
26+
script: mh_style .
27+

README.md

Lines changed: 50 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,67 @@
1-
# CPP_PTB
1+
[![](https://img.shields.io/badge/Octave-CI-blue?logo=Octave&logoColor=white)](https://github.com/cpp-lln-lab/CPP_PTB/actions)
2+
![](https://github.com/cpp-lln-lab/CPP_PTB/workflows/CI/badge.svg)
3+
4+
[![Build Status](https://travis-ci.com/cpp-lln-lab/CPP_BIDS.svg?branch=master)](https://travis-ci.com/cpp-lln-lab/CPP_PTB)
25

36
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
47
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
58
<!-- ALL-CONTRIBUTORS-BADGE:END -->
69

7-
This is List of Crossmodal Perception and Plasticity lab (CPP) PsychToolBox (PTB) toolbox.
10+
# CPP_PTB
11+
12+
<!-- vscode-markdown-toc -->
13+
* 1. [Requirements](#Requirements)
14+
* 2. [Code guidestyle](#Codeguidestyle)
15+
* 3. [How to install](#Howtoinstall)
16+
* 3.1. [Download with git](#Downloadwithgit)
17+
* 3.2. [Add as a submodule](#Addasasubmodule)
18+
* 3.2.1. [Example for submodule usage](#Exampleforsubmoduleusage)
19+
* 3.3. [Direct download](#Directdownload)
20+
* 4. [Setting up keyboards](#Settingupkeyboards)
21+
* 5. [Structure](#Structure)
22+
* 6. [Annexes](#Annexes)
23+
* 6.1. [Experiment template [ WIP ]](#ExperimenttemplateWIP)
24+
* 6.2. [devSandbox (stand-alone)](#devSandboxstand-alone)
25+
* 7. [Contributors ✨](#Contributors)
26+
27+
<!-- vscode-markdown-toc-config
28+
numbering=true
29+
autoSave=true
30+
/vscode-markdown-toc-config -->
31+
<!-- /vscode-markdown-toc -->
32+
33+
34+
This is the Crossmodal Perception and Plasticity lab (CPP) PsychToolBox (PTB) toolbox.
835

936
Those functions are mostly wrappers around some PTB functions to facilitate their use and to have a codebase to facilitate their reuse.
1037

11-
12-
## Requirements
38+
## 1. <a name='Requirements'></a>Requirements
1339

1440
Make sure that the following toolboxes are installed and added to the matlab / octave path.
1541

1642
For instructions see the following links:
1743

1844
| Requirements | Used version |
1945
|----------------------------------------------------------|--------------|
20-
| [PsychToolBox](http://psychtoolbox.org/) Duuuuhh | >=3.0.14 |
21-
| [Matlab](https://www.mathworks.com/products/matlab.html) | 201?? |
46+
| [PsychToolBox](http://psychtoolbox.org/) | >=3.0.14 |
47+
| [Matlab](https://www.mathworks.com/products/matlab.html) | >=2015b |
2248
| or [octave](https://www.gnu.org/software/octave/) | 4.? |
2349

2450
The exact version required for this to work but it is known to work with:
25-
- matlab 2017a or octave 4.2.2 and PTB 3.0.16.
51+
- matlab 2015b or octave 4.2.2 and PTB 3.0.14.
2652

27-
## Code guidestyle
53+
## 2. <a name='Codeguidestyle'></a>Code guidestyle
2854

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

3258
We keep the McCabe complexity as reported by the [check_my_code function](https://github.com/Remi-Gau/check_my_code) below 15.
3359

34-
We use the [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_checker.html) to automatically fix some linting issues.
60+
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.
3561

36-
## How to install
62+
## 3. <a name='Howtoinstall'></a>How to install
3763

38-
### Download with git
64+
### 3.1. <a name='Downloadwithgit'></a>Download with git
3965

4066
``` bash
4167
cd fullpath_to_directory_where_to_install
@@ -59,7 +85,7 @@ To work with a specific version, create a branch at a specific version tag numbe
5985
git checkout -b version1 v0.0.1
6086
```
6187

62-
### Add as a submodule
88+
### 3.2. <a name='Addasasubmodule'></a>Add as a submodule
6389

6490
Add it as a submodule in the repo you are working on.
6591

@@ -81,7 +107,7 @@ git submodule update --remote --merge
81107

82108
Remember that updates to submodules need to be committed as well.
83109

84-
#### Example for submodule usage
110+
#### 3.2.1. <a name='Exampleforsubmoduleusage'></a>Example for submodule usage
85111

86112
So say you want to clone a repo that has some nested submodules, then you would type this to get the content of all the submodules at once (here with my experiment repo):
87113
``` bash
@@ -104,12 +130,8 @@ git submodule update
104130
git submodule foreach --recursive 'git submodule init'
105131
git submodule foreach --recursive 'git submodule update'
106132
```
107-
**TO DO**
108-
<!-- Submodules
109-
pros: in principle, downloading the experiment you have the whole package plus the benefit to stay updated and use version control of this dependency. Can probably handle a use case in which one uses different version on different projects (e.g. older and newer projects).
110-
cons: for pro users and not super clear how to use it at the moment. -->
111133

112-
### Direct download
134+
### 3.3. <a name='Directdownload'></a>Direct download
113135

114136
Download the code. Unzip. And add to the matlab path.
115137

@@ -121,12 +143,7 @@ Or take the latest commit (NOT RECOMMENDED):
121143

122144
https://github.com/cpp-lln-lab/CPP_PTB/archive/master.zip
123145

124-
**TO DO**
125-
<!-- Download a specific version and c/p it in a subfun folder
126-
pros: the easiest solution to share the code and 'installing' it on the stimulation computer (usually not the one used to develop the code).
127-
cons: extreme solution useful only at the very latest stage (i.e. one minute before acquiring your data); prone to be customized/modified (is it what we want?) -->
128-
129-
## Setting up keyboards
146+
## 4. <a name='Settingupkeyboards'></a>Setting up keyboards
130147

131148
To select a specific keyboard to be used by the experimenter or the participant, you need to know
132149
the value assigned by PTB to each keyboard device.
@@ -151,7 +168,11 @@ press the keys necessary to start or abort the experiment.
151168

152169
Using empty vectors (ie `[]`) or a negative value for those means that you will let PTB find and use the default device.
153170

154-
## Structure
171+
## 5. <a name='Structure'></a>Structure
172+
173+
The `cfg` structure is where most of the information about your experiment will be defined.
174+
175+
Below we try to outline what it contains.
155176

156177
```matlab
157178
@@ -209,101 +230,11 @@ cfg.mri.triggerNb
209230
cfg.mri.triggerKey
210231
```
211232

212-
## function details
213-
214-
215-
### initPTB
216-
217-
This will initialize PsychToolBox
218-
219-
- screen
220-
- the windon opened takes the whole screen by default
221-
- set in debug mode with window transparency if necessary
222-
- can skip synch test if you ask for it (nicely)
223-
- gets the flip interval
224-
- computes the pixel per degree of visual angle
225-
- set font details
226-
- keyboard
227-
- sound
228-
229-
### testKeyboards
230-
231-
Checks that the keyboards asked for properly connected.
232-
233-
If no key is pressed on the correct keyboard after the timeOut time this exits with an error.
234-
235-
### cleanUp
236-
237-
A wrapper function to close all windows, ports, show mouse cursor, close keyboard queues
238-
and give access back to the keyboards.
239-
240-
### getExperimentStart
241-
242-
Wrapper function that will show a fixation cross and collect a start timestamp in `cfg.experimentStart`
243-
244-
### getExperimentEnd
245-
246-
Wrapper function that will show a fixation cross and display in the console the whole experiment's duration in minutes and seconds
247-
248-
### getResponse
249-
250-
It is wrapper function to use `KbQueue` which is definitely what you should use to collect responses.
251-
252-
You can easily collect responses while running some other code at the same time.
253-
254-
It will only take responses from one device which can simply be the "main keyboard"
255-
(the default device that PTB will find) or another keyboard connected to the computer
256-
or the response box that the participant is using.
257-
258-
You can use it in a way so that it only takes responses from certain keys and ignore others (like
259-
the triggers from an MRI scanner).
260-
261-
If you want to know more on how to use it check its help section and the `CPP_getResponseDemo.m`.
262-
263-
In brief, there are several actions you can execute with this function.
264-
265-
- init: initialize the buffer for key presses on a given device (you can also specify the keys of interest that should be listened to).
266-
- start: start listening to the key presses (carefully insert into your script - where do you want to start buffering the responses).
267-
- check: till that point, it will check the buffer for all key presses.
268-
- It only reports presses on the keys of interest mentioned at initialization.
269-
- It **can** also check for presses on the escape key and abort if the escape key is part of the keys of interest.
270-
- flush: Empties the buffer of key presses in case you want to discard any previous key presses.
271-
- stop: Stops buffering key presses. You can still restart by calling "start" again.
272-
- release: Closes the buffer for good.
273-
274-
### deg2Pix
275-
276-
For a given field value in degrees of visual angle in the input `structure`,
277-
this computes its value in pixel using the pixel per degree value of the `cfg` structure
278-
and returns a structure with an additional field with Pix suffix holding that new value.
279-
280-
### drawFixationCross
281-
282-
Define the parameters of the fixation cross in `cfg` and `expParameters` and this does the rest.
283-
284-
### eyeTracker
285-
286-
This will handle the Eye Tracker (EyeLink set up) and can be called to initialize the connection and start the calibration, start/stop eye(s) movement recordings and save the `*.edf` file (named with BIDS specification from cpp-lln-lab/CPP_BIDS).
287-
288-
### pressSpace4me
289-
290-
Use that to stop your script and only restart when the space bar is pressed.
291-
292-
### standByScreen
293-
294-
It shows a basic one-page instruction stored in `cfg.task.instruction` and wait for `space` stroke.
295-
296-
### waitForTrigger
297-
298-
Counts a certain number of triggers coming from the mri/scanner before returning.
299-
Requires number of triggers to wait for.
300-
301-
302-
## Annexes
233+
## 6. <a name='Annexes'></a>Annexes
303234

304-
### Experiment template [ WIP ]
235+
### 6.1. <a name='ExperimenttemplateWIP'></a>Experiment template [ WIP ]
305236

306-
### devSandbox (stand-alone)
237+
### 6.2. <a name='devSandboxstand-alone'></a>devSandbox (stand-alone)
307238

308239
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.
309240

@@ -317,7 +248,7 @@ It is composed of two parts:
317248

318249
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`).
319250

320-
## Contributors ✨
251+
## 7. <a name='Contributors'></a>Contributors ✨
321252

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

0 commit comments

Comments
 (0)