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 a0c8874..dc6d344 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit a0c8874fd7894a748758624d94d7b74f7e5c0252 +Subproject commit dc6d3449c5857211f6a60b4944b09dc8fe7f7051 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/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/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/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 d50228a..02b3524 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); @@ -67,7 +67,6 @@ % prepare the KbQueue to collect responses getResponse('init', cfg.keyboard.responseBox, cfg); - getResponse('start', cfg.keyboard.responseBox); % Wait for Trigger from Scanner waitForTrigger(cfg); @@ -75,6 +74,8 @@ %% Experiment Start cfg = getExperimentStart(cfg); + getResponse('start', cfg.keyboard.responseBox); + WaitSecs(cfg.onsetDelay); %% For Each Block @@ -119,62 +120,25 @@ % 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; - 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'; - 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); 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; - 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 @@ -190,8 +154,8 @@ getResponse('release', cfg.keyboard.responseBox); eyeTracker('Shutdown', cfg); - - createBoldJson(cfg, cfg) + + createBoldJson(cfg, cfg); farewellScreen(cfg);