MOLE Modifiable Language Experiments

Monthly Archives: October 2012

You are browsing the site archives by month.

runTrialBlock Instructions

Description

This function takes as input a cell array specifying a block of trials (includes drawing the test stimuli to the screen, playing the audio files, etc.) and allows the user to connect the eyetracker, specify trial order, and specify the type of feedback to be given to subjects.

General

This function takes a specified list of trials (pictures to be shown to and sounds to be played for the subject) and runs through them in a specified order.

trialList and windowPtr must be specified so that the function knows which trial list to display on which screen.

The optional arguments ET, order, feedback, folder, and pictureCoords can be altered depending on the needs of the experiment.
ET turns the eyetracker on,
order specifies whether the trials are presented sequentially or randomly,
feedback specifies which type of feedback to give the subjects (no feedback for artificial lexicon testing, feedback for artificial lexicon learning, and click until correct most likely for real words),
folder specifies where to access the stimuli if they are in a different folder from the one being worked out of, and
pictureCoords allows the experimenter to place the image stimuli in any coordinates desired.

This function will return percent correct (correctness) from the trials to the main program so that the value can be easily used to evaluate performance.

Usage

[correctness] = runTrialBlock(trialList,windowPtr,ET,order,feedback,folder,pictureCoords)

Ex.  runTrialBlock(‘ExpATrials’,5,ETstruct,’RANDOM’,’FEEDBACK’,’ExpA/’,[10 20 30 50; 50 20 70 50; 10 40 30 70; 50 40 70 70]);

OR (this is the same function as the one listed above, only using the defined variable names listed below in the Arguments section):

Ex.   runTrialBlock(arg1,arg2,arg3,arg4,arg5,arg6,arg7)

Arguments

trialList: String value.  The name of the list of trials to be loaded.
Ex.  arg1 = ‘ExpATrials’

windowPtr:  Numerical value specifying the window for the stimuli to be printed to.
Ex.  arg2 = 5

ET:  Optionally skip connecting the eyetracker via the numerical input 0.  Currently, there is no default for connecting the eyetracker.  Either the shell code specifies a variable containing the eyetracker struct, or the user must specify 0 for no eyetracking.
Ex.  arg3 = ETstruct

order:  Optional string value that can specify the trial order to be random via the command ‘RANDOM’.  Will default to ‘SEQUENTIAL’.  Inputs are case sensitive, and must be in all caps.
Ex.  arg4 = ‘RANDOM’

feedback:  Optional string value that lets the user specify the type of feedback desired.  Can choose between ‘NOFEEDBACK’, ‘FEEDBACK’, or ‘CLICKTILLRIGHT’.  Will default to delivering no feedback.  Inputs are case sensitive, and must be in all caps.
Ex.  arg5 = ‘FEEDBACK’

folder:  String value.  Optionally specify the name of the folder containing the stimuli, with a forward slash ( / ) after the name.  It will default to the current folder being worked out of.
Ex.  arg6 = ‘ExpA/’

pictureCoords:  Optional numerical values that allow picture coordinates to be specified.  Each vector will consist of 4 numbers that denote the locations of the upper left and lower right corners (x,y coordinates) of the image.  Can specify the coordinates of multiple pictures by creating new rows for each set of coordinates (maximum number of pictures on screen at a time is 4).
Ex.  arg7 = [10 20 30 50; 50 20 70 50; 10 40 30 70; 50 40 70 70]

Notes

All arguments that require string values must be entered surrounded by single quotation marks (‘ ‘).

All inputs are case sensitive.

The (x,y) coordinate system in MATLAB is different from the normal coordinate system.  The (0,0) point is in the upper left corner, and infinity in both directions is in the lower right corner, so the y values must always be larger than the x values.

To specify new rows for the image vectors, use a semi-colon, not the return key.

All vectors must be surrounded by brackets ( [ ] ).

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

runQuestions Instructions

Description

This function is a frame function for inputdlg that prompts the subject to answer specified questions, and allows the user to store the subject’s answers with his/her experimental data.

General

This function adds onto the inputdlg function by allowing the information entered into the questionnaire to be appended to the subject’s data file.  This function takes a text file containing question info, length of response lines, and default answers and loads it into a questionnaire format for subjects to enter responses.

See help inputdlg for more information.

Usage

runQuestions(instrfile,expt)

Ex. runQuestions(‘Questionnaire’,’ShapesExpQ’)

Arguments

instrfile: String input that specifies the name of the file containing the questions.
Ex. ‘Questionnaire’

expt: String input that specifies the name of the file to append the questionnaire data to.  This should be a file that is named for the experiment that the questionnaire follows/asks about.
Ex. ‘ShapesExpQ’

Notes

All string inputs must be surrounded by single quotation marks ( ‘ ‘ ).

When specifying the length of the answer lines, make sure to include the length of the question as well, since if it is too short, the program will wrap your answer text to the next line.

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

PDF
RTF

runNamingBlock Instructions

Description

This function will run a block of naming trials (draws the test stimulus to the screen in a single specified location) and allows the user to specify trial order, as well as record the response given by the child via typing in the appropriate characters.

General

This function allows the experimenter to type in the child’s response while an image is displayed on the screen.  It also allows the experimenter to view the response and fix the answer (if necessary) before it is officially recorded.

pictureList and windowPtr must be specified so that the function knows which pictures to print to the specified screen.

The optional arguments order, feedback, folder, and pictureCoords can be altered depending on the needs of the experiment.
order specifies whether the trials are presently sequentially or randomly,
folder specifies where to access the stimuli if they are in a different folder from the one being worked out of, and
pictureCoords allows the experimenter to place the image stimulus in any single location desired.

Usage

runNamingBlock(pictureList,windowPtr,order,folder,pictureCoords)

Ex.  runNamingBlock(‘NameExpTrials’,5,’RANDOM’,’NameExp/’,[10 20 30 50]);

OR (this is the same function as the one listed above, only using the defined variable names listed below in the Arguments section):

Ex.  runNamingBlock(arg1,arg2,arg3,arg4,arg5)

Arguments

pictureList:  String value that specifies the text file with the list of image file names (NOT the pictures themselves).
Ex.  arg1 = ‘NameExpTrials’

windowPtr:  Numerical value that specifies which screen the stimuli are going to be drawn to.
Ex.  arg2 = 5

order:  Optional string value that allows the user to specify the order of trials to be random (‘RANDOM’).  Defaults to sequential (‘SEQUENTIAL’).
Ex.  arg3 = ‘RANDOM’

folder:  Optional string value that specifies the folder where the stimuli are located.  If this is not specified, it will default to the current folder being worked out of.
Ex.  arg4 = ‘NameExp/’

pictureCoords:  Numerical values in a 4 element vector that specify the coordinates for the image stimuli.
Ex.  arg5 = [10 20 30 50]

Notes

All string input argument must be surrounded by single quotation marks ( ‘ ‘ ).

All string inputs are case sensitive.

All vectors must be surrounded by brackets ( [ ] ).

When specifying a folder to be worked out of, the name of the folder must be followed by a forward slash ( / ).

The (x,y) coordinate system in MATLAB is different from the normal coordinate system.  The (0,0) point is in the upper left corner, and infinity in both directions is in the lower right corner, so the y values must always be larger than the x values.

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

PDF
RTF

readTrialList Instructions

Description

This function opens a specified file and formats it into an array of n rows by 14 (or more) columns that can easily be read by MATLAB.

General

This function will take the name of a file as an argument, and open the file into an array, labeled as “trialArray” in the format specified by the user.  If no format is specified, the function will default to 1 column of numbers, and 13 columns of text.

trialArray is organized so that each column of the originally opened data file is its own array, which can be indexed via curly braces {}.  To access a particular column of data, the user would enter trialArray{n}, where n specifies the number of the column desired.  For example, the user would enter trialArray{1} to access the first column.

If a particular cell in the array is desired, an additional set of curly braces can be used to index a particular row in the specified column.  For example, the user would enter trialArray{1}{4} to access the fourth row in the first column.

Usage

readTrialList(trialsfile, moreFormatting)

Ex.  readTrialList(‘ExpATrials’,’%s%s%s’)

OR (this is the same function as the one listed above, only using the defined variable names listed below in the Arguments section):

Ex.   readTrialList(arg1,arg2)

Arguments

trialsfile: The name of the file to be loaded.
Ex.  arg1 = ‘ExpATrials’

moreFormatting: Optional character string denoting additional columns (e.g. ‘%s%s%s’ would be three additional columns of strings).
Ex.  arg2 = ‘%s%s%s’

Notes

This function cannot be formatted to have fewer than 14 columns via the moreFormatting argument.  If the user wants to format with fewer columns, the function itself would have to be altered (see program coding comments).

‘CommentStyle’,’%’ applies MATLAB’s default commenting system to the data file (e.g. “%This is a comment!” will not be read as part of the code when added to any information from this data file), but ONLY if the comment is added at the end of the set of columns.  This will NOT work if the comment is inserted in the middle of the specified number of columns.

All string inputs are case sensitive.

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

qqq Instructions

Description

This function shuts down all of the extensions that have been opened during the course of the experiment.

General

This function will close the PsychToolbox screen (where the stimuli were presented), PsychPortAudio (used to play the audio stimuli), any files that were opened in the course of the experiment (trial lists, recorded data, etc), and will stop the eyetracker from recording and subsequently shut it down.

Usage

qqq

Arguments

There are no arguments that need to be fed to this function.

Notes

All programs should have these close functions built into them, but this function is a catch-all in case the experimenter is prone to forgetting to shut down some extensions.

Because the function is called qqq, it is important to remember not to use qqq as a variable name in the code!

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

PDF
RTF


printInstructions Instructions

Description

This function takes a text file of pre-written instructions and prints them to the screen so the subject can see them.

General

This function will take the specified text file (instrfile) and will print it to the specified screen/window (winPtr).  The instructions themselves will be loaded into an array, and then lines of that array will be printed to the screen, but will not be shown to subjects until the screen is flipped.

You can specify a key to be pressed (or the mouse to be clicked) to move on after reading the instructions via the ‘key‘ argument.  The current default for key press is space bar.

This function also allows for text display characteristics to be altered if the experimenter desires.  The text height (size), text color, and background color of the screen can all be altered via the 3-element vector that specifies colors.  The current defaults, respectively, are 20, pink, and white.

Usage

printInstructions(instrfile,winPtr,[key],[textHeight],[textColor],[bgColor])

Ex.  printInstructions(‘ExpAInstructions’,5,’mouse’,50,[0 206 209],[240 128 128])

OR (this is the same function as the one listed above, only using the defined variable names listed below in the Arguments section):

Ex.  printInstructions(arg1,arg2,arg3,arg4,arg5,arg6)

Arguments

instrfile:  The name of the text file of instructions to be loaded.
Ex.  arg1 = ‘ExpAInstructions’

winPtr:  Numerical value designating which window the instructions are going to be printed to.
Ex.  arg2 = 5

key:  Specifies which key is to be pressed in order to advance from the instructions.  The default is SPACE (the spacebar key).  Can also be specified as ‘mouse‘ to advance with a mouse click, as opposed to a key press.
Ex.  arg3 = ‘mouse’
Ex.  arg3 = ‘a’

textHeight:  Numerical value that designates the size of the text to be printed to the screen.  If no value is entered, textHeight defaults to 20.
Ex.  arg4 = 50

textColor:  Numerical 3-element vector that designates the color of the instructions text to be printed to the screen.  If no value is entered, textColor defaults to pink [255 0 255].
Ex.  arg5 = [0 206 209]
Specifies the text color to be dark turquoise.

bgColor:  Numerical 3-element vector that designates the color of the background screen for the instructions to be printed on.  If no value is entered, bgColor defaults to white [255 255 255].
Ex. arg6 = [240 128 128]
Specifies the background color to be light coral.

Notes

This function works only with PsychToolbox installed.

This function will not wrap text; carriage returns must be present in instrfile.

All strings fed to the function must be entered surrounded by single quotation marks ( ‘ ‘ ).

Google can be used to find 3-element vector color codes (RGB codes) easily.

All string inputs are case sensitive.

All vectors must be surrounded by brackets ( [ ] ).

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

PDF
RTF

moveAndTalk Instructions

Description

This function moves a character through a specified set of actions on the screen while a sound file plays.

General

This function is used to create a scene stimulus in which a character is moved around the screen in a specified set of actions while a corresponding sound file plays (e.g. what the character is saying).

For this function, order, shape, wordsound, action, and window must all be specified.
order specifies whether to display the images in sequential or random order,
shape specifies the image for the character,
wordsound specifies the sound file to be played,
action specifies which movements the character will make, and
window specifies where to display the stimuli.

folder and background can be left blank, and the function will fill in default values for these arguments.
folder specifies where MATLAB should pull the stimuli from, and
background specifies an image for the background should the user desire one.

Usage

moveAndTalk(order,shape,wordsound,action,window,folder,background)

Ex.  moveAndTalk(‘SEQUENTIAL’,norming{2},norming{3},norming{4},5,’CatExp/’,’NormingBG.jpg’)

OR (this is the same function as the one listed above, only using the defined variable names listed below in the Arguments section):

Ex.  moveAndTalk(arg1,arg2,arg3,arg4,arg5,arg6,arg7)

Arguments

order:  String value that specifies the order of actions to be displayed.  Can choose from ‘RANDOM’ or ‘SEQUENTIAL’ (there is no default).
Ex.  arg1 = ‘SEQUENTIAL’

shape:  1xn cell array of string values that specifies the .jpg image file of the character to be moved around the screen for each trial.
Ex.  arg2 = norming{2}

wordsound:  1xn cell array of string values that specifies the .wav file to be played while the image is moved around the screen for each trial.
Ex.  arg3 = norming{3}

action:  1xn cell array of string values that specifies the action for the character to do for each trial.  Currently can choose from ‘vbounce’, ‘lefthop’, ‘righthop’ (all bouncing motions), ‘leftstroll’, ‘rightstroll’ (walk-in moves), ‘leftpeep’, ‘rightpeep’,(peeping from behind L or R tree), ‘uppeep’ (peeping up from beneath the grass, center of screen), and ‘distractor’, which is a non-test trial action.
Ex.  arg4 = norming{4}

window:  Numerical value that specifies the window that the stimuli should be drawn to (window pointer).
Ex.  arg5 = wptr

folder:  String value that specifies the folder containing the image and sound stimuli.  If this is not specified, it defaults to the current folder being worked out of.
Ex.  arg6 = ‘CatExp/’

background:  String value that specifies the background of the scene.  Currently defaults to 0 (no background), but if it is specified, will read the background from the folder specified in the folder argument.
Ex. arg7 = ‘CatBG.jpg’

Notes

The specifications for arguments 2, 3, and 4 (shape, wordsound, action) are all contained in separate columns in the text file that the shell script loads.  Therefore, they are specified in the function by indexing the column within the cell array as shown with curly brackets ( {} ) above.

All arguments that are strings must be surrounded by single quotation marks ( ‘ ‘ ).

The shape argument should refer to a .jpg file that is 200×200 pixels in size, to avoid strange appearances.

The user could add their own hard code in the function (adding on to the large switch-case statement) to program for different actions.

All string inputs are case sensitive.

When specifying a folder to be worked out of, the name of the folder must be followed by a forward slash ( / ).

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).

PDF
RTF

fancywavread Instructions

Description

This function adds on to the built-in MATLAB function wavread by converting the input sound file to the correct format  (2 channel, stereo sound) instead of crashing the program.

General

This function will read in the sound file specified and will transform the direction of the vector if it is in a format that PsychPortAudio is unfamiliar with.  This function also allows for the optional argument ‘side’ to be specified, which will play the sound to one specified ear (one side of the headphones).

If the optional argument is specified, the function is able to format a stereo sound to act as a mono sound by overwriting one sound channel with no sound.

The function will return your correctly formatted sound, along with the sampling rate of the sound.

Usage

fancywavread(soundfile,side)

Ex. fancywavread(‘ExpASound’)
Ex. fancywavread(‘ExpASound’,’L’)

Arguments

soundfile:  String input that specifies the name of the sound file (.wav format) to be played.
Ex.  ‘ExpASound’

side:  Optional string input that specifies which ear the mono sound should be played to.  Input takes the form of either ‘L’ for left, or ‘R’ for right.
Ex. ‘L’

Notes

All string inputs must be surrounded by single quotation marks ( ‘ ‘ ).

All string inputs are case sensitive.

If you feed this function a stereo sound but then specify the ‘side’ argument, the non-specified channel will be overwritten with blanksound to create a mono sound.  This means you do not have to feed this function a mono sound if you want it to only be played to one side of the head.

 

If you would like to download this read-me to your computer, you can do so below (right-click and ‘Save As’).
PDF
RTF

 

Welcome to MOLE!

This is the Modifiansflogoble Language Experiment database (abbreviated MOLE). Here you will find some of the most-used MATLAB functions for the protocols run in the Language and Sound Recognition Lab, under the direction of Dr. Sarah Creel. This material is based upon work supported by the National Science Foundation under Grant Number 123-0003. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the Professor Creel and her lab, and do not necessarily reflect the views of the National Science Foundation.

Our lab is a developmental lab, with focus on 3-5 year old preschoolers’ word learning. As many developmental researchers know, it is simple to ask an adult to perform hundreds of repetitive trials in front of a computer screen, but it is no easy task to ask children to do the same thing (while still obtaining reliable data). As a result, our experiments are made more engaging for a younger audience (e.g. cartoon characters perform actions on the screen while a voice identifies the character). Because we also collect eyetracking data on our preschool subjects, these experiments must be coded in MATLAB for precise timing data. The goal of this website is to make our commonly-used MATLAB functions available to other researchers, so that they may build off of what we have already created for their own experimental procedures.

On this website, you will find several things of use to you, described below.

  • Read Me’s: Below this post are several other posts that function as read-me’s for the eight functions on this website.  Each read-me walks you through how the function works by detailing the input arguments and by providing examples. If you would like to download a copy to your computer, there are links at the bottom of each post where you may do this.
  • Demo Walkthroughs: On the top navigation bar, you will find a page named Demo Walkthroughs. This page has step-by-step instructions that will guide you through downloading and using these functions on your own computer. It will provide you with a complete list of the files that you will need to run each function’s demo, and will generally serve as a troubleshooting guide for running the demos.
  • Demo Materials: If you hover over the Demo Walkthroughs link, a drop down menu labeled Demo Materials will appear. This page is where you can download the zip file containing all of the materials for the demos (basic functions with internal comments, text files, stimuli, etc).

Please note that comments are disabled on all pages. If you need help beyond what the website provides, there is a Help page listed on the top bar with information to get in contact with Sarah Creel.

 

We hope you find this website useful.  Happy experimenting!

Disclaimer: These functions were created in MATLAB version 2007-2008 on a Mac, for use with Macs. It is possible that problems arise when trying to run some of these functions on a PC or with newer versions of MATLAB.