Skip to content

Commit 8daf182

Browse files
authored
Merge pull request #119 from cpp-lln-lab/remi-update_V_localizer
update for visual localizer
2 parents aa0799e + 9be7a03 commit 8daf182

File tree

8 files changed

+50
-24
lines changed

8 files changed

+50
-24
lines changed

tests/test_dotMotionSimulation.m renamed to manualTests/test_dotMotionSimulation.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function test_dotMotionSimulationStatic()
1212
doPlot = false;
1313

1414
thisEvent.direction = -1; % degrees
15-
thisEvent.speed = 1; % pix per frame
15+
thisEvent.speedPix = 1; % pix per frame
1616

1717
cfg.design.motionType = 'translation';
1818
cfg.dot.coherence = 1; % proportion
@@ -32,7 +32,7 @@ function test_dotMotionSimulationTranslation()
3232
doPlot = false;
3333

3434
thisEvent.direction = 0; % degrees
35-
thisEvent.speed = 1; % pix per frame
35+
thisEvent.speedPix = 1; % pix per frame
3636

3737
cfg.design.motionType = 'translation';
3838
cfg.dot.coherence = 1; % proportion

src/dot/initDots.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
% decide which dots are signal dots (1) and those are noise dots (0)
2828
dots.isSignal = rand(cfg.dot.number, 1) < cfg.dot.coherence;
2929

30-
dots.speedPixPerFrame = thisEvent.speed(1);
30+
dots.speedPixPerFrame = thisEvent.speedPix(1);
3131
lifeTime = cfg.dot.lifeTime;
3232

3333
% for static dots

src/dot/setDotDirection.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
% after that dots.direction will be a vector
1717
if numel(directionAllDots) == 1
1818

19-
directionAllDots(isSignal) = ones(sum(isSignal), 1) * dots.direction;
19+
directionAllDots = ones(sum(isSignal), 1) * dots.direction;
2020

2121
end
2222

@@ -25,12 +25,12 @@
2525

2626
angleMotion = computeRadialMotionDirection(positions, cfg.dot.matrixWidth, dots);
2727

28-
directionAllDots(isSignal) = angleMotion;
28+
directionAllDots(isSignal == 1) = angleMotion;
2929

3030
end
3131

3232
%% Random direction for the non coherent dots
33-
directionAllDots(~isSignal) = rand(sum(~isSignal), 1) * 360;
33+
directionAllDots(isSignal ~= 1) = rand(sum(isSignal ~= 1), 1) * 360;
3434

3535
%% Express the direction in the 0 to 360 range
3636
directionAllDots = mod(directionAllDots, 360);

src/keyboard/getResponse.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function talkToMe(action, cfg)
201201

202202
end
203203

204-
if verbose
204+
if verbose > 2
205205
fprintf('\n %s\n\n', msg);
206206

207207
end

src/utils/pixToDeg.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
pix = getfield(structure, fieldName); %#ok<GFLD>
2525

2626
structure = setfield(structure, [strrep(fieldName, 'Pix', '') 'DegVA'], ...
27-
floor(pix / cfg.screen.ppd)); %#ok<SFLD>
27+
pix / cfg.screen.ppd); %#ok<SFLD>
2828

2929
end

test-2.py

Whitespace-only changes.

test-permission.py

Whitespace-only changes.

tests/test_initDots.m

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ function test_initDotsBasic()
3131
cfg.screen.ifi = 0.01; % in seconds
3232

3333
thisEvent.direction = 0;
34-
thisEvent.speed = 10;
34+
thisEvent.speedPix = 10;
3535

3636
[dots] = initDots(cfg, thisEvent);
3737

3838
%% Undeterministic ouput
3939
assertTrue(all(dots.positions(:) >= 0));
40-
assertTrue(all(dots.positions(:) <= 2000));
40+
assertTrue(all(dots.positions(:) <= 50));
4141
assertTrue(all(dots.time(:) >= 0));
4242
assertTrue(all(dots.time(:) <= 1 / 0.01));
4343

@@ -53,7 +53,7 @@ function test_initDotsBasic()
5353
dots = rmfield(dots, 'positions');
5454

5555
%% test
56-
assertEqual(expectedStructure, dots);
56+
assertEqual(dots, expectedStructure);
5757

5858
end
5959

@@ -64,12 +64,11 @@ function test_initDotsStatic()
6464
cfg.dot.coherence = 1; % proportion
6565
cfg.dot.lifeTime = 0.250; % in seconds
6666
cfg.dot.matrixWidth = 50; % in pixels
67-
cfg.screen.winWidth = 2000; % in pixels
6867
cfg.timing.eventDuration = 1; % in seconds
6968
cfg.screen.ifi = 0.01; % in seconds
7069

7170
thisEvent.direction = -1;
72-
thisEvent.speed = 10;
71+
thisEvent.speedPix = 10;
7372

7473
[dots] = initDots(cfg, thisEvent);
7574

@@ -85,34 +84,61 @@ function test_initDotsStatic()
8584
expectedStructure.direction = -1;
8685

8786
%% test
88-
assertEqual(expectedStructure, dots);
87+
assertEqual(dots, expectedStructure);
8988

9089
end
9190

9291
function test_initDotsRadial()
9392

93+
%% set up
94+
95+
% % Dot life time in seconds
96+
% cfg.dot.lifeTime
97+
% % Number of dots
98+
% cfg.dot.number
99+
% Proportion of coherent dots.
100+
% cfg.dot.coherence
101+
%
102+
% % Direction (an angle in degrees)
103+
% thisEvent.direction
104+
% % Speed expressed in pixels per frame
105+
% thisEvent.speed
106+
94107
cfg.design.motionType = 'radial';
95108
cfg.dot.number = 10;
96109
cfg.dot.coherence = 1; % proportion
97110
cfg.dot.lifeTime = 0.250; % in seconds
98111
cfg.dot.matrixWidth = 50; % in pixels
99-
cfg.screen.winWidth = 2000; % in pixels
100112
cfg.timing.eventDuration = 1; % in seconds
101113
cfg.screen.ifi = 0.01; % in seconds
102114

103-
thisEvent.direction = 666; % outward motion
104-
thisEvent.speed = 10;
115+
thisEvent.direction = 666;
116+
thisEvent.speedPix = 10;
105117

106118
[dots] = initDots(cfg, thisEvent);
107119

108-
%% data to test against
109-
XY = dots.positions - 2000 / 2;
110-
angle = cart2pol(XY(:, 1), XY(:, 2));
111-
angle = angle / pi * 180;
112-
[horVector, vertVector] = decomposeMotion(angle);
113-
speeds = [horVector, vertVector] * 10;
120+
%% Deterministic output : data to test against
121+
expectedStructure.lifeTime = 25;
122+
expectedStructure.isSignal = ones(10, 1);
123+
expectedStructure.speedPixPerFrame = 10;
124+
expectedStructure.direction = 666;
125+
126+
directionAllDots = setDotDirection( ...
127+
dots.positions, ...
128+
cfg, ...
129+
expectedStructure, ...
130+
expectedStructure.isSignal);
131+
[horVector, vertVector] = decomposeMotion(directionAllDots);
132+
if strcmp(cfg.design.motionType, 'radial')
133+
vertVector = vertVector * -1;
134+
end
135+
expectedStructure.speeds = [horVector, vertVector] * expectedStructure.speedPixPerFrame;
136+
137+
% remove undeterministic output
138+
dots = rmfield(dots, 'time');
139+
dots = rmfield(dots, 'positions');
114140

115141
%% test
116-
% assertEqual(speeds, dots.speeds);
142+
assertEqual(dots, expectedStructure);
117143

118144
end

0 commit comments

Comments
 (0)