From aced700414beca8b452b38a1840507a80f8150cd Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 11:45:16 +0200 Subject: [PATCH 1/6] add draft of the code --- src/eyeTracker.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/eyeTracker.m b/src/eyeTracker.m index f8e3a9c..fb81ace 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -1,4 +1,4 @@ -function [el, cfg] = eyeTracker(input, cfg) +function [el, cfg] = eyeTracker(input, cfg, varargin) % [el] = eyeTracker(input, cfg) % % Wrapper function that deals with all the necessery actions to implement @@ -170,6 +170,15 @@ % Stop recoding. Eyelink('StopRecording'); + case 'Message' + + %% Add tag during the recording (e.g. trial_type) + + message = varargin; + + % EyeLink Stop recording the block. + Eyelink('Message', message); + case 'Shutdown' %% End of the experiment From ef1d712f59b748ceaeee093979816c88f58459a6 Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 16:49:23 +0200 Subject: [PATCH 2/6] mh fix --- src/eyeTracker.m | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/eyeTracker.m b/src/eyeTracker.m index fb81ace..bd50112 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -102,21 +102,21 @@ Eyelink('Command', 'calibration_samples = 6'); Eyelink('Command', 'calibration_sequence = 0,1,2,3,4,5'); Eyelink('Command', 'calibration_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ... - 640, 512, ... % width/2,height/2 - 640, 102, ... % width/2,height*0.1 - 640, 614, ... % width/2,height*0.6 - 128, 341, ... % width*0.1,height*1/3 - 1152, 341); % width-width*0.1,height*1/3 + 640, 512, ... % width/2,height/2 + 640, 102, ... % width/2,height*0.1 + 640, 614, ... % width/2,height*0.6 + 128, 341, ... % width*0.1,height*1/3 + 1152, 341); % width-width*0.1,height*1/3 % Validation target locations Eyelink('Command', 'validation_samples = 5'); Eyelink('Command', 'validation_sequence = 0,1,2,3,4,5'); Eyelink('Command', 'validation_targets = %d,%d %d,%d %d,%d %d,%d %d,%d', ... - 640, 512, ... % width/2,height/2 - 640, 102, ... % width/2,height*0.1 - 640, 614, ... % width/2,height*0.6 - 128, 341, ... % width*0.1,height*1/3 - 1152, 341); % width-width*0.1,height*1/3 + 640, 512, ... % width/2,height/2 + 640, 102, ... % width/2,height*0.1 + 640, 614, ... % width/2,height*0.6 + 128, 341, ... % width*0.1,height*1/3 + 1152, 341); % width-width*0.1,height*1/3 end @@ -186,9 +186,9 @@ % Set the edf file path + name. edfFileName = fullfile( ... - cfg.dir.outputSubject, ... - cfg.fileName.modality, ... - cfg.fileName.eyetracker); + cfg.dir.outputSubject, ... + cfg.fileName.modality, ... + cfg.fileName.eyetracker); Eyelink('Command', 'set_idle_mode'); @@ -212,8 +212,8 @@ if exist(edfFileName, 'file') == 2 fprintf('Data file ''%s'' can be found in ''%s''\n', ... - cfg.fileName.eyetracker, ... - fullfile(cfg.dir.outputSubject, 'eyetracker')); + cfg.fileName.eyetracker, ... + fullfile(cfg.dir.outputSubject, 'eyetracker')); end From 8c9b8e7168c25dcd875a61d80706a496fd4c4d8c Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 17:19:24 +0200 Subject: [PATCH 3/6] move up the code --- src/eyeTracker.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/eyeTracker.m b/src/eyeTracker.m index bd50112..5337a8b 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -157,6 +157,15 @@ % Mark the beginning of the trial, here start the stimulation of the experiment. Eyelink('Message', 'start_recording'); + case 'Message' + + %% Add tag during the recording (e.g. trial_type) + + message = varargin; + + % EyeLink Stop recording the block. + Eyelink('Message', message); + case 'StopRecordings' %% Stop recording of eye-movements @@ -170,15 +179,6 @@ % Stop recoding. Eyelink('StopRecording'); - case 'Message' - - %% Add tag during the recording (e.g. trial_type) - - message = varargin; - - % EyeLink Stop recording the block. - Eyelink('Message', message); - case 'Shutdown' %% End of the experiment From 54d5a351eefb8442612f76f0a0e21546554ee49c Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 17:21:44 +0200 Subject: [PATCH 4/6] add explanation --- src/eyeTracker.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eyeTracker.m b/src/eyeTracker.m index 5337a8b..ec8a325 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -12,6 +12,8 @@ % -- 'custom calibration' (cfg.eyeTracker.defaultCalibration = 'false') will run a % calibration with 6 points but the experimenter can choose their position on the screen % - StartRecording: to start eye movements recording + % - Message: will add a tag (e.g. 'Block_n1') in the ET output file, the tag is a string and it + % is input from `varargin` % - StopRecordings: to stop eye movements recornding % - Shutdown: to save the `.edf` file with BIDS compliant name, from cpp-lln-lab/CPP_BIDS, in % the output folder and shut the connection between the stimulation computer and the EyeLink From 2b8508750cf1eef941089a4111401982a53b90b3 Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 17:22:10 +0200 Subject: [PATCH 5/6] add explanation pt2 --- src/eyeTracker.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eyeTracker.m b/src/eyeTracker.m index ec8a325..f1ae373 100755 --- a/src/eyeTracker.m +++ b/src/eyeTracker.m @@ -1,5 +1,5 @@ function [el, cfg] = eyeTracker(input, cfg, varargin) - % [el] = eyeTracker(input, cfg) + % [el] = eyeTracker(input, cfg, varargin) % % Wrapper function that deals with all the necessery actions to implement % Eye Tracker recording with eyelink. From c93313f985034ca56845fde26bf3e0a6bc784917 Mon Sep 17 00:00:00 2001 From: marcobarilari Date: Wed, 23 Sep 2020 17:23:30 +0200 Subject: [PATCH 6/6] update documentation --- docs/10_functions_description.md | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/10_functions_description.md b/docs/10_functions_description.md index a7318f8..66a608f 100644 --- a/docs/10_functions_description.md +++ b/docs/10_functions_description.md @@ -38,7 +38,7 @@ This will initialize PsychToolBox. -It is pretty much necessary to use this function to set up the stage for using +It is pretty much necessary to use this function to set up the stage for using any other functions of CPP_PTB. - checks OS and PTB version @@ -57,45 +57,46 @@ any other functions of CPP_PTB. ### 1.2. cleanUp -A wrapper function to close all windows, ports, show mouse cursor, close keyboard +A wrapper function to close all windows, ports, show mouse cursor, close keyboard queues and give you back access to the keyboards. ### 1.3. getExperimentStart -Wrapper function that will show a fixation cross and collect a start timestamp +Wrapper function that will show a fixation cross and collect a start timestamp in `cfg.experimentStart` ### 1.4. getExperimentEnd -Wrapper function that will show a fixation cross and display in the console +Wrapper function that will show a fixation cross and display in the console the whole experiment's duration in minutes and seconds ### 1.5. degToPix For a given field value in degrees of visual angle in the input `structure`, -this computes its value in pixel using the pixel per degree value of the `cfg` +this computes its value in pixel using the pixel per degree value of the `cfg` structure and returns a structure with an additional field with Pix suffix holding that new value. ### 1.6. computeFOV -Gives you the width of the field on view in degress of visual angle based on +Gives you the width of the field on view in degress of visual angle based on the screen width and distance to the screen in cm (taken from the `cfg`) ### 1.7. eyeTracker -This will handle the Eye Tracker (EyeLink set up) and can be called to initialize -the connection and start the calibration, start/stop eye(s) movement recordings +This will handle the Eye Tracker (EyeLink set up) and can be called to initialize +the connection and start the calibration, start/stop eye(s) movement recordings and save the `*.edf` file (named with BIDS specification from cpp-lln-lab/CPP_BIDS). There are several actions to perform: - Calibration: to initialize EyeLink and run calibration - 'default calibration' (default) will run a calibration with 6 points - - 'custom calibration' (cfg.eyeTracker.defaultCalibration = 'false') will run + - 'custom calibration' (cfg.eyeTracker.defaultCalibration = 'false') will run a calibration with 6 points but the experimenter can choose their position on the screen - StartRecording: to start eye movements recording +- Message: will add a tag (e.g. 'Block_n1') in the ET output file, the tag is a string and it is input from `varargin` - StopRecordings: to stop eye movements recornding -- Shutdown: to save the `.edf` file with BIDS compliant name, from cpp-lln-lab/CPP_BIDS, +- Shutdown: to save the `.edf` file with BIDS compliant name, from cpp-lln-lab/CPP_BIDS, in the output folder and shut the connection between the stimulation computer and the EyeLink computer ### 1.8. standByScreen @@ -107,7 +108,7 @@ It shows a basic one-page instruction stored in `cfg.task.instruction` and wait Counts a certain number of triggers coming from the mri/scanner before returning. Requires number of triggers to wait for. -This can also be used if you want to let the scanner pace the experiment and you +This can also be used if you want to let the scanner pace the experiment and you want to synch stimulus presentation to the scanner trigger. ### 1.10. waitFor @@ -116,8 +117,8 @@ A generic function that you can use to for a certain amount of time or a number ### 1.11. readAndFilterLogfile -Displays in the command window part of the `*events.tsv` file filtered by an element -(e.g. 'trigger'). It can take the last output produced (through `cfg`) or any +Displays in the command window part of the `*events.tsv` file filtered by an element +(e.g. 'trigger'). It can take the last output produced (through `cfg`) or any output BIDS compatible (through file path). ## 2. Keyboard functions: response collection and aborting experiment @@ -130,7 +131,7 @@ If no key is pressed on the correct keyboard after the timeOut time this exits w ### 2.2. getResponse -It is wrapper function to use `KbQueue` which is definitely what you should use +It is wrapper function to use `KbQueue` which is definitely what you should use to collect responses. You can easily collect responses while running some other code at the same time. @@ -146,15 +147,15 @@ If you want to know more on how to use it check its help section and the `CPP_ge In brief, there are several actions you can execute with this function. -- init: initialize the buffer for key presses on a given device (you can also +- init: initialize the buffer for key presses on a given device (you can also specify the keys of interest that should be listened to). -- start: start listening to the key presses (carefully insert into your script - +- start: start listening to the key presses (carefully insert into your script - where do you want to start buffering the responses). - check: till that point, it will check the buffer for all key presses. - It only reports presses on the keys of interest mentioned at initialization. - - It **can** also check for presses on the escape key and abort if the escape + - It **can** also check for presses on the escape key and abort if the escape key is part of the keys of interest. -- flush: empties the buffer of key presses in case you want to discard any +- flush: empties the buffer of key presses in case you want to discard any previous key presses. - stop: stops buffering key presses. You can still restart by calling "start" again. - release: closes the buffer for good. @@ -163,13 +164,13 @@ previous key presses. Use that to stop your script and only restart when the space bar is pressed. -This can be useful if as an experimenter you want to have one final check on +This can be useful if as an experimenter you want to have one final check on some set up before giving the green light. ### checkAbort -A simple function that will quit your experiment if you press the key you have -defined in `cfg.keyboard.escapeKey`. +A simple function that will quit your experiment if you press the key you have +defined in `cfg.keyboard.escapeKey`. ## 3. Fixations @@ -187,17 +188,17 @@ Functions that can be used to create random stimuli sequences. ### 6.1. shuffle -Is just there to replace the Shuffle function from PTB in case it is not in the +Is just there to replace the Shuffle function from PTB in case it is not in the path. Can be useful for testing or for continuous integration. ### 6.2. setTargetPositionInSequence -For a sequence of length `seqLength` where we want to insert `nbTarget` targets, -this will return `nbTarget` random position in that sequence and make sure that +For a sequence of length `seqLength` where we want to insert `nbTarget` targets, +this will return `nbTarget` random position in that sequence and make sure that they are not in consecutive positions. ### 6.3. repeatShuffleConditions -Given `baseConditionVector`, a vector of conditions (coded as numbers), this will -create a longer vector made of `nbRepeats` of this base vector and make sure that +Given `baseConditionVector`, a vector of conditions (coded as numbers), this will +create a longer vector made of `nbRepeats` of this base vector and make sure that a given condition is not repeated one after the other.