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
12 changes: 6 additions & 6 deletions audioLocTranslational.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
% Safety loop: close the screen if code crashes
try

%% Init the experiment
[cfg] = initPTB(cfg);

% % % REFACTOR THIS FUNCTION % % %

[cfg] = loadAudioFiles(cfg);

% % % REFACTOR THIS FUNCTION % % %

%% Init the experiment
[cfg] = initPTB(cfg);

[el] = eyeTracker('Calibration', cfg);

% % % REFACTOR THIS FUNCTION % % %
Expand All @@ -51,7 +51,7 @@
logFile.extraColumns = cfg.extraColumns;
logFile = saveEventsFile('open', cfg, logFile);

disp(cfg);
% disp(cfg);

% Show experiment instruction
standByScreen(cfg);
Expand All @@ -71,14 +71,14 @@

%% For Each Block

for iBlock = 1:cfg.numBlocks
for iBlock = 1:cfg.design.nbBlocks

fprintf('\n - Running Block %.0f \n', iBlock);

eyeTracker('StartRecording', cfg);

% For each event in the block
for iEvent = 1:cfg.numEventsPerBlock
for iEvent = 1:cfg.design.nbEventsPerBlock

% Check for experiment abortion from operator
checkAbort(cfg, cfg.keyboard.keyboard);
Expand Down
4 changes: 2 additions & 2 deletions initEnv.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
persistent cacheval % speeds up repeated calls

if isempty (cacheval)
cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0);
cacheval = (exist ('OCTAVE_VERSION', 'builtin') > 0);
end

retval = cacheval;
Expand All @@ -86,7 +86,7 @@
function addDependencies()

pth = fileparts(mfilename('fullpath'));
addpath(fullfile(pth, 'lib', 'CPP_BIDS', 'src'));
addpath(genpath(fullfile(pth, 'lib', 'CPP_BIDS', 'src')));
addpath(fullfile(pth, 'lib', 'CPP_PTB'));
addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src')));
addpath(fullfile(pth, 'subfun'));
Expand Down
9 changes: 6 additions & 3 deletions setParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@

%% Experiment Design

% cfg.design.motionType = 'translation';
% cfg.design.motionType = 'radial';
cfg.design.motionType = 'translation';
cfg.design.names = {'static', 'motion'};
cfg.design.possibleDirections = [-1 1]; % 1 motion , -1 static %NOT IN USE AT THE MOMENT
cfg.design.nbBlocks = size(cfg.design.names, 2); % TO CHECK
cfg.design.nbRepetitions = 1; % AT THE MOMENT IT IS NOT SET IN THE MAIN SCRIPT
cfg.design.nbBlocks = size(cfg.design.names, 2); % TO CHECK
cfg.design.nbRepetitions = 4; % AT THE MOMENT IT IS NOT SET IN THE MAIN SCRIPT
cfg.design.nbEventsPerBlock = 12;

%% Timing
Expand Down Expand Up @@ -78,7 +81,7 @@
cfg.fixation.yDisplacement = 0;

cfg.target.maxNbPerBlock = 2;
cfg.target.duration = 0.05; % In secs
cfg.target.duration = 0.5; % In secs

cfg.extraColumns = {'direction', 'speed', 'target', 'event', 'block', 'keyName'};

Expand Down
63 changes: 43 additions & 20 deletions subfun/doAudMot.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [onset, duration] = doAudMot(cfg, thisEvent, phandle)

function [onset, duration] = doAudMot(cfg, thisEvent)
% Play the auditopry stimulation of moving in 4 directions or static noise bursts
%
% DIRECTIONS
Expand All @@ -13,19 +13,19 @@
% Output:
% -
%

%% Get parameters

sound = [];

direction = thisEvent.direction(1);
isTarget = thisEvent.target(1);
targetDuration = cfg.target.duration;

soundData = cfg.soundData;

% if isTarget == 0

if direction == -1
sound = soundData.S;
elseif direction == 90
Expand All @@ -37,7 +37,7 @@
elseif direction == 180
sound = soundData.L;
end

% elseif isTarget == 1
%
% if direction == -1
Expand All @@ -53,21 +53,44 @@
% end
%
% end

% Start the sound presentation
PsychPortAudio('FillBuffer', phandle, sound);
playTime = PsychPortAudio('Start', phandle);
onset = playTime;

PsychPortAudio('FillBuffer', cfg.audio.pahandle, sound);
PsychPortAudio('Start', cfg.audio.pahandle);
onset = GetSecs;

% draw first fixation and get a first visual time stamp
% ideally we would want to synch that first time stamp and the sound start
thisFixation.fixation = cfg.fixation;
thisFixation.screen = cfg.screen;
if GetSecs < (onset + targetDuration) && isTarget == 1
if isTarget == 1
thisFixation.fixation.color = cfg.fixation.colorTarget;
end
drawFixation(thisFixation);

vbl = Screen('Flip', cfg.screen.win);

while 1

% set default cross cross color but update if target time is not
% finished
thisFixation.fixation.color = cfg.fixation.color;
if GetSecs < (onset + targetDuration) && isTarget == 1
thisFixation.fixation.color = cfg.fixation.colorTarget;
end

drawFixation(thisFixation);
vbl = Screen('Flip', cfg.screen.win, vbl + cfg.screen.ifi);

status = PsychPortAudio('GetStatus', cfg.audio.pahandle);
if ~status.Active
break;
end

end

% Get the end time
% [~, ~, ~, stopTime] = PsychPortAudio('Stop',phandle);

% duration = stopTime - onset;
duration = onset + 1.2;
waitForEndOfPlayback = 1; % hard coding that will need to be moved out
[onset, ~, ~, estStopTime] = PsychPortAudio('Stop', cfg.audio.pahandle, ...
waitForEndOfPlayback);

duration = estStopTime - onset;
Loading