Introduction to MATLAB programming Assignment 2
Due: 5pm Friday 18th April 2019
Attempt to answer all questions. For each question, describe your approach to solving the problem as clearly as possible in plain English, followed by the corresponding MATLAB code. Comment explicitly on your results and conclude. There is no word limit, but answers should be as concise as possible.
Save your answers in one .m file (script) AND a .pdf file* containing any figures.
* Using the PUBLISH tab in MATLAB, you can publish your code (i.e., .m file) as html, then print (i.e., save) the html file to .pdf. Publishing executes the code and inserts figures and results after their respective code.
Important notes on marking: The markers will attempt to execute the code in your .m file to ensure that it runs correctly and produces the correct output. Your code will be run using the markers pathname to the exam folder. If you have created or are using functions that are not included in the exam folder, please submit these along with your answers so that the markers can add the file to the folder.
1/6
1/6
Background. You have conducted an experiment that aims to examine how accurate conversational facial expressions can communicate the social messages of ‘thinking,’ ‘interested,’ ‘bored,’ and ‘confused’ within each of two different cultures – Western and East Asian.
To test this, you conducted a within culture signal detection task. On each trial, observers viewed one of 4 social messages – ‘thinking,’ ‘interested,’ ‘bored,’ and ‘confused’ – followed by a facial expression, which either correctly matched the label (e.g., ‘thinking’ followed by a facial expression of thinking) or did not (e.g., ‘thinking’ followed by a facial expression of confusion). Observers indicate whether the label and facial expression stimulus match (by responding ‘yes’) or not (by responding ‘no’). Thus, each trial can be categorized as a hit (responding ‘yes’ when the label and facial expression match), a miss (responding ‘no’ when the label and facial expression match), a false alarm (responding ‘yes’ when the label and facial expression do not match), or a correct rejection (responding ‘no’ when the label and facial expression do not match). Using the proportions of hits and false alarms can then be used to measure d-prime, which measures signal detection sensitivity. Fifteen Western observers and 15 East Asian observers each completed the task using facial expressions from their own culture and displayed on same-ethnicity face identities.
Your task is to understand whether these conversational facial expressions can clearly communicate their intended social messages – ‘thinking,’ ‘interested,’ ‘bored,’ and ‘confused’ – within each culture.
Data files. You have been given a folder, which contains the following:
1. facial_expression_models.mat.Thisfilecontainsthestimulusinformationofeach facial expression. Each facial expression is a specific dynamic pattern comprising a set of individual face movements called Action Units (AUs), each of which have 6 values that represent the movement pattern of the AU.
The .mat file contains 2 variables – one for each culture. Each variable is a 4 dimensional matrix (temporal parameters X total number of AUs X number of social messages X number of individual facial expressions), which contains the following stimulus information for each facial expression:
(a) Temporal parameters: (1): AU is present – 1, absent – 0, (2) AU peak amplitude, (3) AU peak latency, (4) AU onset latency, (5), AU offset latency, (6) AU deceleration, (7) AU acceleration. Values for 2 -7 have been normalized to the range 0-1.
(b) AUs: Corresponding AU names can be found in long_names42.mat
(c) Social messages: 1 – thinking, 2 – interested, 3 – bored, and 4 – confused
(d) Individual facial expressions. Location corresponds with the numbers in
model_num (see 3d below)
2. long_names42.mat.AcellarraycontainingthenamesofeachAU.Ordercorresponds to that in facial_expression_models.mat
2/6
2/6
3. EastAsiansubjects(folder).ThisfoldercontainsthebehavioraldataofallEastAsian participants each stored as a separate .mat file. It contains the following variables:
(a) resps. Observer responses where 1 – yes, 2 – no
(b) sti_cat. Intended social messages of the facial expressions where 1 – thinking, 2 –
interested, 3 – bored, and 4 – confused
(c) word_all. Social message label presented on each trial
(d) model_num. The identity number of the facial expression, which corresponds to its
location in facial_expression_models.mat
4. Westernsubjects(folder).As3abovebutforWesternsubjects.
3/6
3/6
QUESTIONS (22 points)
Q1. How do the 4 response types (hits, misses, false alarms, correct rejections) distribute within each culture for each facial expression type? For each of the 15 individual subjects in each culture, compute the number of hits, misses, false alarms, and correct rejections for each of the four facial expression types (thinking, interested, bored, confused) separately. Display the results of each culture as a 15 (subjects) X 4 (response types) color-coded matrix where red indicates a high number and blue indicates a low number.To compare data across cultures, use a 1 X 2 (cultures) subplot. Include all necessary features (e.g., title, axes titles, colorbar). (3 POINTS)
Q2. Compute d-prime for each subject and facial expression type. Using the necessary proportions of hits and false alarms, compute d-prime for each individual subject in each culture for each facial expression type separately. Plot your results as individual points using a 2 x 2 (4 facial expression types) with the data of each culture shown side by side. Include all necessary features (e.g., title, axes titles, colorbar). (3 POINTS)
Q3. Do any subjects show a significantly higher or lower d-prime than the group (i.e., are potential outliers)? For each culture and facial expression type separately, compute the Z- score of each subject’s d-prime and show whether it is significantly above, significantly below, or not significantly different from the mean. Re-plot your data as in Q2 above using asterisks to indicate any significant differences. Save this figure as a .tiff file in a new folder called Results Figures. (3 POINTS)
Q4. Understanding confusions. False alarms occur when subjects report the presence of a signal (here, a social message such as ‘confused’) when it is not present (that is, when the facial expression presented does not match the label). To examine any patterns of confusion, create a matrix that shows for each social message label (y-axis) the number of “yes” responses to each of the different facial expression types (x-axis). If subjects tend to be accurate, the diagonal squares will have high values. Display your results as a color- coded matrix using a different color map from Q1. To compare data across cultures, use a 1 X 2 (cultures) subplot. Include all necessary features (e.g., title, axes titles, colorbar). Save this figure as a .jpg file in the Results Figures folder (3 POINTS)
Q5. Understanding the source of low d-prime values (i). D-prime values can reflect 1 of four response patterns: (a) high hits, low false alarms (facial expressions transmit the intended social message to the subject), (b) low hits, high false alarms (the facial expressions transmit another social message to the subject than the one intended; they are confused with another message), (c) high hits, high false alarms (the facial expressions transmit more than one social message to the subject; they are ambiguous), (d) low hits, low false alarms (the facial expressions do not transmit any social message to the subject). For each facial expression type and culture separately, create a figure that shows how each subject’s responses distribute across these four different response categories. Include all necessary features (e.g., title, axes titles, colorbar). (3 POINTS)
Q6. Understanding the source of d-prime values (ii). A subject’s d-prime value could also be diminished or increased by specific facial expressions that omit or include specific face movements (Action Units – AUs) that are necessary for accurate recognition. To examine this, show how d-prime varies as a function of specific AU presence or absence in the facial expressions. To do this, compute for each facial expression type and culture
4/6
4/6
5/6
separately the d-prime value of each individual facial expression by pooling the responses of the subjects. Then for each individual AU, compute separate average d-prime values for when the AU is present and when it is absent, and compute the difference between them. Plot your results using the y-axis for the AUs and the x-axis for the difference in d-prime values. Using sub-plotting and color-coding as you see fit. Add a white line demarcating the point of zero difference. Include all necessary features (e.g., title, axes titles, colorbar). Finally, for each facial expression type and culture separately, rank the AUs according to their diagnosticity – that is the magnitude of the increase in d-prime when they are present – and show a list of their AU names in the command line (4 POINTS)
Q7. Sharing your data. You need to send all of your data to a collaborator in another lab. Since they do not use MATLAB, they need all the data prepared and saved as .txt files. Prepare and save all of your data as .txt files using a sensible arrangement. (3 POINTS)
END OF EXAM
5/6
Things to do and to avoid when writing code
Please do:
– use code efficiently
– clearly comment your code
– use script cells to structure your code
– produce complete figures (e.g., includes legend, axes labels)
– give new variables meaningful names
– suppress large outputs using ; (unless output is required)
– make your script scalable by using variables than a manual input – e.g., if your for loop
is the length of another (meaningful) variable, use the length of that variable as your loop variable (e.g., for participants = 1:nr_participants)
Please do not:
– use unnecessarily lengthy solutions (e.g., unnecessary loops) – give new variables incomprehensible names
– name new variables with an existing function name
– use unnecessary commands (e.g., ; after first for loop line)
– avoid suppressing large outputs
– manually input values where a (meaningful) variable could be used
6/6
6/6