0% found this document useful (0 votes)
88 views

Week 3 - PART III: The Serial Reaction Time Task

The document describes an experiment to examine implicit learning using a variation of the Serial Reaction Time Task. Participants see cues appear in one of four boxes in a patterned sequence without awareness and must press the corresponding button. Reaction times are logged to a file. The summary analyzes the logged data to determine if reaction times decreased more for the learned sequence trials than random trials, indicating implicit learning occurred.

Uploaded by

Andrei Firte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

Week 3 - PART III: The Serial Reaction Time Task

The document describes an experiment to examine implicit learning using a variation of the Serial Reaction Time Task. Participants see cues appear in one of four boxes in a patterned sequence without awareness and must press the corresponding button. Reaction times are logged to a file. The summary analyzes the logged data to determine if reaction times decreased more for the learned sequence trials than random trials, indicating implicit learning occurred.

Uploaded by

Andrei Firte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Week 3 - PART III: The Serial Reaction Time Task 

Data files: The materials (log files and MATLAB scripts) needed for PART III can be found on 
CANVAS.  
In PART III we will set all of our skills to work by analyzing the data of a cognitive experiment, 
of course using a script. 

CASE:​ After our ‘success’ with our cognitive therapy we want to learn more about implicit 
learning, the ability to learn patterns while being unaware (i.e. without clear awareness of the 
notion that we are learning something). 

To examine implicit learning we designed a variation of the ‘Serial Reaction Time Task’ (SRTT), 
a task in which the participant sees a cue on one of several positions on the screen and then 
has to respond as quickly as possible by pressing a button that matches the position of the 
cue. The key of this task is that the stimuli are not random in time, but that there is a hidden 
sequence in the location of where the cue appears, with ‘implicit learning’ of this sequence 
resulting in a faster reaction time of the participant. 

In our variant of the SRTT we implemented the following task: 

1) We show 4 boxes on a computer screen, arranged in a ‘plus’ shaped pattern, which are 
continuously present. We label the four boxes A, B, C, D. The computer keeps track of 
the exact times at which each of the stimuli is shown on the screen in a detailed log 
file. 

2) The participant receives a ‘button box’ containing 4 buttons, also arranged in a star 
shaped pattern, with each of the buttons linked to the four boxes A, B, C, D. The button 
box is connected to the computer, which measures the exact time that each of the 
buttons is pressed. 

3) During the task, during each trial, we show a * in one of the 4 boxes (the cue). 

4) The participant now has to press as quickly as possible the matching button A, B, C or 
D in response to the stimulus. 

5) Step 3 and 4 are repeated for a series of trials (i.e. tens to hundreds) with with a little 
bit of ‘jitter’ in time applied to the exact time of stimulus presentation (to prevent the 
participant from being able to fully anticipate when a stimulus is coming). 
2  Academic Skill : ​Cognitive Neuroscience  Week 3  

The participant is instructed to respond as fast as possible, but with as high as possible 
accuracy and to make as few mistakes as possible. The participant is told that we are 
conducting a ‘boring’ experiment on ‘the reaction time of visual stimuli’ and that stimuli are 
presented completely ​at​ r​ andom​ on the screen. However, we actually pre-made the order in 
which the stimuli will be presented on the screen. We designed the stimuli not to be 
randomly ordered but to contain a hidden sequence. The participant is completely 
unaware of this. We are interested in whether or not the participant learns this sequence, 
improving his/her reaction time (i.e. button presses are faster, as the brain is ‘learning’ 
which button needs to be pressed next before the stimulus is presented), without being 
‘consciously aware’ of the fact that there is a pattern in the stimuli.  

In this experiment, we have hidden a fixed sequence of 8 cues, being ​B-A-D-C-D-B-C-A.  

To further avoid that the participant becomes aware of the pattern during the experiment, 
the sequence is alternated with series of actually random stimuli, which vary in length. 

Our prepared sequence of stimuli (of which the participant is thus unaware) looks 
something like this: 

B-B-B-C-A-A-A-A-C-D-​B-A-D-C-D-B-C-A-​A-C-D-C-A-A-​B-A-D-C-D-B-C-A-​B-
D-B-A-B-D-B-A-B-​B-A-D-C-D-B-C-A-​D-B-A-C-A-, ​etcetera.. 
3  Academic Skill : ​Cognitive Neuroscience  Week 3  

At the end of the experiment we ask the participants how they experienced the test and 
whether or not they noticed anything special. In all cases, the participants mentioned they did 
not notice anything in particular.  

We are now interested in whether the participant has still (or has not) ‘learned’ the sequence 
without being aware of the sequence being actually there (so completely implicit). We logged 
all information into our log file and we are now going to analyze the logged information. We 
are of course going to use our new MATLAB skills to do this! 

Goal: ​Our goal is to see whether the reaction times of the ‘sequence trials’ decreased over 
time, more than the reaction times of the ‘random trials’. Our end goal is: 

- To show a figure of the reaction times over time for both conditions (random and 
sequence trials) 

- To determine whether our participant ‘learned’ the sequence without being aware? 

MESSAGE FOR EXPERIENCED PROGRAMMERS: If you are an expert in programming, good 


luck from now on. You can start with an empty MATLAB script, read in the log file, extract the 
values, run the analysis, and make a fancy shiny plot. From now on, we provide you with 
several hints and example code. If you are able to make this part you are ready to go for the 
Big Data course! 
4  Academic Skill : ​Cognitive Neuroscience  Week 3  

We are first going to read in the log file into MATLAB. We prepared a MATLAB script with 
commands to perform some of the steps. It is your job to finish this script and fill in your own 
code. Please go to the folder on your PC where you stored the files of this workshop. The log 
file should be in this folder, and your the MATLAB ‘working directory’ should be here. One 
simple way to do this is to use the ‘Open’ button in the MATLAB editor. To launch the MATLAB 
editor, simply type:  

>> edit  

Click the ‘Open’ button in the top left corner and navigate to the Analysis_of_Logfile_SRTT8.m 
and open this file. Press ‘Run’, and in the popup window click the option to change the 
MATLAB current path to the directory where also the log file is located.​ M
​ ATLAB should now 
be running in the correct folder. 

An alternative option is to navigate to the file in your MATLAB terminal: 

>> edit 
~/martijn/Desktop/Files_for_programming_Practical_CogNeuro2020/We
ek3/Analysis_of_Logfile_SRTT8.m

In the script you see already some code we prepared, starting with some commands to read in 
the log file and select the relevant information from the log file. Go ahead and run the first 
section of the script. 

(Tip: after each section you see the command ​return​. This stops the script and returns to the 
5  Academic Skill : ​Cognitive Neuroscience  Week 3  

MATLAB prompt. Using this you can fill in each exercise one by one, running the script only to 
that part. Remove a ​return ​or use ​%return​ when you are working on the next exercise and 
run the code from the beginning all the way to the next ​return​.) 

Let’s start by looking at the data. Open the log file in a text editor and take a look at it.  

Q3.00)​ What kind of information is present in this log file? Does the whole file look the same, 
are there any special values? 

Q3.0)​ What information do you think you'll need in order to calculate whether reaction time on 
the ‘sequence trials’ decreased over the course of the experiment?  

No need to write down your answers, just keep them in mind for the next exercises. 

Now let’s load in the log file into MATLAB and store its contents in a t
​ able​, which will make it 
easy to view the total data set. (Remember: a t
​ able​ is just a handy way of storing data in 
MATLAB, a little bit more versatile than a matrix or a ​struct​). 
6  Academic Skill : ​Cognitive Neuroscience  Week 3  

Run the script until the first ​return​ statement to load the data and organize it into a table. 

%% -- READING THE LOG FILE INTO MATLAB 


  
% Open the file and read the contents. 
% If you want to know more about these functions, use the "help" function. 
fileID = fopen(​'subject190613_seq8SRTT.log'​); 
trials = textscan(fileID, ​'%f %s %s %s %f %f'​, ​'Headerlines'​, 5); 
fclose(fileID); 
  
% We'll store the contents of the log file into separate variables. 
trialNumber = trials{1}; ​% the trial number 
condition = trials{2}; ​% the experimental condition (sequence or random) 
stimulus = trials{3}; ​% the stimulus presented 
response = trials{4}; ​% the response given by the subject 
startTime = trials{5}; ​% the time at which the trial started (in 1/10,000 of a second 
precision) 
endTime = trials{6}; ​% the time at which the response was given (in 1/10,000 of a second 
precision) 
  
%% **** your task is to replace YOUR_CODE_HERE with your own code. Leave all other code intact **** 
  
%% -- EXERCISE 1 
  
% We can visualize the contents of the log file using a table in MATLAB. 
myTable = table(trialNumber, condition, stimulus, response, startTime, endTime, ​... 
​'VariableNames'​, {​'trialNumber'​, ​'condition'​, ​'stimulus'​, ​'response'​, ​'startTime'​, ​'endTime'​}); 
  
disp(myTable); ​% show the table in the Command Window 

TIP: use the ‘ Run’ button for this OR select the text with your mouse, then right click and 
‘Evaluate Selection’. 

To get a fair estimate of reaction times on the task, we first want to filter out all the trials in 
which the participant gave the wrong answer, or did not give an answer at all. The easiest way 
to do this is to select all the correct trials and use only these in the analysis. In MATLAB, we 
can create a “filter” that selects specific elements of an array by checking if they satisfy a 
certain condition.  

Q3.1:​ Which condition should our trials satisfy in order to be considered "correct" trials? 

Let’s implement this in MATLAB. We will create a new array consisting of zeros and ones, 
where a zero means "does not satisfy the condition" and a one means "satisfies the condition". 

- Tip: take another look at the help or documentation of the s


​ trcmp​ function. What do 
we need to pass as its arguments to get ones for correct responses and zeros for 
everything else?  
- Complete the code. Hint: you can access a specific column of a table using the name 
of the table, followed by a dot and the name of the column (for example, 
myTable.condition​ gives you all the data from the column ​condition​ of the 
table m
​ yTable​). 
7  Academic Skill : ​Cognitive Neuroscience  Week 3  

- How many trials were performed correctly by the participant?  

We will now use our new array of zeros and ones to extract only the correct trials from the 
table. This technique is called l​ ogical indexing​ in computer language jargon (​indexing​ simply 
means selecting from an array, and l​ ogical​ means using computer logic values, namely 0
​ ​ a.k.a. 
false​ and ​1​ a.k.a. ​true​). As we have seen before, we can index a variable in MATLAB using 
the following syntax: 

>> mySelection = myVariable(myIndex); 

The cool thing is, m


​ yIndex​ can be a single value or a logical array (indicating for each index 
whether to select it (​1​) or not (​0​).). That’s perfect for us, because we just created such a 
logical array! 

But we’re not there yet… To index our table (which has rows and columns), we need both a row 
index and a column index.  

Q3.2: ​Do we need to use our newly created logical array as the row index or column index? 
And what do we need to use as the other index? 

Q3.3:​ Complete the code to create a new table called ​correctTrials​ that contains all 
information from m
​ yTable​ for only the correct trials. Use logical indexing here! 

Hint: 

>> myTable(1,:) % gives you the first row of a table 

>> myTable(:,1) % gives you the first column of a table 

% The result of myTable(1,:) will itself be a table again! 

Q3.4:​ Complete the code to create a new column in our c


​ orrectTrials​ table that represents 
the reaction time. 

Q3.5:​ Complete the code to plot the reaction times for all correct trials. For the x-axis, use the 
trialNumber​ column, and for the y-axis, use the ​reactionTime​ ​column. Hint: look up the 
usage of the p
​ lot​ function if necessary! 

As you can see from the plot, there are a few trials with an unusually long reaction time. These 
8  Academic Skill : ​Cognitive Neuroscience  Week 3  

represent trials during which the participant was distracted from the task. We would like to 
exclude these “outlier” trials as they might bias our results (always make sure you have a good 
reason before throwing away any data points!). 

Q3.6: ​Create a variable called ​outliers​ that is a logical array containing 1


​ ​ if the reaction time 
on a trial is an outlier, and ​0​ otherwise. We’ll define being an outlier as being h
​ igher than​ 2 
standard deviations above the mean. You’re allowed to use the functions m
​ ean​ and s
​ td​. 

Q3.7:​ Create a new table c


​ orrectTrials_no_outliers​ table so that it only contains 
non​-outliers. Hint: the MATLAB symbol for ‘not’ is a tilde (​~​). 

Q3.8: ​After confirming that the outliers are indeed removed, you can overwrite your earlier 
correctTrials​ table with the new ​correctTrials_no_outliers​ table (to prevent 
having to type such a long name many times). Make sure to add the following line to your 
script: 

>> correcTrials = correctTrials_no_outliers; 

We are ready to compare the reaction times on the random trials versus the sequence trials! 

Q3.9:​ Complete the code to plot the reaction times of random trials versus the reaction times 
on sequence trials. You can use logical indexing again to select the trials that are “random” 
and those that are “sequence”. 

Q3.10: D
​ oes the plot look like you expected? How do you interpret these results? 

SUBJECT analysis 

In this final part you’ll harness the full power of doing analyses using computer programming. 
What if we have multiple participants, each one of them having a log file? Instead of having to 
go through each log file manually, we can now write a simple script that will do all the analyses 
that we programmed before automatically on many participants, no matter if there are 2 
participants, 10, 100, or even 10,000.  

To keep things simple, we define a single “performance score” for each participant. We’ll base 
this performance score on the last 200 trials in the experiment, where the participant should 
have learned the sequence. The score will be the difference between the average reaction time 
on the random and the sequence trials in these last 200 trials. 

Q3.11:​ In your analysis script (for one subject), create a variable called ​finalTrials​ that 
stores the last 200 correct trials. 

Q3.12:​ Select the random and sequence trials from the f


​ inalTrials​ and store them in 
9  Academic Skill : ​Cognitive Neuroscience  Week 3  

separate variables (for example, f


​ inalRandom​ and f
​ inalSequence​). 

Q3.13:​ Calculate the performance score (this should be the difference in average reaction time 
between the random and the sequence trials). 

Q3.14:​ You can now run your script on 1 subject, but also on several other subjects. Put your 
code into a f
​ unction​ file called getSRTTScore_answer.m that takes as i​ nput​ the LOG file 
name and as o
​ utput ​the value s
​ core​. You can test out your new script with the provided log 
file of our first subject. On CANVAS you find the log-files of several other subjects, for example 
subject204300_seq8SRTT.log a
​ nd​ subject208654_seq8SRTT.log. D
​ ownload the two log files 
and compute the s
​ core ​of these two subjects in your MATLAB output using your new 
function.

When you have finished the exercises you can send in your results. What you have to send in 
to CANVAS is: 

- a matlab .m script file (named : 


week3_assignments_YOURNAME_YOURSTUDENTNUMBER.m, for example 
week3_assignments_MartijnvandenHeuvel_1020304) which lists all the code you 
made to solve the questions of this week. An example script can be found on 
CANVAS. 
- your matlab function files of (.m files): 
- Analysis_of_Logfile_SRTT8.m 
- getSRTTScore_answer.m 
- a document (PDF file) that summarizes the MATLAB command output from your 
code (so the SOLUTIONS to the questions). The PDF file should also include 
screenshots of the figures you made 

You might also like