12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414 |
-
- %% MEMOREYE - UNATTENDED
- % Bernhard Spitzer and Juan Linde Domingo, MARCH 2021, CN@RC
- %% Main diferences re previous version (00)
- % Reduced size of pings and objects
- % Correct delay between last ping and tests
- % Including 6 different colorsets for Pings
- % Background set to 128
- %% Main diferences re previous version (00_1)
- % Practice added
- % Min delay between pings increased to 600ms (400ms before)
- %% Main diferences re previous version (00_5)
- % Practice and instructions done
- %% Only diferences re previous version (01)
- % Positions between cue and uncued items are uncorrelated
- % Gazebo images modified
- %% Only diferences re previous version (01_1)
- % Detecting whether participant are not looking to the fix cross and adding
- % this "null" trials to a final block. (no more than 48 trials)
- %% Only diferences re previous version (01_5)
- % Adding trials (50%) where after the test for the cued item we ask for the
- % uncued item
- % Only concrete task
- % Adding the possibility of not using pings
- % Instead of having a fixation cross, use a fixation DOT
- %% Differences compare to Memory_unateended_in_progress
- % Optimizing the off screen message
- %% Some changes in in progress 02
- % (1) Remove pings (although we can leave an option to turn them on again)
- % - Here pings are important since we use their onset to check the gaze
- % during the delay period. One solution is not showing the object although
- % we keep the onset
- % (end) Update the output file
- % Change the spatial fix threshold (1.5)
- % Change the instructions
- % FB message closer to the center
- % No repetion of null triaLS (NON-FIXED)
- % Add a temporal threshold for non-fix messages
- % Push back the auditory cue after feedback 500ms
- %% Clean workspace and initialize the random number generator
- clear all;
- rand('state', sum(100*clock)); % Initialize the random number generator
- %% Adding PTB pathq
- ptb_path
- %% Prompt window
- prompt = {'Do you want to run a practice with instructions or the real task? (only practice=1; only real task=2)'};
- defaults = {'2'};
- answer = inputdlg(prompt, 'Practice or real experiment?', 1, defaults);
- [supra] = deal(answer{:});
- supra = str2num(supra);
- % Open a Prompt Window and decoding the answer
- prompt = {'Task Version','Using the EEG-Lab PC? (0=no, 1=yes)','New Participant (0=no, 1=yes) ','Participant ID','Gender (M/F/Other)','Age','Righthanded? (0=no, 1=yes)','Stimuli subset (1 to 3)','Using Eye-tracking? (0=No;1=Yes)','Using EEG Triggers? (0=No;1=Yes)','Skip Sync Tests? (0=No;1=Yes)','First trial','Using pings (0=No;1=Yes)','Pings coloset (1 to 6)','Repeating non-fix trials? (0=No;1=Yes)'};
- defaults = {mfilename, '1','1','XXX','X','99','1','2','1','0','0','1','0','1','0' };
- answer = inputdlg(prompt, 'Experimental Setup Information', 1, defaults);
- [taskversion,lab,new_participant,subID, gender, age, righthanded, setofobjects,eyetracking,triggers_on, SkipSyncTests, firstrial, pingsareon, pingcolorset, repnonfixtrial] = deal(answer{:});
-
- age = str2num(age);
- righthanded = str2num(righthanded);
- eyetracking = str2num(eyetracking);
- original_eyetracking=eyetracking;
- triggers_on= str2num(triggers_on);
- original_triggers_on= triggers_on;
- SkipSyncTests =str2num(SkipSyncTests);
- setofobjects=str2num(setofobjects);
- pingcolorset = str2num(pingcolorset);
- firstrial=str2num(firstrial);
- new_participant=str2num(new_participant);
- lab=str2num(lab);
- repnonfixtrial=str2num(repnonfixtrial);
- pingsareon=str2num(pingsareon); %Ping on/off
-
-
- if supra==1
- mxsq=1:3;
- elseif supra==2
- if repnonfixtrial==1
- mxsq=4:5;
- elseif repnonfixtrial==0
- mxsq=4;
- end
- end
-
- if supra==1
- subID=[subID 'pr']
- end
-
- fixtrh=70.5;
- gazeofftimelim=0.5; %time limits for the eyeoff
- %
- if new_participant==0
-
- prompt = {'Participants could have a old EDF file. Choose the name for the new EDF file'};
- defaults = {'1'};
- answer = inputdlg(prompt, 'Experimental Setup Information', 1, defaults);
- [subID_neo] = deal(answer{:});
-
- end
-
-
- %% Screen setup
-
- % Background color: cho ose a number from 0 (black) to 255 (white)
- backgroundColor = 128;
- clear screen
- if SkipSyncTests
- Screen('Preference', 'SkipSyncTests', 1) %%% IMPORTANT!!
- end
- whichScreen = max(Screen('Screens'));
- if lab
- [window1, rect] = Screen('Openwindow',whichScreen,backgroundColor,[],[],2);
- else
- [window1, rect] = Screen('Openwindow',whichScreen,backgroundColor,[0 0 800 600],[],2);
- end
- 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);
- %% Preparing Eyelink - Eye Tracking
-
- if eyetracking==1
- dummymode=0;
-
- % STEP 2
- % Provide Eyelink with details about the graphics environment
- % and perform some initializations. The information is returned
- % in a structure that also contains useful defaults
- % and control codes (e.g. tracker state bit and Eyelink key values).
- el=EyelinkInitDefaults(window1);
-
- % STEP 3
- % Initialization of the connection with the Eyelink Gazetracker.
- % exit program if this fails.
- if ~EyelinkInit(dummymode)
- fprintf('Eyelink Init aborted.\n');
- end
-
- [v vs]=Eyelink('GetTrackerVersion');
- fprintf('Running experiment on a ''%s'' tracker.\n', vs );
-
- % open file for recording data
- if new_participant
- edfFile=[subID '.edf'];
- Eyelink('Openfile', edfFile);
- else
- edfFile=[subID_neo '.edf'];
- Eyelink('Openfile', edfFile);
- end
- % STEP 4
- % Do setup and calibrate the eye tracker
- EyelinkDoTrackerSetup(el);
- Eyelink('command', 'calibration_area_proportion = 0.45 0.45');
- Eyelink('command', 'calibration_validation_proportion = 0.45 0.45');
- % do a final check of calibration using driftcorrection
- % You have to hit esc before return.
- EyelinkDoDriftCorrection(el);
-
- % STEP 5
- % Start recording eye position
- Eyelink('StartRecording');
- % record a few samples before we actually start displaying
- WaitSecs(0.5);
- else
- edfFile=[];
- end
- %% Checking keyboard, screens, audio, and adding others settings (e.g. timing) for the experiment
- settings_memoreye_unattended_inprogress;
- %% Open the serial port (Triggers)
- if triggers_on
- TB = IOPort('OpenSerialPort','COM4'); % in the lab x=4
- else
- TB =[];
- end
- %% Run the task
- % time of start of experiment and date
- trigger_beginning_end=245;
- ExpStart = GetSecs;
- today = date;
- barColor=[100 100 100]
- % Counter for interblock message accuracy
-
- accuracy_con= [];
- accuracy_abs= [];
-
- for maxiblock=mxsq; %3 first miniblocks of practices and then the task
-
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle,(audtest)');
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
-
- if maxiblock==1 %first block of practice
- sequence=sequencepract1;
- practice=1;
- % eyetracking=0;
- triggers_on=0;
- imageFolder_in = 'instructions/one';
- imgList_in = dir(fullfile(imageFolder_in,['*.jpg']));
- imgList_in = {imgList_in(:).name};
- showingslides(imgList_in,imageFolder_in,window1,W,H,backgroundColor,responseKeys)
-
- elseif maxiblock==2
- sequence=sequencepract2;
- practice=1;
- % eyetracking=0;
- triggers_on=0;
- imageFolder_in = 'instructions/two';
- imgList_in = dir(fullfile(imageFolder_in,['*.jpg']));
- imgList_in = {imgList_in(:).name};
- showingslides(imgList_in,imageFolder_in,window1,W,H,backgroundColor,responseKeys)
-
- elseif maxiblock==3
- sequence=sequencepract3;
- practice=1;
- % eyetracking=0;
- triggers_on=0;
- imageFolder_in = 'instructions/three';
- imgList_in = dir(fullfile(imageFolder_in,['*.jpg']));
- imgList_in = {imgList_in(:).name};
- showingslides(imgList_in,imageFolder_in,window1,W,H,backgroundColor,responseKeys)
-
- elseif maxiblock==4 %real task
-
- sequencenull=[] %Sequence of null trials
- sequence=sequence_real;
- practice=0;
-
- if original_eyetracking % Restore eyetracking on/off to original (to send triggers)
- eyetracking=1;
- else
- eyetracking=0;
- end
-
- if original_triggers_on % Restore triggers on/off to original
- triggers_on=1;
- else
- triggers_on=0;
- end
- press_trigger(trigger_beginning_end,TB,triggers_on);
- press_eyelink_trigger(trigger_beginning_end,eyetracking)
-
- % First Message
- Screen(window1, 'FillRect', backgroundColor);
-
- Screen('TextSize',window1,18);
- msg=['Welcome to the experiment'];
- DrawFormattedText(window1, msg, 'center', (H/4.5), textColor);
- DrawFormattedText(window1, '[Press the space bar to start]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
-
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle,(audtest)');
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
-
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- end
- end
-
- elseif maxiblock==5 %repeating null trials (fix point)
-
- %randomize the sequencenull
- sequencenull=sequencenull(randperm(size(sequencenull,1)),:)
- sequencenull(:,10)=nblocks+1; %and put the same number for the blocks
- if size(sequencenull,1)>48 %Maximum trials to repeat
- sequencenull=sequencenull(1:48,:)
- end
-
- sequence=sequencenull;
- practice=0;
- firstrial=1;
-
- if original_eyetracking % Restore eyetracking on/off to original (to send triggers)
- eyetracking=1;
- else
- eyetracking=0;
- end
-
- if original_triggers_on % Restore triggers on/off to original
- triggers_on=1;
- else
- triggers_on=0;
- end
- press_trigger(trigger_beginning_end,TB,triggers_on);
- press_eyelink_trigger(trigger_beginning_end,eyetracking)
-
- % First Message
- Screen(window1, 'FillRect', backgroundColor);
-
- Screen('TextSize',window1,18);
- msg=['Almost done. We will repeat some trials where your gaze was not in the center'];
- DrawFormattedText(window1, msg, 'center', (H/4.5), textColor);
- DrawFormattedText(window1, '[Press the space bar to start]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
-
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle,(audtest)');
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
-
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- end
- end
-
- end
-
- for trial=firstrial:size(sequence,1)
-
- % Parameters for each trial (clarification)
-
- % In Sequence:
-
- % 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
-
- object_1_id=sequence(trial,1);
- object_2_id=sequence(trial,2);
- object_1_rot=sequence(trial,3);
- object_2_rot=sequence(trial,4);
- cue=sequence(trial,5);
- type_of_task=sequence(trial,7);
- object_test_id=sequence(trial,8);
- object_test_rot=sequence(trial,9);
- block=sequence(trial,10);
- all_rotation = unique(sequence_real(:,3));
-
- object_cue_id=sequence(trial,6);
- object_cue_rot=sequence(trial,11);
-
- object_uncued_id=sequence(trial,13);
- object_uncued_rot=sequence(trial,15);
-
- pingfixated=zeros(1,8);
- pingfixated_2=zeros(1,8);
- testinguncued=sequence(trial,12);
-
- object_test_id_uncued=sequence(trial,13);
- object_test_rot_uncued=sequence(trial,14);
-
-
- if trial<size(sequence,1);
- next_trial_block=sequence(trial+1,10);
- else % we are in the last trial of the experiment, no next block
- next_trial_block=block;
- end
-
- if cue==1
- %object_cue_rot=object_1_rot;
- uncue=2;
-
- elseif cue==2
- % object_cue_rot=object_2_rot;
- uncue=1
- end
-
- Onset_ping=NaN(1,10); % (creating a vector to include up to 10 pings onsets in the outputfile)
- Onset_ping_2=NaN(1,10); % (creating a vector to include up to 10 pings onsets in the outputfile)
- %% Trigger info (EEG and Eye-Tracking)
- % % Changes: Gaze-off triggers removed (this info is included in the
- % output file). Triggers for "Thanks" messages included.
-
- % % -orientations (1:16): 001:1:016
- % % -sample item code (1:3): 20:20:60
- % % -1st/2nd sample position: 000/100
- % %
- % % i.e. item 2 at 45?? in first sample position would be 42; in 2nd sample position t would be 142
- % %
- % % - first retrocue: 1/2 (first or second item respectively)
- % % - second retrocue (for the uncued item): 3/4 (first or second item respectively)
- % %
- % % - thanks message after test for the CUED item: 5
- % % - thanks message after test for the UNCUED item: 6
- % %
- % % -Object onset in abstract test for the CUED item: 201:209 (object identity from 1 to 9)
- % % -Object onset in abstract test for the UNCUED item: 211:219 (object identity from 1 to 9)
- % %
- % % -Object onset in concrete test for the CUED item: 220/221 (for left/right tilted)
- % % -Object onset in concrete test for the UNCUED item: 223/224 (for left/right tilted)
- % %
- % % -230 Ping - First delay
- % % -231 Oddball Ping - First delay
- % %
- % % -232 Ping - Second delay
- % % -233 Oddball - Second delay
- % %
- % % -241 left button press
- % % -242 right button press
- % % -243 up/accept button press
- % % -244 feedback cued item
- % % -245 feedback uncued item
- % %
- % % -246 beginning/end of the task
- %% IMPORTANT - MODIFIED BASED ON THE PREVIOUS LIST
- trigger_object_1 = (find(object_1_rot==all_rotation))+(object_1_id*20)
- trigger_object_2 = (find(object_2_rot==all_rotation))+(object_2_id*20)+100
- trigger_retrocue = cue;
- trigger_retrocue_2 = uncue+2;
- trigger_thanks = 5;
- trigger_thanks_2 = 6;
- trigger_taskcue = NaN; %not used here
- %To remove
- % trigger_object_1_null=100;
- % trigger_object_2_null=200;
- % trigger_ping_null=232
- degdiff=angdiff(deg2rad(object_cue_rot),deg2rad(object_test_rot)); % angular difference
- degdiff=rad2deg(degdiff);
-
- trigger_object_concrete= 220+(degdiff>0);
- trigger_object_abstract=object_test_id+200;
- trigger_object_concrete_uncued= 222+(degdiff>0);
- trigger_object_abstract_uncued=object_test_id+210;
- trigger_ping=230;
- trigger_odd_ping=231;
- trigger_ping_2=232;
- trigger_odd_ping_2=233;
- trigger_left_key=241;
- trigger_right_key=242;
- trigger_up_key=243;
- trigger_feedback=244;
- trigger_feedback_uncued=245;
- trigger_beginning_end=246;
- %% Pre-load stimuli and other settings
-
- bth=254% treshold to subtitute for background
- sc_o=(10000/W)*1.4;
-
- %Object 1
-
- file_object_1 = imgList{object_1_id};
- img_object_1 = imread(fullfile(imageFolder ,file_object_1));
- img_object_1((img_object_1>=bth))=backgroundColor; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_1 = Screen('MakeTexture', window1, img_object_1);
-
- % Calculate image position (center of the screen) OBJECT 1
- imageSize_o1 = size(img_object_1)/sc_o;
- pos_o1 = [(W-imageSize_o1(2))/2 (H-imageSize_o1(1))/2 (W+imageSize_o1(2))/2 (H+imageSize_o1(1))/2];
-
- %Object 2
-
- file_object_2 = imgList{object_2_id};
- img_object_2 = imread(fullfile(imageFolder ,file_object_2));
- img_object_2((img_object_2>=bth))=backgroundColor; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_2 = Screen('MakeTexture', window1, img_object_2);
-
- % Calculate image position (center of the screen) OBJECT 2
- imageSize_o2 = size(img_object_2)/sc_o;
- pos_o2 = [(W-imageSize_o2(2))/2 (H-imageSize_o2(1))/2 (W+imageSize_o2(2))/2 (H+imageSize_o2(1))/2];
-
- %Object Memory Test (we will use a difference object for the
- %abstract task)
-
- if type_of_task==2
-
- file_object_t = imgList_test{object_test_id};
- img_object_t = imread(fullfile(imageFolder_test ,file_object_t));
- img_object_t((img_object_t>=bth))=backgroundColor; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_test = Screen('MakeTexture', window1, img_object_t);
-
- else
-
- file_object_t = imgList{object_test_id};
- img_object_t = imread(fullfile(imageFolder,file_object_t));
- img_object_t((img_object_t>=bth) )=backgroundColor ; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_test = Screen('MakeTexture', window1, img_object_t);
-
- proof=img_object_t;proof(:,:,1)=proof(:,:,1)./1.5;proof(:,:,3)=proof(:,:,3)./1.5;
- proof((img_object_t==backgroundColor) )=backgroundColor ; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_test_green = Screen('MakeTexture', window1, proof);
-
- proof=img_object_t;proof(:,:,2)=proof(:,:,2)./1.5;proof(:,:,3)=proof(:,:,3)./1.5;
- proof((img_object_t==backgroundColor))=backgroundColor ; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_test_red = Screen('MakeTexture', window1, proof);
-
-
- file_object_t_uncued = imgList{object_test_id_uncued};
- img_object_t_uncued = imread(fullfile(imageFolder,file_object_t_uncued));
- img_object_t_uncued((img_object_t_uncued>=bth) )=backgroundColor ; %REMOVING BACKGROUND FOR EACH IMAGE
- objectDisplay_test_uncued = Screen('MakeTexture', window1, img_object_t_uncued);
-
-
- end
-
- % Calculate image position (center of the screen) OBJECT TEST
- imageSize_ot = size(img_object_t)/sc_o;
- pos_ot = [(W-imageSize_ot(2))/2 (H-imageSize_ot(1))/2 (W+imageSize_ot(2))/2 (H+imageSize_ot(1))/2];
-
- %Setting the position of the oddball ping
-
- %Calcularing the time gap between pings
-
- pausvec=pingT(npings,nodd,delth,pilth,minipi,maxsend,minstart)
-
- odvec=[zeros(1,npings-nodd) ones(1,nodd)]; % vector defining which ping is an oddball
- oddpingpos=odvec(randperm(npings));
-
- %Calcularing the time gap between pings for the SECOND delay
-
- pausvec_2=pingT(npings_2,nodd_2,delth_2,pilth_2,minipi_2,maxsend_2,minstart_2)
-
- odvec_2=[zeros(1,npings_2-nodd_2) ones(1,nodd_2)]; % vector defining which ping is an oddball
- oddpingpos_2=odvec_2(randperm(npings_2));
- %% Showing OBJECT 1
- objectodisplay=objectDisplay_1;
- rottodisplay=object_1_rot;
- positiontodisplay=pos_o1;
- OnsetResp=0;
- rt_catch = 0;
- resp_text = 0;
- resp_catch = 'No_Response'; %Just in case we don't have response
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- if eyetracking==1 % Before 'Flip' check whether the eyes are well fixated to change the trigger id
- eyesin=0;
- eyesout=0;
- eyes_were_out=0;
- too=[];
- %if eyes are not fixated, the trial will not start
- while eyesin==0
- too(1) = gazein(W,H,fixtrh,gazeofftimelim,0);
- too(1)
- if too(1)==1
- eyesin=1;
- elseif too(1)==0
- eyes_were_out=1;
- end
- end
- end
-
- %If eyes were not fixated before the trial start (time lenght
- %defined by fixationDuration)
- if eyes_were_out
-
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (fixationDuration - slack),0) %Adding between 0 and 0.5 second randomly to the minimum for the fixation duration
-
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- end
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (fixationDuration + (rand(1)/2))- slack,0) %Adding between 0 and 0.5 second randomly to the minimum for the fixation duration
- % Show Object 1
-
- Screen('DrawTexture', window1, objectodisplay, [], positiontodisplay,rottodisplay);
- drawDot(window1,W,H,barColor); %Fixcross on top
-
- object_1_fixated=0; %eye centered
- if eyetracking==1 % Before 'Flip' check whether the eyes are well fixated to change the trigger id
-
- object_1_fixated = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- end
-
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_1 = startTime-ExpStart; %Onset
- tdel=press_trigger(trigger_object_1,TB,triggers_on);
- press_eyelink_trigger(trigger_object_1,eyetracking)
- startout=[];
- while (GetSecs - startTime) < objectTimeout - tdel - slack
- [keyIsDown,secs,keyCode] = KbCheck;
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
-
- respTime = GetSecs;
- pressedKeys = find(keyCode);
-
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
-
- break
-
- end
- end
- end
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
-
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- object_1_fixated=1;
- end
- end
-
-
- end
- % Empty screen between object offset and next fix cross
- % Screen priority
-
- Priority(MaxPriority(window1));
- Priority(2);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1 )
-
- while (GetSecs - startTime) < postobjectTimeout1 - slack
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
- [keyIsDown,secs,keyCode] = KbCheck;
- respTime = GetSecs;
- pressedKeys = find(keyCode);
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp_catch = responseKeys{i};
- rt_catch = respTime - startTime;
- OnsetResp = GetSecs - ExpStart;
- break
- end
- end
- end
- end
- %% Showing OBJECT 2
- objectodisplay=objectDisplay_2;
- rottodisplay=object_2_rot;
- positiontodisplay=pos_o2;
- OnsetResp=0;
- rt_catch = 0;
- resp_text = 0;
- resp_catch = 'No_Response'; %Just in case we don't have response
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor);
-
- % %If eyes were not fixated in object 1
- % if object_1_fixated
- % Screen('TextSize',window1,40);
- % DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- % end
-
- tFixation = Screen('Flip', window1);
-
-
- Screen('Flip', window1, tFixation + (fixationDuration)- slack,0)
-
- % Show Object 2
-
- Screen('DrawTexture', window1, objectodisplay, [], positiontodisplay,rottodisplay);
- drawDot(window1,W,H,barColor); %Fixcross on top
-
-
- object_2_fixated=0; %eye centered
- if eyetracking==1 % Before 'Flip' check whether the eyes are well fixated to change the trigger id
- object_2_fixated = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- end
-
-
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_2 = startTime-ExpStart; %Onset
- tdel=press_trigger(trigger_object_2,TB,triggers_on);
- press_eyelink_trigger(trigger_object_2,eyetracking)
- startout=[];
-
- while (GetSecs - startTime)< objectTimeout - tdel - slack
- [keyIsDown,secs,keyCode] = KbCheck;
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
-
- respTime = GetSecs;
- pressedKeys = find(keyCode);
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
-
- break
- end
- end
- end
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
-
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- object_2_fixated=1;
- end
- end
- end
- % Empty screen between object offset and next fix cross
- % Screen priority
-
- Priority(MaxPriority(window1));
- Priority(2);
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor); %Fixcross on top
-
- %If eyes were not fixated in object 2
- if object_2_fixated
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- end
-
-
- startTime = Screen('Flip', window1 )
-
- while (GetSecs - startTime)< postobjectTimeout2 - slack
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
- [keyIsDown,secs,keyCode] = KbCheck;
- respTime = GetSecs;
- pressedKeys = find(keyCode);
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp_catch = responseKeys{i};
- rt_catch = respTime - startTime;
- OnsetResp = GetSecs - ExpStart;
- break
- end
- end
- end
- end
-
- %% Showing retro cue (sounds)
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- startTime = Screen('Flip', window1);
- Onset_retrocue = startTime-ExpStart; %Onset
- press_trigger(trigger_retrocue,TB,triggers_on);
- press_eyelink_trigger(trigger_retrocue,eyetracking)
-
- % % % % Show retro cue (visual)
- % % %
- % % % % Screen('Flip', window1, tFixation + (fixationDuration + rand(1))- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
- % % % %
- % % % %
- % % % % Screen('TextSize',window1,60);
- % % % % DrawFormattedText(window1, num2str(cue), 'center', 'center', [255 255 255]);
- % % % %
- % % % % startTimePing = Screen('Flip',window1)-ExpStart; % first screen time
-
- % Presenting retro cue with audio
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle,(audcue{cue})');
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
-
- % WaitSecs(audiogap)
-
- %% Presenting task cue (sounds)
-
- % if type_of_task==1
- % taskmessage='photo'
- % audio=aud1;
- % else
- % taskmessage='rotation'
- % audio=aud2;
- %
- % end
- % % Screen priority
- % Priority(MaxPriority(window1));
- % Priority(2);
- %
- % % Show fixation cross
- % Screen(window1, 'FillRect', backgroundColor);
- % drawDot(window1,W,H,barColor);
- % startTime = Screen('Flip', window1);
- % press_trigger(trigger_taskcue,TB,triggers_on);
- % press_eyelink_trigger(trigger_taskcue,eyetracking)
- %
- % % % %
- % % % % Screen('Flip', window1, tFixation + (fixationDuration + rand(1))- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
- % % % % Screen(window1, 'FillRect', backgroundColor);
- % % %
- % % % % % Show task cue (visual
- % % %
- % % % % Screen('TextSize',window1,60);
- % % % % DrawFormattedText(window1, taskmessage, 'center', 'center', [255 255 255]);
- % % % %
- % % % % startTimePing = Screen('Flip',window1)-ExpStart; % first screen time
- %
- % % Presenting task cue with audio
- %
- % % PLAY SOUND (here trig is a sound signal)
- % % 1) fill the buffer
- % PsychPortAudio('FillBuffer', pahandle,(audtaskcue{type_of_task})');
- % % 2) play it
- % PsychPortAudio('Start', pahandle, repetitions, startCue);
- %
- % % 3) Stop when it's done playing
- % PsychPortAudio('Stop', pahandle,1);
- %
- % Onset_taskcue = startTime-ExpStart; %Onset
- %
- %% Showing the Pings (if the option is on)
-
- if pingsareon % Draw the pings if the variable pingsareon is 1
-
- for pings=1:size(oddpingpos,2) %How many pings
-
-
- %In this example the oddball will be a different color for the
- %text
-
- if oddpingpos(pings)==1
- rectColor_s=rectColor_odd;
- trigger_ping_selected=trigger_odd_ping
- else
- rectColor_s=rectColor;
- trigger_ping_selected=trigger_ping
- end
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- %Duration of fix cross is based on "pausvec"
-
- Screen('Flip', window1, tFixation + (pausvec(pings)/1000)- slack,0) %Adding time to the minimum for the fixation duration
-
- Screen('FillOval', window1, rectColor_s{1}, centeredRect1, maxDiameter1);
- Screen('FillOval', window1, rectColor_s{2}, centeredRect2, maxDiameter2);
- Screen('FillOval', window1, rectColor_s{3}, centeredRect3, maxDiameter3);
- Screen('FillOval', window1, rectColor_s{4}, centeredRect4, maxDiameter4);
- Screen('FillOval', window1, rectColor_s{5}, centeredRect5, maxDiameter5);
-
- drawDot(window1,W,H,barColor); %Fixcross on top
-
- pingfixated(pings)=0; %eye centered
- if eyetracking==1 % Before 'Flip' check whether the eyes are well fixated to change the trigger id
- pingfixated(pings) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if pingfixated(pings)
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- end
-
- end
-
- % Flip to the screen
- startTime = Screen('Flip', window1);
-
-
- tdel=press_trigger(trigger_ping_selected,TB,triggers_on);
- press_eyelink_trigger(trigger_ping_selected,eyetracking)
- Onset_ping(pings) = startTime-ExpStart;
- startout=[];
-
- while GetSecs - startTime < ((pilth/1000)-tdel - slack)
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
-
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- pingfixated(pings)=1;
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- startTimeFiXM =Screen('Flip', window1)
-
- end
-
- end
-
- end
-
- end
-
-
- else %if PINGS are off
-
- startout=[];
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor);
- startTimeA = Screen('Flip', window1);
-
- while GetSecs - startTimeA < ((delth/1000)-(pausvec(end)/1000)- slack) % During the time of the delay period
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- pingfixated(1)=1;
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- startTimeFiXM =Screen('Flip', window1)
-
- end
-
- end
-
- end
-
-
- end
- %% Showing OBJECTs for Memory test (Discrete/perceptual task)
-
- if type_of_task==1
-
- acc_trial_concrete=NaN;
- OnsetResp=0;
- rt_resp_concrete = 0;
- resp_text = 0;
- resp = 'No_Response'; %Just in case we don't have response
- rotationAngle_test=object_test_rot;
- finalrot_concrete=NaN;
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (pausvec(end)/1000)- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
-
- % Show Object
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test);
- startTime_test = Screen('Flip', window1); % Start of trial
- press_trigger(trigger_object_concrete,TB,triggers_on);
- press_eyelink_trigger(trigger_object_concrete,eyetracking)
- Onset_object_pt = startTime-ExpStart; %Onset
- Onset_test = startTime_test-ExpStart; %Onset
- responsetimeout=0;
-
- stop=1;
-
-
- while stop % GetSecs - startTime < objectTimeout
-
- [keyIsDown,secs,keyCode] = KbCheck;
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
-
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
- respTime = GetSecs;
- pressedKeys = find(keyCode);
-
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 2:3
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp = responseKeys{i};
- rt_resp_concrete= respTime - startTime_test;
- OnsetResp = GetSecs - ExpStart;
-
- if keyCode(KbName('RightArrow')) == 1
- press_trigger(trigger_right_key,TB,triggers_on);
- press_eyelink_trigger(trigger_right_key,eyetracking)
- elseif keyCode(KbName('LeftArrow')) == 1
- press_trigger(trigger_left_key,TB,triggers_on);
- press_eyelink_trigger(trigger_left_key,eyetracking)
- end
-
- break
-
- end
- end
- end
-
- if rt_resp_concrete > 0
- stop=0;
- break
- elseif (GetSecs - startTime_test > concreteTimeout - slack)
- stop=0;
- responsetimeout=1;
- end
- end
-
- % Showing the move
-
- if keyCode(KbName('RightArrow')) == 1
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test+distrot/contestdif);
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_pt = startTime-ExpStart; %Onset
-
- finalrot_concrete=rotationAngle_test+distrot/contestdif;
-
- end
-
- if keyCode(KbName('LeftArrow')) == 1
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test-distrot/contestdif);
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_pt = startTime-ExpStart; %Onset
-
- finalrot_concrete=rotationAngle_test-distrot/contestdif;
-
- end
-
- WaitSecs(fbrespcon)
-
-
- %% Feedback Concrete using images
-
- %Obtaining right answer
-
- if responsetimeout
- fb_message= (['Try to respond faster'])
- acc_trial_concrete=2;
- textColor_fb=[255 0 0]
-
- else
- degdiff=angdiff(deg2rad(object_cue_rot),deg2rad(object_test_rot)); % angular difference
- degdiff=rad2deg(degdiff)
- if degdiff<0
- corr_r='R'
- else
- corr_r='L'
- end
-
- %Preparing FB message
- if resp(1)==corr_r
- fb_message = 'correct'
- accuracy_con=[accuracy_con 1];
- acc_trial_concrete=1;
- objectDisplay_fb=objectDisplay_test_green;
- textColor_fb=[0 255 100]
-
- else
- fb_message = 'incorrect'
- accuracy_con=[accuracy_con 0];
- acc_trial_concrete=0;
- objectDisplay_fb=objectDisplay_test_red;
- textColor_fb=[255 0 0]
-
-
- end
-
- end
-
- Screen('TextSize',window1,20);
- DrawFormattedText(window1, fb_message, 'center', (H/4.5), textColor_fb);
- Screen('DrawTexture', window1, objectDisplay_test,[], pos_ot,object_cue_rot,1,0.9);
- startTime=Screen('Flip', window1); % Start of feedback
- Onset_feedback = startTime-ExpStart; %Onset
- press_trigger(trigger_feedback,TB,triggers_on);
- press_eyelink_trigger(trigger_feedback,eyetracking)
-
- WaitSecs(fbtimeoutcon- slack)
- end
-
- %% Showing OBJECTs for Memory test (Abstract task)
-
- if type_of_task==2
-
- OnsetResp=0;
- rt_resp_abstract = 0;
- rt_resp_abstract_ini = [];
- resp_text = 0;
- resp_catch = 'No_Response'; %Just in case we don't have response
- rotationAngle_test=object_test_rot;
- Onset_movl=0;
- rotFac=1;
- responsetimeout=0;
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + ( pausvec(end)/1000)- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
-
- % Show Object
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, ['Press <- or -> to ROTATE; press ' keytoaccepabs ' to accept '], 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test);
- startTime_test = Screen('Flip', window1); % Start of trial
- press_trigger(trigger_object_abstract,TB,triggers_on);
- press_eyelink_trigger(trigger_object_abstract,eyetracking)
- Onset_object_pt = startTime_test-ExpStart; %Onset
- Onset_test = startTime_test-ExpStart; %Onset
-
- stop=1;
- while stop % GetSecs - startTime < objectTimeout
- [keyIsDown,secs,keyCode] = KbCheck;
-
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
-
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- return;
- end
-
- pressedKeys = find(keyCode);
-
- if keyCode(KbName('RightArrow')) == 1
-
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, ['Press <- or -> to ROTATE; press ' keytoaccepabs ' to accept '], 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test+rotSensi*rotFac);
- startTime=Screen('Flip', window1); % Moving
-
- Onset_movn = startTime-ExpStart; %Onset
- ddd=Onset_movn-Onset_movl;
- if ddd<keypul
- rotFac= rotFac+keyacce;
- else
- rotFac=1
- end
- Onset_movl=Onset_movn;
-
- rotationAngle_test=rotationAngle_test+(rotSensi*rotFac)
-
- if isempty(rt_resp_abstract_ini) %saving time a key was pressed first time
- rt_resp_abstract_ini= startTime-ExpStart;
- press_trigger(trigger_right_key,TB,triggers_on);
- press_eyelink_trigger(trigger_right_key,eyetracking)
- end
-
- end
-
- if keyCode(KbName('LeftArrow')) == 1
-
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, ['Press <- or -> to ROTATE; press ' keytoaccepabs ' to accept '], 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test-rotSensi*rotFac);
- startTime=Screen('Flip', window1); % Moving
-
- Onset_movn = startTime-ExpStart; %Onset
- ddd=Onset_movn-Onset_movl;
- if ddd<keypul
- rotFac= rotFac+keyacce;
- else
- rotFac=1
- end
- Onset_movl=Onset_movn;
-
- rotationAngle_test=rotationAngle_test-(rotSensi*rotFac)
-
- if isempty(rt_resp_abstract_ini) %saving time a key was pressed first time
- rt_resp_abstract_ini= startTime-ExpStart;
- press_trigger(trigger_left_key,TB,triggers_on);
- press_eyelink_trigger(trigger_left_key,eyetracking)
-
- end
-
- end
-
- if keyCode(KbName(keytoaccepabs)) == 1
-
- press_trigger(trigger_up_key,TB,triggers_on);
- press_eyelink_trigger(trigger_up_key,eyetracking)
- rt_resp_abstract = GetSecs - startTime_test;
- stop=0;
- elseif (GetSecs - startTime_test > abstractTimeout)
- rt_resp_abstract=0;
- stop=0;
- responsetimeout=1;
- end
-
- end
- end
-
- WaitSecs(fbrespabs- slack)
-
- %% Giving feedback (B updated to circular) (Continuous task)
-
- if type_of_task==2
-
- degdiff=angdiff(deg2rad(rotationAngle_test),deg2rad(object_cue_rot)); % angular difference
- degdiff=rad2deg(degdiff); % back to degrees
- mes_catch=(['Difference in degrees = ' num2str(round(abs(degdiff)))])
- fb=1;
-
- if fb==1 % percentage correct
- perc=abs(degdiff);
- perc=1-abs(degdiff)/180;
- perc=round(1000*perc)/10;
- mes_catch= (['Accuracy score: ' num2str(perc) ' %' ])
- textColor_fb=[255 255 255]
- acc_trial_abstract=(perc)
- end
-
- if responsetimeout
- mes_catch= (['Try to respond faster'])
- textColor_fb=[255 0 0]
- acc_trial_abstract=NaN
- end
- %To give averall feedback about performance in a block
- accuracy_abs=[accuracy_abs perc];
-
- % % % % Show fixation cross
- % % %
- % % % drawDot(window1,W,H,barColor);
- % % % tFixation = Screen('Flip', window1);
- % % %
- % % % % Show fixation cross
- % % % Screen(window1, 'FillRect', backgroundColor);
- % % % Screen('Flip', window1, tFixation + (fixationDuration + rand(1))- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
- % % %
- % Show Feedback Screen
-
- % % % DrawFormattedText(window1, mes_catch, 'center', 'center', textColor);
- % % %
- % % % startTime = Screen('Flip', window1);
- % % % Onset_feedback = startTime-ExpStart; %Onset
- % % %
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, mes_catch, 'center', (H/4.5), textColor_fb);
- Screen('DrawTexture', window1, objectDisplay_test, [], pos_ot,rotationAngle_test);
- startTime=Screen('Flip', window1); % Start of feedback
-
- press_trigger(trigger_feedback,TB,triggers_on);
- press_eyelink_trigger(trigger_feedback,eyetracking)
- Onset_feedback = startTime-ExpStart; %Onset
-
- WaitSecs(fbtimeoutabs- slack)
-
- end
-
-
-
- %% At the end of the cued item test, we will either:
-
- % (i) present an "Thank you" audio, to finish the trial
- % (ii) cue the uncued item
- if testinguncued
- second_aud=(audcue{uncue})';
- trigger_ready_2=trigger_retrocue_2; % If we test the uncued, the trigger will be retrocued_2
- else
- second_aud=(audthanks{1})';
- trigger_ready_2= trigger_thanks; % If we DO NOT test the uncued, the trigger will be trigger_thanks (thanks messages after testing the cued item)
- end
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- startTime = Screen('Flip', window1);
- Onset_retrocue_2 = startTime-ExpStart; %Onset
- press_trigger(trigger_ready_2,TB,triggers_on);
- press_eyelink_trigger(trigger_ready_2,eyetracking)
-
- % WaitSecs(fbaudiogap)
-
-
- % Presenting retro cue with audio
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle,second_aud);
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
-
-
-
- %% If there is a TEST for the UNCUED item
-
-
- if testinguncued
-
- %% Showing the Pings
-
- if pingsareon %If PINGS are ON
-
- for pings=1:size(oddpingpos_2,2) %How many pings
-
-
- %In this example the oddball will be a different color for the
- %text
-
- if oddpingpos_2(pings)==1
- rectColor_s=rectColor_odd;
- trigger_ping_selected=trigger_odd_ping_2
- else
- rectColor_s=rectColor;
- trigger_ping_selected=trigger_ping_2
- end
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- %Duration of fix cross is based on "pausvec"
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (pausvec_2(pings)/1000)- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
-
-
- Screen('FillOval', window1, rectColor_s{1}, centeredRect1, maxDiameter1);
- Screen('FillOval', window1, rectColor_s{2}, centeredRect2, maxDiameter2);
- Screen('FillOval', window1, rectColor_s{3}, centeredRect3, maxDiameter3);
- Screen('FillOval', window1, rectColor_s{4}, centeredRect4, maxDiameter4);
- Screen('FillOval', window1, rectColor_s{5}, centeredRect5, maxDiameter5);
-
- drawDot(window1,W,H,barColor); %Fixcross on top
-
-
-
-
- pingfixated_2(pings)=0; %eye centered
- if eyetracking==1 % Before 'Flip' check whether the eyes are well fixated to change the trigger id
-
- pingfixated_2(pings) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
-
-
- if pingfixated_2(pings)
-
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- end
- end
-
- % Flip to the screen
- startTime = Screen('Flip', window1);
-
- tdel=press_trigger(trigger_ping_selected,TB,triggers_on);
- press_eyelink_trigger(trigger_ping_selected,eyetracking)
- Onset_ping_2(pings) = startTime-ExpStart;
- startout=[];
-
- while GetSecs - startTime < ((pilth/1000)-tdel- slack)
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
-
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- pingfixated_2(pings)=1;
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- startTimeFiXM =Screen('Flip', window1)
-
- end
-
- end
- end
-
-
- end
-
- else %If PINGS are off
-
- startout=[];
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- Screen(window1, 'FillRect', backgroundColor);
- drawDot(window1,W,H,barColor);
- startTimeA = Screen('Flip', window1);
-
- while GetSecs - startTimeA < ((delth_2/1000)-(pausvec_2(end)/1000)- slack) % During the time of the delay period
-
-
- if eyetracking==1
-
- nnf(1) = gazeoff(W,H,fixtrh,gazeofftimelim,0);
- if nnf(1)==0
- continue
-
- end
-
- startout=[startout GetSecs];
-
- if startout(end)-startout(1)>gazeofftimelim %pingfixated(1) %Eyes not fixated!
- pingfixated_2(1)=1;
- Screen('TextSize',window1,40);
- DrawFormattedText(window1, 'FIXATE!', 'center', 'center', [200 0 0]);
- startTimeFiXM =Screen('Flip', window1)
-
- end
-
- end
-
-
- end
- end
- %%
-
- if type_of_task==1
-
- acc_trial_concrete_uncued=NaN;
- OnsetResp_uncued=0;
- rt_resp_concrete_uncued = 0;
- resp_text_uncued = 0;
- resp_uncued = 'No_Response'; %Just in case we don't have response
- rotationAngle_test=object_test_rot_uncued;
- finalrot_concrete_uncued=NaN;
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (pausvec_2(end)/1000)- slack,0) %Adding between 0 and 1 second randomly to the minimum for the fixation duration
-
- % Show Object
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test_uncued, [], pos_ot,rotationAngle_test);
- startTime_test = Screen('Flip', window1); % Start of trial
- press_trigger(trigger_object_concrete_uncued,TB,triggers_on);
- press_eyelink_trigger(trigger_object_concrete_uncued,eyetracking)
- Onset_object_pt_uncued = startTime-ExpStart; %Onset
- Onset_test_uncued = startTime_test-ExpStart; %Onset
- responsetimeout=0;
-
- stop=1;
-
-
- while stop % GetSecs - startTime < objectTimeout
-
- [keyIsDown,secs,keyCode] = KbCheck;
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
-
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
- respTime = GetSecs;
- pressedKeys = find(keyCode);
-
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 2:3
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp_uncued = responseKeys{i};
- rt_resp_concrete_uncued= respTime - startTime_test;
- OnsetResp_uncued = GetSecs - ExpStart;
-
- if keyCode(KbName('RightArrow')) == 1
- press_trigger(trigger_right_key,TB,triggers_on);
- press_eyelink_trigger(trigger_right_key,eyetracking)
- elseif keyCode(KbName('LeftArrow')) == 1
- press_trigger(trigger_left_key,TB,triggers_on);
- press_eyelink_trigger(trigger_left_key,eyetracking)
- end
-
- break
-
- end
- end
- end
-
- if rt_resp_concrete_uncued > 0
- stop=0;
- break
- elseif (GetSecs - startTime_test > concreteTimeout- slack)
- stop=0;
- responsetimeout=1;
- end
- end
-
- % Showing the move
-
- if keyCode(KbName('RightArrow')) == 1
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test_uncued, [], pos_ot,rotationAngle_test+distrot/contestdif);
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_pt = startTime-ExpStart; %Onset
-
- finalrot_concrete_uncued=rotationAngle_test+distrot/contestdif;
-
- end
-
- if keyCode(KbName('LeftArrow')) == 1
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, 'Press <- or -> to CHOOSE the right direction', 'center', (H/4.5), textColor);
- Screen('DrawTexture', window1, objectDisplay_test_uncued, [], pos_ot,rotationAngle_test-distrot/contestdif);
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_pt = startTime-ExpStart; %Onset
-
- finalrot_concrete_uncued=rotationAngle_test-distrot/contestdif;
-
- end
-
- WaitSecs(fbrespcon- slack)
-
-
- %% Feedback Concrete using images
-
- %Obtaining right answer
-
- if responsetimeout
- fb_message= (['Try to respond faster'])
- acc_trial_concrete_uncued=2;
- textColor_fb=[255 0 0]
-
- else
- degdiff=angdiff(deg2rad(object_uncued_rot),deg2rad(object_test_rot_uncued)); % angular difference
- degdiff=rad2deg(degdiff)
- if degdiff<0
- corr_r='R'
- else
- corr_r='L'
- end
-
- %Preparing FB message
- if resp_uncued(1)==corr_r
- fb_message = 'correct'
- accuracy_con=[accuracy_con 1];
- acc_trial_concrete_uncued=1;
- objectDisplay_fb=objectDisplay_test_green;
- textColor_fb=[0 255 100]
-
- else
- fb_message = 'incorrect'
- accuracy_con=[accuracy_con 0];
- acc_trial_concrete_uncued=0;
- objectDisplay_fb=objectDisplay_test_red;
- textColor_fb=[255 0 0]
-
-
- end
-
- end
-
- Screen('TextSize',window1,20);
- DrawFormattedText(window1, fb_message, 'center', (H/4.5), textColor_fb);
- Screen('DrawTexture', window1, objectDisplay_test_uncued,[], pos_ot,object_uncued_rot,1,0.9);
- startTime=Screen('Flip', window1); % Start of feedback
- Onset_feedback_uncued = startTime-ExpStart; %Onset
- press_trigger(trigger_feedback_uncued,TB,triggers_on);
- press_eyelink_trigger(trigger_feedback_uncued,eyetracking)
-
- WaitSecs(fbtimeoutcon- slack)
-
- %% At the end of trial we present an "Thank you" audio, to finish the trial
-
- second_aud=(audthanks{1})';
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawDot(window1,W,H,barColor);
- startTime = Screen('Flip', window1);
- Onset_thanks_uncued = startTime-ExpStart; %Onset
- press_trigger(trigger_thanks_2,TB,triggers_on);
- press_eyelink_trigger(trigger_thanks_2,eyetracking)
-
- WaitSecs(fbaudiogap)
- % Presenting retro cue with audio
- % PLAY SOUND (here trig is a sound signal)
- % 1) fill the buffer
- PsychPortAudio('FillBuffer', pahandle, second_aud);
- % 2) play it
- PsychPortAudio('Start', pahandle, repetitions, startCue);
- % 3) Stop when it's done playing
- PsychPortAudio('Stop', pahandle,1);
- end
-
- end
- %% Updating outputfile
-
- %Info to include (related to trial)
-
- pingsareon; %Ping on/off
- block;
- testinguncued;
-
- object_1_id;
- object_2_id;
-
- file_object_1; %name of the file
- file_object_2;
- object_1_rot;
- object_2_rot;
-
- object_1_fixated;
- object_2_fixated;
-
- cue;
- uncue;
-
- object_cue_id;
- object_cue_rot;
-
- object_uncued_id;
- object_uncued_rot;
-
- type_of_task=sequence(trial,7); %1=concrete and 2=abstract
-
- total_of_pings= length(oddpingpos); %sequence of pings (1== oddball)
- position_odd_pings= find(oddpingpos==1);
- pingfixated;
- object_test_id;
- object_test_rot;
-
- total_of_pings_2= length(oddpingpos_2); %sequence of pings (1== oddball)
- position_odd_pings_2= find(oddpingpos_2==1);
- pingfixated_2;
-
- object_test_id_uncued;
- object_test_rot_uncued;
-
- %Info to include (related to partipants' response)
- if type_of_task==2
- trigger_object_concrete=NaN;
- rt_resp_concrete =NaN;
- acc_trial_concrete =NaN; %0== Incorrect, 1== Correct; 2== No response/too slow)
- finalrot_concrete =NaN;% final rotation for concrete task
- elseif type_of_task==1
- trigger_object_abstract=NaN;
- rt_resp_abstract_ini=NaN
- rt_resp_abstract =NaN;
- acc_trial_abstract =NaN; % Percentage; NaN == No response/too slow)
- rotationAngle_test =NaN; % final rotation for abstract task
- end
-
- if testinguncued ==0
-
- resp_uncued = NaN;
- trigger_object_concrete_uncued = NaN;
- rt_resp_concrete_uncued = NaN;
- acc_trial_concrete_uncued = NaN; %0== Incorrect, 1== Correct; 2== No response/too slow)
- finalrot_concrete_uncued = NaN;% final rotation for concrete task
-
- Onset_test_uncued= NaN;
- OnsetResp_uncued = NaN;
- Onset_feedback_uncued=NaN;
- Onset_thanks_uncued = NaN;
-
- end
-
- % Time Onsets - A temporal list
-
- Onset_object_1; %Object 1
- Onset_object_2;%Object 2
- Onset_retrocue;%Retro cue
- Onset_taskcue=NaN;%Task cue. Nothing here in this task.
- Onset_ping; %List the ping onset
- Onset_test;%Test on screen
- OnsetResp; %Response onset for the cued test
- Onset_feedback;%Feedback
- Onset_retrocue_2; % Important: this can be retrocue for uncued or a thank message
- Onset_ping_2; %List the ping onset (second delay)
- Onset_test_uncued; %Test for the uncued on screen (only if tested)
- OnsetResp_uncued; %Response onset for the uncued test (only if tested)
- Onset_feedback_uncued; %FB for the uncued on screen (only if tested)
- Onset_thanks_uncued;
- % For the bonus system
- if maxiblock==4
- bon_acc_concrete(trial)=acc_trial_concrete;
- bon_acc_abstract(trial)=acc_trial_abstract;
- end
- % Save the null trials for a
- if nansum([pingfixated(:); pingfixated_2(:); object_1_fixated; object_2_fixated])>0&&repnonfixtrial
- if practice==0
- sequencenull=[sequencenull; sequence(trial,:)]
- if size(sequencenull,1)>48
- % fixtrh=35;
- end
- end
- end
- if maxiblock==5
- blocknulrep=1;
- else
- blocknulrep=0;
- end
- %% Saving data to outputfile
-
- % Set up the output file (this output is for info related with the
- % presention of room-object association and word tasks)
- % 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_cue_id\t object_cue_rot\t type_of_task\t type_of_ings\t position_odd_pings\t object_test_name\t object_test_id\t object_test_rot\t rt_resp_concrete\t acc_trial_concrete\t final_rot_concrete\t rt_resp_abstract_first_key\t rt_resp_abstract\t acc_trial_abstract\t final_rot_abstract\t onset_object_1\t onset_object_2\t onset_retrocue\t onset_taskcue\t onset_test\t onset_feedback\t onset_ping_1\t onset_ping_2\t onset_ping_3\t onset_ping_4\t onset_ping_5\t onset_ping_6\t onset_ping_7\t onset_ping_8\t onset_ping_9\t onset_ping_10\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\n');
- if pingsareon %if we are using pings the outputfile will be more detailed
- % Save results to file
- fprintf(outputfile, '%s\t %s\t %s\t %s\t %d\t %d\t %d\t %s\t %d\t %d\t %s\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %s\t %d\t %d\t %s\t %d\t %d\t %f\t %d\t %f\t %f\t %d\t %f\t %d\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\n',...
- taskversion, today, subID, gender, age, block, trial, file_object_1, object_1_id, object_1_rot, file_object_2, object_2_id , object_2_rot, cue, object_cue_id, object_cue_rot, uncue, object_uncued_id, object_uncued_rot, type_of_task, total_of_pings, position_odd_pings, total_of_pings_2, position_odd_pings_2, pingsareon, file_object_t, object_test_id, object_test_rot, file_object_t_uncued, object_test_id_uncued, object_test_rot_uncued, rt_resp_concrete, acc_trial_concrete, finalrot_concrete, rt_resp_concrete_uncued, acc_trial_concrete_uncued, finalrot_concrete_uncued, testinguncued, Onset_object_1, Onset_object_2, Onset_retrocue, Onset_taskcue, Onset_test, OnsetResp, Onset_feedback, Onset_retrocue_2, Onset_test_uncued,OnsetResp_uncued, Onset_feedback_uncued,Onset_thanks_uncued, Onset_ping(1), Onset_ping(2), Onset_ping(3), Onset_ping(4), Onset_ping(5), Onset_ping_2(1), Onset_ping_2(2), Onset_ping_2(3), Onset_ping_2(4),Onset_ping_2(5), trigger_object_1, trigger_object_2, trigger_retrocue, trigger_taskcue, trigger_object_concrete, trigger_object_abstract, pingcolorset, practice, righthanded, pingfixated(1),pingfixated(2),pingfixated(3), pingfixated(4), pingfixated_2(1), pingfixated_2(2), pingfixated_2(3),pingfixated_2(4), object_1_fixated, object_2_fixated,blocknulrep, fixtrh);
- else
- % Save results to file
- fprintf(outputfile, '%s\t %s\t %s\t %s\t %d\t %d\t %d\t %s\t %d\t %d\t %s\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %s\t %d\t %d\t %s\t %d\t %d\t %f\t %d\t %f\t %f\t %d\t %f\t %d\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\n',...
- taskversion, today, subID, gender, age, block, trial, file_object_1, object_1_id, object_1_rot, file_object_2, object_2_id , object_2_rot, cue, object_cue_id, object_cue_rot, uncue, object_uncued_id, object_uncued_rot, type_of_task, pingsareon, file_object_t, object_test_id, object_test_rot, file_object_t_uncued, object_test_id_uncued, object_test_rot_uncued, rt_resp_concrete, acc_trial_concrete, finalrot_concrete, rt_resp_concrete_uncued, acc_trial_concrete_uncued, finalrot_concrete_uncued, testinguncued, Onset_object_1, Onset_object_2, Onset_retrocue, Onset_taskcue, Onset_test, OnsetResp, Onset_feedback, Onset_retrocue_2, Onset_test_uncued,OnsetResp_uncued, Onset_feedback_uncued,Onset_thanks_uncued, trigger_object_1, trigger_object_2, trigger_retrocue, trigger_taskcue, trigger_object_concrete, trigger_object_abstract, practice, righthanded, pingfixated(1), pingfixated_2(1), object_1_fixated, object_2_fixated,blocknulrep, fixtrh);
- end
-
-
- %%
- %
- % p1_name = stimuli_info.Item_Name(sequence_of_n_back(t,1),:);
- %
- % % Save results to file
- % fprintf(outputfile,'%s\t %s\t %d\t %f\t %f\n' ,...
- % today, p1_name, rt_catch, Onset_object_p1,OnsetResp);
- %
- % fprintf(outputfile, 'date\t object_name\t rt_resp_concreteonse\t Onset_object\t Onset_response\n');
-
- %% Interblock MESSAGE
-
- if block~=next_trial_block
-
- ddo=block/nblocks
- baseRect = [0 0 W/4 W/32];
- baseRect_done = [0 0 (W/4)*ddo W/32];
- rectColorBase = [100 100 100];
- rectColor_done = [0 200 10];
- centeredRect = CenterRectOnPointd(baseRect, xCenter, yCenter);
- centeredRect_done = centeredRect;
- trd=centeredRect(1)+((centeredRect(3)-centeredRect(1))*ddo);
- centeredRect_done(3)=trd;
- % Draw the square to the screen. For information on the command used in
- % this line see Screen FillRect?
- Screen('FillRect', window1, rectColorBase, centeredRect);
- Screen('FillRect', window1, rectColor_done, centeredRect_done);
- Screen('TextSize',window1,18);
- msg=['Great! You finished the ',num2str(ddo*100),' % of the task'];
- DrawFormattedText(window1, msg, 'center', (H/2.5), textColor);
- DrawFormattedText(window1, ['Accuracy: ' num2str(mean(accuracy_con)*100)], 'center', (H/4.5), textColor);
- DrawFormattedText(window1, '[Press the space bar to continue]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- elseif keyCode(KbName('Q'))==1
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- end
-
- end
- % Counter for interblock message accuracy
- accuracy_con= [];
- accuracy_abs= [];
-
- end
- end
- end
- %%
- %% FINAL MESSAGE
- if practice
- msg=['Great! You finished the practice blocks'];
- else
- msg=['Great! You finished ',num2str(block),' of ', num2str(nblocks), ' blocks'];
- end
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, msg, 'center', (H/4.5), textColor);
- DrawFormattedText(window1, '[Press the space bar to continue]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- end
- end
- %% BONUS
- if practice==0
-
- msg= ['We will take 5 random trials of each task (new/same object).'];
- msg2= ['If your accuracy is >= 60% you will get a bonus payment.']
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, msg, 'center', (H/4.5), textColor);
- DrawFormattedText(window1, msg2, 'center', 'center', textColor);
-
- DrawFormattedText(window1, '[Press the space bar to continue]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
-
- WaitSecs(1);
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- end
- end
-
- WaitSecs(2);
-
- toi=~isnan(bon_acc_concrete);
- bonnac=bon_acc_concrete(toi);
- gg=randperm(length(bonnac));
- bonusfinconcrete=mean(bonnac(gg(1:5))==1);
-
- % toi=~isnan(bon_acc_abstract);
- % bonnac=bon_acc_abstract(toi);
- % gg=randperm(length(bonnac));
- % bonusfinabstract=mean(bonnac(gg(1:5)));
-
- msg= ['Accuracy: ' num2str(bonusfinconcrete*100) ' %'];
-
-
- if bonusfinconcrete>=.60%&bonusfinabstract>=80
- msg2=['Congrats! You got the bonus payment'];
- else
- msg2=['Unfortunately you did not get the bonus payment"'];
- end
-
- Screen('TextSize',window1,18);
- DrawFormattedText(window1, msg, 'center', (H/4.5), textColor);
- DrawFormattedText(window1, msg2, 'center', 'center', textColor);
-
- DrawFormattedText(window1, '[Press the space bar to finish]', 'center', (H/1.5), textColor);
- overviewTime = Screen('Flip',window1)-ExpStart; % first screen time
- Screen('TextSize',window1,40);
-
- % Wait for subject to press spacebar
- while 1
- [keyIsDown,secs,keyCode] = KbCheck;
- if keyCode(KbName('space'))==1
- break
- end
- end
- end
- WaitSecs(1);
- %% END
- endexperiment(window1,pahandle,outputfile,triggers_on,TB,trigger_beginning_end,eyetracking,edfFile)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Subfunctions
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% End the experiment
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function endexperiment(window1,pahandle,outputfile, triggers_on,TB,ti,eyetracking,edfFile)
-
- if triggers_on
-
- % ti is the trigger id
- % Set the port to zero state 0
- IOPort('Write', TB, uint8(0),0);
- WaitSecs(0.005)
- % Set Bit 0 (Pin 2 of the Output(to Amp)
- IOPort('Write', TB, uint8(ti),0);
- % Wait 2ms and reset the port to zero state
- WaitSecs(0.005)
- IOPort('Write', TB, uint8(0),0);
- WaitSecs(0.005)
-
-
- % Then disconnect/close the serial port object from the serial port
- IOPort('Close', TB);
- end
-
-
- if eyetracking==1
-
- % mark zero-plot time in data file
- mel=num2str(ti)
- Eyelink('Message', mel);
-
-
- % STEP 8
- % finish up: stop recording eye-movements,
- % close graphics window, close data file and shut down tracker
- Eyelink('StopRecording');
- Eyelink('CloseFile');
- Eyelink('ReceiveFile',edfFile, ['data_eyelink/' edfFile])
- Eyelink('Shutdown');
-
- end
-
- % Close audio settings (pahandle)
- PsychPortAudio('Close', pahandle);
- RestrictKeysForKbCheck([]);
- fclose(outputfile);
- Screen(window1,'Close');
- close all
- sca;
- return
- end
-
- %% Detecting a that gaze is non-centered
-
- function [isoff]= gazeoff(W,H,fixtrh,gazeofftimelim,wentout)
- isoff=0;
- if Eyelink( 'NewFloatSampleAvailable') > 0
- evt = Eyelink( 'NewestFloatSample');
-
- if abs(round(evt.gx(1))-(W/2))>fixtrh|abs(round(evt.gy(1))-(H/2))>fixtrh %Eyes NOT fixated!
- startout=GetSecs;
- wentout=1;
- isoff=1; %eye not centered
- return
- end
- end
- end
- %% Detecting a that gaze is centered
- function [isin]= gazein(W,H,fixtrh,gazeofftimelim,wentout)
- isin=0;
- if Eyelink( 'NewFloatSampleAvailable') > 0
- evt = Eyelink( 'NewestFloatSample');
-
- if abs(round(evt.gx(1))-(W/2))<= fixtrh|abs(round(evt.gy(1))-(H/2))<= fixtrh %Eyes NOT fixated!
- isin=1; %eye centered
- return
- end
-
- end
- end
-
- %% Draw a fixation cross (overlapping horizontal and vertical bar)
- function drawCross(window,W,H,barColor)
- if nargin==3
- barColor = [0 0 0];
- end
- barLength = 16; % in pixels
- barWidth = 2; % in pixels
- %0.5; % number from 0 (black) to 1 (white)
- Screen('FillRect', window, barColor,[ (W-barLength)/2 (H-barWidth)/2 (W+barLength)/2 (H+barWidth)/2]);
- Screen('FillRect', window, barColor,[ (W-barWidth)/2 (H-barLength)/2 (W+barWidth)/2 (H+barLength)/2]);
- end
- %% Draw a fixation DOT (overlapping horizontal and vertical bar)
- function drawDot(window,W,H,barColor)
- if nargin==3
- barColor = [0 0 0];
- end
- barLength = 8; % in pixels
- barWidth = 8; % in pixels
- %0.5; % number from 0 (black) to 1 (white)
- Screen('FillOval', window, barColor, [(W-barLength)/2 (H-barWidth)/2 (W+barLength)/2 (H+barWidth)/2]);
- end
- % Screen(???DrawDots???, windowPtr, xy [,size] [,color] [,center] [,dot_type][, lenient]);
- %% Doing the timing job for delay between encoding (last item) and test
- function pausvec=pingT(npings,nodd,delth,pilth,minipi,maxsend,minstart)
- pausvec=NaN(1,npings+1);
- pausvec(1)=randsample(minstart:maxsend,1); % pause before first ping (<minipi) % JLD edited
- pausvec(end)=randsample(minipi+pilth:maxsend,1); % pause after last ping (>pilth, <minipi) % JLD edited
- for p=2:npings-1
- tleft=delth-nansum(pausvec); % time left
- pleft=npings-p; % #pings left
- maxipi=tleft-pleft*minipi; % max inter-ping-interval
- pausvec(p)=randsample(minipi:maxipi,1); % pseudo-random pause length
- end
- pausvec(end-1)=delth-nansum(pausvec);% allocate remaining time left
- % shorten post-ping time by ping lenghts (already done for last one)
- pausvec(2:end)=pausvec(2:end)-pilth;
- % do another permute to be sure:
- pausvec=pausvec([1 randperm(npings-1)+1 npings+1]);
- if sum(pausvec)~=delth-pilth*npings
- error('ping time assignment error')
- end
- end
- %% Trigger functions
- function tdel=press_trigger(ti,TB,triggers_on)
- c=tic;
- if triggers_on
- % ti is the trigger id
- % Set the port to zero state 0
- IOPort('Write', TB, uint8(0),0);
- WaitSecs(0.005)
- % Set Bit 0 (Pin 2 of the Output(to Amp)
- IOPort('Write', TB, uint8(ti),0);
- % Wait 2ms and reset the port to zero state
- WaitSecs(0.005)
- IOPort('Write', TB, uint8(0),0);
- WaitSecs(0.005)
- end
- tdel=toc(c);
- end
- function press_eyelink_trigger(ti,eyetracking)
- if eyetracking==1
- % mark zero-plot time in data file
- mel=num2str(ti)
- Eyelink('Message', mel);
- end
- end
- %% Showing slides
- function showingslides(imgList_in,imageFolder_in,window1,W,H,backgroundColor,responseKeys)
- imtotal = 1:size(imgList_in,2)
- t=1
- ttrue=1;
- while ttrue==1
-
- % Load image
- file_in = imgList_in{t};
- img_in = imread(fullfile(imageFolder_in,file_in));
- imageDisplay_in = Screen('MakeTexture', window1, img_in);
-
- % Calculate image position (center of the screen)
-
- rat=(W/size(img_in,2))*.7;
-
-
- imageSize = size(img_in)*rat;
- pos = [(W-imageSize(2))/2 (H-imageSize(1))/2 (W+imageSize(2))/2 (H+imageSize(1))/2];
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show the images
- Screen(window1, 'FillRect', backgroundColor);
- Screen('DrawTexture', window1, imageDisplay_in, [], pos);
- startTime = Screen('Flip', window1); % Start of trial
-
- % Get keypress response
- rt = 0;
- resp = 0;
- while 1
- [keyIsDown,~,keyCode] = KbCheck;
- respTime = GetSecs;
- pressedKeys = find(keyCode);
-
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- clear all
- close all
- sca
- return;
- end
-
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp = responseKeys{i};
- rt = respTime - startTime;
- end
- end
- end
-
- % Exit loop once a response is recorded. Delete that to keep the
- % image after the response
-
- if keyCode(KbName('RightArrow'))==1
- t=t+1;
- break;
- elseif keyCode(KbName('LeftArrow'))==1&t>1;
- t=t-1;
- break
- end
-
- end
- WaitSecs(1);
- % Clear textures
- Screen(imageDisplay_in,'Close');
- if t>imtotal;
- ttrue=0;
- end
-
- end
- end
|