Skip to content

Commit

Permalink
updating instructions, timing, and probability
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemrupp committed Sep 24, 2024
1 parent df59956 commit 3f3f9a8
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 23 deletions.
4 changes: 1 addition & 3 deletions habit.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
correctTrials = 0;

%% instructions
if 0
[onset, output] = instructions(system, 1);
end
[onset, output] = instructions(system, 1);

%% start timing and data collection
record(length(timing)) = struct();
Expand Down
134 changes: 120 additions & 14 deletions private/instructions.m
Original file line number Diff line number Diff line change
@@ -1,44 +1,150 @@
function [onset, output] = instructions(system, number, varargin)
function [onset, output] = instructions(system, number, t, varargin)
output.instruction = number;

acceptkeys = KbName({'space','LeftArrow','UpArrow','RightArrow','Return','1'}); % Define accepted keys

k = 0;
%% positon choice options
chest_w = 60; chest_h = 60;
% Instruction 1
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background
DrawFormattedText(system.w, 'In this task you will be looking for treasure in three treasure chests', ...
% chest graphics
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.left.x system.pos.left.y system.pos.left.x+chest_w system.pos.left.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.up.x system.pos.up.y system.pos.up.x+chest_w system.pos.up.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.right.x system.pos.right.y system.pos.right.x+chest_w system.pos.right.y+chest_h] );

DrawFormattedText(system.w, 'In this task you will be looking for treasure in three treasure chests (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the first instruction
Screen('Flip', system.w); % Display the content on the screen
waitForKeys(acceptkeys, Inf);
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
disp(k)
end

% Instruction 2
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
DrawFormattedText(system.w, 'Two keys will appear in front of two of the three chests. You can choose between these two chests with keys', ...
% chest graphics
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.left.x system.pos.left.y system.pos.left.x+chest_w system.pos.left.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.up.x system.pos.up.y system.pos.up.x+chest_w system.pos.up.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.right.x system.pos.right.y system.pos.right.x+chest_w system.pos.right.y+chest_h] );

% add keys to chests
Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.right.x+20 system.pos.right.y+20 system.pos.right.x+chest_w system.pos.right.y+chest_h] );

Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.left.x+20 system.pos.left.y+20 system.pos.left.x+chest_w system.pos.left.y+chest_h] );

DrawFormattedText(system.w, 'Two keys will appear in front of two of the three chests. You can choose between these two chests with keys (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the second instruction
Screen('Flip', system.w); % Display the content on the screen
waitForKeys(acceptkeys, Inf);
k =0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end


% Instruction 2.5
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
% chest graphics
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.left.x system.pos.left.y system.pos.left.x+chest_w system.pos.left.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.up.x system.pos.up.y system.pos.up.x+chest_w system.pos.up.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.right.x system.pos.right.y system.pos.right.x+chest_w system.pos.right.y+chest_h] );

% add keys to chests
Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.right.x+20 system.pos.right.y+20 system.pos.right.x+chest_w system.pos.right.y+chest_h] );

Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.left.x+20 system.pos.left.y+20 system.pos.left.x+chest_w system.pos.left.y+chest_h] );

DrawFormattedText(system.w, 'Button 1 will go LEFT. Buttons 2 and 3 will go UP. Button 4 will go RIGHT (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the second instruction
Screen('Flip', system.w); % Display the content on the screen
k =0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end


% Instruction 2.7
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
% chest graphics
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.left.x system.pos.left.y system.pos.left.x+chest_w system.pos.left.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.up.x system.pos.up.y system.pos.up.x+chest_w system.pos.up.y+chest_h] );
Screen('DrawTexture', system.w, system.tex.chest_sprites{1,1},...
[], [ system.pos.right.x system.pos.right.y system.pos.right.x+chest_w system.pos.right.y+chest_h] );

% add keys to chests
Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.right.x+20 system.pos.right.y+20 system.pos.right.x+chest_w system.pos.right.y+chest_h] );

Screen('DrawTexture', system.w, system.tex.key,...
[], [ system.pos.left.x+20 system.pos.left.y+20 system.pos.left.x+chest_w system.pos.left.y+chest_h] );

DrawFormattedText(system.w, 'But be quick. You only have 2 seconds to choose a chest (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the second instruction
Screen('Flip', system.w); % Display the content on the screen
k =0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end



% Instruction 3
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
DrawFormattedText(system.w, 'The odds that a chest has treasure will be different. Your task is to learn which chest is most likely to have treasure', ...
DrawFormattedText(system.w, 'The odds that a chest has treasure will be different. Your task is to learn which chest is most likely to have treasure (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the third instruction
Screen('Flip', system.w); % Display the content on the screen
waitForKeys(acceptkeys, Inf);

k =0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end

% Instruction 4
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
DrawFormattedText(system.w, 'Push any key to start', ...
DrawFormattedText(system.w, 'The green bar at the bottom of the task lets you know how much longer in the task you have (push to continue)', ...
'center', 'center', [255, 255, 255]); % Draw the third instruction
Screen('Flip', system.w); % Display the content on the screen

k=0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end

% Instruction 5
Screen('Flip', system.w); % Clear the screen
Screen('DrawTexture', system.w, system.tex.ocean_bottom); % Show the background again
DrawFormattedText(system.w, 'Push any key twice to start', ...
'center', 'center', [255, 255, 255]); % Draw the final instruction
Screen('Flip', system.w); % Display the content on the screen
waitForKeys(acceptkeys, Inf);
k=0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end

% Ready to run the task
onset = Screen('Flip', system.w, 0); % Final screen flip, getting the onset time
acceptkeys = KbName({'space','LeftArrow','UpArrow','RightArrow','Return','1'}); % Define accepted keys

% Wait for a key press to start the task
[output.k, output.rt] = waitForKeys(acceptkeys, Inf);
k=0;
while k == 0
[k,rt]= waitForKeyPress(k,'rtbox');
end

end
12 changes: 6 additions & 6 deletions private/load_events.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% fprintf('# loading event timing\n');

nblocks = 3;
ntrials = 15;
ntrials = 50;
i = 0;

for block = 1:nblocks
Expand All @@ -20,11 +20,11 @@

% Set chance values depending on the block
if block == 1
timing(i).chance = [0,1,1,1]; % left, up, up,right
timing(i).chance = [.2,.5,.5,1]; % left, up, up,right
elseif block == 2
timing(i).chance = [0.5,0.5,0.5,1]; % left, up, up,right since rtbox has 2 options for up
timing(i).chance = [0.5,0.2,0.2,1]; % left, up, up,right since rtbox has 2 options for up
elseif block == 3
timing(i).chance = [0.5,1,1,0.5]; % left, up,up, right
timing(i).chance = [0.75,0.75,0.75,0.75]; % left, up,up, right
end

timing(i).max_rt = timing(i).dur;
Expand All @@ -40,15 +40,15 @@

i=i+1;
timing(i).event_name = 'isi';
timing(i).dur = .2;
timing(i).dur = .52;
timing(i).cross_color = [0,0,255]; % blue
timing(i).func = @moveCharacter;
timing(i).onset = timing(i-1).onset + timing(i-1).dur; % as soon as choice ends
timing(i).i = i;

i=i+1;
timing(i).event_name = 'feedback';
timing(i).dur = .1;
timing(i).dur = .52;
timing(i).func = @feedback;
timing(i).onset = timing(i-1).onset + timing(i-1).dur;
timing(i).i = i;
Expand Down

0 comments on commit 3f3f9a8

Please sign in to comment.