COGTOOLBOX CONTENTS

This page describes all of the function in the CogToolbox. For installation instructions and more, please see the main CogToolbox page.

Functions in the CogToolbox were written by Scott Fraundorf, Michael Diaz, Jason Finley, Molly Lewis, Kristen Tooley, Angie Isaacs, Sarah Brown-Schmidt, Tuan Lam, and Laurel Brehm.

Distractor Tasks

AdditionDistractorTaskPresents 2-digit addition problems for a specified duration.
DivisionDistractorTaskPresents 2-digit division problems for a specified duration.
MathDistractorTaskPresents 2-digit addition and subtraction problems (mixed) for a specified duration.
MultiplicationDistractorTaskPresents 2-digit multiplication problems for a specified duration.
SubtractionDistractorTaskPresents 2-digit subtraction problems for a specified duration.

File Reading and Saving

BWtoRGBConverts a black-and-white or grayscale image to RGB format. (This doesn't colorize the image; it just changes the format so you can do color-related operations on it.)
changeFolderUpdates MATLAB's active directory to the directory where the current script is.
csvToStructOpens a comma-separated spreadsheet with a set of named columns and converts it to a struct ... slowly
dualfprintfPrints using fprintf both to the MATLAB Command Window and to a file
getSubjectNumberGets a valid subject number from the experimenter and verifies it hasn't already been used. Optionally, can also rotate subjects through a set of lists.
imageToTextureLoads an image from a file and puts it in a new texture.
loadimageLoads an image from a file and puts it in a new offscreen window. This window can then be quickly copied to another using PTB's Screen("CopyWindow") function
makeValidPathEnsures that a path is a properly formatted folder name, and creates that folder if needed.
openValidFileRepeatedly prompts the user for a filename until a valid file is opened
picturetesterDisplays a folder of pictures one at a time to make sure they look good in your experiment.
save_triangSaves the upper- or lower-triangular part of a matrix
ScreenshotTakes a screenshot of the current experiment display and save it in a file that you can use to demonstrate your experiment.
textFileToCellArrayReads a text file into a cell array, with each line as one entry in the cell array. Optionally, can read just a limited # of lines.

Keyboard and Mouse

allKbNamesDisplay the numerical code corresponding to each keyboard key. For use in programming only.
getKeysWaits for the user to press a key and determines what key was pressed. Unlike PTB functions, this ignores keys already been held down. Optionally, can end after a maximum time has elapsed with no keypress.
Wait4KeyWaits for the user to press one of a particular set of a keys and returns the RT and key pressed.
Wait4KeyTimedSame as Wait4Key, but can force the user to respond with a particular time limit.
Wait4MouseWaits for the user to click one of a particular set of regions on the screen. Returns RT and area clicked.
Wait4MouseTimedSame as Wait4Mouse, but with a time limit.

List Creation

listmakerCreates sets of experimental lists using Latin Square designs. Can include multiple factors and filler trials.
makeLagListCreates a presentation list for an experiment in which the stimuli vary in lag between 1st and 2nd presentation. Can also include non-repeated stimuli.

Math and Matrices

containsDuplicatesTests if any value is repeated more than one in a matrix.
countValueCounts how many times a specified value appears in a matrix.
fitROCFits an ROC curve to some data.
horizshiftShifts elements horizontally within each row of a matrix.
hourminReturns a nicely formatted version of the current time (optionally, with seconds)
InscribeCircleFinds the x, y coordinates for a point inscribed in a given circle.
isevenDetermines whether a given number is an even integer
IsInBoundsDetermines whether a particular point would be within the bounds of a N-dimensional matrix.
isoddDetermines whether a given number is an odd integer.
modrzPerforms modular division (remainder of X divided by Y), but replaces outputsof 0 with Y.
nthPerforms a given function, and returns the Nth element of the result of that function
RaggedCellArrayToMatrixConverts a cell array of vectors, which may be of uneven length, into a matrix.
randorderPuts the elements of a vector in random order.
repelemCreates a vector with each element repeated a certain number of times.
reversescoreReverse score a Likert scale response.
reversevectorPuts the elements of a vector in reverse order

Matlab Demos

CenterOnScreenDemo of how to make your own functions in Matlab.
graphicsdemoDemo of how to do graphics in Psychophysics Toolbox.
InstructionsScreenDemoDemo of how to use the InstructionsScreen function.
matlabbasicsDemo of how to do basic operations and run an experiment in Matlab.
RSVPDemo of stimulus display, in the context of a simple rapid serial visual presentation task.
selfpacedDemo of stimulus display and user response, in the context of a simple self-paced reading task.
sounddemoDemo of how to play & record sound in Psychophysics Toolbox.
visualworldSkeleton of a visual world eye-tracking experiment that provides accurate timing measurements and flicker-free picture display and movement. It has to be filled in with the details of your experiment; it does not run on its own.

Memory Tests and Scoring

freerecallPerforms a free recall test. Allows for a particular minimum and maximum number of responses. Can return the words recalled and RTs, or save them to a file.
FreeRecallScoreScores the data from a free recall test against a list of targets. Allows the user to decide how to score particular intrusions, misspellings, etc.
GetEchoStringCuedT4Prompts the subject to enter a word and returns the word & time taken. Optionally, a cue may be specified for cued recall.
lenientcompareCalculates a score from 0-100 of how similar two strings are; can be used to score recall data that might contain misspellings, etc.
lenientcomparesetUses lenientcompare to compare one string to a SET of possible matches and find the best match.

Perceptual Speed Tests

LetterComparisonTask in which participant must make speeded judgments as to whether sets of consonants are identical or not.
LetterSetCreateUsed internally by LetterComparison only.
PatternComparisonTask in which participant must make speeded judgments as to whether line patterns are identical or not.
PatternCreateUsed internally by PatternComparison only.

Prefab Screens & Tests

AdjustVolumeScreen to allow users to adjust the volume before an experiment.
antisaccadeAntisaccade task in which participants must saccade in the opposite direction of a peripheral cue.
colordemoDemo what various colors look like on this monitor.
doIndividualDifferencesUsed internally by IndividualDifferences.m only
flankerClassic flanker task.
IndividualDifferencesRuns a battery of individual differences measures.
InitExperimentStart an experiment by defining colors and pixel size, and seeding random number generator.
InstructionsScreenDisplays an instruction screen with the specified text. Forces the subject to spend time reading the instructions before they can advance.
shipleyvocab40 item forced-choice vocab test. Auto-scored. Test items not included.
StroopShort Stroop test with 2 blocked conditions: reading words, and then color naming. Automatically paced.
StroopRTLong Stroop test with 2 blocked conditions: naming colors of patches and words. Paced by participants, collects RT.
vocabAdministers a multiple-choice vocabulary task. Test items not included.

Pseudowords

guptaPseudoword repetition task from Gupta (2003)

Questionnaires

BinaryQuestionAsks a question with 2 choices.
LikertAsks a Likert scale question with a varying number of response options.
OpenResponseQuestionAsks a question with free response by participant.
QuestionnaireAsks 2 basic demographics question: hometown & languages spoken.
YesNoQuestionAsks a yes/no question.

Reading

compQAsks a reading comprehension question.
movingwindowPerforms a self-paced moving window reading task on a sentence.
movingwindowQDo a moving window item followed by a comprehension question.
movingwindowTesterTests the screen layout of moving window items by displaying the entire item on the screen at once.
ResidReadingCalculate residual reading times from the output of movingwindow.

Shape Drawing

CenterInRectReturns the coordinates that would center a shape within a given region.
DrawArrowDraws an arrow from one point to another.
DrawLineAnimatedDraw a line incrementally.
FilledPolyDraws a polygon filled with a color.
FilledRectDraws a rectangle filled with a color.
FilledRectWTextDraws a colored rectangle and writes text in it.
FramedRectDraws the outline of a rectangle.
FramedRectWTextDraws the outline of a rectangle and writes text in it.
makeRadialGridDraws circles evenly arranged radially around the center of the screen.
snapToBorderSnaps an image to the border of a larger region.

String and Text Processing

analyzeMarkupCodeReads an HTML-style markup code and determines what code it is.
asPercentConverts a proportion to a percent.
divideSentenceInTwoSplits a string in half so that each half has an equal number of words.
doubleToSingleSpacingConverts double- and triple-spacing to single-spacing.
extractNumbersExtracts all the numbers from a string of text.
extractTextFromLinesGiven a cell array of lines of text, can extract a string that may span multiple lines.
findInCellMatrixSearches a cell array for a particular string, and returns a matrix indicating the location of all the matches.
findUtteranceStartWithin a block of text, finds where a particular sentence started.
getClosingTagDetermines the closing tag for a markup tag.
getNextComplete SentenceReads the next complete sentence from an open file.
initialsCapsOnlyCapitalizes the first letter of every word in a string, and puts everything else in lowercase.
makeTextWidthAdds space or truncates a string to make it fit a particular width.
matchesInStringSetCompares a string (or set of strings) to a cell array of strings and determines where a match is.
num2strLZConverts a number to a string and adds leading zeros to force it to be a particular length.
parseNumberListAllows you to create a vector by describing it in a string, e.g. "1-3,5" -> [1 2 3 5]
randTokensTakes in a string that contains tokens separated by spaces and returns string that randomizes the order of the tokens (e.g., "This is a sentence" could return "is This sentence a")
stripLeadingCharacterRemoves any instances of a particular character at the start of a string.
stripManyStringsRemoves several different substrings from a given string.
stripPunctuationRemoves all punctuation from a string.
stripStringRemoves all cases of a substring from a string.
stripStringNumRemoves a portion of a string defined by its numerical starting and ending point.
strrepManyWithin a string, makes multiple replacements of different substrings with other substrings.
strrepNumReplaces part of a string with something different, defined (unlike strtok) by numerical position.
strtokMultipleCompletely divides a string into multiple tokens, based on a delimiter.
wordCountCounts the number of words in a string.

Text Display

File2ScreenPrints the contents of a text file to the screen.
optimalTextSizeFor a moving window experiment, finds the largest text size that allows every sentence in the experiment to fit on one line.
WriteCenteredWrites text on the screen, centered at a particular point. Now runs onto multiple lines if needed.
WriteLeftWrite left-aligned text on the screen.
WriteLineWrite text on the screen, with word wrap. Includes options for paragraph breaks, double-spacing, and various font effects (e.g. boldface, italics, highlighting certain words in color).
WriteRightWrite right-aligned text on the screen.

Text Input

GetEchoStringDisplayGet text from the user, and display it as they're typing. Unlike PTB-3's GetEchoString, this can preserve what's already on the screen when you call the function.
GetEchoStringFreeResponseAsks a free response question to the participant
inputnumberHas the Matlab user enter a number within a particular minimum and maximum.
inputstringForces the Matlab user to enter a non-empty string.
inputynGets an answer to a yes/no question from the Matlab user.

Window and Monitor Management

CreateOffWinOpen a new offscreen window and set its font and color properties.
GetRefreshReturns your monitor's refresh rate.
monitorsizeCalculates the physical dimensions of your monitor.
pixels2visangleConverts a measure of pixels from center to visual angle.
visangle2pixelsConverts a measure of visual angle to pixels from center.
visangle2widthConverts a measure of visual angle to physical distance.
width2visangleConverts a measure of physical distance to visual angle

Working Memory Tasks

alphabetspanSubject must recall words in alphabetical order.
listeningspanListen to sentences, make true/false judgments, and recall the last word from each sentence.
lspanListen to sentences, make true/false judgments, and recall intervening letters.
minus2spanRecall a set of numbers in order while subtracting 2 from each
ospanJudge the answers to arithmetic equations and recall intervening letters.
readingspanRead sentences aloud, make judgments, and recall the last word from each sentence.
rspanRead sentences aloud, make judgments, and recall intervening letters.
wmbatteryAdministers the alphabetspan, listeningspan, minus2span, and readingspan tasks. Automated scoring.