Skip to content

Commit ad48d9f

Browse files
Merge pull request #31 from marcobarilari/marco-readme
[WIP] readme for main folder and translational loc
2 parents f815ccd + fb1b03a commit ad48d9f

File tree

6 files changed

+186
-103
lines changed

6 files changed

+186
-103
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
# motion_Visual-Localizer
2-
This repo collects the most common localizers in use to define hMT/V5
3-
4-
5-
## Installing dependencies
6-
7-
All the dependencies needed to run this are listed in the [mpm-requirements.txt file](.mpm-requirements.txt). If those functions are not in the matlab path the scripts in this repository will not work.
1+
# Motion Visual-Localizer
82

9-
If you are using the [matlab package manager](https://github.com/mobeets/mpm), you can simply download the appropriate version of those dependencies and add them to your path by running the `getDependencies` function.
10-
11-
```matlab
12-
getDependencies('update')
13-
```
14-
15-
If you only already have the appropriate version but just want to add them to the matlab path, then run.
3+
This repo collects the most common localizers in use to define hMT/V5
164

17-
```matlab
18-
getDependencies()
19-
```
5+
1. Radial Motion
6+
2. [Translational motion](/Visual-loc_translational) (4 directions: up-, dowm-, left-, right-ward)

Visual-loc_translational/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Translational Motion
2+
3+
## Requirements
4+
5+
Make sure that the following toolboxes are installed and added to the matlab / octave path.
6+
7+
For instructions see the following links:
8+
9+
| Requirements | Used version |
10+
|----------------------------------------------------------|--------------|
11+
| [CPP_BIDS](https://github.com/cpp-lln-lab/CPP_BIDS) | ? |
12+
| [CPP_PTB](https://github.com/cpp-lln-lab/CPP_PTB) | ? |
13+
| [PsychToolBox](http://psychtoolbox.org/) | >=3.0.14 |
14+
| [Matlab](https://www.mathworks.com/products/matlab.html) | >=2017 |
15+
| or [octave](https://www.gnu.org/software/octave/) | >=4.? |
16+
17+
## Installing dependencies
18+
19+
All the dependencies needed to run this are listed in the [mpm-requirements.txt file](.mpm-requirements.txt). If those functions are not in the matlab path the scripts in this repository will not work.
20+
21+
If you are using the [matlab package manager](https://github.com/mobeets/mpm), you can simply download the appropriate version of those dependencies and add them to your path by running the `getDependencies` function.
22+
23+
```matlab
24+
getDependencies('update')
25+
```
26+
27+
If you already have the appropriate version but just want to add them to the matlab path, then run.
28+
29+
```matlab
30+
getDependencies()
31+
```
32+
## Structure and function details
33+
34+
### visualLocTranslational
35+
36+
Running this script will show blocks of motion dots (soon also moving gratings) and static dots. Motion blocks will show dots(/gratings) moving in one of four directions (up-, down-, left-, and right-ward)
37+
38+
By default it is run in `Debug mode` meaning that it does not run care about subjID, run n., fMRI triggers, Eye Tracker, etc..
39+
40+
Any details of the experiment can be changed in `setParameters.m` (e.g., experiment mode, motion stimuli details, exp. design, etc.)
41+
42+
### setParameters
43+
44+
`setParameters.m` is the core engine of the experiment. It contains the following tweakable sections:
45+
46+
- Debug mode setting
47+
- MRI settings
48+
- Engine parameters:
49+
- Monitor parameters
50+
- Monitor parameters for PsychToolBox
51+
- Keyboards
52+
- Experiment Design
53+
- Visual Stimulation
54+
- Task(s)
55+
- Instructions
56+
- Task #1 parameters
57+
58+
### subfun/doDotMo
59+
60+
#### Input:
61+
- `cfg`: PTB/machine configurations returned by `setParameters` and `initPTB`
62+
- `expParameters`: parameters returned by `setParameters`
63+
- `logFile`: structure that stores the experiment logfile to be saved
64+
65+
#### Output:
66+
- Event `onset`
67+
- Event `duration`
68+
69+
The dots are drawn on a square that contains the round aperture, then any dots outside of the aperture is turned into a NaN so effectively the actual number of dots on the screen at any given time is not the one that you input but a smaller number (nDots / Area of aperture) on average.
70+
71+
### subfun/expDesign
72+
Creates the sequence of blocks and the events in them. The conditions are consecutive static and motion blocks (Gives better results than randomised). It can be run as a stand alone without inputs to display a visual example of possible design.
73+
74+
#### EVENTS
75+
The `numEventsPerBlock` should be a multiple of the number of "base" listed in the `motionDirections` and `staticDirections` (4 at the moment).
76+
77+
#### TARGETS:
78+
- If there are 2 targets per block we make sure that they are at least 2 events apart.
79+
- Targets cannot be on the first or last event of a block
80+
81+
#### Input:
82+
- `expParameters`: parameters returned by `setParameters`
83+
- `displayFigs`: a boolean to decide whether to show the basic design matrix of the design
84+
85+
#### Output:
86+
- `expParameters.designBlockNames` is a cell array `(nr_blocks, 1)` with the name for each block
87+
- `expParameters.designDirections` is an array `(nr_blocks, numEventsPerBlock)` with the direction to present in a given block
88+
- `0 90 180 270` indicate the angle
89+
- `-1` indicates static
90+
- `expParameters.designSpeeds` is an array `(nr_blocks, numEventsPerBlock) * speedEvent`
91+
- `expParameters.designFixationTargets` is an array `(nr_blocks, numEventsPerBlock)` showing for each event if it should be accompanied by a target
92+
93+
### subfun/eyeTracker
94+
Eyetracker script, still to be debugged. Will probably moved in the CPP_PTB package. It deals with the calibration (dufault or custom), eye movements recording and saving the files.
95+
96+
### subfun/wait4Trigger
97+
Simple functions that counts the triggers sent by the MRI computer to the stimulation computer to sync brain volume recordings and stimulation.

Visual-loc_translational/setParameters.m

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727
cfg.numTriggers = 4;
2828
cfg.eyeTracker = false; % Set to 'true' if you are testing in MRI and want to record ET data
2929

30-
31-
%% Keyboards
32-
33-
% cfg.responseBox would be the device used by the participant to give his/her response:
34-
% like the button box in the scanner or a separate keyboard for a behavioral experiment
35-
%
36-
% cfg.keyboard is the keyboard on which the experimenter will type or press the keys necessary
37-
% to start or abort the experiment.
38-
% The two can be different or the same.
39-
40-
% Using empty vectors should work for linux and MacOS when to select the
41-
% "main" keyboard. You might have to try some other values for Windows
42-
cfg.keyboard = [];
43-
cfg.responseBox = [];
44-
45-
4630
%% Engine parameters
4731

4832
% Monitor parameters
@@ -61,11 +45,24 @@
6145
cfg.textSize = 18;
6246
cfg.textStyle = 1;
6347

48+
%% Keyboards
49+
50+
% cfg.responseBox would be the device used by the participant to give his/her response:
51+
% like the button box in the scanner or a separate keyboard for a behavioral experiment
52+
%
53+
% cfg.keyboard is the keyboard on which the experimenter will type or press the keys necessary
54+
% to start or abort the experiment.
55+
% The two can be different or the same.
56+
57+
% Using empty vectors should work for linux and MacOS when to select the
58+
% "main" keyboard. You might have to try some other values for Windows
59+
cfg.keyboard = [];
60+
cfg.responseBox = [];
61+
6462
% Keyboard
6563
cfg.escapeKey = 'Escape';
6664

6765

68-
6966
% The code below will help you decide which keyboard device to use for the partipant and the experimenter
7067

7168
% Computer keyboard to quit if it is necessary
@@ -80,31 +77,31 @@
8077

8178

8279
switch lower(cfg.device)
83-
84-
80+
81+
8582
% this part might need to be adapted because the "default" device
8683
% number might be different for different OS or set up
87-
84+
8885
case 'pc'
89-
86+
9087
cfg.keyboard = [];
9188
cfg.responseBox = [];
92-
89+
9390
if ismac
9491
cfg.keyboard = [];
9592
cfg.responseBox = [];
9693
end
97-
94+
9895
case 'scanner'
99-
96+
10097
otherwise
101-
98+
10299
% Cfg.keyboard = max(Cfg.keyboardNumbers);
103100
% Cfg.responseBox = min(Cfg.keyboardNumbers);
104-
101+
105102
cfg.keyboard = [];
106103
cfg.responseBox = [];
107-
104+
108105
end
109106

110107
%% Experiment Design
@@ -159,4 +156,4 @@
159156
fprintf('######################################## \n')
160157
fprintf('## DEBUG MODE, NOT THE SCANNER CODE ## \n')
161158
fprintf('######################################## \n\n')
162-
end
159+
end

Visual-loc_translational/subfun/doDotMo.m

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
% 0=Right; 90=Up; 180=Left; 270=down
66
%
77
% Input:
8-
% - Cfg: PTB/machine configurations returned by SetParameters and initPTB
9-
% - ExpParameters: parameters returned by SetParameters
10-
% - logFile: structur that stores the experiment logfile to be saved
8+
% - cfg: PTB/machine configurations returned by setParameters and initPTB
9+
% - expParameters: parameters returned by setParameters
10+
% - logFile: structure that stores the experiment logfile to be saved
1111
%
1212
% Output:
13-
% -
13+
% -
1414
%
1515
% The dots are drawn on a square that contains the round aperture, then any
1616
% dots outside of the aperture is turned into a NaN so effectively the
@@ -58,7 +58,7 @@
5858
% [1,1] is the bottom / right of the square that contains the square aperture
5959
xy = rand(ndots, 2);
6060

61-
% Set a N x 2 matrix that gives jump size in pixels
61+
% Set a N x 2 matrix that gives jump size in pixels
6262
% pix/sec * sec/frame = pix / frame
6363
dxdy = repmat(...
6464
speed * 10/(diamAperture*10) * (3/cfg.monRefresh) ...
@@ -84,69 +84,69 @@
8484
onset = vbl;
8585

8686
while continueShow
87-
87+
8888
% L are the dots that will be moved
8989
L = rand(ndots,1) < coh;
90-
90+
9191
% Move the selected dots
9292
xy(L,:) = xy(L,:) + dxdy(L,:);
93-
93+
9494
% If not 100% coherence, we get new random locations for the other dots
9595
if sum(~L) > 0
9696
xy(~L,:) = rand(sum(~L),2);
9797
end
98-
98+
9999
% Create a logical vector to detect any dot that has:
100100
% - an xy position inferior to 0
101101
% - an xy position superior to 1
102102
% - has exceeded its liftime
103103
N = any([xy > 1, xy < 0, dotTime > dotLifeTime], 2) ;
104-
104+
105105
% If there is any such dot we relocate it to a new random position
106106
% and change its lifetime to 1
107107
if any(N)
108108
xy(N,:) = rand(sum(N), 2);
109109
dotTime(N, 1) = 1;
110110
end
111-
111+
112112
% Convert the dot position to pixels
113113
xy_pix = floor( xy * diamAperturePix );
114-
114+
115115
% This assumes that zero is at the top left, but we want it to be
116116
% in the center, so shift the dots up and left, which just means
117117
% adding half of the aperture size to both the x and y direction.
118118
xy_pix = (xy_pix - diamAperturePix/2)';
119-
119+
120120
% NaN out-of-circle dots
121121
% We use Pythagore's theorem to figure out which dots are out of the
122122
% circle
123123
outCircle = sqrt(xy_pix(1,:).^2 + xy_pix(2,:).^2) + dotSizePix/2 > (diamAperturePix / 2);
124124
xy_pix(:, outCircle) = NaN;
125-
126-
125+
126+
127127
%% PTB draws the dots stimulation
128-
128+
129129
% Draw the fixation cross
130130
color = expParameters.fixationCrossColor;
131131
% If this frame shows a target we change the color
132132
if GetSecs < (onset+targetDuration) && isTarget==1
133133
color = expParameters.fixationCrossColorTarget;
134134
end
135135
drawFixationCross(cfg, expParameters, color)
136-
136+
137137
% Draw the dots
138138
Screen('DrawDots', cfg.win, xy_pix, dotSizePix, dotColor, cfg.center, 2);
139-
139+
140140
Screen('DrawingFinished', cfg.win, dontClear );
141-
141+
142142
vbl = Screen('Flip', cfg.win, vbl+cfg.ifi, dontClear );
143-
144-
143+
144+
145145
%% Update counters
146146

147147
% Check for end of loop
148148
continueShow = continueShow - 1;
149-
149+
150150
% Add one frame to the dot lifetime to each dot
151151
dotTime = dotTime + 1;
152152

0 commit comments

Comments
 (0)