77end
88
99function test_initDotsBasic()
10-
10+
1111 %% set up
12-
12+
1313 % % Dot life time in seconds
1414 % cfg.dot.lifeTime
1515 % % Number of dots
@@ -21,7 +21,7 @@ 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
@@ -30,34 +30,37 @@ function test_initDotsBasic()
3030 cfg.screen.winWidth = 2000 ; % in pixels
3131 cfg.timing.eventDuration = 1 ; % in seconds
3232 cfg.screen.ifi = 0.01 ; % in seconds
33-
33+
3434 thisEvent.direction = 0 ;
3535 thisEvent.speed = 10 ;
36-
37- % [dots] = initDots(cfg, thisEvent);
38-
36+
37+ [dots ] = initDots(cfg , thisEvent );
38+
3939 %% Undeterministic ouput
40- % assertTrue(all(dots.positions(:) >= 0));
41- % assertTrue(all(dots.positions(:) <= 2000));
42- % assertTrue(all(dots.time(:) >= 0));
43- % assertTrue(all(dots.time(:) <= 1 / 0.01));
44-
40+ assertTrue(all(dots .positions(: ) >= 0 ));
41+ assertTrue(all(dots .positions(: ) <= 2000 ));
42+ assertTrue(all(dots .time(: ) >= 0 ));
43+ assertTrue(all(dots .time(: ) <= 1 / 0.01 ));
44+
4545 %% Deterministic output : data to test against
4646 expectedStructure.lifeTime = 25 ;
4747 expectedStructure.isSignal = ones(10 , 1 );
4848 expectedStructure.speeds = repmat([1 0 ], 10 , 1 ) * 10 ;
49-
49+ expectedStructure.speedPixPerFrame = 10 ;
50+ expectedStructure.direction = zeros(10 , 1 );
51+ expectedStructure.directionAllDots = zeros(10 , 1 );
52+
5053 % remove undeterministic output
51- % dots = rmfield(dots, 'time');
52- % dots = rmfield(dots, 'positions');
53-
54+ dots = rmfield(dots , ' time' );
55+ dots = rmfield(dots , ' positions' );
56+
5457 %% test
55- % assertEqual(expectedStructure, dots);
56-
58+ assertEqual(expectedStructure , dots );
59+
5760end
5861
5962function test_initDotsStatic()
60-
63+
6164 cfg.design.motionType = ' translation' ;
6265 cfg.dot.number = 10 ;
6366 cfg.dot.coherence = 1 ; % proportion
@@ -66,28 +69,31 @@ function test_initDotsStatic()
6669 cfg.screen.winWidth = 2000 ; % in pixels
6770 cfg.timing.eventDuration = 1 ; % in seconds
6871 cfg.screen.ifi = 0.01 ; % in seconds
69-
72+
7073 thisEvent.direction = - 1 ;
7174 thisEvent.speed = 10 ;
72-
73- % [dots] = initDots(cfg, thisEvent);
74-
75+
76+ [dots ] = initDots(cfg , thisEvent );
77+
7578 % remove undeterministic output
76- % dots = rmfield(dots, 'time');
77- % dots = rmfield(dots, 'positions');
78-
79+ dots = rmfield(dots , ' time' );
80+ dots = rmfield(dots , ' positions' );
81+
7982 %% data to test against
8083 expectedStructure.lifeTime = Inf ;
8184 expectedStructure.isSignal = ones(10 , 1 );
8285 expectedStructure.speeds = zeros(10 , 2 );
83-
86+ expectedStructure.speedPixPerFrame = 0 ;
87+ expectedStructure.direction = - 1 * ones(10 , 1 );
88+ expectedStructure.directionAllDots = - 1 * ones(10 , 1 );
89+
8490 %% test
85- % assertEqual(expectedStructure, dots);
86-
91+ assertEqual(expectedStructure , dots );
92+
8793end
8894
8995function test_initDotsRadial()
90-
96+
9197 cfg.design.motionType = ' radial' ;
9298 cfg.dot.number = 10 ;
9399 cfg.dot.coherence = 1 ; % proportion
@@ -96,20 +102,20 @@ function test_initDotsRadial()
96102 cfg.screen.winWidth = 2000 ; % in pixels
97103 cfg.timing.eventDuration = 1 ; % in seconds
98104 cfg.screen.ifi = 0.01 ; % in seconds
99-
105+
100106 thisEvent.direction = 666 ; % outward motion
101107 thisEvent.speed = 10 ;
102-
103- % [dots] = initDots(cfg, thisEvent);
104-
108+
109+ [dots ] = initDots(cfg , thisEvent );
110+
105111 %% data to test against
106- % XY = dots.positions - 2000 / 2;
107- % angle = cart2pol(XY(:, 1), XY(:, 2));
108- % angle = angle / pi * 180;
109- % [horVector, vertVector] = decomposeMotion(angle);
110- % speeds = [horVector, vertVector] * 10;
111-
112+ XY = dots .positions - 2000 / 2 ;
113+ angle = cart2pol(XY(: , 1 ), XY(: , 2 ));
114+ angle = angle / pi * 180 ;
115+ [horVector , vertVector ] = decomposeMotion(angle );
116+ speeds = [horVector , vertVector ] * 10 ;
117+
112118 %% test
113- % assertEqual(speeds, dots.speeds);
114-
119+ % assertEqual(speeds, dots.speeds);
120+
115121end
0 commit comments