Skip to content

Commit 5120396

Browse files
committed
mh autofix
1 parent 6b3330a commit 5120396

File tree

6 files changed

+64
-68
lines changed

6 files changed

+64
-68
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
function direction = computeRadialMotionDirection(cfg, positions, direction)
22
if strcmp(cfg.design.motionType, 'radial')
3-
3+
44
cartesianCoordinates = positions - cfg.screen.winWidth / 2;
5-
6-
[angle, ~] = cart2pol(cartesianCoordinates(:,1), cartesianCoordinates(:,2));
5+
6+
[angle, ~] = cart2pol(cartesianCoordinates(:, 1), cartesianCoordinates(:, 2));
77
angle = angle / pi * 180;
8-
8+
99
if direction == -666
1010
angle = angle - 180;
1111
end
12-
12+
1313
direction = angle;
14-
14+
1515
end
16-
end
16+
end

src/dot/initDots.m

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
% thisEvent.speed
1515
%
1616
%
17-
17+
1818
% TODO
1919
% bound direction between 0 and 360 ??
20-
20+
2121
direction = thisEvent.direction(1);
22-
22+
2323
speedPixPerFrame = thisEvent.speed(1);
2424

2525
lifeTime = cfg.dot.lifeTime;
@@ -33,30 +33,30 @@
3333
lifeTime = Inf;
3434
isSignal = true(cfg.dot.number, 1);
3535
end
36-
36+
3737
%% Set an array of dot positions [xposition, yposition]
3838
% These can never be bigger than 1 or lower than 0
3939
% [0,0] is the top / left of the square
4040
% [1,1] is the bottom / right of the square
4141
positions = rand(cfg.dot.number, 2) * cfg.screen.winWidth;
4242

43-
%% Set vertical and horizontal speed for all dots
43+
%% Set vertical and horizontal speed for all dots
4444
directionAllDots = setDotDirection(cfg, positions, direction, isSignal);
45-
45+
4646
[horVector, vertVector] = decomposeMotion(directionAllDots);
4747
speeds = [horVector, vertVector];
48-
48+
4949
% we were working with unit vectors. we now switch to pixels
5050
speeds = speeds * speedPixPerFrame;
5151

5252
%% Create a vector to update to dotlife time of each dot
5353
% Not all set to 1 so the dots will die at different times
5454
% The maximum value is the duraion of the event in frames
5555
time = floor(rand(cfg.dot.number, 1) * cfg.eventDuration / cfg.screen.ifi);
56-
56+
5757
%% Convert from seconds to frames
5858
lifeTime = ceil(lifeTime / cfg.screen.ifi);
59-
59+
6060
%%
6161
dots.lifeTime = lifeTime;
6262
dots.time = time;
@@ -66,17 +66,15 @@
6666
end
6767

6868
function directionAllDots = setDotDirection(cfg, positions, direction, isSignal)
69-
69+
7070
directionAllDots = nan(cfg.dot.number, 1);
71-
71+
7272
direction = computeRadialMotionDirection(cfg, positions, direction);
73-
73+
7474
% Coherent dots
7575
directionAllDots(isSignal) = direction;
7676
% Random direction for the non coherent dots
7777
directionAllDots(~isSignal) = rand(sum(~isSignal), 1) * 360;
78-
directionAllDots = rem(directionAllDots,360);
79-
80-
end
81-
78+
directionAllDots = rem(directionAllDots, 360);
8279

80+
end

src/dot/reseedDots.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function dots = reseedDots(dots, cfg)
2-
2+
33
% Create a logical vector to detect any dot that has:
44
% - an xy position inferior to 0
55
% - an xy position superior to winWidth
@@ -17,5 +17,5 @@
1717
dots.positions(N, :) = rand(sum(N), 2) * cfg.screen.winWidth;
1818
dots.time(N, 1) = 1;
1919
end
20-
21-
end
20+
21+
end

tests/test_computeRadialMotionDirection.m

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@ function test_computeRadialMotionDirectionBasic()
1313
cfg.design.motionType = 'radial';
1414
cfg.screen.winWidth = 100; % in pixels
1515
direction = 666;
16-
16+
1717
positions = [
18-
100, 100/2; ... % middle of right side
18+
100, 100 / 2; ... % middle of right side
1919
100, 100; ... % top right corner
20-
100/2, 100; ...
21-
0, 100/2; ...
20+
100 / 2, 100; ...
21+
0, 100 / 2; ...
2222
0, 0; ...
23-
100/2, 0];
24-
23+
100 / 2, 0];
24+
2525
direction = computeRadialMotionDirection(cfg, positions, direction);
26-
26+
2727
expectedDirection = [
2828
0; ... right
2929
45; ... up-right
3030
90; ... up
3131
180; ... left
3232
-135; ... down left
3333
-90]; % down
34-
35-
34+
3635
%% test
3736
assertEqual(expectedDirection, direction);
3837

39-
end
38+
end

tests/test_initDots.m

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
function test_initDotsBasic()
1010

1111
%% set up
12-
12+
1313
% % Dot life time in seconds
1414
% cfg.dot.lifeTime
1515
% % Number of dots
@@ -21,32 +21,32 @@ function test_initDotsBasic()
2121
% thisEvent.direction
2222
% % Speed expressed in pixels per frame
2323
% thisEvent.speed
24-
24+
2525
cfg.design.motionType = 'translation';
2626
cfg.dot.number = 10;
2727
cfg.dot.coherence = 1; % proportion
2828
cfg.dot.lifeTime = 0.250; % in seconds
2929
cfg.screen.winWidth = 2000; % in pixels
3030
cfg.eventDuration = 1; % in seconds
3131
cfg.screen.ifi = 0.01; % in seconds
32-
32+
3333
thisEvent.direction = 0;
3434
thisEvent.speed = 10;
3535

3636
[dots] = initDots(cfg, thisEvent);
37-
37+
3838
%% Undeterministic ouput
3939
assertTrue(all(dots.positions(:) >= 0));
4040
assertTrue(all(dots.positions(:) <= 2000));
4141
assertTrue(all(dots.time(:) >= 0));
4242
assertTrue(all(dots.time(:) <= 1 / 0.01));
4343

44-
%% Deterministic output : data to test against
45-
expectedStructure.lifeTime = 25;
44+
%% Deterministic output : data to test against
45+
expectedStructure.lifeTime = 25;
4646
expectedStructure.isSignal = ones(10, 1);
4747
expectedStructure.speeds = repmat([1 0], 10, 1) * 10;
48-
49-
% remove undeterministic output
48+
49+
% remove undeterministic output
5050
dots = rmfield(dots, 'time');
5151
dots = rmfield(dots, 'positions');
5252

@@ -64,27 +64,26 @@ function test_initDotsStatic()
6464
cfg.screen.winWidth = 2000; % in pixels
6565
cfg.eventDuration = 1; % in seconds
6666
cfg.screen.ifi = 0.01; % in seconds
67-
67+
6868
thisEvent.direction = -1;
6969
thisEvent.speed = 10;
7070

7171
[dots] = initDots(cfg, thisEvent);
72-
72+
7373
% remove undeterministic output
7474
dots = rmfield(dots, 'time');
7575
dots = rmfield(dots, 'positions');
7676

77-
%% data to test against
78-
expectedStructure.lifeTime = Inf;
77+
%% data to test against
78+
expectedStructure.lifeTime = Inf;
7979
expectedStructure.isSignal = ones(10, 1);
8080
expectedStructure.speeds = zeros(10, 2);
81-
81+
8282
%% test
8383
assertEqual(expectedStructure, dots);
8484

8585
end
8686

87-
8887
function test_initDotsRadial()
8988

9089
cfg.design.motionType = 'radial';
@@ -94,20 +93,20 @@ function test_initDotsRadial()
9493
cfg.screen.winWidth = 2000; % in pixels
9594
cfg.eventDuration = 1; % in seconds
9695
cfg.screen.ifi = 0.01; % in seconds
97-
96+
9897
thisEvent.direction = 666; % outward motion
9998
thisEvent.speed = 10;
10099

101100
[dots] = initDots(cfg, thisEvent);
102-
103-
%% data to test against
104-
XY = dots.positions - 2000/2;
105-
angle = cart2pol(XY(:,1), XY(:,2));
101+
102+
%% data to test against
103+
XY = dots.positions - 2000 / 2;
104+
angle = cart2pol(XY(:, 1), XY(:, 2));
106105
angle = angle / pi * 180;
107106
[horVector, vertVector] = decomposeMotion(angle);
108107
speeds = [horVector, vertVector] * 10;
109108

110109
%% test
111110
assertEqual(speeds, dots.speeds);
112111

113-
end
112+
end

tests/test_setDefaultsPTB.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@
77
end
88

99
function test_setDefaultsPtbBasic()
10-
10+
1111
% set up
1212
cfg = setDefaultsPTB;
13-
13+
1414
% test data
1515
expectedCfg = returnExpectedCFG();
1616

1717
% test
1818
assertEqual(expectedCfg, cfg);
19-
19+
2020
end
2121

2222
function test_setDefaultsPtbOverwrite()
2323

2424
% set up
2525
cfg.screen.monitorWidth = 36;
2626
cfg = setDefaultsPTB(cfg);
27-
27+
2828
% test data
2929
expectedCfg = returnExpectedCFG();
3030
expectedCfg.screen.monitorWidth = 36;
3131

3232
% test
3333
assertEqual(expectedCfg, cfg);
34-
34+
3535
end
3636

3737
function test_setDefaultsPtbAudio()
3838

3939
% set up
4040
cfg.audio.do = 1;
4141
cfg = setDefaultsPTB(cfg);
42-
42+
4343
% test data
4444
expectedCfg = returnExpectedCFG();
4545
expectedCfg.audio = struct( ...
@@ -54,11 +54,11 @@ function test_setDefaultsPtbAudio()
5454

5555
% test
5656
assertEqual(expectedCfg, cfg);
57-
57+
5858
end
5959

6060
function expectedCFG = returnExpectedCFG()
61-
61+
6262
expectedCFG = struct( ...
6363
'testingDevice', 'pc', ...
6464
'debug', struct('do', true, 'transpWin', true, 'smallWin', true), ...
@@ -68,21 +68,21 @@ function test_setDefaultsPtbAudio()
6868
'screen', struct( ...
6969
'monitorWidth', 42, ...
7070
'monitorDistance', 134));
71-
71+
7272
% fixation cross or dot
7373
expectedCFG.fixation.type = 'cross';
7474
expectedCFG.fixation.xDisplacement = 0;
7575
expectedCFG.fixation.yDisplacement = 0;
7676
expectedCFG.fixation.color = [255 255 255];
7777
expectedCFG.fixation.width = 1;
7878
expectedCFG.fixation.lineWidthPix = 5;
79-
79+
8080
% define visual apperture field
8181
expectedCFG.aperture.type = 'none';
82-
82+
8383
expectedCFG.keyboard.keyboard = [];
8484
expectedCFG.keyboard.responseBox = [];
8585
expectedCFG.keyboard.responseKey = {};
8686
expectedCFG.keyboard.escapeKey = 'ESCAPE';
87-
87+
8888
end

0 commit comments

Comments
 (0)