From ecd99ad1b22c5c42b14344ddd1e616b4688cb330 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 5 Aug 2020 16:02:18 +0200 Subject: [PATCH 1/4] mh autofix --- setParameters.m | 12 ++++++------ subfun/expDesign.m | 14 +++++++------- visualLocTanslational.m | 33 ++++++++++++++++----------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/setParameters.m b/setParameters.m index 413ac19..5fb65fc 100644 --- a/setParameters.m +++ b/setParameters.m @@ -34,23 +34,23 @@ %% Experiment Design -% cfg.design.motionType = 'translation'; -% cfg.design.motionType = 'radial'; + % cfg.design.motionType = 'translation'; + % cfg.design.motionType = 'radial'; cfg.design.motionType = 'translation'; cfg.design.names = {'static'; 'motion'}; cfg.design.nbRepetitions = 4; cfg.design.nbEventsPerBlock = 12; % DO NOT CHANGE %% Timing - + % FOR 7T: if you want to create localizers on the fly, the following must be % multiples of the scanneryour sequence TR - % + % % IBI % block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock % Time between blocs in secs - cfg.IBI = 1.8*3; % 8; + cfg.IBI = 1.8 * 3; % 8; % Time between events in secs cfg.ISI = 0.1; % Number of seconds before the motion stimuli are presented @@ -59,7 +59,7 @@ cfg.endDelay = .1; cfg.eventDuration = 0.8; % second - + %% Visual Stimulation % Speed in visual angles / second diff --git a/subfun/expDesign.m b/subfun/expDesign.m index 4e4d0c9..f2bd16c 100644 --- a/subfun/expDesign.m +++ b/subfun/expDesign.m @@ -57,7 +57,7 @@ % Set variables here for a dummy test of this function if nargin < 1 || isempty(cfg) -% cfg.design.motionType = 'translation'; + % cfg.design.motionType = 'translation'; cfg.design.motionType = 'radial'; cfg.design.names = {'static'; 'motion'}; cfg.design.nbRepetitions = 4; @@ -184,20 +184,20 @@ end function [MOTION_DIRECTIONS, STATIC_DIRECTIONS] = getDirectionBaseVectors(cfg) - + % CONSTANTS % Set directions for static and motion condition - + STATIC_DIRECTIONS = [-1 -1 -1 -1]; - + switch cfg.design.motionType case 'translation' MOTION_DIRECTIONS = [0 90 180 270]; case 'radial' STATIC_DIRECTIONS = [666 -666 666 -666]; MOTION_DIRECTIONS = [666 -666 666 -666]; - end - + end + end function [nbBlocks, nbRepet, nbEventsBlock, maxTargBlock] = getInput(cfg) @@ -271,7 +271,7 @@ function diplayDesign(cfg, displayFigs) title('Fixation Targets position distribution'); figure(2); - + [motionDirections] = getDirectionBaseVectors(cfg); motionDirections = unique(motionDirections); diff --git a/visualLocTanslational.m b/visualLocTanslational.m index d50228a..d1c1f6b 100644 --- a/visualLocTanslational.m +++ b/visualLocTanslational.m @@ -34,7 +34,7 @@ [cfg] = initPTB(cfg); cfg.dot.matrixWidth = cfg.screen.winHeight; - + % Convert some values from degrees to pixels cfg.dot = degToPix('size', cfg.dot, cfg); cfg.dot = degToPix('speed', cfg.dot, cfg); @@ -56,7 +56,7 @@ % Prepare for the output logfiles with all logFile.extraColumns = cfg.extraColumns; logFile = saveEventsFile('open', cfg, logFile); - + % prepare textures cfg = apertureTexture('init', cfg); cfg = dotTexture('init', cfg); @@ -119,9 +119,9 @@ % saving in the tsv file responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ... getOnlyPress); - + if isfield(responseEvents(1), 'onset') && ~isempty(responseEvents(1).onset) - + for iResp = 1:size(responseEvents, 1) responseEvents(iResp).onset = ... responseEvents(iResp).onset - cfg.experimentStart; @@ -134,28 +134,28 @@ responseEvents(iResp).trial_type = 'trigger'; end end - + responseEvents(1).fileID = logFile.fileID; responseEvents(1).extraColumns = logFile.extraColumns; saveEventsFile('save', cfg, responseEvents); - + end - + % wait for the inter-stimulus interval WaitSecs(cfg.ISI); end - + eyeTracker('StopRecordings', cfg); - + WaitSecs(cfg.IBI); - + % trigger monitoring triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ... getOnlyPress); - + if isfield(triggerEvents(1), 'onset') && ~isempty(triggerEvents(1).onset) - + for iResp = 1:size(triggerEvents, 1) triggerEvents(iResp).onset = ... triggerEvents(iResp).onset - cfg.experimentStart; @@ -168,13 +168,12 @@ triggerEvents(iResp).trial_type = 'trigger-baseline'; end end - + triggerEvents(1).fileID = logFile.fileID; triggerEvents(1).extraColumns = logFile.extraColumns; saveEventsFile('save', cfg, triggerEvents); - - end + end end @@ -190,8 +189,8 @@ getResponse('release', cfg.keyboard.responseBox); eyeTracker('Shutdown', cfg); - - createBoldJson(cfg, cfg) + + createBoldJson(cfg, cfg); farewellScreen(cfg); From a4dd824dd8f9bcc6979bb157352b1a82d47b36fe Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 5 Aug 2020 16:05:53 +0200 Subject: [PATCH 2/4] make trigger name in log more explicit --- lib/CPP_PTB | 2 +- visualLocTanslational.m | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/CPP_PTB b/lib/CPP_PTB index a0c8874..b1cdd20 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit a0c8874fd7894a748758624d94d7b74f7e5c0252 +Subproject commit b1cdd20ee9e0d52f07aa61c583d16adb6ec52603 diff --git a/visualLocTanslational.m b/visualLocTanslational.m index d1c1f6b..050e94c 100644 --- a/visualLocTanslational.m +++ b/visualLocTanslational.m @@ -67,13 +67,14 @@ % prepare the KbQueue to collect responses getResponse('init', cfg.keyboard.responseBox, cfg); - getResponse('start', cfg.keyboard.responseBox); % Wait for Trigger from Scanner waitForTrigger(cfg); %% Experiment Start cfg = getExperimentStart(cfg); + + getResponse('start', cfg.keyboard.responseBox); WaitSecs(cfg.onsetDelay); @@ -131,7 +132,8 @@ responseEvents(iResp).speed = 'n/a'; responseEvents(iResp).target = 'n/a'; if strcmp(responseEvents(iResp).keyName, 't') - responseEvents(iResp).trial_type = 'trigger'; + responseEvents(iResp).trial_type = ... + ['trigger_' cfg.design.blockNames{iBlock}]; end end @@ -165,7 +167,7 @@ triggerEvents(iResp).speed = 'n/a'; triggerEvents(iResp).target = 'n/a'; if strcmp(triggerEvents(iResp).keyName, 't') - triggerEvents(iResp).trial_type = 'trigger-baseline'; + triggerEvents(iResp).trial_type = 'trigger_baseline'; end end From 0768b41f9bb6a22559241b40dfe600bf37dd3841 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 6 Aug 2020 14:10:19 +0200 Subject: [PATCH 3/4] update submodules --- lib/CPP_BIDS | 2 +- lib/CPP_PTB | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CPP_BIDS b/lib/CPP_BIDS index d2a4c43..c6659f7 160000 --- a/lib/CPP_BIDS +++ b/lib/CPP_BIDS @@ -1 +1 @@ -Subproject commit d2a4c43725ec69a87afccd4a0ec39d800c5968a8 +Subproject commit c6659f74e995ab870336bc266fe849c554a9f044 diff --git a/lib/CPP_PTB b/lib/CPP_PTB index b1cdd20..dc6d344 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit b1cdd20ee9e0d52f07aa61c583d16adb6ec52603 +Subproject commit dc6d3449c5857211f6a60b4944b09dc8fe7f7051 From 770003e0d88d25416f49d49686338377db313f40 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 6 Aug 2020 14:13:15 +0200 Subject: [PATCH 4/4] refactor response and trigger collection --- subfun/doDotMo.m | 2 +- subfun/saveResponsesAndTriggers.m | 24 ++++++++++++++++ visualLocTanslational.m | 47 ++++--------------------------- 3 files changed, 30 insertions(+), 43 deletions(-) create mode 100644 subfun/saveResponsesAndTriggers.m diff --git a/subfun/doDotMo.m b/subfun/doDotMo.m index 29b2067..23217c8 100644 --- a/subfun/doDotMo.m +++ b/subfun/doDotMo.m @@ -46,7 +46,7 @@ apertureTexture('draw', cfg, thisEvent); - % If this frame shows a target we change the color + % If this frame shows a target we change the color of the cross thisFixation.fixation = cfg.fixation; thisFixation.screen = cfg.screen; if thisEvent.target(1) && GetSecs < (onset + cfg.target.duration) diff --git a/subfun/saveResponsesAndTriggers.m b/subfun/saveResponsesAndTriggers.m new file mode 100644 index 0000000..61f8e5a --- /dev/null +++ b/subfun/saveResponsesAndTriggers.m @@ -0,0 +1,24 @@ +function saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString) + + if isfield(responseEvents(1), 'onset') && ~isempty(responseEvents(1).onset) + + for iResp = 1:size(responseEvents, 1) + responseEvents(iResp).onset = ... + responseEvents(iResp).onset - cfg.experimentStart; + responseEvents(iResp).event = 'n/a'; + responseEvents(iResp).block = 'n/a'; + responseEvents(iResp).direction = 'n/a'; + responseEvents(iResp).speed = 'n/a'; + responseEvents(iResp).target = 'n/a'; + if strcmp(responseEvents(iResp).keyName, 't') + responseEvents(iResp).trial_type = triggerString; + end + end + + responseEvents(1).fileID = logFile.fileID; + responseEvents(1).extraColumns = logFile.extraColumns; + saveEventsFile('save', cfg, responseEvents); + + end + +end diff --git a/visualLocTanslational.m b/visualLocTanslational.m index 050e94c..02b3524 100644 --- a/visualLocTanslational.m +++ b/visualLocTanslational.m @@ -73,7 +73,7 @@ %% Experiment Start cfg = getExperimentStart(cfg); - + getResponse('start', cfg.keyboard.responseBox); WaitSecs(cfg.onsetDelay); @@ -121,27 +121,8 @@ responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ... getOnlyPress); - if isfield(responseEvents(1), 'onset') && ~isempty(responseEvents(1).onset) - - for iResp = 1:size(responseEvents, 1) - responseEvents(iResp).onset = ... - responseEvents(iResp).onset - cfg.experimentStart; - responseEvents(iResp).event = 'n/a'; - responseEvents(iResp).block = 'n/a'; - responseEvents(iResp).direction = 'n/a'; - responseEvents(iResp).speed = 'n/a'; - responseEvents(iResp).target = 'n/a'; - if strcmp(responseEvents(iResp).keyName, 't') - responseEvents(iResp).trial_type = ... - ['trigger_' cfg.design.blockNames{iBlock}]; - end - end - - responseEvents(1).fileID = logFile.fileID; - responseEvents(1).extraColumns = logFile.extraColumns; - saveEventsFile('save', cfg, responseEvents); - - end + triggerString = ['trigger_' cfg.design.blockNames{iBlock}]; + saveResponsesAndTriggers(responseEvents, cfg, logFile, triggerString); % wait for the inter-stimulus interval WaitSecs(cfg.ISI); @@ -156,26 +137,8 @@ triggerEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ... getOnlyPress); - if isfield(triggerEvents(1), 'onset') && ~isempty(triggerEvents(1).onset) - - for iResp = 1:size(triggerEvents, 1) - triggerEvents(iResp).onset = ... - triggerEvents(iResp).onset - cfg.experimentStart; - triggerEvents(iResp).event = 'n/a'; - triggerEvents(iResp).block = 'n/a'; - triggerEvents(iResp).direction = 'n/a'; - triggerEvents(iResp).speed = 'n/a'; - triggerEvents(iResp).target = 'n/a'; - if strcmp(triggerEvents(iResp).keyName, 't') - triggerEvents(iResp).trial_type = 'trigger_baseline'; - end - end - - triggerEvents(1).fileID = logFile.fileID; - triggerEvents(1).extraColumns = logFile.extraColumns; - saveEventsFile('save', cfg, triggerEvents); - - end + triggerString = 'trigger_baseline'; + saveResponsesAndTriggers(triggerEvents, cfg, logFile, triggerString); end