diff --git a/demos/CPP_checkAbortDemo.m b/demos/CPP_checkAbortDemo.m index 4d79b65..8ca7dee 100644 --- a/demos/CPP_checkAbortDemo.m +++ b/demos/CPP_checkAbortDemo.m @@ -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, '..')); diff --git a/demos/CPP_getResponseDemo.m b/demos/CPP_getResponseDemo.m index c0744c2..2969827 100644 --- a/demos/CPP_getResponseDemo.m +++ b/demos/CPP_getResponseDemo.m @@ -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 diff --git a/demos/CPP_pressSpaceForMeDemo.m b/demos/CPP_pressSpaceForMeDemo.m index 636ad77..d7470a8 100644 --- a/demos/CPP_pressSpaceForMeDemo.m +++ b/demos/CPP_pressSpaceForMeDemo.m @@ -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, '..')); diff --git a/demos/CPP_waitForTriggerDemo.m b/demos/CPP_waitForTriggerDemo.m index a326d9a..158e4b0 100644 --- a/demos/CPP_waitForTriggerDemo.m +++ b/demos/CPP_waitForTriggerDemo.m @@ -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; diff --git a/demos/miss_hit.cfg b/demos/miss_hit.cfg new file mode 100644 index 0000000..0333c2c --- /dev/null +++ b/demos/miss_hit.cfg @@ -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 \ No newline at end of file diff --git a/miss_hit.cfg b/miss_hit.cfg index 42f49fe..99d85d7 100644 --- a/miss_hit.cfg +++ b/miss_hit.cfg @@ -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 diff --git a/src/aperture/apertureTexture.m b/src/aperture/apertureTexture.m index 90b9307..c406887 100644 --- a/src/aperture/apertureTexture.m +++ b/src/aperture/apertureTexture.m @@ -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) % diff --git a/src/aperture/eccenLogSpeed.m b/src/aperture/eccenLogSpeed.m index fb4c86e..02ddb2f 100644 --- a/src/aperture/eccenLogSpeed.m +++ b/src/aperture/eccenLogSpeed.m @@ -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 diff --git a/src/aperture/getApertureName.m b/src/aperture/getApertureName.m new file mode 100644 index 0000000..e6dc8c0 --- /dev/null +++ b/src/aperture/getApertureName.m @@ -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 diff --git a/src/aperture/saveAperture.m b/src/aperture/saveAperture.m new file mode 100644 index 0000000..d5e116b --- /dev/null +++ b/src/aperture/saveAperture.m @@ -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 diff --git a/src/aperture/saveApertures.m b/src/aperture/saveApertures.m new file mode 100644 index 0000000..ddb79a3 --- /dev/null +++ b/src/aperture/saveApertures.m @@ -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 diff --git a/src/aperture/smoothOval.m b/src/aperture/smoothOval.m new file mode 100644 index 0000000..9ae34f3 --- /dev/null +++ b/src/aperture/smoothOval.m @@ -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 diff --git a/src/aperture/smoothRect.m b/src/aperture/smoothRect.m new file mode 100644 index 0000000..96b4542 --- /dev/null +++ b/src/aperture/smoothRect.m @@ -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 diff --git a/src/dot/computeCartCoord.m b/src/dot/computeCartCoord.m index a2c6f40..c2c2bd5 100644 --- a/src/dot/computeCartCoord.m +++ b/src/dot/computeCartCoord.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cartesianCoordinates = computeCartCoord(positions, dotMatrixWidth) cartesianCoordinates = ... diff --git a/src/dot/computeRadialMotionDirection.m b/src/dot/computeRadialMotionDirection.m index 1879f61..718ece2 100644 --- a/src/dot/computeRadialMotionDirection.m +++ b/src/dot/computeRadialMotionDirection.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function angleMotion = computeRadialMotionDirection(positions, dotMatrixWidth, dots) positions = computeCartCoord(positions, dotMatrixWidth); diff --git a/src/dot/decomposeMotion.m b/src/dot/decomposeMotion.m index ba58da7..6f235e2 100644 --- a/src/dot/decomposeMotion.m +++ b/src/dot/decomposeMotion.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [horVector, vertVector] = decomposeMotion(angleMotion) % [horVector, vertVector] = decomposeMotion(angleMotion) % diff --git a/src/dot/dotMotionSimulation.m b/src/dot/dotMotionSimulation.m index f160fad..b11867e 100644 --- a/src/dot/dotMotionSimulation.m +++ b/src/dot/dotMotionSimulation.m @@ -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 diff --git a/src/dot/dotTexture.m b/src/dot/dotTexture.m index 50e287b..cf23ce9 100644 --- a/src/dot/dotTexture.m +++ b/src/dot/dotTexture.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cfg = dotTexture(action, cfg, thisEvent) switch action diff --git a/src/dot/generateNewDotPositions.m b/src/dot/generateNewDotPositions.m index d59bb04..1858a98 100644 --- a/src/dot/generateNewDotPositions.m +++ b/src/dot/generateNewDotPositions.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function newPositions = generateNewDotPositions(dotMatrixWidth, nbDots) newPositions = rand(nbDots, 2) * dotMatrixWidth; diff --git a/src/dot/initDots.m b/src/dot/initDots.m index 7f8000a..32175b5 100644 --- a/src/dot/initDots.m +++ b/src/dot/initDots.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [dots] = initDots(cfg, thisEvent) % [dots] = initDots(cfg, thisEvent) % diff --git a/src/dot/reseedDots.m b/src/dot/reseedDots.m index d30e7a9..38eb3f0 100644 --- a/src/dot/reseedDots.m +++ b/src/dot/reseedDots.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function dots = reseedDots(dots, cfg) fixationWidthPix = 0; diff --git a/src/dot/seedDots.m b/src/dot/seedDots.m index c219ea9..05e7630 100644 --- a/src/dot/seedDots.m +++ b/src/dot/seedDots.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [positions, speeds, time] = seedDots(varargin) [dots, cfg, isSignal] = deal(varargin{:}); @@ -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 diff --git a/src/dot/setDotDirection.m b/src/dot/setDotDirection.m index 922695c..141a1d4 100644 --- a/src/dot/setDotDirection.m +++ b/src/dot/setDotDirection.m @@ -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 % diff --git a/src/dot/updateDots.m b/src/dot/updateDots.m index 329a81a..14c0b1f 100644 --- a/src/dot/updateDots.m +++ b/src/dot/updateDots.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [dots] = updateDots(dots, cfg) % Move the selected dots diff --git a/src/drawFieldOfVIew.m b/src/drawFieldOfVIew.m index 4eae9be..f3c314b 100644 --- a/src/drawFieldOfVIew.m +++ b/src/drawFieldOfVIew.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function drawFieldOfVIew(cfg) % drawFieldOfVIew(cfg) % diff --git a/src/errors/errorAbort.m b/src/errors/errorAbort.m index c67f7f9..6464944 100644 --- a/src/errors/errorAbort.m +++ b/src/errors/errorAbort.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function errorAbort errorStruct.message = 'Escape key press detected: aborting experiment.'; errorStruct.identifier = 'checkAbort:abortRequested'; diff --git a/src/errors/errorAbortGetReponse.m b/src/errors/errorAbortGetReponse.m index 78ec208..b65fae3 100644 --- a/src/errors/errorAbortGetReponse.m +++ b/src/errors/errorAbortGetReponse.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function errorAbortGetReponse errorStruct.message = 'Escape key press detected by getResponse: aborting experiment.'; diff --git a/src/errors/errorDistanceToScreen.m b/src/errors/errorDistanceToScreen.m index 486ebe4..3778c0d 100644 --- a/src/errors/errorDistanceToScreen.m +++ b/src/errors/errorDistanceToScreen.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function errorDistanceToScreen(cfg) errorStruct.message = sprintf([ diff --git a/src/errors/errorRestrictedKeysGetReponse.m b/src/errors/errorRestrictedKeysGetReponse.m index b0c0a5a..101a735 100644 --- a/src/errors/errorRestrictedKeysGetReponse.m +++ b/src/errors/errorRestrictedKeysGetReponse.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function errorRestrictedKeysGetReponse errorStruct.message = 'getResponse reported a key press on a restricted key'; diff --git a/src/eyeTracker.m b/src/eyeTracker.m index 4373e03..7378bd3 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [el, cfg] = eyeTracker(input, cfg, varargin) % [el] = eyeTracker(input, cfg, varargin) % @@ -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 = ''; @@ -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 = []; @@ -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); diff --git a/src/fixation/drawFixation.m b/src/fixation/drawFixation.m index da0a928..19907f5 100644 --- a/src/fixation/drawFixation.m +++ b/src/fixation/drawFixation.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function drawFixation(cfg) % Define the parameters of the fixation cross in `cfg` and `expParameters` diff --git a/src/fixation/initFixation.m b/src/fixation/initFixation.m index 876a997..2c21617 100644 --- a/src/fixation/initFixation.m +++ b/src/fixation/initFixation.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cfg = initFixation(cfg) % cfg = initFixation(cfg) % diff --git a/src/getExperimentEnd.m b/src/getExperimentEnd.m index a2389f4..4e74e96 100644 --- a/src/getExperimentEnd.m +++ b/src/getExperimentEnd.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cfg = getExperimentEnd(cfg) drawFixation(cfg); diff --git a/src/getExperimentStart.m b/src/getExperimentStart.m index cdd451b..231bd45 100644 --- a/src/getExperimentStart.m +++ b/src/getExperimentStart.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cfg = getExperimentStart(cfg) % cfg = getExperimentStart(cfg) % diff --git a/src/initPTB.m b/src/initPTB.m index e2faa67..f1c97ba 100644 --- a/src/initPTB.m +++ b/src/initPTB.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function [cfg] = initPTB(cfg) % [cfg] = initPTB(cfg) % diff --git a/src/isOctave.m b/src/isOctave.m index f4a11ec..72d116b 100644 --- a/src/isOctave.m +++ b/src/isOctave.m @@ -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 diff --git a/src/keyboard/checkAbort.m b/src/keyboard/checkAbort.m index 7d987c3..ed2e0df 100644 --- a/src/keyboard/checkAbort.m +++ b/src/keyboard/checkAbort.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function checkAbort(cfg, deviceNumber) % checkAbort(cfg, deviceNumber) % diff --git a/src/keyboard/checkAbortGetResponse.m b/src/keyboard/checkAbortGetResponse.m index 8bbf513..15800fc 100644 --- a/src/keyboard/checkAbortGetResponse.m +++ b/src/keyboard/checkAbortGetResponse.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function checkAbortGetResponse(responseEvents, cfg) if isfield(responseEvents, 'keyName') > 0 && ... diff --git a/src/keyboard/collectAndSaveResponses.m b/src/keyboard/collectAndSaveResponses.m index 222ad85..45bf36a 100644 --- a/src/keyboard/collectAndSaveResponses.m +++ b/src/keyboard/collectAndSaveResponses.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function responseEvents = collectAndSaveResponses(cfg, logFile, experimentStart) responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg); diff --git a/src/keyboard/getResponse.m b/src/keyboard/getResponse.m index 1467955..11aee4e 100644 --- a/src/keyboard/getResponse.m +++ b/src/keyboard/getResponse.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) % responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) % diff --git a/src/keyboard/pressSpaceForMe.m b/src/keyboard/pressSpaceForMe.m index b6c209d..feef001 100644 --- a/src/keyboard/pressSpaceForMe.m +++ b/src/keyboard/pressSpaceForMe.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function pressSpaceForMe() % pressSpaceForMe() % diff --git a/src/keyboard/testKeyboards.m b/src/keyboard/testKeyboards.m index 6ce8e7a..4aa175d 100644 --- a/src/keyboard/testKeyboards.m +++ b/src/keyboard/testKeyboards.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function testKeyboards(cfg) % testKeyboards(cfg) % diff --git a/src/randomization/repeatShuffleConditions.m b/src/randomization/repeatShuffleConditions.m index c4a2ba7..a769021 100644 --- a/src/randomization/repeatShuffleConditions.m +++ b/src/randomization/repeatShuffleConditions.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function shuffledRepeats = repeatShuffleConditions(baseConditionVector, nbRepeats) % shuffledRepeats = repeatShuffleConditions(baseConditionVector, nbRepeats) % diff --git a/src/randomization/setTargetPositionInSequence.m b/src/randomization/setTargetPositionInSequence.m index 2f7a9bf..7fb0f96 100644 --- a/src/randomization/setTargetPositionInSequence.m +++ b/src/randomization/setTargetPositionInSequence.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function chosenPositions = setTargetPositionInSequence(seqLength, nbTarget, forbiddenPos) % chosenPositions = setTargetPositionInSequence(seqLength, nbTarget, forbiddenPos) % diff --git a/src/randomization/shuffle.m b/src/randomization/shuffle.m index 3aa2980..33326ca 100644 --- a/src/randomization/shuffle.m +++ b/src/randomization/shuffle.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function shuffled = shuffle(unshuffled) % in case PTB is not in the path % mostly for unit test diff --git a/src/readAndFilterLogfile.m b/src/readAndFilterLogfile.m new file mode 100644 index 0000000..9049b44 --- /dev/null +++ b/src/readAndFilterLogfile.m @@ -0,0 +1,52 @@ +% (C) Copyright 2020 CPP_PTB developers + +function outputFiltered = readAndFilterLogfile(columnName, filterBy, varargin) + % outputFiltered = readOutputFilter(filterHeader, filterContent, varargin) + % + % It will display in the command window the content of the `output.tsv' filtered by one element + % of a target column. + % + % DEPENDENCIES: + % - bids_matlab (from CPP_BIDS) + % + % INPUT: + % + % - columnName: string, the header of the column where the content of insterest is stored + % (e.g., for 'trigger' will be 'trial type') + % - filterBy: string, the content of the column you want to filter out. It can take just + % part of the content name (e.g., you want to display the triggers and you have + % 'trigger_motion' and 'trigger_static', 'trigger' as input will do) + % - varargin: either cfg (to display the last run output) or the file path as string + % + % OUTPUT: + % + % - outputFiltered: dataset with only the specified content, to see it in the command window + % use display(outputFiltered) + + % Checke if input is cfg or the file path + if ischar(varargin{1}) + tsvFile = varargin{1}; + elseif isstruct(varargin{1}) + tsvFile = fullfile(varargin{1}.dir.outputSubject, ... + varargin{1}.fileName.modality, ... + varargin{1}.fileName.events); + end + + % Check if the file exists + if ~exist(tsvFile, 'file') + error([newline 'Input file does not exist']); + end + + % Read the the tsv file and store each column in a field of `output` structure + output = bids.util.tsvread(tsvFile); + + % Get the index of the target contentent to filter and display + filterIdx = find(strncmp(output.(columnName), filterBy, length(filterBy))); + + % Convert the structure to dataset + outputDataset = struct2dataset(output); + + % Get the dataset with the content of intereset + outputFiltered = outputDataset(filterIdx, :); + +end diff --git a/src/screen/farewellScreen.m b/src/screen/farewellScreen.m index 37e0ad2..abbe0ab 100644 --- a/src/screen/farewellScreen.m +++ b/src/screen/farewellScreen.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function farewellScreen(cfg) Screen('FillRect', cfg.screen.win, cfg.color.background, cfg.screen.winRect); diff --git a/src/screen/standByScreen.m b/src/screen/standByScreen.m index 3293dba..41610ee 100644 --- a/src/screen/standByScreen.m +++ b/src/screen/standByScreen.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function standByScreen(cfg) Screen('FillRect', cfg.screen.win, cfg.color.background, cfg.screen.winRect); diff --git a/src/utils/checkPtbVersion.m b/src/utils/checkPtbVersion.m index c1de8fe..6acd23d 100644 --- a/src/utils/checkPtbVersion.m +++ b/src/utils/checkPtbVersion.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function checkPtbVersion() % Checks that the right dependencies are installed. diff --git a/src/utils/cleanUp.m b/src/utils/cleanUp.m index aeb7d6b..261de89 100755 --- a/src/utils/cleanUp.m +++ b/src/utils/cleanUp.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cleanUp() % cleanUp() % diff --git a/src/utils/computeFOV.m b/src/utils/computeFOV.m index e825a43..0526244 100644 --- a/src/utils/computeFOV.m +++ b/src/utils/computeFOV.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function FOV = computeFOV(cfg) % FOV = computeFOV(cfg) % diff --git a/src/utils/degToPix.m b/src/utils/degToPix.m index bb5fac5..a2a1c09 100644 --- a/src/utils/degToPix.m +++ b/src/utils/degToPix.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function structure = degToPix(fieldName, structure, cfg) % structure = degToPix(fieldName, structure, cfg) % @@ -21,6 +23,6 @@ deg = getfield(structure, fieldName); %#ok structure = setfield(structure, [fieldName 'Pix'], ... - floor(deg * cfg.screen.ppd)); %#ok + deg * cfg.screen.ppd); %#ok end diff --git a/src/utils/makeGif.m b/src/utils/makeGif.m new file mode 100644 index 0000000..ef5a729 --- /dev/null +++ b/src/utils/makeGif.m @@ -0,0 +1,39 @@ +% (C) Copyright 2020 CPP_PTB developers + +close all; +clear; +clc; + +output_folder = fullfile(pwd, 'ouputs'); +screen_capture_folder = fullfile(output_folder, 'screen_capture'); +screen_capture_filename = fullfile(screen_capture_folder, ... + 'EMCL_kaks_frame-'); + +gif_file = fullfile(screen_capture_folder, ... + 'EMCL_kaks_frame.gif'); + +FigDim = [100, 100, 1000, 1500]; +Visibility = 'on'; + +for tif_img = 6:26 % 128 + + filename = fullfile([screen_capture_filename sprintf('%04.0f', tif_img) '.tif']); + + h = figure('name', 'test', ... + 'Position', FigDim, 'Color', [1 1 1], ... + 'Visible', Visibility); + + imshow(imread(filename)); + + frame = getframe(h); + im = frame2im(frame); + [imind, cm] = rgb2ind(im, 256); + + if tif_img == 1 + imwrite(imind, cm, gif_file, 'gif', 'Loopcount', inf); + else + imwrite(imind, cm, gif_file, 'gif', 'WriteMode', 'append'); + end + + close all; +end diff --git a/src/utils/pixToDeg.m b/src/utils/pixToDeg.m index b8334f7..728d558 100644 --- a/src/utils/pixToDeg.m +++ b/src/utils/pixToDeg.m @@ -1,4 +1,4 @@ -% 2020 CPP BIDS SPM-pipeline developpers +% (C) Copyright 2020 CPP_PTB developers function structure = pixToDeg(fieldName, structure, cfg) % structure = pixToDeg(fieldName, structure, cfg) diff --git a/src/utils/printCreditsCppPtb.m b/src/utils/printCreditsCppPtb.m index 77035ba..9c8c7bb 100644 --- a/src/utils/printCreditsCppPtb.m +++ b/src/utils/printCreditsCppPtb.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function printCreditsCppPtb() try diff --git a/src/utils/printScreen.m b/src/utils/printScreen.m new file mode 100644 index 0000000..071ffc0 --- /dev/null +++ b/src/utils/printScreen.m @@ -0,0 +1,16 @@ +% (C) Copyright 2020 CPP_PTB developers + +function frame = printScreen(win, filename, frame) + + image_array = Screen('GetImage', win); + + imagesc(image_array); + box off; + axis off; + set(gca, 'position', [0 0 1 1], 'units', 'normalized'); + + print(gcf, [filename sprintf('%04.0f', frame) '.jpeg'], '-djpeg'); + + frame = frame + 1; + +end diff --git a/src/utils/setDefaults.m b/src/utils/setDefaults.m index b7ad426..e9238dc 100644 --- a/src/utils/setDefaults.m +++ b/src/utils/setDefaults.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function structure = setDefaults(structure, fieldsToSet) % structure = setDefaults(structure, fieldsToSet) % diff --git a/src/utils/setDefaultsPTB.m b/src/utils/setDefaultsPTB.m index e0dea8f..7aa90bd 100644 --- a/src/utils/setDefaultsPTB.m +++ b/src/utils/setDefaultsPTB.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function cfg = setDefaultsPTB(cfg) % cfg = setDefaultsPTB(cfg) % @@ -64,7 +66,7 @@ end if isfield(cfg, 'eyeTracker') && cfg.eyeTracker.do - + % Calibration environment fieldsToSet.eyeTracker.defaultCalibration = true; fieldsToSet.eyeTracker.backgroundColor = [192 192 192]; diff --git a/src/waitFor.m b/src/waitFor.m index 29d8e99..b612608 100644 --- a/src/waitFor.m +++ b/src/waitFor.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function waitFor(cfg, timeToWait) % waitFor(cfg, timeToWait) % diff --git a/src/waitForTrigger.m b/src/waitForTrigger.m index 74965f1..a686e6c 100644 --- a/src/waitForTrigger.m +++ b/src/waitForTrigger.m @@ -1,3 +1,5 @@ +% (C) Copyright 2020 CPP_PTB developers + function waitForTrigger(varargin) % waitForTrigger(cfg, deviceNumber, quietMode, nbTriggersToWait) %