diff --git a/tests/test_dotMotionSimulation.m b/manualTests/test_dotMotionSimulation.m similarity index 93% rename from tests/test_dotMotionSimulation.m rename to manualTests/test_dotMotionSimulation.m index 83e715e..8140072 100644 --- a/tests/test_dotMotionSimulation.m +++ b/manualTests/test_dotMotionSimulation.m @@ -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 @@ -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 diff --git a/src/dot/initDots.m b/src/dot/initDots.m index 94077b0..7f8000a 100644 --- a/src/dot/initDots.m +++ b/src/dot/initDots.m @@ -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 diff --git a/src/dot/setDotDirection.m b/src/dot/setDotDirection.m index 3d093b4..922695c 100644 --- a/src/dot/setDotDirection.m +++ b/src/dot/setDotDirection.m @@ -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 @@ -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); diff --git a/src/keyboard/getResponse.m b/src/keyboard/getResponse.m index 8070949..1467955 100644 --- a/src/keyboard/getResponse.m +++ b/src/keyboard/getResponse.m @@ -201,7 +201,7 @@ function talkToMe(action, cfg) end - if verbose + if verbose > 2 fprintf('\n %s\n\n', msg); end diff --git a/src/utils/pixToDeg.m b/src/utils/pixToDeg.m index a55978c..b8334f7 100644 --- a/src/utils/pixToDeg.m +++ b/src/utils/pixToDeg.m @@ -24,6 +24,6 @@ pix = getfield(structure, fieldName); %#ok structure = setfield(structure, [strrep(fieldName, 'Pix', '') 'DegVA'], ... - floor(pix / cfg.screen.ppd)); %#ok + pix / cfg.screen.ppd); %#ok end diff --git a/test-2.py b/test-2.py deleted file mode 100644 index e69de29..0000000 diff --git a/test-permission.py b/test-permission.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_initDots.m b/tests/test_initDots.m index 75a50d8..3f0dce7 100644 --- a/tests/test_initDots.m +++ b/tests/test_initDots.m @@ -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)); @@ -53,7 +53,7 @@ function test_initDotsBasic() dots = rmfield(dots, 'positions'); %% test - assertEqual(expectedStructure, dots); + assertEqual(dots, expectedStructure); end @@ -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); @@ -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