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
2 changes: 2 additions & 0 deletions demos/CPP_checkAbortDemo.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

% add parent directory to the path (to make sure we can access the CPP_PTB
% functions)
addpath(fullfile(pwd, '..'));
Expand Down
2 changes: 2 additions & 0 deletions demos/CPP_getResponseDemo.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

%% Demo showing how to use the getResponse function

% This small script shows how to use the getReponse function
Expand Down
2 changes: 2 additions & 0 deletions demos/CPP_pressSpaceForMeDemo.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

% add parent directory to the path (to make sure we can access the CPP_PTB
% functions)
addpath(fullfile(pwd, '..'));
Expand Down
3 changes: 2 additions & 1 deletion demos/CPP_waitForTriggerDemo.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
% add parent/src directory to the path (to make sure we can access the CPP_PTB functions)
% (C) Copyright 2020 CPP_PTB developers

% add parent/src directory to the path (to make sure we can access the CPP_PTB functions)
addpath(genpath(fullfile(pwd, '..', 'src')));

cfg.mri.triggerNb = 5;
Expand Down
12 changes: 12 additions & 0 deletions demos/miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
line_length: 100
regex_function_name: "CPP_[a-z]+(([A-Z]){1}[A-Za-z]+)*"
copyright_entity: "Sam Schwarzkopf"
copyright_entity: "Agah Karakuzu"
copyright_entity: "CPP_PTB developers"

# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
metric "cnest": limit 4
metric "file_length": limit 500
metric "cyc": limit 15
metric "parameters": limit 5
4 changes: 3 additions & 1 deletion miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
line_length: 100
regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*"
suppress_rule: "copyright_notice"
copyright_entity: "Sam Schwarzkopf"
copyright_entity: "Agah Karakuzu"
copyright_entity: "CPP_PTB developers"

# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
metric "cnest": limit 4
Expand Down
3 changes: 3 additions & 0 deletions src/aperture/apertureTexture.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
% (C) Copyright 2010-2020 Sam Schwarzkopf
% (C) Copyright 2020 CPP_PTB developers

function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)
% [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)
%
Expand Down
2 changes: 2 additions & 0 deletions src/aperture/eccenLogSpeed.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [cfg] = eccenLogSpeed(cfg, time)
% vary CurrScale so that expansion speed is log over eccentricity
% cf. Tootell 1997; Swisher 2007; Warnking 2002 etc
Expand Down
16 changes: 16 additions & 0 deletions src/aperture/getApertureName.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% (C) Copyright 2020 CPP_PTB developers

function apertureName = getApertureName(cfg, apertures, iApert)

switch cfg.aperture
case 'Bar'
apertureName = sprintf('bar_angle-%i_position-%02.2f.tif', ...
apertures.barAngle(iApert), ...
apertures.barPostion(iApert));
case 'Wedge'
apertureName = sprintf('wedge_nb-%i.tif', iApert);
case 'Ring'
apertureName = sprintf('ring_nb-%i.tif', iApert);
end

end
36 changes: 36 additions & 0 deletions src/aperture/saveAperture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
% (C) Copyright 2010-2020 Sam Schwarzkopf
% (C) Copyright 2020 CPP_PTB developers

if SaveAps
if SaveAps == 1
ApFrm = zeros(100, 100, Parameters.Volumes_per_Trial * length(Parameters.Conditions));
elseif SaveAps == 2
ApFrm = zeros(640, 480, 3);
sf = 0;
end
SavWin = Screen('MakeTexture', Win, 127 * ones(StimRect([3 3])));
end

% If saving movie
if SaveAps == 1 && PrevVolume ~= CurrVolume
PrevVolume = CurrVolume;
CurApImg = Screen('GetImage', Win);
CurApImg = rgb2gray(CurApImg);
CurApImg = imresize(CurApImg, [Rect(4) Rect(3)]);
Fxy = round(CenterRect(FrameRect, Rect) + ...
[Parameters.Image_Position Parameters.Image_Position]);
CurApImg = CurApImg(Fxy(2):Fxy(4), Fxy(1):Fxy(3));
CurApImg = double(abs(double(CurApImg) - 127) > 1);
CurApImg = imresize(CurApImg, [100 100]);
ApFrm(:, :, Parameters.Volumes_per_Trial * (Trial - 1) + CurrVolume) = CurApImg;
elseif SaveAps == 2
CurApImg = Screen('GetImage', Win);
CurApImg = imresize(CurApImg, [640 480]);
sf = sf + 1;
ApFrm(:, :, :, sf) = CurApImg;
end

if SaveAps == 2
ApFrm = uint8(ApFrm);
save('Stimulus_movie', 'ApFrm');
end
45 changes: 45 additions & 0 deletions src/aperture/saveApertures.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
% (C) Copyright 2010-2020 Sam Schwarzkopf
% (C) Copyright 2020 CPP_PTB developers

function saveApertures(saveAps, cfg, apertures)

if saveAps

matFile = fullfile( ...
cfg.outputDir, ...
strrep(cfg.fileName.events, '.tsv', '_AperturesPRF.mat'));
if IsOctave
save(matFile, '-mat7-binary');
else
save(matFile, '-v7.3');
end

for iApert = 1:size(apertures.Frames, 3)

tmp = apertures.Frames(:, :, iApert);

% We skip the all nan frames and print the others
if ~all(isnan(tmp(:)))

close all;

imagesc(apertures.Frames(:, :, iApert));

colormap gray;

box off;
axis off;
axis square;

apertureName = getApertureName(cfg, apertures, iApert);

print(gcf, ...
fullfile(cfg.aperture.outputDir, [ApertureName '.tif']), ...
'-dtiff');
end

end

end

end
16 changes: 16 additions & 0 deletions src/aperture/smoothOval.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% (C) Copyright 2010-2020 Sam Schwarzkopf
% (C) Copyright 2020 CPP_PTB developers

function smoothOval(win, color, rect, fringe)
% SmoothOval(WindowPtr, Color, Rect, Fringe)
%
% Draws a filled oval (using the PTB parameters) with a transparent fringe.
%

alphas = linspace(0, 255, fringe);

for f = 0:fringe - 1
Screen('FillOval', win, ...
[color alphas(f + 1)], ...
[rect(1) + f rect(2) + f rect(3) - f rect(4) - f]);
end
16 changes: 16 additions & 0 deletions src/aperture/smoothRect.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% (C) Copyright 2010-2020 Sam Schwarzkopf
% (C) Copyright 2020 CPP_PTB developers

function smoothRect(win, color, rect, fringe)
% SmoothRect(WindowPtr, Color, Rect, Fringe)
%
% Draws a filled rect (using the PTB parameters) with a transparent fringe.
%

alphas = linspace(0, 255, fringe);

for f = 0:fringe - 1
Screen('FillRect', win, ...
[color alphas(f + 1)], ...
[rect(1) + f rect(2) + f rect(3) - f rect(4) - f]);
end
2 changes: 2 additions & 0 deletions src/dot/computeCartCoord.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function cartesianCoordinates = computeCartCoord(positions, dotMatrixWidth)

cartesianCoordinates = ...
Expand Down
2 changes: 2 additions & 0 deletions src/dot/computeRadialMotionDirection.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function angleMotion = computeRadialMotionDirection(positions, dotMatrixWidth, dots)

positions = computeCartCoord(positions, dotMatrixWidth);
Expand Down
2 changes: 2 additions & 0 deletions src/dot/decomposeMotion.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [horVector, vertVector] = decomposeMotion(angleMotion)
% [horVector, vertVector] = decomposeMotion(angleMotion)
%
Expand Down
4 changes: 4 additions & 0 deletions src/dot/dotMotionSimulation.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
% (C) Copyright 2020 CPP_PTB developers

function relativeDensityContrast = dotMotionSimulation(cfg, thisEvent, nbEvents, doPlot)
% relativeDensityContrast = dotMotionSimulation(cfg, thisEvent, nbEvents, doPlot)
%
% to simulate where the dots are more dense on the screen
% relativeDensityContrast : hard to get it below 0.10

Expand Down
2 changes: 2 additions & 0 deletions src/dot/dotTexture.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function cfg = dotTexture(action, cfg, thisEvent)

switch action
Expand Down
2 changes: 2 additions & 0 deletions src/dot/generateNewDotPositions.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function newPositions = generateNewDotPositions(dotMatrixWidth, nbDots)

newPositions = rand(nbDots, 2) * dotMatrixWidth;
Expand Down
2 changes: 2 additions & 0 deletions src/dot/initDots.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [dots] = initDots(cfg, thisEvent)
% [dots] = initDots(cfg, thisEvent)
%
Expand Down
2 changes: 2 additions & 0 deletions src/dot/reseedDots.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function dots = reseedDots(dots, cfg)

fixationWidthPix = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/dot/seedDots.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [positions, speeds, time] = seedDots(varargin)

[dots, cfg, isSignal] = deal(varargin{:});
Expand All @@ -22,7 +24,7 @@

%% Create a vector to update to dotlife time of each dot
% Not all set to 1 so the dots will die at different times
% The maximum value is the duraion of the event in frames
% The maximum value is the duration of the event in frames
time = floor(rand(nbDots, 1) * cfg.timing.eventDuration / cfg.screen.ifi);

end
4 changes: 3 additions & 1 deletion src/dot/setDotDirection.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
% (C) Copyright 2020 CPP_PTB developers

function directionAllDots = setDotDirection(positions, cfg, dots, isSignal)
% dots = setDotDirection(cfg, dots)
% directionAllDots = setDotDirection(positions, cfg, dots, isSignal)
%
% creates some new direction for the dots
%
Expand Down
2 changes: 2 additions & 0 deletions src/dot/updateDots.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [dots] = updateDots(dots, cfg)

% Move the selected dots
Expand Down
2 changes: 2 additions & 0 deletions src/drawFieldOfVIew.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function drawFieldOfVIew(cfg)
% drawFieldOfVIew(cfg)
%
Expand Down
2 changes: 2 additions & 0 deletions src/errors/errorAbort.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function errorAbort
errorStruct.message = 'Escape key press detected: aborting experiment.';
errorStruct.identifier = 'checkAbort:abortRequested';
Expand Down
2 changes: 2 additions & 0 deletions src/errors/errorAbortGetReponse.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function errorAbortGetReponse

errorStruct.message = 'Escape key press detected by getResponse: aborting experiment.';
Expand Down
2 changes: 2 additions & 0 deletions src/errors/errorDistanceToScreen.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function errorDistanceToScreen(cfg)

errorStruct.message = sprintf([
Expand Down
2 changes: 2 additions & 0 deletions src/errors/errorRestrictedKeysGetReponse.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function errorRestrictedKeysGetReponse

errorStruct.message = 'getResponse reported a key press on a restricted key';
Expand Down
8 changes: 5 additions & 3 deletions src/eyeTracker.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [el, cfg] = eyeTracker(input, cfg, varargin)
% [el] = eyeTracker(input, cfg, varargin)
%
Expand Down Expand Up @@ -100,7 +102,7 @@
% coordinates, here for 6 dots.

% [width, height]=Screen('WindowSize', screenNumber);

% TODO - update those values with the content set up by
% CPP_PTB in the cfg
% fieldsToSet.eyeTracker.CalibrationPosition = '';
Expand Down Expand Up @@ -133,7 +135,7 @@

% Enter Eyetracker camera setup mode, calibration and validation.
EyelinkDoTrackerSetup(el);

% TODO - update content of cfg after initializing and
% calibration
% fieldsToSet.eyeTracker.SamplingFrequency = [];
Expand All @@ -142,7 +144,7 @@
% fieldsToSet.eyeTracker.SoftwareVersions = '';
% fieldsToSet.eyeTracker.MaximalCalibrationError = [];
% fieldsToSet.eyeTracker.AverageCalibrationError = [];

% Go back to default screen background color.
Screen('FillRect', cfg.screen.win, cfg.color.background);
Screen('Flip', cfg.screen.win);
Expand Down
2 changes: 2 additions & 0 deletions src/fixation/drawFixation.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function drawFixation(cfg)
% Define the parameters of the fixation cross in `cfg` and `expParameters`

Expand Down
2 changes: 2 additions & 0 deletions src/fixation/initFixation.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function cfg = initFixation(cfg)
% cfg = initFixation(cfg)
%
Expand Down
2 changes: 2 additions & 0 deletions src/getExperimentEnd.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function cfg = getExperimentEnd(cfg)

drawFixation(cfg);
Expand Down
2 changes: 2 additions & 0 deletions src/getExperimentStart.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function cfg = getExperimentStart(cfg)
% cfg = getExperimentStart(cfg)
%
Expand Down
2 changes: 2 additions & 0 deletions src/initPTB.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function [cfg] = initPTB(cfg)
% [cfg] = initPTB(cfg)
%
Expand Down
3 changes: 3 additions & 0 deletions src/isOctave.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
% (C) Copyright 2010-2020 Agah Karakuzu
% (C) Copyright 2020 CPP_PTB developers

function retval = isOctave
% Return: true if the environment is Octave.
% mostly used to testing when PTB is not in the path
Expand Down
2 changes: 2 additions & 0 deletions src/keyboard/checkAbort.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function checkAbort(cfg, deviceNumber)
% checkAbort(cfg, deviceNumber)
%
Expand Down
2 changes: 2 additions & 0 deletions src/keyboard/checkAbortGetResponse.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function checkAbortGetResponse(responseEvents, cfg)

if isfield(responseEvents, 'keyName') > 0 && ...
Expand Down
2 changes: 2 additions & 0 deletions src/keyboard/collectAndSaveResponses.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
% (C) Copyright 2020 CPP_PTB developers

function responseEvents = collectAndSaveResponses(cfg, logFile, experimentStart)

responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg);
Expand Down
Loading