# Habituation example - familiarization to a category

## About this protocol

This protocol is based on a commonly-given example of [habituation ](/bittsy/goals-and-capabilities/paradigms/visual-fixation-procedure.md)rather than a particular study. The question is whether young infants can recognize that objects of the same kind but with their own unique appearances all belong to the same category. Can infants recognize a pattern in the images that are being presented - that they are all cats, or that they are all dogs? And when an image is presented that does not belong to the category, do they notice that it is different?

As infants recognize the pattern or "rule" in the habituation phase (that all the images are the same kind of animal) we expect them to start to pay less attention to the individual images. This decrement in looking time across trials is the principle of habituation. But what really demonstrates whether they have learned the pattern is whether they show an increase in looking time when presented with something outside of the category, relative to another novel example of the trained category.

Here, we'll habituate infants to either instances of cats or instances of dogs. Later, to both groups, we'll present one new image each of a dog and a cat. We might think that breeds of dogs are more visually dissimilar from each other than breeds of cats, and we might expect that infants who are habituated to cats will have greater success in detecting which test phase image doesn't belong to their learned category. They may be more likely to recognize that the dog presented in the test phase is something different and more interesting than another cat image, while infants who are habituated to dogs may be less likely to recognize the cat in the test phase as particularly novel.

At the very beginning and very end of our experiment, we'll have pre-test and post-test trials. These help us see whether the participant is as actively engaged at the end of the experiment as they were at the beginning. It lets us differentiate children who didn't recognize the category switch but were still paying attention in general (looking longer at the post-test stimulus, even if they didn't look long during the test phase) from children who were simply bored or inattentive (looking very little at the post-test stimulus).

## Starting the protocol

### Starting definitions

We'll begin with our starting definitions. In this protocol, we'll only use one central display, and code looks towards/away that monitor.

```
SIDES ARE {CENTER}
DISPLAYS ARE {CENTER}
```

### Tags

We have a lot of tags to define for this protocol, because we'll be using a lot of image files. We'll have a maximum of twenty images displayed of either cats or dogs in the habituation phase of the experiment, plus one of each for test, and two unrelated images for a pre-test and post-test (these should be consistently *really* interesting to infants - but as a placeholder, we'll use turtles). We'll also show an attention-getter video in between trials.

This file definition section is a very large portion of our protocol. We've abbreviated it below.&#x20;

```
LET attentiongetter = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\baby.mp4"
LET cat1 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\cats\cat1.png"
LET cat2 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\cats\cat2.png"
...
LET cat20 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\cats\cat20.png"
LET cat_test = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\cats\cat21.png"
LET dog1 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\dogs\dog1.png"
LET dog2 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\dogs\dog2.png"
...
LET dog20 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\dogs\dog20.png"
LET dog_test = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\dogs\dog21.png"
LET turtle1 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\turtles\turtle1.png"
LET turtle2 = "C:\Users\ldev\Desktop\BITTSy\HabitExample\stim\turtles\turtle2.png"
```

{% hint style="success" %}
For tags like our cat and dog stimuli, which are named systematically, never type the whole thing out - there's a much easier way! We use Excel or Google Sheets and click and drag to fill cells with components of these lines that will be the same, auto-fill series to make columns of the numbers in increasing order, and a [CONCATENATE function](https://support.google.com/docs/answer/3094123?hl=en) that we then click and drag to apply down the rows to put each of the lines together. Then you can just copy and paste the results into your protocol!
{% endhint %}

### Groups

First, let's define [groups ](/bittsy/creating-protocols/tags/groups.md)for habituation and our pre-test and post-test.&#x20;

```
LET cats = {cat1, cat2, cat3, cat4, cat5, cat6, cat7, cat8, cat9, cat10, cat11, cat12, cat13, cat14, cat15, cat16, cat17, cat18, cat19, cat20}
LET dogs = {dog1, dog2, dog3, dog4, dog5, dog6, dog7, dog8, dog9, dog10, dog11, dog12, dog13, dog14, dog15, dog16, dog17, dog18, dog19, dog20}
LET prepost = {turtle1, turtle2}
```

We'll have two conditions that participants are randomly assigned to - they will either be habituated to the group `cats`, or the group `dogs`. After they are habituated to that group, they will see the images `dog_test` and `cat_test`. In this protocol, we'll have infants always see the image that *wasn't* the category they were habituated to as the first image of the test phase, then the other example of the habituated category on their second test trial. Let's create groups that list what they'll see in each of these possible conditions, in order of presentation.

```
LET habitcats = {cats, dog_test, cat_test}
LET habitdogs = {dogs, cat_test, dog_test}
```

Note that these two groups, `habitcats` and `habitdogs`, contain first a group, then two tags that refer directly to files. We'll need to remember this as we use these groups for stimulus selection and presentation later. In the habituation phase, when we're pulling items from the group cats or dogs, we'll need a [choose statement](/bittsy/creating-protocols/selection-and-randomization.md#choose-statements-and-dynamic-tags) to pick a tag from the group before we present it onscreen. But in the test phase, we can display these tags directly - they refer to particular files, rather than a group of files.

Lastly, so that we can randomly select a condition for the participant at the start of a study session, we'll make a group that contains both.

```
LET conditions = {habitdogs, habitcats}
```

### Experiment settings

Some optional experiment settings may be useful here. This is a live-coded experiment, so we might want to decide what [minimum length of look](/bittsy/creating-protocols/optional-experiment-settings.md#minimum-look-lengths) "counts" for looking time calculations. We also might want to change [key assignments](/bittsy/creating-protocols/optional-experiment-settings.md#key-assignments) to something other than C for `CENTER` and W for `AWAY`, or the [background color](/bittsy/creating-protocols/optional-experiment-settings.md#background-color).

```
BACKGROUND WHITE
DEFINE COMPLETELOOKAWAY 100
DEFINE COMPLETELOOK 100
```

We also have [habituation settings](/bittsy/creating-protocols/habituation/setting-criteria.md) to specify for this study. These should be decided based on previous studies, or some piloting in your lab. Here are the settings we chose for this example.

```
DEFINE WINDOWSIZE 2
DEFINE WINDOWOVERLAP NO
DEFINE CRITERIONREDUCTION 0.65
DEFINE BASISCHOSEN LONGEST
DEFINE WINDOWTYPE SLIDING
```

## STEPS for execution

### Pre-test

Now, our experiment begins. First, we'll have a pre-test phase, where we'll show something unrelated to our habituation and test images. Here we're using two similar images for pre- and post-test and will select them randomly from the `prepost` group, but it is common to use the same image for both.

```
STEP 1
Phase Pretrial Start

STEP 2
VIDEO CENTER attentiongetter LOOP
UNTIL KEY C

STEP 3
VIDEO CENTER OFF
LET prepost1 = (TAKE prepost RANDOM)
Trial Start

STEP 4
IMAGE CENTER prepost1
UNTIL SINGLELOOKAWAY prepost1 GREATERTHAN 2000
UNTIL TIME 20000

STEP 5
Trial End
IMAGE CENTER OFF

STEP 6
Phase End
```

Like all other trials in our study, we'll play an attention-getter video beforehand, and only start the trial once the experimenter indicates the child is looking at the screen. Then, the experimenter will continue to code the child's looks toward and away from the image being displayed. If the child has a single look away from the screen that lasts at least 2 seconds, or if the image has been displayed for a maximum length of 20 seconds, the trial will end.

### Habituation

Next comes our habituation phase. First, we will need to assign this participant to one of our study conditions - habituating to cats, or habituating to dogs. We'll choose this randomly.&#x20;

```
STEP 7
Phase Habituation Start
LET condition = (FROM conditions RANDOM)
```

Recall that this `condition` we pick (either `habitcats` or `habitdogs`) contains three tags:

1. the group of tags to display in habituation
2. a tag referring to the test item from the novel category
3. a tag referring to the test item from the familiarized category

We need to refer to the first one in the habituation phase, so in this same step, let's pull it out of our chosen `condition` with another [choose statement](/bittsy/creating-protocols/selection-and-randomization.md).

```
LET habit_category = (TAKE condition FIRST)
```

Now, we'll display another attention-getter and a habituation trial.

```
STEP 8
VIDEO CENTER attentiongetter LOOP
UNTIL KEY C

STEP 9
VIDEO CENTER OFF
Trial Start

STEP 10
LET habit_item = (TAKE habit_category RANDOM)
IMAGE CENTER habit_item
UNTIL SINGLELOOKAWAY habit_item GREATERTHAN 2000
UNTIL TIME 20000

STEP 11
Trial End
IMAGE CENTER OFF
```

We want to keep running habituation trials until the child either [meets our habituation criterion](/bittsy/creating-protocols/habituation/meeting-a-criterion.md), or reaches a maximum number of trials. We'll do this by [looping ](/bittsy/creating-protocols/loops.md)back to `STEP 8` and repeating this section until one of those conditions are met. When one of them is, our habituation phase is over.

```
STEP 12
LOOP STEP 8
UNTIL 19 TIMES
UNTIL CRITERIONMET

STEP 13
Phase End
```

### Test phase

Now for our test phase. We'll start it off, and keep having attention-getter videos in between trials.

```
STEP 14
Phase Test Start

STEP 15
VIDEO CENTER attentiongetter LOOP
UNTIL KEY C

STEP 16
VIDEO CENTER OFF
Trial Start
```

What goes in our test trial? Recall that the group called `condition` that we chose earlier for this participant has two remaining items in it, after we selected the habituation group from it with our earlier [TAKE statement](/bittsy/creating-protocols/selection-and-randomization.md#selection-without-replacement). They are our two test items, in the order we want them presented. We can use another `TAKE` statement to remove them in order and display them.

```
STEP 17
LET test_item = (TAKE condition FIRST)
IMAGE CENTER test_item
UNTIL TIME 20000
UNTIL SINGLELOOKAWAY test_item GREATERTHAN 2000

STEP 18
Trial End
IMAGE CENTER OFF
```

There are two test trials - so let's loop to repeat this section to play the second one.

```
STEP 19
LOOP STEP 15
UNTIL 1 TIMES

STEP 20
Phase End
```

### Post-test

Lastly, the post-test. This is identical to our pre-test phase earlier, so we can specify it in our protocol the same way. We just copy-pasted it and changed the step numbers, phase name, and name of the [dynamic tag](/bittsy/creating-protocols/tags/dynamic-tags.md).

```
STEP 21
Phase Posttest Start

STEP 22
VIDEO CENTER attentiongetter LOOP
UNTIL KEY C

STEP 23
VIDEO CENTER OFF
LET prepost2 = (TAKE prepost RANDOM)
Trial Start

STEP 24
IMAGE CENTER prepost2
UNTIL SINGLELOOKAWAY prepost2 GREATERTHAN 2000
UNTIL TIME 20000

STEP 25
Trial End
IMAGE CENTER OFF

STEP 26
Phase End
```

And the experiment is done! See the [resources ](/bittsy/support/resources.md#example-protocols)page for a full copy of this protocol.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ldevumd.gitbook.io/bittsy/creating-protocols/example-protocols/more-complex-habituation-category-learning-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
