R.Muralikrishnan, MPI for Empirical Aesthetics. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Licence. ############################################################################## ## ## ## Selfpace : Self-paced Reading ERP Study with Judgement & Probe Tasks ## ## Experiment Script for use with Presentation ## ## Author: R. Muralikrishnan ## ## ## ############################################################################## ############################################################################## # Scenario Description Language (SDL) Header Part ############################################################################## # These button codes have to correspond to those set in 'Settings -> Response' active_buttons = 3; # There are 3 active buttons defined in 'Settings -> Response' button_codes = 1,2,3; # These are the codes of those buttons response_matching = simple_matching; # Enables features not in legacy_matching # Only those button presses that one expects are logged; not all response_logging = log_active; # Needed for EEG Trigger files write_codes = true; pulse_width = 5; default_output_port = 1; # This is most probably going to be the same for everyone. # This is the LPT Parallel port that you will define in the Port settings tab of # Presentation. This will be used as the output port for sending codes to EEG. # Defining this here saves getting a port number in the PCL part from the output_manager # and calling send_code etc. Stimulus events themselves will send these for us, provided we # define the correct port_codes in each Stimulus event. # Default Settings for Font, FG and BG Colours etc. default_background_color = "0, 0, 0"; # RGB codes in decimal; #000000 => Black default_font = "Nazli"; # Alternatives: Courier New Bold, "Arabic Typesetting"; "Arial Unicode MS"; default_font_size = 72; default_text_color = "000, 102, 153"; # "000, 102, 153"; # 006699 A pleasant bluish colour default_text_align = align_center; default_deltat = 0; default_picture_duration = next_picture; #/* This implies that all pictures ... #...are shown until the next picture is shown, unless otherwise specified */ #default_all_responses = false; # max_y = 1000; # Scaling of things on screen. The bigger the value, the smaller the text/image. ############################################################################## # Scenario Description Language (SDL) Part ############################################################################## begin; # ============================ # SDL Variable Declarations: - # ============================ # # We don't use any variables. All the timer parameters appear as numbers. # ============================== # Picture Stimuli Definitions: - Everything that is shown, including text! # ============================== # Screen definition for the trial that starts an Experimental Session. # Used as the first screen that the participant sees. Operator Controlled. line_graphic { coordinates = -600, -72, -600, 71; coordinates = 600, -72, 600, 71; coordinates = -600, -70, 600, -70; coordinates = -600, 70, 600, 70; line_width = 4; line_color = 32, 32, 32; } Lin_Border; picture { #text { caption = "Welcome! The Experiment will begin shortly."; max_text_width = 1200; }; text { caption = "!مرحباً. سنبدأ بعد قليل"; }; x = 0; y = 0; line_graphic Lin_Border; x = 0; y = 0; } P_Start_Exp; # Screen definition for the Pause trial # Operator Controlled! picture { #text { caption = "Let us continue after a short break!"; }; text { caption = "!خذ استراحة قصيرة"; }; x = 0; y = 0; line_graphic Lin_Border; x = 0; y = 0; } P_Pause; # Screen definition for the Continue trial # Participant Controlled! picture { #text { caption = "Please press a key to continue."; }; text { caption = "!اضغط على الزر (نعم) للاستمرار"; }; x = 0; y = 0; line_graphic Lin_Border; x = 0; y = 0; } P_Continue; # Screen definition for showing the focus star picture { bitmap { filename = "Focus_Star_new1.bmp"; }; # Use Focus_Star.bmp #text {caption = "+"; text_align = align_left; max_text_width = 1200; }; # left_x = -520; # The text/bitmap will be displayed starting from (not centered around) the left_x value # (unlike the case with a simple x value, in which case it will be centered around it ). right_x = 609; top_y = 16; # Adapt the values as necessary to correspond to the text displayed in P_Selfpaced_Visual_Stimulus below. } P_Focus_Star; # Screen definition for the End_Thanks trial picture { #text {caption = "We're done! Thank you very much!";}; text {caption = "!وصلنا النهاية. شكراً على المشاركة";}; x = 0; y = 0; line_graphic Lin_Border; x = 0; y = 0; } P_End_Thanks; #### Specific for presenting Visual Stimuli -------------------------------- # Screen definition for the trial that presents Visual Stimuli word-by-word. picture { text { caption = " "; text_align = align_right; max_text_width = 1200; # This parameter works only in Presentation Version 16.4 or later versions. # Very useful parameter indeed. (Especially to recompose sentences, without having to # bother about inserting \n after every n words, and not worrying if the words/lines would be too long etc.) # invert_caption = true; # This does the right-to-left thing, but in a stupid way...character by character. Not useful for us. } Txt_Selfpaced_Visual_Stimulus; #x = 0; #y = 0; #left_x = -500; # The text/bitmap will be displayed starting from (not centered around) the left_x value # (unlike the case with a simple x value, in which case it will be centered around it ). right_x = 580; top_y = 70; } P_Selfpaced_Visual_Stimulus; #### #### Specific for presenting Probe Task from Textfile --------- # Screen definition for Probe Task (text) picture { text {caption = " "; } Txt_Probe; # PCL Program fills the caption. x = -450; y = 0; } P_Probe; ##### #===================== # Trial Definitions: - #===================== /**** /# Note that the name 'Trial' could be misleading. Unless otherwise specified, /# what we mean by a 'Trial' here is actually a sub-trial or sub-task that is /# part - and thereby defines the structure - of an actual experimental trial. ****/ /**** /# Template for defining an SDL Trial. /# trial /# { /# Trial-related parameters such as trial_duration, trial_type etc. /# Trial-related parameters /# /# Stimulus event 1 such as picture, sound, video, nothing or force-FB; /# Stimulus event parameters such as time, event code etc. /# If the parameters aren't specified, the default values are used!!! /# /# Stimulus event 2; /# its parameters...and so on /# } ****/ # Screen definition of the Trial to show a Blank Screen between Experimental Trials trial { trial_duration = 1000; all_responses = false; stimulus_event { picture {}; # This is the default picture, which is nothing! #code = "CLS"; # Comment this out to avoid seeing this in the logfile. } E_Blank_Screen; } T_Blank_Screen; # Definition of the Trial to start an Experimental Session. # Operator Controlled! trial { trial_duration = forever; # Keep running the trial... trial_type = specific_response; # ...until the following specific response. terminator_button = 3; # Operator PC - ENTER key. stimulus_event { picture P_Start_Exp; # Show P_Start_Exp. code = "The Experiment starts now!"; }; } T_Start_Exp; # Definition of the Trial to continue further. # Participant Controlled! trial { trial_duration = forever; # Keep running the trial... trial_type = specific_response; # ...until the following specific response. terminator_button = 1,2; # Participant Joystick - L or R button. stimulus_event { picture P_Continue; # Show P_Continue. code = "Trials follow!"; }; } T_Continue; # Definition of the Trial to Launch an Experimental Trial trial { trial_duration = 300; # Run the trial for 500 ms... all_responses = false; # ..without recognising any key presses. stimulus_event { picture P_Focus_Star; # Show the focus star for fixation. code = ""; # Code set below in the PCL program. # port_code = ; # Port code set by the PCL program. } E_Launch_New_Trial; } T_Launch_New_Trial; #### Specific for presenting Visual Stimuli -------------------------------- # Definition of the Trial to present Visual Stimuli word-by-word in a SELFPACED manner, with an integrated acceptability judgement. trial { trial_duration = forever; # PCL Program changes this!!! trial_type = specific_response; terminator_button = 1,2; # The exact response can be either of these; stimulus_event { picture P_Selfpaced_Visual_Stimulus; code = ""; # PCL Program fills this!!! # port_code = ; # PCL Program fills this!!! target_button = 2; # 2 is good, 1 is bad; as always! } E_Selfpaced_Visual_Stimulus; } T_Selfpaced_Visual_Stimulus; #### # Definition of the Trial to show the Probe Task trial { trial_duration = 2000; trial_type = specific_response; terminator_button = 1,2; # The exact response can be either of these; stimulus_event { picture P_Probe; code = "195"; # PCL Program sets this. #port_code = 195; # Send '195' to EEG # target_button = 1,2; # PCL Program sets this. } E_Probe; } T_Probe; # Definition of the Trial to send a code indicating that a Timeout has occurred. /*# When a button-pressed response occurs, 1 or 2 is sent to EEG depending upon the button pressed. # When a timeout occurs, nothing gets sent. Just in order to have equal number of lines in the # trigger files later, it's better to send a code indicating timeout. # (Yes, IN ADDITION to the usual code 199 that will follow.) */ trial { trial_duration = 10; all_responses = false; stimulus_event { nothing {}; # This is the default picture, which is nothing! code = "3"; #"Timeout"; #port_code = 3; } E_Report_Timeout; } T_Report_Timeout; # Definition of the Trial to send the response code to EEG trial { trial_duration = 20; all_responses = false; stimulus_event { nothing {}; # Basically, nothing is done! time = 15; /*# Start this event 15 seconds after the trial starts. This is to provide a delay in # sending the code to EEG to avoid trying to reach the port when it is still busy # having just received the response 1 or 2 from the button box, or the timeout code. */ # code = "Send Code"; # Comment this out to avoid seeing this in the logfile. # port_code = 192, 193, 196, 197 or 199, PCL Program fills this!!! } E_Response_Code_to_EEG; } T_Response_Code_to_EEG; # Definition of the Trial to show a Pause # Operator Controlled trial { trial_duration = forever; trial_type = specific_response; terminator_button = 3; stimulus_event { picture P_Pause; code = "Pause"; }; } T_Pause; # Definition of the Trial to end the session # Operator Controlled trial { trial_duration = forever; all_responses = false; trial_type = first_response; stimulus_event { picture P_End_Thanks; code = "End of Session!"; }; picture P_End_Thanks; } T_End_Thanks; ############################################################################## # Presentation Control Language (PCL) Program Part ############################################################################## begin_pcl; int N_of_Trials = 240; # Number of Experimental Trials per Session. int N_of_Blocks = 6; # Number of Blocks per Session. int N_of_Trials_per_Block = N_of_Trials/N_of_Blocks; # Number of Experimental Trials per Block. preset string V_Version; # Prompt the version at the beginning!!! input_file F_Session_List = new input_file; F_Session_List.open("Session_List_" + V_Version + ".txt"); # This is the file containing the list of stimuli for one session. # Each line in this file must correspond to one experimental trial. #### Specific for presenting Visual Stimuli -------------------------------- input_file F_Visual_Stimulus = new input_file; F_Visual_Stimulus.open("Visual_Stimulus_List_" + V_Version + ".txt"); string V_Visual_Stimulus; string V_Visual_Blanks; string V_Selfpaced_Visual_Stimulus; array<string> A_Stimulus_Words[0]; array<string> A_Selfpaced_Visual_Stimulus[0]; #### Specific for presenting Visual Stimuli + Text Comprehension Question --- int V_Current_Word; int V_Underscore_Index; int V_Star_Index; int V_Current_Letter; string V_Stimulus_Words; string V_Stimulus_Blanks; int V_Current_Selfpaced_Stimulus; string V_Temp_Store_Restore; int V_Counter; #### Specific for presenting Probe Task from Textfile --------- #input_file F_Probe = new input_file; #F_Probe.open("Probe_List_" + V_Version + ".txt"); #### # Columns of strings in the order found in the input Session List file. string V_Stimulus_Sentence; string V_Context_Question; # If any, otherwise dummy for visual experiments!!! string V_Item; string V_Condition; string V_Condition_Code; string V_Probe_Code; string V_Probe; string V_Expected_Response; # output_port O_Port_to_EEG = output_port_manager.get_port(1); stimulus_data D_Stimulus_Data = stimulus_manager.last_stimulus_data(); #======================== # Main Experiment Loop: - #======================== loop /*** Begin Main Loop 1 for Blocks ***/ int V_Current_Block = 1 until V_Current_Block > N_of_Blocks begin if V_Current_Block == 1 then T_Start_Exp.present(); T_Continue.present(); else T_Pause.present(); T_Continue.present(); end; T_Blank_Screen.present(); #========== # Loop 2: - #========== loop /*** Begin Loop 2 for Trials ***/ int V_Current_Trial = 1 until V_Current_Trial > N_of_Trials_per_Block begin V_Stimulus_Sentence = F_Session_List.get_string(); # Eg: 01SAI V_Item = F_Session_List.get_string(); # Eg: 01 V_Condition = F_Session_List.get_string(); # Eg: SAI V_Condition_Code = F_Session_List.get_string(); # Eg: 230 V_Expected_Response = F_Session_List.get_string(); # Eg: 2 (Left button => Correct) V_Probe = F_Session_List.get_string(); # Eg: Q01SAIC # V_Probe_Code = F_Probe.get_string(); # Get the Probe word and code from the Probe List file. # V_Probe = F_Probe.get_string(); # Do filename and event-code assignments valid during this exp-trial; # Load wavefile and bitmap stimuli that are needed for this trial; /*# We do this before launching the experimental trial so as to keep # as minimal intereference as possible in trial timings. You see, # these things consume processor time, however small they are! */ E_Launch_New_Trial.set_event_code("B" + string(V_Current_Block) + " T" + string(V_Current_Trial)); E_Probe.set_target_button(int(V_Expected_Response)); # Execute the Experimental Trial!!! # Dirty hard-coded solution for the 08-09 Presentation Bug!!! if (V_Item == "08") then V_Item = "8"; elseif (V_Item == "09") then V_Item = "9"; end; E_Launch_New_Trial.set_port_code(int(V_Item)); T_Launch_New_Trial.present(); # Show Star for 500 ms /***************** Visual Stimulus Presentation Begins ***********************/ T_Blank_Screen.set_duration(100); # This duration will be the inter-word interval. See below. T_Blank_Screen.present(); A_Stimulus_Words.resize(0); # Empty the arrays. A_Selfpaced_Visual_Stimulus.resize(0); V_Visual_Stimulus = F_Visual_Stimulus.get_line(); # Read one line at a time from the file. V_Visual_Blanks = V_Visual_Stimulus; # Copy the line to another variable, # which will be used to display blanks/dashes identical in length # to the stimulus sentence. # Replace all the letters except spaces and _ (for displaying phrases) to "." (ASCII Character 46). # See explanation withing loop 2 below for the rationale for choosing a '.' instead of '-' as the placeholder. loop V_Current_Letter = 1 until V_Current_Letter > V_Visual_Stimulus.count() begin if (V_Visual_Stimulus.substring(V_Current_Letter,1) != " " && V_Visual_Stimulus.substring(V_Current_Letter,1) != "_") then V_Visual_Blanks.set_char(V_Current_Letter, 46); # 45 -> "-" / 46 -> "." / 95 -> "_" / 126 -> ~ Not working: 151 -> "Em Dash" / 150 -> "En Dash" end; V_Current_Letter = V_Current_Letter + 1; end; # Empty all the strings that will be used further below. V_Selfpaced_Visual_Stimulus = ""; # Split the stimulus sentence word by word, and store the words in an array. # If two words need to be together, there must be an _ in the input! V_Visual_Stimulus.split(" ",A_Stimulus_Words); # Split the blank sentence similarly, and store the blank words in another array. V_Visual_Blanks.split(" ",A_Selfpaced_Visual_Stimulus); # In both the above arrays, the first array element is the Condition Code from the Stimulus List. # We will take care not to display that (see below). # #============ # Loop 2.2: - #============ loop /*** Begin Loop 2.1 for Presenting Stimulus Words with Blanks ***/ V_Current_Selfpaced_Stimulus = 1 until V_Current_Selfpaced_Stimulus > A_Stimulus_Words.count() begin #if V_Current_Selfpaced_Stimulus == 1 then #A_Stimulus_Words[1] = "\u0FE0"; V_Temp_Store_Restore = A_Selfpaced_Visual_Stimulus[V_Current_Selfpaced_Stimulus]; A_Selfpaced_Visual_Stimulus[V_Current_Selfpaced_Stimulus] = A_Stimulus_Words[V_Current_Selfpaced_Stimulus]; #if A_Selfpaced_Visual_Stimulus.count() < 6 then loop V_Current_Word = 1 until V_Current_Word > A_Selfpaced_Visual_Stimulus.count() begin if (V_Current_Word == 1) then # Leave the first one out, because that's the Stimulus Number or Index or so. V_Selfpaced_Visual_Stimulus = V_Selfpaced_Visual_Stimulus; # Just nothing, or, if some star or something is necessary, that can be included here. /* RIGHT to LEFT Text Direction */ elseif (V_Current_Word != A_Selfpaced_Visual_Stimulus.count()) then V_Selfpaced_Visual_Stimulus = " " + A_Selfpaced_Visual_Stimulus[V_Current_Word] + V_Selfpaced_Visual_Stimulus; # Right to Left Text Direction else V_Selfpaced_Visual_Stimulus = A_Selfpaced_Visual_Stimulus[V_Current_Word] + V_Selfpaced_Visual_Stimulus; # Right to Left Text Direction end; # The logic above works fine, as long as the text fits in one line. The moment we need a second line, then there's quite a problem with # getting the linebreak to work in a way we want. The first few words appear on the second line, and the last words appear on the first... # so basically giving the impression that the text runs from right to left, bottom to top! Right to left yes, but it should still be # top to bottom. We tried getting that to work, first by changing how the loop (and then the master loop) works, then by seeing if # invert_caption is set to true etc., and then by inserting the \n manually. But given that we're only displaying the words from right to # left, with the native text direction still working in the left to right default, we had no luck. A possible way to get that working would be # to compose two lines of text, then displaying them on the same Txt_... screen simultaneously on two different lines. But given the # the screen accommodates 7 words comfortably (if only we choose a '.' instead of '-' for the blanks, we just did that, and chose the '.' as the # place holder. And then, all seem to work well (and given we don't/won't have stimuli that are longer than 7 words for the self-paced # study (at least not now), we can and will live with that (instead of fussing over/messing about the whole thing)! And in fact, . looks # much better than -. /* LEFT to RIGHT Text Direction elseif (V_Current_Word != A_Selfpaced_Visual_Stimulus.count()) then V_Selfpaced_Visual_Stimulus = V_Selfpaced_Visual_Stimulus + A_Selfpaced_Visual_Stimulus[V_Current_Word] + " "; # Left to Right Text Direction else V_Selfpaced_Visual_Stimulus = V_Selfpaced_Visual_Stimulus + A_Selfpaced_Visual_Stimulus[V_Current_Word]; # Left to Right Text Direction end; */ V_Current_Word = V_Current_Word + 1; end; A_Selfpaced_Visual_Stimulus[V_Current_Selfpaced_Stimulus] = V_Temp_Store_Restore; # Send event codes for each word. E_Selfpaced_Visual_Stimulus.set_event_code(V_Condition_Code + " " + A_Stimulus_Words[V_Current_Selfpaced_Stimulus]); # E_Selfpaced_Visual_Stimulus.set_port_code(int(V_Condition_Code)); # Increment the trigger to use for the next word. V_Condition_Code = string(int(V_Condition_Code) + 1); /* Find if there's an underscore in the current stimulus. If there's one, replace it with a space (ASCII Char 32) before presenting the words. An underscore means that the words need to be presented together, as in 'Of course'! For now, we'll run the loop 5 times, meaning we can replace up to 5 underscores here. */ loop V_Counter = 1 until V_Counter > 5 begin V_Underscore_Index = 0; V_Underscore_Index = V_Selfpaced_Visual_Stimulus.find("_"); if V_Underscore_Index != 0 then V_Selfpaced_Visual_Stimulus.set_char(V_Underscore_Index, 32); end; V_Counter = V_Counter + 1; end; Txt_Selfpaced_Visual_Stimulus.set_caption(V_Selfpaced_Visual_Stimulus); Txt_Selfpaced_Visual_Stimulus.redraw(); T_Selfpaced_Visual_Stimulus.present(); ## No response monitoring necessary, because we don't need EEG triggers. # Reset things before going to the next word! V_Selfpaced_Visual_Stimulus = ""; E_Selfpaced_Visual_Stimulus.set_event_code(""); # E_Selfpaced_Visual_Stimulus.set_port_code(port_code_none); # Go to the next word. V_Current_Selfpaced_Stimulus = V_Current_Selfpaced_Stimulus + 1; #============= # End Loop 2.2 #============= end; /*** End Loop 2.1 for Presenting Stimulus Words with Blanks ***/ /***************** Visual Stimulus Presentation Ends *************************/ # Blank Screen between last stimulus word and the probe task. T_Blank_Screen.present(); /***************** Probe Task Begins **********************/ Txt_Probe.set_caption(V_Probe + " ?"); Txt_Probe.redraw(); T_Probe.present(); ## No response monitoring necessary, because we don't need EEG triggers, ## but because we want to track time-outs, this is done here. # Monitor the Response and send appropriate port codes to EEG!!! D_Stimulus_Data = stimulus_manager.last_stimulus_data(); # To delay sending the following codes to the Output Port!!! # Because these are almost at the same time as the Response there, so the port # cannot handle it unless there's a short delay. # if (D_Stimulus_Data.type() == stimulus_miss) then # T_Report_Timeout.present(); # end; if (D_Stimulus_Data.type() == stimulus_hit) then E_Response_Code_to_EEG.set_port_code(196); E_Response_Code_to_EEG.set_event_code("Correct"); T_Response_Code_to_EEG.present(); elseif (D_Stimulus_Data.type() == stimulus_incorrect) then E_Response_Code_to_EEG.set_port_code(197); E_Response_Code_to_EEG.set_event_code("Incorrect"); T_Response_Code_to_EEG.present(); elseif (D_Stimulus_Data.type() == stimulus_miss) then T_Report_Timeout.present(); E_Response_Code_to_EEG.set_port_code(199); E_Response_Code_to_EEG.set_event_code("TimeoutP"); T_Response_Code_to_EEG.present(); end; /***************** Probe Task Ends **********************/ # Reset Duration for the Blank Screen T_Blank_Screen.set_duration(1000); T_Blank_Screen.present(); # Go to the Next Trial V_Current_Trial = V_Current_Trial + 1; #=========== # End Loop 2 #=========== end; /*** End Loop 2 for Trials ***/ # Go to the Next Block V_Current_Block = V_Current_Block + 1; #================ # End Main Loop 1 #================ end; /*** End Main Loop 1 for Blocks ***/ # Close all the open files F_Session_List.close(); F_Visual_Stimulus.close(); #F_Probe.close(); # Finish off the session!!! T_End_Thanks.present();