@@ -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
5858end
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
9089end
9190
9291function 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
118144end
0 commit comments