Skip to content

Commit 95f750e

Browse files
authored
Merge pull request #110 from cpp-lln-lab/remi-radial_motion
add radial motion
2 parents 199069e + 9e6f7a2 commit 95f750e

24 files changed

+487
-179
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,9 @@ git submodule foreach --recursive 'git submodule update'
154154

155155
Download the code. Unzip. And add to the matlab path.
156156

157-
Pick a specific version:
157+
Pick a specific version from [here](https://github.com/cpp-lln-lab/CPP_PTB/releases).
158158

159-
https://github.com/cpp-lln-lab/CPP_PTB/releases
160-
161-
Or take the latest commit (NOT RECOMMENDED):
162-
163-
https://github.com/cpp-lln-lab/CPP_PTB/archive/master.zip
159+
Or take [the latest commit](https://github.com/cpp-lln-lab/CPP_PTB/archive/master.zip) - NOT RECOMMENDED.
164160

165161
### Add CPP_PTB globally to the matlab path
166162

@@ -187,7 +183,6 @@ In practice, we use the following regular expression for function names:
187183
>
188184
> - A quick [intro to regular expression](https://www.rexegg.com/)
189185
> - And many websites allow you to "design and test" your regular expression:
190-
> - [regexr](https://regexr.com/)
191186
> - [regexper](https://regexper.com/#%5Ba-z%5D%2B%28%28%5BA-Z%5D%7C%5B0-9%5D%29%7B1%7D%5Ba-z%5D%2B%29)
192187
> - ...
193188

docs/00_index.md renamed to docs/00-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ let PTB find and use the default device.
193193
## 3. <a name='functionsdescriptions'></a>functions descriptions
194194

195195
The main functions of the toolbox are described
196-
[here](./10_functions_description.md).
196+
[here](./10-functions-description.md).
197197

198198
## 4. <a name='Annexes'></a>Annexes
199199

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
11
# functions description
22

3-
<!-- vscode-markdown-toc -->
4-
5-
- 1. [ General functions](#Generalfunctions)
6-
- 1.1. [initPTB](#initPTB)
7-
- 1.2. [cleanUp](#cleanUp)
8-
- 1.3. [getExperimentStart](#getExperimentStart)
9-
- 1.4. [getExperimentEnd](#getExperimentEnd)
10-
- 1.5. [degToPix](#degToPix)
11-
- 1.6. [computeFOV](#computeFOV)
12-
- 1.7. [eyeTracker](#eyeTracker)
13-
- 1.8. [standByScreen](#standByScreen)
14-
- 1.9. [waitForTrigger](#waitForTrigger)
15-
- 1.10. [waitFor](#waitFor)
16-
- 1.11. [readAndFilterLogfile](#readAndFilterLogfile)
17-
- 2. [Keyboard functions: response collection and aborting experiment](#Keyboardfunctions:responsecollectionandabortingexperiment)
18-
- 2.1. [testKeyboards](#testKeyboards)
19-
- 2.2. [getResponse](#getResponse)
20-
- 2.3. [pressSpaceForme](#pressSpaceForme)
21-
- 3. [Fixations](#Fixations)
22-
- 3.1. [drawFixationCross](#drawFixationCross)
23-
- 4. [Drawing dots](#Drawingdots)
24-
- 5. [Drawing apertures](#Drawingapertures)
25-
- 6. [Randomization](#Randomization)
26-
- 6.1. [shuffle](#shuffle)
27-
- 6.2. [setTargetPositionInSequence](#setTargetPositionInSequence)
28-
- 6.3. [repeatShuffleConditions](#repeatShuffleConditions)
29-
- 6.4. [setUpRand](#setUprand)
30-
31-
<!-- vscode-markdown-toc-config
32-
numbering=true
33-
autoSave=true
34-
/vscode-markdown-toc-config -->
35-
<!-- /vscode-markdown-toc -->
36-
37-
## 1. <a name='Generalfunctions'></a> General functions
38-
39-
### 1.1. <a name='initPTB'></a>initPTB
3+
<!-- TOC -->
4+
5+
- [functions description](#functions-description)
6+
- [General functions](#general-functions)
7+
- [initPTB](#initptb)
8+
- [cleanUp](#cleanup)
9+
- [getExperimentStart](#getexperimentstart)
10+
- [getExperimentEnd](#getexperimentend)
11+
- [degToPix](#degtopix)
12+
- [computeFOV](#computefov)
13+
- [eyeTracker](#eyetracker)
14+
- [standByScreen](#standbyscreen)
15+
- [waitForTrigger](#waitfortrigger)
16+
- [waitFor](#waitfor)
17+
- [readAndFilterLogfile](#readandfilterlogfile)
18+
- [Keyboard functions: response collection and aborting experiment](#keyboard-functions-response-collection-and-aborting-experiment)
19+
- [testKeyboards](#testkeyboards)
20+
- [getResponse](#getresponse)
21+
- [pressSpaceForme](#pressspaceforme)
22+
- [checkAbort](#checkabort)
23+
- [Fixations](#fixations)
24+
- [drawFixationCross](#drawfixationcross)
25+
- [Drawing dots](#drawing-dots)
26+
- [Drawing apertures](#drawing-apertures)
27+
- [Randomization](#randomization)
28+
- [shuffle](#shuffle)
29+
- [setTargetPositionInSequence](#settargetpositioninsequence)
30+
- [repeatShuffleConditions](#repeatshuffleconditions)
31+
32+
<!-- /TOC -->
33+
34+
## General functions
35+
36+
### initPTB
4037

4138
This will initialize PsychToolBox.
4239

@@ -57,34 +54,34 @@ any other functions of CPP_PTB.
5754
- hides cursor
5855
- sound
5956

60-
### 1.2. <a name='cleanUp'></a>cleanUp
57+
### cleanUp
6158

6259
A wrapper function to close all windows, ports, show mouse cursor, close
6360
keyboard queues and give you back access to the keyboards.
6461

65-
### 1.3. <a name='getExperimentStart'></a>getExperimentStart
62+
### getExperimentStart
6663

6764
Wrapper function that will show a fixation cross and collect a start timestamp
6865
in `cfg.experimentStart`
6966

70-
### 1.4. <a name='getExperimentEnd'></a>getExperimentEnd
67+
### getExperimentEnd
7168

7269
Wrapper function that will show a fixation cross and display in the console the
7370
whole experiment's duration in minutes and seconds
7471

75-
### 1.5. <a name='degToPix'></a>degToPix
72+
### degToPix
7673

7774
For a given field value in degrees of visual angle in the input `structure`,
7875
this computes its value in pixel using the pixel per degree value of the `cfg`
7976
structure and returns a structure with an additional field with Pix suffix
8077
holding that new value.
8178

82-
### 1.6. <a name='computeFOV'></a>computeFOV
79+
### computeFOV
8380

8481
Gives you the width of the field on view in degress of visual angle based on the
8582
screen width and distance to the screen in cm (taken from the `cfg`)
8683

87-
### 1.7. <a name='eyeTracker'></a>eyeTracker
84+
### eyeTracker
8885

8986
This will handle the Eye Tracker (EyeLink set up) and can be called to
9087
initialize the connection and start the calibration, start/stop eye(s) movement
@@ -106,40 +103,40 @@ There are several actions to perform:
106103
cpp-lln-lab/CPP_BIDS, in the output folder and shut the connection between
107104
the stimulation computer and the EyeLink computer
108105

109-
### 1.8. <a name='standByScreen'></a>standByScreen
106+
### standByScreen
110107

111108
It shows a basic one-page instruction stored in `cfg.task.instruction` and wait
112109
for `space` stroke.
113110

114-
### 1.9. <a name='waitForTrigger'></a>waitForTrigger
111+
### waitForTrigger
115112

116113
Counts a certain number of triggers coming from the mri/scanner before
117114
returning. Requires number of triggers to wait for.
118115

119116
This can also be used if you want to let the scanner pace the experiment and you
120117
want to synch stimulus presentation to the scanner trigger.
121118

122-
### 1.10. <a name='waitFor'></a>waitFor
119+
### waitFor
123120

124121
A generic function that you can use to for a certain amount of time or a number
125122
of triggers
126123

127-
### 1.11. <a name='readAndFilterLogfile'></a>readAndFilterLogfile
124+
### readAndFilterLogfile
128125

129126
Displays in the command window part of the `*events.tsv` file filtered by an
130127
element (e.g. 'trigger'). It can take the last output produced (through `cfg`)
131128
or any output BIDS compatible (through file path).
132129

133-
## 2. <a name='Keyboardfunctions:responsecollectionandabortingexperiment'></a>Keyboard functions: response collection and aborting experiment
130+
## Keyboard functions: response collection and aborting experiment
134131

135-
### 2.1. <a name='testKeyboards'></a>testKeyboards
132+
### testKeyboards
136133

137134
Checks that the keyboards asked for are properly connected.
138135

139136
If no key is pressed on the correct keyboard after the timeOut time this exits
140137
with an error.
141138

142-
### 2.2. <a name='getResponse'></a>getResponse
139+
### getResponse
143140

144141
It is wrapper function to use `KbQueue` which is definitely what you should use
145142
to collect responses.
@@ -172,7 +169,7 @@ In brief, there are several actions you can execute with this function.
172169
again.
173170
- release: closes the buffer for good.
174171

175-
### 2.3. <a name='pressSpaceForme'></a>pressSpaceForme
172+
### pressSpaceForme
176173

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

@@ -184,39 +181,39 @@ some set up before giving the green light.
184181
A simple function that will quit your experiment if you press the key you have
185182
defined in `cfg.keyboard.escapeKey`.
186183

187-
## 3. <a name='Fixations'></a>Fixations
184+
## Fixations
188185

189-
### 3.1. <a name='drawFixationCross'></a>drawFixationCross
186+
### drawFixationCross
190187

191188
Define the parameters of the fixation cross in `cfg` and `expParameters` and
192189
this does the rest.
193190

194-
## 4. <a name='Drawingdots'></a>Drawing dots
191+
## Drawing dots
195192

196-
## 5. <a name='Drawingapertures'></a>Drawing apertures
193+
## Drawing apertures
197194

198-
## 6. <a name='Randomization'></a>Randomization
195+
## Randomization
199196

200197
Functions that can be used to create random stimuli sequences.
201198

202-
### 6.1. <a name='shuffle'></a>shuffle
199+
### shuffle
203200

204201
Is just there to replace the Shuffle function from PTB in case it is not in the
205202
path. Can be useful for testing or for continuous integration.
206203

207-
### 6.2. <a name='setTargetPositionInSequence'></a>setTargetPositionInSequence
204+
### setTargetPositionInSequence
208205

209206
For a sequence of length `seqLength` where we want to insert `nbTarget` targets,
210207
this will return `nbTarget` random position in that sequence and make sure that
211208
they are not in consecutive positions.
212209

213-
### 6.3. <a name='repeatShuffleConditions'></a>repeatShuffleConditions
210+
### repeatShuffleConditions
214211

215212
Given `baseConditionVector`, a vector of conditions (coded as numbers), this
216213
will create a longer vector made of `nbRepeats` of this base vector and make
217214
sure that a given condition is not repeated one after the other.
218215

219-
### 6.4. <a name='setUpRand'></a>setUpRand
216+
### 6.4. setUpRand
220217

221-
Resets the seed of the random number generator. Will "adapt" depending on the matlab/octave version.
222-
It is of great importance to do this before anything else!
218+
Set up the randomizers for uniform and normal distributions. It is of great
219+
importance to do this before anything else!

manualTests/test_radialMotion.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
% ensure that dot density contrast is not too low when we kill dots often enough
2+
3+
% There is an actual official unit test in the tests folder so this here is more
4+
% to have the visualization turned on.
5+
6+
nbEvents = 100;
7+
doPlot = true;
8+
9+
thisEvent.direction = 0; % degrees
10+
thisEvent.speed = 1; % pix per frame
11+
12+
cfg.design.motionType = 'radial';
13+
14+
cfg.dot.coherence = 1; % proportion
15+
cfg.dot.lifeTime = .1; % in seconds
16+
cfg.dot.matrixWidth = 250; % in pixels
17+
cfg.dot.proportionKilledPerFrame = 0;
18+
19+
cfg.timing.eventDuration = 1.8; % in seconds
20+
21+
relativeDensityContrast = dotMotionSimulation(cfg, thisEvent, nbEvents, doPlot);

src/aperture/apertureTexture.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106

107107
case 'circle'
108108

109+
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
110+
109111
diameter = cfg.aperture.widthPix;
110112

111113
if isfield(cfg.aperture, 'xPosPix')

src/dot/computeCartCoord.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
function cartesianCoordinates = computeCartCoord(positions, cfg)
1+
function cartesianCoordinates = computeCartCoord(positions, dotMatrixWidth)
2+
23
cartesianCoordinates = ...
3-
[positions(:, 1) - cfg.dot.matrixWidth / 2, ... % x coordinate
4-
positions(:, 2) - cfg.dot.matrixWidth / 2]; % y coordinate
4+
[positions(:, 1) - dotMatrixWidth / 2, ... % x coordinate
5+
positions(:, 2) - dotMatrixWidth / 2]; % y coordinate
56

6-
% cartesianCoordinates = positions;
77
end

src/dot/computeRadialMotionDirection.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function angleMotion = computeRadialMotionDirection(cfg, dots)
1+
function angleMotion = computeRadialMotionDirection(positions, dotMatrixWidth, dots)
22

3-
cartesianCoordinates = computeCartCoord(dots.positions, cfg);
3+
positions = computeCartCoord(positions, dotMatrixWidth);
44

5-
[angleMotion, ~] = cart2pol(cartesianCoordinates(:, 1), cartesianCoordinates(:, 2));
5+
[angleMotion, ~] = cart2pol(positions(:, 1), positions(:, 2));
66
angleMotion = angleMotion / pi * 180;
77

88
if dots.direction == -666

0 commit comments

Comments
 (0)