Skip to content

Commit 73580bb

Browse files
authored
Merge pull request #56 from cpp-lln-lab/remi-localizer_update
Updates from localizer: move sub-functions into CPP_PTB and update readme
2 parents a24203e + 46f990f commit 73580bb

19 files changed

+340
-48
lines changed

README.md

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,74 @@ We use the [MISS_HIT linter](https://florianschanda.github.io/miss_hit/style_che
3535

3636
## How to install
3737

38-
### Use the matlab package manager
38+
### Download with git
39+
40+
``` bash
41+
cd fullpath_to_directory_where_to_install
42+
# use git to download the code
43+
git clone https://github.com/cpp-lln-lab/CPP_PTB.git
44+
# move into the folder you have just created
45+
cd CPP_PTB
46+
# add the src folder to the matlab path and save the path
47+
matlab -nojvm -nosplash -r "addpath(fullfile(pwd)); savepath ();"
48+
```
3949

40-
This repository can be added as a dependencies by listing it in a [mpm-requirements.txt file](.mpm-requirements.txt)
41-
as follows:
50+
Then get the latest commit:
51+
```bash
52+
# from the directory where you downloaded the code
53+
git pull origin master
54+
```
4255

43-
CPP_PTB -u https://github.com/cpp-lln-lab/CPP_PTB.git
56+
To work with a specific version, create a branch at a specific version tag number
57+
```bash
58+
# creating and checking out a branch that will be calle version1 at the version tag v0.0.1
59+
git checkout -b version1 v0.0.1
60+
```
4461

45-
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.
62+
### Add as a submodule
4663

47-
```matlab
48-
function getDependencies(action)
49-
% Will install on your computer the matlab dependencies specified in the mpm-requirements.txt
50-
% and add them to the matlab path. The path is never saved so you need to run getDependencies() when
51-
% you start matlab.
52-
%
53-
% getDependencies('update') will force the update and overwrite previous version of the dependencies.
54-
%
55-
% getDependencies() If you only already have the appropriate version but just want to add them to the matlab path.
56-
57-
experimentName = YOUR_EXPERIMENT_NAME;
58-
59-
if nargin<1
60-
action = '';
61-
end
62-
63-
switch action
64-
case 'update'
65-
% install dependencies
66-
mpm install -i mpm-requirements.txt -f -c YOUR_EXPERIMENT_NAME
67-
end
68-
69-
% adds them to the path
70-
mpm_folder = fileparts(which('mpm'));
71-
addpath(genpath(fullfile(mpm_folder, 'mpm-packages', 'mpm-collections', experimentName)));
72-
73-
end
64+
Add it as a submodule in the repo you are working on.
65+
66+
``` bash
67+
cd fullpath_to_directory_where_to_install
68+
# use git to download the code
69+
git submodule add https://github.com/cpp-lln-lab/CPP_PTB.git
70+
# move into the folder you have just created
71+
cd CPP_PTB
72+
# add the src folder to the matlab path and save the path
73+
matlab -nojvm -nosplash -r "addpath(fullfile(pwd))"
74+
```
75+
76+
To get the latest commit you then need to update the submodule with the information
77+
on its remote repository and then merge those locally.
78+
```bash
79+
git submodule update --remote --merge
7480
```
7581

82+
Remember that updates to submodules need to be commited as well.
83+
84+
**TO DO**
85+
<!-- Submodules
86+
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).
87+
cons: for pro users and not super clear how to use it at the moment. -->
88+
89+
### Direct download
90+
91+
Download the code. Unzip. And add to the matlab path.
92+
93+
Pick a specific version:
94+
95+
https://github.com/cpp-lln-lab/CPP_PTB/releases
96+
97+
Or take the latest commit (NOT RECOMMENDED):
98+
99+
https://github.com/cpp-lln-lab/CPP_PTB/archive/master.zip
100+
101+
**TO DO**
102+
<!-- Download a specific version and c/p it in a subfun folder
103+
pros: the easiest solution to share the code and 'installing' it on the stimulation computer (usually not the one used to develop the code).
104+
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?) -->
105+
76106
## Setting up keyboards
77107

78108
To select a specific keyboard to be used by the experimenter or the participant, you need to know

apertureTexture.m

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function cfg = apertureTexture(action, cfg, thisEvent)
2+
3+
transparent = [0 0 0 0];
4+
5+
switch action
6+
7+
case 'init'
8+
9+
% we take the screen height as maximum aperture width if not
10+
% specified.
11+
if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width)
12+
cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd;
13+
end
14+
cfg.aperture = degToPix('width', cfg.aperture, cfg);
15+
16+
cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
17+
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
18+
19+
case 'make'
20+
21+
switch cfg.aperture.type
22+
23+
case 'none'
24+
25+
Screen('Fillrect', cfg.aperture.texture, transparent);
26+
27+
case 'circle'
28+
29+
diameter = cfg.aperture.widthPix;
30+
31+
xPos = cfg.screen.center(1);
32+
yPos = cfg.screen.center(2);
33+
if isfield(cfg.aperture, 'xPosPix')
34+
xPos = cfg.screen.center(1) + cfg.aperture.xPosPix;
35+
end
36+
if isfield(cfg.aperture, 'yPosPix')
37+
yPos = cfg.screen.center(2) + cfg.aperture.yPosPix;
38+
end
39+
40+
Screen('FillOval', cfg.aperture.texture, transparent, ...
41+
CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ...
42+
xPos, yPos));
43+
44+
end
45+
46+
case 'draw'
47+
48+
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture);
49+
50+
% Screen('DrawTexture', cfg.screen.win, apertureTexture, ...
51+
% cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90);
52+
53+
end
54+
55+
end

computeFOV.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
%
44
% computes the number of degrees of visual angle in the whole field of view
55
%
6+
% δ = 2 arctan ( d / 2D )
7+
%
8+
% δ is the angular diameter, and d is the actual diameter of the object,
9+
% and D is the distance to the object.
10+
% The result obtained is in radians.
11+
%
612

7-
FOV = 2 * ...
8-
(180 * (atan(cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance)) / pi));
13+
FOV = ...
14+
180 / pi * ...
15+
2 * atan(cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance));
916

1017
end

decompMotion.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function [horVector, vertVector] = decompMotion(angleMotion)
2+
% decompose angle of start motion into horizontal and vertical vector
3+
horVector = cos(pi * angleMotion / 180);
4+
vertVector = -sin(pi * angleMotion / 180);
5+
end

degToPix.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
deg = getfield(structure, fieldName); %#ok<GFLD>
99

1010
structure = setfield(structure, [fieldName 'Pix'], ...
11-
floor(cfg.screen.ppd * deg)) ; %#ok<SFLD>
11+
floor(deg * cfg.screen.ppd)) ; %#ok<SFLD>
1212

1313
end

dotTexture.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function cfg = dotTexture(action, cfg, thisEvent)
2+
3+
switch action
4+
5+
case 'init'
6+
cfg.dot.texture = Screen('MakeTexture', cfg.screen.win, ...
7+
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
8+
9+
case 'make'
10+
11+
dotType = 2;
12+
13+
Screen('FillRect', cfg.dot.texture, cfg.color.background);
14+
Screen('DrawDots', cfg.dot.texture, ...
15+
thisEvent.dot.positions, ...
16+
cfg.dot.sizePix, ...
17+
cfg.dot.color, ...
18+
cfg.screen.center, ...
19+
dotType);
20+
21+
case 'draw'
22+
23+
Screen('DrawTexture', cfg.screen.win, cfg.dot.texture);
24+
25+
end
26+
27+
end

drawFixation.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function drawFixation(cfg)
2+
% Define the parameters of the fixation cross in `cfg` and `expParameters`
3+
4+
if strcmp(cfg.fixation.type, 'cross')
5+
6+
smooth = 1;
7+
8+
Screen('DrawLines', ...
9+
cfg.screen.win, ...
10+
cfg.fixation.allCoords, ...
11+
cfg.fixation.lineWidthPix, ...
12+
cfg.fixation.color, ...
13+
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
14+
end
15+
16+
end

drawFixationCross.m

Lines changed: 0 additions & 11 deletions
This file was deleted.

farewellScreen.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function farewellScreen(cfg)
2+
3+
Screen('FillRect', cfg.screen.win, cfg.color.background, cfg.screen.winRect);
4+
DrawFormattedText(cfg.screen.win, 'Thank you!', 'center', 'center', cfg.text.color);
5+
Screen('Flip', cfg.screen.win);
6+
WaitSecs(cfg.mri.repetitionTime * 2);
7+
8+
end

getExperimentEnd.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function cfg = getExperimentEnd(cfg)
2+
3+
drawFixation(cfg);
4+
endExpmt = Screen('Flip', cfg.screen.win);
5+
6+
disp(' ');
7+
ExpmtDur = endExpmt - cfg.experimentStart;
8+
ExpmtDurMin = floor(ExpmtDur / 60);
9+
ExpmtDurSec = mod(ExpmtDur, 60);
10+
disp(['Experiment lasted ', ...
11+
num2str(ExpmtDurMin), ' minutes ', ...
12+
num2str(ExpmtDurSec), ' seconds']);
13+
disp(' ');
14+
15+
end

0 commit comments

Comments
 (0)