123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Checking keyboard, screens
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Response keys (optional; for no subject response use empty list)
- responseKeys = {'UpArrow','RightArrow','LeftArrow','space'};
- % Background color: cho ose a number from 0 (black) to 255 (white)
- % Text color: choose a number from 0 (black) to 255 (white)
- textColor = 200;
- % % Screen setup
- % clear screen
- %
- % if SkipSyncTests
- % Screen('Preference', 'SkipSyncTests', 1) %%% IMPORTANT!! REMOVE THIS LINE WHEN RUNNING THE TASK
- % end
- %
- % whichScreen = max(Screen('Screens'));
- %
- % [window1, rect] = Screen('Openwindow',whichScreen,backgroundColor,[],[],2);
- %
- % slack = Screen('GetFlipInterval', window1)/2;
- %
- % W=rect(RectRight); % screen width
- % H=rect(RectBottom); % screen height
- %
- % % Get the centre coordinate of the window
- % [xCenter, yCenter] = RectCenter(rect);
- %
- % Screen(window1,'FillRect',backgroundColor);
- % HideCursor(window1);
- % Screen('Flip', window1);
- % Keyboard setup
- KbName('UnifyKeyNames');
- if lab
- KbCheckList = [KbName('space'),KbName('ESCAPE'),KbName('Q'),KbName('Control')];
- keytoaccepabs='Control';
- else
- KbCheckList = [KbName('space'),KbName('ESCAPE'),KbName('Q'),KbName('RightShift')];
- keytoaccepabs='RightShift';
- end
- for i = 1:length(responseKeys)
- KbCheckList = [KbName(responseKeys{i}),KbCheckList];
- end
- RestrictKeysForKbCheck(KbCheckList);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Set up TIMING
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- % Fix cross + JITTER (0 to 500ms)
- fixationDuration = 1; %PLUS JITTER!! (0 to 500ms)
- % Object 1 presented
- objectTimeout = 2; %timeout of the object
- postobjectTimeout1 =0.5; %gap between object1 time out and next fix cross
- % Fix cross
- fixationDuration = 1;
- % Object 2 presented
- objectTimeout = 2; %timeout of the object
- postobjectTimeout2 =0.5; %gap between object2 time out and next event (retro cue)
- % Fix cross
- % Audio item cue (350ms)
- % Not in Memoreye % audiogap=0.2% gap between audio cues (seconds) - Not in Memoreye
- %Pins and timing
- npings=3; % total number of pings
- nodd=1; % number of odd pings
- delth=3500; % delay period length (ms)
- pilth=100; % ping duration (ms)
- minipi=600; % minimum inter-ping-interval
- maxsend=1000; %max pause (ms) before first/last ping
- minstart = 300 %minimum start time
- % Memory tasks 1 (here only concrete task)
- % (i) Abtract task
- abstractTimeout = 10;%Timeout to respond in the abstract task (in seconds)
- fbrespabs = 0.2; %Abstract task. How long we show the rotation selected before show feedback (in seconds) -avoiding trigger of response and fb too close
- fbtimeoutabs = 0.5; %Abstract task. How long we show the feedback screen (in seconds)
- % (ii) Concrete task
- concreteTimeout = 2.5;%Timeout to respond in the concrete task (in seconds)
- fbrespcon = 0.2; %Concrete task. How long we show the rotation selected (visual feedback to key pressed) (in seconds)
- fbtimeoutcon = 0.3; %Concrete task. How long we show the feedback screen (in seconds)
- fbaudiogap = 0.5; %After receiving FB leaving a gab before the next audio message
- % Fix cross
- % Audio item cue (300ms) / Or thank you sound ( 300ms if the uncued item is not
- % tested)
- % If the uncued item is also tested
- % 2nd Delay period
- npings_2=2; % total number of pings
- nodd_2=1; % number of odd pings
- delth_2=2500; % delay period length (ms) - Keeping in mind the fb-audio gap and the audio
- pilth_2=100; % ping duration (ms)
- minipi_2=600; % minimum inter-ping-interval
- maxsend_2=1000; %max pause (ms) before first/last ping
- minstart_2 = 300 %minimum start time
- % Same timing as in (ii) Concrete task
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Creating a sequence of trials for the task
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % "sequence" is a matrix where each row is a trial and each column:
- % Column 1 = Object 1
- % Column 2 = Object 2
- % Column 3 = Rotation Object 1
- % Column 4 = Rotarion Object 2
- % Column 5 = Target: 1 or 2
- % Column 6 = Target Object (id)
- % Column 7 = Type of task (1= concrete/perceptual; 2=continuous/abstract)
- % Column 8 = Object memory test
- % Column 9 = Rotation Object memory test
- % Column 10 = Block number
- % Column 11 = Rotation target
- % Column 12 = Testing uncued (True / False)
- % Column 13 = Object memory test 2
- % Column 14 = Rotation Object memory test 2
- % Column 15 = Rotation UNCUED
- % Inputs
- nc=3% Number of cue objects
- % nat=9% Number of objects for the abstract task
- npr=16% Number of positions/possible rotations
- contestdif=3.5; % Difficulty of perceptual task. The memory test object will be presented +-(distrot/contestdif) from original position
- nblocks = 16;
- if new_participant == 1
-
- [sequence_real distrot]=create_sequence_210311_BSJL(nc, npr, contestdif,nblocks);
- nblocks; %number of blocks
- name_sti = strcat('sequences/m_sequence_',subID,'.mat');
- name_val = strcat('sequences/other_info_',subID,'.mat');
- save(name_sti,'sequence_real');
- save(name_val,'distrot','nblocks','setofobjects');
-
- [sequence_pract distrot]=create_sequence_210311_BSJL(nc, npr, contestdif,nblocks);
-
- poi1=sequence_pract(:,12)==0&sequence_pract(:,10)==1; %Preparing a sequence for practice (only cue)
- sequencepract1=sequence_pract(poi1,:);
- sequencepract1=sequencepract1(1:8,:);% only 8 trials
-
- poi2=sequence_pract(:,12)==1&sequence_pract(:,10)==1; %Preparing a sequence for practice (only trials where we also ask for the uncued)
- sequencepract2=sequence_pract(poi2,:);
- sequencepract2=sequencepract2(1:8,:);% only 8 trials
-
- poi3=sequence_pract(:,10)==2; %Preparing a sequence for practice (mixed)
- sequencepract3=sequence_pract(poi3,:);
- sequencepract3=sequencepract3(1:8,:);% only 8 trials
-
- elseif new_participant == 0
-
- name_sti_load = strcat('sequences/m_sequence_',subID,'.mat');
- name_val_load = strcat('sequences/other_info_',subID,'.mat');
-
- load(name_sti_load);
- load(name_val_load);
-
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Set up stimuli lists
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % First, selecting one of 4 different subsets
- % in setst, 1= object used for as cue; 0= object used only in abstract
- % test
- %IMPORTANT TO CHANGES THIS FOR 3 TARGETS
- setst = [0 0 0 1 0 0 0 0 0 0 1 1 ;...
- 1 0 0 0 0 1 0 1 0 0 0 0 ;...
- 0 0 1 0 1 0 0 0 1 0 0 0 ];
-
- subset= setofobjects;
- subsetfff= setst(subset,:);
- delete stimuli/all_pics/.DS_Store
- delete stimuli/target/*.*
- delete stimuli/abstract_test/*.*
- list_a=dir('stimuli/all_pics/*.jpg');
- list_a=struct2cell(list_a);
- orifolder='stimuli/all_pics'
-
- for f= 1:length(subsetfff);
- objname=list_a{1,f};
- ffolder=strcat(orifolder,'/',objname);
- if subsetfff(f)==1
- copyfile(ffolder, 'stimuli/target');
- else
- copyfile(ffolder, 'stimuli/abstract_test');
- end
- end
-
- % Get the image files for the experiment:
-
- imageFolder = 'stimuli/target';
- imgList = dir(fullfile(imageFolder,['*.' 'jpg']));
- imgList = {imgList(:).name};
-
- % Get the image files for the experiment (test in the abstract condition):
-
- imageFolder_test = 'stimuli/abstract_test';
- imgList_test = dir(fullfile(imageFolder_test,['*.' 'jpg']));
- imgList_test = {imgList_test(:).name};
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Audio files and Audio Setting
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- [audcue1(:,1),Fs] = audioread('sound_demo/Cue_one_JH.wav');
- [audcue1(:,2),Fs] = audioread('sound_demo/Cue_one_JH.wav');
- [audcue2(:,1),Fs] = audioread('sound_demo/Cue_two_JH.wav');
- [audcue2(:,2),Fs] = audioread('sound_demo/Cue_two_JH.wav');
- %
- % audcue1=audcue1(1:size(audcue1,1)/2,:); %Cutting these long audio files
- % audcue2=audcue2(1:size(audcue2,1)/2,:);
- audcue{1}=audcue1;
- audcue{2}=audcue2;
- [aud1,Fs] = audioread('sound_demo/camera300.wav');
- [aud2,Fs] = audioread('sound_demo/magic300.wav');
- audtaskcue{1}=aud1;
- audtaskcue{2}=aud2;
- [audtest,Fs] = audioread('sound_demo/test.wav');
- [aud1th(:,1),Fs] = audioread('sound_demo/Cue_thanks_JH.wav');
- [aud1th(:,2),Fs] = audioread('sound_demo/Cue_thanks_JH.wav'); %fake stereo
- audthanks{1}=aud1th;
- % Audio
- InitializePsychSound;
- devices = PsychPortAudio('GetDevices',[]);
- if lab
- DEVICE_NUMBER=[14]; % when running in the lap
- else
- DEVICE_NUMBER=[];% when running on laptop
- end
- % Options
- repetitions = 1;
- startCue = 0;
- pahandle = PsychPortAudio('Open', DEVICE_NUMBER, 1, 1, Fs, 2);
- %
- % 'reqlatencyclass' Allows to select how aggressive PsychPortAudio should be about
- % minimizing sound latency and getting good deterministic timing, i.e. how to
- % trade off latency vs. system load and playing nicely with other sound
- % applications on the system. Level 0 means: Don't care about latency or timing
- % precision. This mode works always and with all settings, plays nicely with other
- % sound applications. Level 1 (the default) means: Try to get the lowest latency
- % that is possible under the constraint of reliable playback, freedom of choice
- % for all parameters and interoperability with other applications. Level 2 means:
- % Take full control over the audio device, even if this causes other sound
- % applications to fail or shutdown. Level 3 means: As level 2, but request the
- % most aggressive settings for the given device. Level 4: Same as 3, but fail if
- % device can't meet the strictest requirements.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Set up other keyboard inputs parameter
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %Abstract task
- if lab
- rotSensi=0.03%360/(npr*4);% Sensibility to rotate the images with the keyboard (abstract)
- keypul=0.05 % Minimum delay between key pulse (seconds) to start accelerating the speed of rotation
- keyacce=0.2 % Acceleration increase
- else
- rotSensi=0.03%360/(npr*4);% Sensibility to rotate the images with the keyboard (abstract)
- keypul=0.05 % Minimum delay between key pulse (seconds) to start accelerating the speed of rotation
- keyacce=1.6 % Acceleration increase
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Set up PINGS
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- % Make a base Rect
- redup = 0.42;% to reduce the diameter of pings
- baseRect1 = [0 0 W/2 W/2].*redup;
- baseRect2 = [0 0 W/2.5 W/2.5].*redup;
- baseRect3 = [0 0 W/3.5 W/3.5].*redup;
- baseRect4 = [0 0 W/6 W/6].*redup;
- baseRect5 = [0 0 W/15 W/15].*redup;
- % For Ovals we set a miximum diameter up to which it is perfect for
- maxDiameter1 = (max(baseRect1) * 1.01);
- maxDiameter2 = (max(baseRect2) * 1.01);
- maxDiameter3 = (max(baseRect3) * 1.01);
- maxDiameter4 = (max(baseRect4) * 1.01);
- maxDiameter5 = (max(baseRect5) * 1.01);
- % Center the rectangle on the centre of the screen
- centeredRect1 = CenterRectOnPointd(baseRect1, xCenter, yCenter);
- centeredRect2 = CenterRectOnPointd(baseRect2, xCenter, yCenter);
- centeredRect3 = CenterRectOnPointd(baseRect3, xCenter, yCenter);
- centeredRect4 = CenterRectOnPointd(baseRect4, xCenter, yCenter);
- centeredRect5 = CenterRectOnPointd(baseRect5, xCenter, yCenter);
- if pingcolorset==1
- AcP = [250 0 0]; %Red Odd
- BcP = [245 245 245]; %White Odd
- CcP = [90 90 90];%Grey Normal
- DcP = [255 255 255];%White Normal
- elseif pingcolorset==2
- AcP = [90 90 90];%Grey Odd
- BcP = [255 255 255];%White Odd
- CcP = [250 0 0]; %Red Normal
- DcP = [255 255 255]; %White Normal
- elseif pingcolorset==3
- AcP = [0 250 0]; %Green Odd
- BcP = [255 255 255]; %White Odd
- CcP = [90 90 90];%Grey Normal
- DcP = [255 255 255];%White Normal
- elseif pingcolorset==4
- AcP = [90 90 90];%Grey Odd
- BcP = [255 255 255];%White Odd
- CcP = [0 250 0]; %Green Normal
- DcP = [255 255 255]; %White Normal
- elseif pingcolorset==5
- AcP = [200 200 0]; %Yellow Odd
- BcP = [255 255 255]; %White Odd
- CcP = [90 90 90];%Grey Normal
- DcP = [255 255 255];%White Normal
- elseif pingcolorset==6
- AcP = [90 90 90];%Grey Odd
- BcP = [255 255 255];%White Odd
- CcP = [200 200 0]; %Yellow Normal
- DcP = [255 255 255]; %White Normal
- end
- % Set the color for obbball pings
- rectColor_odd{1} = AcP;
- rectColor_odd{2} = BcP;
- rectColor_odd{3} = AcP;
- rectColor_odd{4} = BcP;
- rectColor_odd{5} = AcP;
- % Set the color for pings
- rectColor{1} = CcP;
- rectColor{2} = DcP;
- rectColor{3} = CcP;
- rectColor{4} = DcP;
- rectColor{5} = CcP;
-
- %% Setting the pixel deviation from the center to show fixation cross in different position
-
- % Important info regarding our setup (data recorded during spring 2021)
- % The size of our screen in mm is 600x340. The distance between the screen and participants' eyes is around 620mm. So, using a 2K resolution (2560x1440px), a pixel is equal to 0.0217 visual degrees.
- vdperpixel=0.0217;
- pp=visdegdis/vdperpixel;
-
- % these are the 8 different values that we can add to the center to show the fix cross (both
- % w and h dimensions); third column is just a value to send a trigger
-
- fixcrosdev=[0 -pp 1;...
- 0 pp 2;...
- pp -pp 3;...
- pp 0 4;...
- pp pp 5;...
- -pp -pp 6;
- -pp 0 7;...
- -pp pp 8;
- 0 0 9];
-
-
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Set up results file
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Set up the output file (this output is for info related with the
- % presention of room-object association and word tasks)
- %
- % subID='1';
- % gender='xxx';
- % age=99;
- if pingsareon %if we are using ping we will have a more detailed output file
-
- resultsFolder = 'outputfiles';
- outputfile = fopen([resultsFolder '/resultfile_' num2str(subID) '.txt'],'a');
- fprintf(outputfile, 'task_version\t date\t subID\t sub_gender\t sub_age\t block_number\t trial\t object_1_name\t object_1_id\t object_1_rot\t object_2_name\t object_2_id\t object_2_rot\t retro_cue\t object_cued_id\t object_cued_rot\t retro_cue_uncued\t object_uncued_id\t object_uncue_rot\t type_of_task\t total_of_pings_1\t position_odd_pings_1\t total_of_pings_2\t position_odd_pings_2\t pings_on_off\t object_test_name_cued\t object_test_id_cued\t object_test_rot_cued\t object_test_name_uncued\t object_test_id_uncued\t object_test_rot_uncued\t rt_resp_concrete_cued\t acc_trial_concrete_cued\t final_rot_concrete_cued\t rt_resp_concrete_uncued\t acc_trial_concrete_uncued\t final_rot_concrete_uncued\t testing_uncued\t onset_object_1\t onset_object_2\t onset_retrocue\t onset_taskcue\t onset_test_cued\t onset_response_cued\t onset_feedback_cued\t onset_retrocue_2_or_thanks\t onset_test_uncued\t onset_response_uncued\t onset_feedback_uncued\t onset_thanks_uncued\t onset_ping_1_delay_1\t onset_ping_2_delay_1\t onset_ping_3_delay_1\t onset_ping_4_delay_1\t onset_ping_5_delay_1\t onset_ping_1_delay_2\t onset_ping_2_delay_2\t onset_ping_3_delay_2\t onset_ping_4_delay_2\t onset_ping_5_delay_2\t trigger_object_1\t trigger_object_2\t trigger_retrocue_1\t trigger_taskcue\t trigger_object_concrete\t trigger_object_abstract\t colorset_pins\t practice\t righthanded\t ping_null_1\t ping_null_2\t ping_null_3\t ping_null_4\t ping_null_2_1\t ping_null_2_2\t ping_null_2_3\t ping_null_2_4\t object_null_1\t object_null_2\t block_repe_null\t threshold_fix\n');
- else
-
- resultsFolder = 'outputfiles';
- outputfile = fopen([resultsFolder '/resultfile_eyetest_' num2str(subID) '.txt'],'a');
- fprintf(outputfile, 'task_version\t date\t subID\t sub_gender\t sub_age\t block_number\t trial\t object_1_name\t object_1_id\t object_1_rot\t object_2_name\t object_2_id\t object_2_rot\t retro_cue\t object_cued_id\t object_cued_rot\t retro_cue_uncued\t object_uncued_id\t object_uncue_rot\t type_of_task\t pings_on_off\t object_test_name_cued\t object_test_id_cued\t object_test_rot_cued\t object_test_name_uncued\t object_test_id_uncued\t object_test_rot_uncued\t rt_resp_concrete_cued\t acc_trial_concrete_cued\t final_rot_concrete_cued\t rt_resp_concrete_uncued\t acc_trial_concrete_uncued\t final_rot_concrete_uncued\t testing_uncued\t onset_object_1\t onset_object_2\t onset_retrocue\t onset_taskcue\t onset_test_cued\t onset_response_cued\t onset_feedback_cued\t onset_retrocue_2_or_thanks\t onset_test_uncued\t onset_response_uncued\t onset_feedback_uncued\t onset_thanks_uncued\t trigger_object_1\t trigger_object_2\t trigger_retrocue_1\t trigger_taskcue\t trigger_object_concrete\t trigger_object_abstract\t practice\t righthanded\t delay_1_null\t delay_2_null\t object_null_1\t object_null_2\t block_repe_null\t cue_fix_dev_1\t cue_fix_dev_2\t cue_fix_dev_3\t cue_fix_dev_4\t cue_fix_dev_5\t cue_fix_dev_6\t cue_fix_dev_7\t cue_fix_dev_8\t cue_fix_dev_9\t fix_dev_vd_distance threshold_fix\n');
-
- end
-
-
-
-
-
-
-
|