|
1 | | -function [dots] = initializeDots(cfg, thisEvent) |
| 1 | +function [dots] = initDots(cfg, thisEvent) |
2 | 2 |
|
3 | 3 | direction = thisEvent.direction(1); |
4 | 4 |
|
|
12 | 12 | % for static dots |
13 | 13 | if direction == -1 |
14 | 14 | speedPixPerFrame = 0; |
15 | | - dots.lifeTime = cfg.eventDuration; |
16 | | - dots.isSignal = ones(cfg.dot.number, 1); |
| 15 | + dots.lifeTime = Inf; |
| 16 | + dots.isSignal = true(cfg.dot.number, 1); |
17 | 17 | end |
18 | 18 |
|
19 | 19 | % Convert from seconds to frames |
|
33 | 33 | dots.speeds(dots.isSignal, :) = ... |
34 | 34 | repmat([horVector, vertVector], sum(dots.isSignal), 1); |
35 | 35 |
|
36 | | - % If not 100% coherence, we get new random direction for the other dots |
37 | | - direction = rand(sum(~dots.isSignal), 1) * 360; |
38 | | - [horVector, vertVector] = decompMotion(direction); |
39 | | - dots.speeds(~dots.isSignal, :) = [horVector, vertVector]; |
| 36 | + % Random direction for the non coherent dots |
| 37 | + if any(~dots.isSignal) |
| 38 | + randomDirection = rand(sum(~dots.isSignal), 1) * 360; |
| 39 | + [horVector, vertVector] = decompMotion(randomDirection); |
| 40 | + dots.speeds(~dots.isSignal, :) = [horVector, vertVector]; |
| 41 | + end |
40 | 42 |
|
41 | 43 | % So far we were working wiht unit vectors convert that speed in pixels per |
42 | 44 | % frame |
43 | 45 | dots.speeds = dots.speeds * speedPixPerFrame; |
44 | 46 |
|
45 | 47 | % Create a vector to update to dotlife time of each dot |
46 | | - % Not all set to one so the dots will die at different times |
| 48 | + % Not all set to 1 so the dots will die at different times |
| 49 | + % The maximum value is the duraion of the event in frames |
47 | 50 | dots.time = floor(rand(cfg.dot.number, 1) * cfg.eventDuration / cfg.screen.ifi); |
48 | 51 |
|
49 | 52 | end |
0 commit comments