Psycholinguistics

Back to all tutorials

  • Python program to present an array of pictures and their labels

    In a visual world eye-tracking experiment, sometimes the researcher needs to familiarise participants with the pictures they will see before the eye-tracking procedure to allow the participants to associate each picture with a specific label. On this page I share a Python program for this familiarisation task, based on pygame.

  • Reducing breathing and room noise from speech samples

    On this page I share my Python script that removes breathing and room noise from recordings of my participants’ responses in a speech production experiment.

  • Get audio file durations using Praat

    On this page I share a Praat script that gets audio file durations from a directory containing audio files. The script outputs a .csv file.

  • Convert audio file formats using Python

    I work closely with auditory stimuli. Sometimes I need to convert a large number of audio files from one format to another, usually because different experiment software works better with different audio formats. Here I share my Python script that converts all audio files in a folder from one format to another.

  • Remove track loss trials from visual world eye-tracking data

    One step of cleaning visual world eye-tracking data is to exclude track loss trials. These are trials where for an extensive amount of time, no eye gaze was detected on any objects in the visual display. There are multiple reasons for track loss. For example, the participant may not have paid attention to the visual display, or the eye-tracker may have been ‘drifting’. On this page, I share an R function that removes track loss trials from visual world eye-tracking data.

  • Comparing images from two folders

    Sometimes psychology researchers need to recycle stimuli from old experiments, usually because they have already got some standardized measures for the old stimuli.

    Say for my new experiment, I want to recycle visual stimuli from both Exp A and Exp B. But here’s the problem: some of the stimuli from the two experiments are duplicates, and the duplicates all have different file names. How do I make sure I don’t have duplicates in the recycled stimuli?

    On this page, I share a Python script that compares images from two folders and removes duplicates.

  • Make auditory serial presentation stimuli

    Psycholinguistic research sometimes requires the stimuli to have specific timing. On this page, I share a Praat script that given the stimulus-onset asynchrony (SOA), makes auditory serial presentation stimuli from continuous speech recordings and their textgrids.

  • Extract normalised pitch contour

    On this page I present a Praat script that extracts pitch contour information based on .wav sounds and .Textgrid files.

  • Automated processing of Chinese cloze responses

    The cloze task is widely used in psycholinguistics, mainly to determine the predictability of a word given certain context. In a cloze task, the participant sees incomplete sentences, and is asked to complete the sentences by writing down one or a few words. The predictability, or the cloze probability, of a given word is the proportion of people who fill a gap in a sentence with that specific word. Therefore, processing cloze responses includes counting the frequency of each word appeared in all responses. In many languages, such as English, this task is easy to automate: word boundaries are easy to determine. In languages such as Chinese, where no written word boundaries exist, we need a solution to automate the processing of cloze responses.