Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function test_dotMotionSimulationStatic()
doPlot = false;

thisEvent.direction = -1; % degrees
thisEvent.speed = 1; % pix per frame
thisEvent.speedPix = 1; % pix per frame

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

thisEvent.direction = 0; % degrees
thisEvent.speed = 1; % pix per frame
thisEvent.speedPix = 1; % pix per frame

cfg.design.motionType = 'translation';
cfg.dot.coherence = 1; % proportion
Expand Down
2 changes: 1 addition & 1 deletion src/dot/initDots.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
% decide which dots are signal dots (1) and those are noise dots (0)
dots.isSignal = rand(cfg.dot.number, 1) < cfg.dot.coherence;

dots.speedPixPerFrame = thisEvent.speed(1);
dots.speedPixPerFrame = thisEvent.speedPix(1);
lifeTime = cfg.dot.lifeTime;

% for static dots
Expand Down
6 changes: 3 additions & 3 deletions src/dot/setDotDirection.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
% after that dots.direction will be a vector
if numel(directionAllDots) == 1

directionAllDots(isSignal) = ones(sum(isSignal), 1) * dots.direction;
directionAllDots = ones(sum(isSignal), 1) * dots.direction;

end

Expand All @@ -25,12 +25,12 @@

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

directionAllDots(isSignal) = angleMotion;
directionAllDots(isSignal == 1) = angleMotion;

end

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

%% Express the direction in the 0 to 360 range
directionAllDots = mod(directionAllDots, 360);
Expand Down
2 changes: 1 addition & 1 deletion src/keyboard/getResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function talkToMe(action, cfg)

end

if verbose
if verbose > 2
fprintf('\n %s\n\n', msg);

end
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pixToDeg.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
pix = getfield(structure, fieldName); %#ok<GFLD>

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

end
Empty file removed test-2.py
Empty file.
Empty file removed test-permission.py
Empty file.
58 changes: 42 additions & 16 deletions tests/test_initDots.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ function test_initDotsBasic()
cfg.screen.ifi = 0.01; % in seconds

thisEvent.direction = 0;
thisEvent.speed = 10;
thisEvent.speedPix = 10;

[dots] = initDots(cfg, thisEvent);

%% Undeterministic ouput
assertTrue(all(dots.positions(:) >= 0));
assertTrue(all(dots.positions(:) <= 2000));
assertTrue(all(dots.positions(:) <= 50));
assertTrue(all(dots.time(:) >= 0));
assertTrue(all(dots.time(:) <= 1 / 0.01));

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

%% test
assertEqual(expectedStructure, dots);
assertEqual(dots, expectedStructure);

end

Expand All @@ -64,12 +64,11 @@ function test_initDotsStatic()
cfg.dot.coherence = 1; % proportion
cfg.dot.lifeTime = 0.250; % in seconds
cfg.dot.matrixWidth = 50; % in pixels
cfg.screen.winWidth = 2000; % in pixels
cfg.timing.eventDuration = 1; % in seconds
cfg.screen.ifi = 0.01; % in seconds

thisEvent.direction = -1;
thisEvent.speed = 10;
thisEvent.speedPix = 10;

[dots] = initDots(cfg, thisEvent);

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

%% test
assertEqual(expectedStructure, dots);
assertEqual(dots, expectedStructure);

end

function test_initDotsRadial()

%% set up

% % Dot life time in seconds
% cfg.dot.lifeTime
% % Number of dots
% cfg.dot.number
% Proportion of coherent dots.
% cfg.dot.coherence
%
% % Direction (an angle in degrees)
% thisEvent.direction
% % Speed expressed in pixels per frame
% thisEvent.speed

cfg.design.motionType = 'radial';
cfg.dot.number = 10;
cfg.dot.coherence = 1; % proportion
cfg.dot.lifeTime = 0.250; % in seconds
cfg.dot.matrixWidth = 50; % in pixels
cfg.screen.winWidth = 2000; % in pixels
cfg.timing.eventDuration = 1; % in seconds
cfg.screen.ifi = 0.01; % in seconds

thisEvent.direction = 666; % outward motion
thisEvent.speed = 10;
thisEvent.direction = 666;
thisEvent.speedPix = 10;

[dots] = initDots(cfg, thisEvent);

%% data to test against
XY = dots.positions - 2000 / 2;
angle = cart2pol(XY(:, 1), XY(:, 2));
angle = angle / pi * 180;
[horVector, vertVector] = decomposeMotion(angle);
speeds = [horVector, vertVector] * 10;
%% Deterministic output : data to test against
expectedStructure.lifeTime = 25;
expectedStructure.isSignal = ones(10, 1);
expectedStructure.speedPixPerFrame = 10;
expectedStructure.direction = 666;

directionAllDots = setDotDirection( ...
dots.positions, ...
cfg, ...
expectedStructure, ...
expectedStructure.isSignal);
[horVector, vertVector] = decomposeMotion(directionAllDots);
if strcmp(cfg.design.motionType, 'radial')
vertVector = vertVector * -1;
end
expectedStructure.speeds = [horVector, vertVector] * expectedStructure.speedPixPerFrame;

% remove undeterministic output
dots = rmfield(dots, 'time');
dots = rmfield(dots, 'positions');

%% test
% assertEqual(speeds, dots.speeds);
assertEqual(dots, expectedStructure);

end