> For the complete documentation index, see [llms.txt](https://help.imotions.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.imotions.com/lab/study-setup-and-design/imotions-setup/using-a-test-plan-for-study-design.md).

# Using a test plan for study design

Build a study from a file that gives every respondent their own stimulus order, for counterbalanced, blocked and randomized designs.

A test plan is a text file that lists the respondents in a study and the exact order in which each of them sees the stimuli. Use one when the order has to be controlled per respondent in a way the Study Builder's own randomization cannot express. iMotions Lab builds the complete study, respondents included, from the file when you import it.

## Designs a test plan can implement

| Design                | What the test plan does                                                                                                                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Monadic               | Exposes each respondent to one stimulus out of the set in the study.                                                                                                                                                                |
| Completely randomized | Gives each respondent a different random order of all stimuli.                                                                                                                                                                      |
| Randomized block      | Splits the stimuli into blocks and gives each respondent the blocks in a different order, with the stimuli inside a block kept together. This is not the same as a randomized block design in statistics, which groups respondents. |
| Cell                  | Splits the respondents into cells that receive a fixed order each, for example product A before product B in one cell and the reverse in the other.                                                                                 |

## Creating and importing a test plan

1. Write the test plan file. The first line names the respondent columns, and each line after that describes one respondent and their stimulus order. See [The test plan file](#the-test-plan-file). Save it as `.csv` or `.txt`, and close the spreadsheet program before continuing.
2. Create a folder named `Stimuli` next to the file and put every image, video, audio and survey file the plan references into it.

   ```
   My study\
     My Test Plan.csv
     Stimuli\
       A_STIM1.JPG
       A_STIM2.JPG
       B_STIM1.JPG
       B_STIM2.JPG
   ```
3. In iMotions Lab, create a new study and choose **Test Plan**.
4. Click **Browse** and select the test plan file. iMotions Lab checks the file straight away and shows any problem in red under the file name. See [Import errors](#import-errors).
5. Under **Test plan type**, choose **Desktop** or **Remote Data Collection**, and click **Next**. For a desktop study, set up the respondent screen on the next page and click **Next** again.
6. Check the preview page. It lists the stimuli and the respondents with their name, city, gender, age, group and background variables. Select a respondent to see their stimuli in the order they will be shown. Anything that does not match what you wrote is a formatting problem in the file, not a setting you can correct here.
7. Click **Next**, select the sensors for the study, name the study and click **Create study**.

{% hint style="warning" %}
The `Stimuli` folder has to exist and **must not be empty**, even when the plan references only websites or screen recordings and has no file stimuli at all. Put any small image in it to satisfy the check.
{% endhint %}

{% hint style="danger" %}
Respondents cannot be added to a test plan study after it has been created. Include every respondent you will need in the file before you import it.
{% endhint %}

## The test plan file

The first line of the file names the respondent columns. Every line after it is one respondent: the respondent values first, then the stimuli in exposure order.

```csv
NAME;GENDER;AGE;CITY
Michael;M;22;COP;A_STIM1.JPG;A_STIM2.JPG;B_STIM1.JPG;B_STIM2.JPG
Eric;M;43;COP;B_STIM2.JPG;B_STIM1.JPG;A_STIM2.JPG;A_STIM1.JPG
John;M;63;COP;A_STIM1.JPG;A_STIM2.JPG;B_STIM1.JPG;B_STIM2.JPG
Brad;M;24;COP;B_STIM2.JPG;B_STIM1.JPG;A_STIM1.JPG;A_STIM2.JPG
```

Values are separated by a semicolon or a comma. Use the same one throughout the file. In a spreadsheet program the four respondent columns are the first four columns, the stimuli follow from the fifth column on, and the sheet is saved as CSV. If any name contains letters outside the English alphabet, such as `Søren`, save the file as UTF-8, for example with **CSV UTF-8** in Excel. Otherwise those letters are not read correctly and the import fails.

A line that starts with `#` is a comment and is ignored, so you can use comments to document the plan, for example to label the cells of a design.

```csv
NAME;GENDER;AGE;CITY
# Cell 1: product A before product B
Michael;M;22;COP;A_STIM1.JPG;B_STIM1.JPG
# Cell 2: product B before product A
Eric;M;43;COP;B_STIM1.JPG;A_STIM1.JPG
```

### Respondent columns

The first four columns are mandatory and have to appear in this order.

| Column             | Required | Value                                                                                                                                                                                             |
| ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NAME`             | Yes      | Letters, digits and spaces, for example `RESPONDENT 1` or `Michael`. Punctuation such as `-`, `.` and `@` is rejected.                                                                            |
| `GENDER`           | Yes      | `F`, `M` or `O`. Lower case is accepted.                                                                                                                                                          |
| `AGE`              | Yes      | A whole number from 1 to 99, or an age range written as two numbers from 10 to 99 separated by a hyphen, such as `25-34`. `0` is rejected.                                                        |
| `CITY`             | Yes      | A city name or code, such as `NEW YORK` or `COP`.                                                                                                                                                 |
| `GROUP`            | No       | Fifth column. Assigns the respondent to a respondent group, which is shown on the import page and travels with the respondent into analysis and exports. Letters and digits only, without spaces. |
| Any further column | No       | A background variable, such as `Profession` or `IncomeGroup`, with letters, digits and spaces as values. You can select respondents by background variable when you set up an analysis.           |

Background variable names have to be unique within the file and cannot reuse the reserved names `NAME`, `GENDER`, `AGE`, `CITY` and `GROUP`.

```csv
NAME;GENDER;AGE;CITY;GROUP;PROFESSION
RESPONDENT 1;M;26;MOSCOW;Control;SelfEmployed;A_STIM1.JPG;A_STIM2.JPG
RESPONDENT 2;F;27;MOSCOW;Exposed;HomeMaker;A_STIM2.JPG;A_STIM1.JPG
```

### Stimulus columns

Everything after the respondent columns is the stimulus sequence for that respondent, in the order it will be shown. Each entry is either the file name of a file in the `Stimuli` folder, with its extension, or the name of a website, screen recording or scene recording defined in a header line at the top of the file.

* A stimulus can be referenced only once per respondent.
* Every respondent needs at least one stimulus.
* Write names with the same capitalization as the file in the `Stimuli` folder or the name in the header line.

### Exposure time and manual advance

Two optional settings can be attached to a stimulus, in braces after its name and separated by a space.

```csv
NAME;GENDER;AGE;CITY
Ronald;M;22;COP;1_stimuli.png{ExposureTime=119.5 ManualAdvance=true};2_stimuli.png{ManualAdvance=true};3_stimuli.png{ExposureTime=10}
Jimmy;M;63;COP;3_stimuli.png;1_stimuli.png;2_stimuli.png
Gerald;M;24;COP;2_stimuli.png;3_stimuli.png;1_stimuli.png
```

| Setting         | Value                                                       | Effect                                                                                                                                                                  |
| --------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ExposureTime`  | A positive number of seconds, with a full stop for decimals | Overrides the default exposure time for the stimulus.                                                                                                                   |
| `ManualAdvance` | `true` or `false`                                           | Turns on manual advance for the stimulus, so the moderator moves on to the next one. The maximum exposure time is then 30 s unless `ExposureTime` sets a different one. |

Write the setting names exactly as shown. A misspelled setting, or a value such as `119,5`, is ignored without an error, and the stimulus keeps its default.

These settings belong to the stimulus and apply everywhere it appears, not to one respondent. For an image, video or survey, define them the first time the stimulus appears in the file; settings on later lines are ignored. For a website, screen recording or scene recording, write the same settings on every reference, because the last reference in the file decides them.

## Websites, screen recordings and scene recordings

Websites, screen recordings and scene recordings have no file in the `Stimuli` folder. Define each one in a header line above the respondent column line, then reference it by name in the respondent lines.

Two separators in a row mean the field between them is empty, which is how an optional icon is left out. An icon path can be a full path or a path relative to the `Stimuli` folder.

### Websites

```
WebRecording;<name>;<icon path>;<url>
```

| Field         | Required | Value                                                           |
| ------------- | -------- | --------------------------------------------------------------- |
| `<name>`      | Yes      | The name used to reference the website in the respondent lines. |
| `<icon path>` | No       | Path to an image used as the stimulus icon in iMotions Lab.     |
| `<url>`       | Yes      | The address to open.                                            |

```csv
WebRecording;GooglePage;;http://google.com
WebRecording;YahooPage;;http://yahoo.com
WebRecording;BingPage;;http://bing.com
NAME;GENDER;AGE;CITY
RESPONDENT1;M;26;PETERSBURG;GooglePage;YahooPage;BingPage
RESPONDENT2;M;26;PETERSBURG;YahooPage;GooglePage;BingPage
RESPONDENT3;M;26;PETERSBURG;BingPage;YahooPage;GooglePage
```

### Screen recordings

A screen recording either records whatever is on the screen, or launches a program first and records the screen while the respondent uses it.

```
ScreenRecording;<name>;<icon path>;<program path>;<program argument>;RecordScreen=<true|false>;RecordSensorData=<true|false>
```

| Field                | Required | Value                                                                                                                    |
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| `<name>`             | Yes      | The name used to reference the screen recording in the respondent lines.                                                 |
| `<icon path>`        | No       | Path to an image used as the stimulus icon in iMotions Lab.                                                              |
| `<program path>`     | No       | Path to a program that is launched when the stimulus starts. Leave it empty to record whatever is already on the screen. |
| `<program argument>` | No       | An argument passed to the program, such as a file path or an address.                                                    |
| `RecordScreen`       | No       | `False` records no screen video for this stimulus. Leave the field out to record it.                                     |
| `RecordSensorData`   | No       | `False` records no sensor data for this stimulus. Leave the field out to record it.                                      |

Recording the screen with nothing launched:

```csv
ScreenRecording;Desktop;;
NAME;GENDER;AGE;CITY
RESPONDENT1;M;26;MOSCOW;instructionslide-1.jpg;Desktop
RESPONDENT2;F;27;MOSCOW;instructionslide-2.jpg;Desktop
```

Launching a program with a file, and using an icon:

```csv
ScreenRecording;NotePad1;C:\icons\notepad.png;C:\Windows\System32\NotePad.exe;C:\textfile1.txt
ScreenRecording;NotePad2;C:\icons\notepad.png;C:\Windows\System32\NotePad.exe;C:\textfile2.txt
NAME;GENDER;AGE;CITY;PROFESSION
RESPONDENT1;M;26;MOSCOW;SelfEmployed;NotePad1
RESPONDENT2;F;27;MOSCOW;HomeMaker;NotePad2
```

{% hint style="info" %}
A web survey hosted outside iMotions, such as a Qualtrics survey, rarely needs screen video or sensor data. Define it as a screen recording that opens the survey in a browser and **turn both off**, which keeps the study smaller without taking the survey out of the sequence.

```csv
ScreenRecording;Qualtrics;;C:\Program Files\Google\Chrome\Application\chrome.exe;https://yourdomain.qualtrics.com/jfe/form/SV_0000000000;RecordScreen=False;RecordSensorData=False
```

{% endhint %}

### Scene recordings

A scene recording is a trial recorded with a scene camera or eye tracking glasses, for example a respondent handling a physical package. Sequencing scene recordings in a test plan is how a design with several such trials in a controlled order is set up.

```
SceneRecording;<name>;<icon path>
```

```csv
SceneRecording;MySceneRecording;C:\icons\scene.jpg
NAME;GENDER;AGE;CITY
RESPONDENT1;M;22;BOSTON;MySceneRecording
```

Without an icon, the field is left empty: `SceneRecording;MySceneRecording;`

## Surveys in a test plan

A survey slide is stored as an XML file next to a folder of the same name holding its images. Reference the XML file the way you would reference an image, and put both the file and its folder in the `Stimuli` folder.

```
Stimuli\
  instructions.jpg
  buying-intention1.xml
  buying-intention1\
    sportscar.jpg
  buying-intention2.xml
  buying-intention2\
    sportscar.jpg
```

```csv
NAME;GENDER;AGE;CITY
RESPONDENT1;M;22;COP;instructions.jpg;buying-intention1.xml;buying-intention2.xml
RESPONDENT2;F;31;COP;instructions.jpg;buying-intention2.xml;buying-intention1.xml
RESPONDENT3;M;45;COP;instructions.jpg;buying-intention1.xml;buying-intention2.xml
RESPONDENT4;F;28;COP;instructions.jpg;buying-intention2.xml;buying-intention1.xml
```

Header lines and file stimuli can be combined in one plan. This example gives half of the respondents one news site and the other half another, with the same survey slides around it:

```csv
WebRecording;CNN;;http://cnn.com
WebRecording;BBC;;http://bbc.co.uk
NAME;GENDER;AGE;CITY;GROUP
CNN RESPONDENT1;M;31;CPH;CNN;instructions.xml;CNN;surveyslide1.xml;surveyslide2.xml
BBC RESPONDENT1;M;29;CPH;BBC;instructions.xml;BBC;surveyslide1.xml;surveyslide2.xml
CNN RESPONDENT2;F;42;CPH;CNN;instructions.xml;CNN;surveyslide1.xml;surveyslide2.xml
BBC RESPONDENT2;F;38;CPH;BBC;instructions.xml;BBC;surveyslide1.xml;surveyslide2.xml
```

## Working with a test plan study after import

The test plan is read at import and is not kept in sync with the study afterwards. Editing the file after the study exists changes nothing until you import it again as a new study.

* **Deleting a respondent.** Right-click the respondent and select **Delete**. This removes the respondent from the study but does not change the file, so importing the same file again produces all of the original respondents.
* **Editing stimuli.** Click **Edit stimuli**, then **STIMULI OVERVIEW**, to change properties such as exposure time or stimulus name for the imported stimuli. Select several stimuli to change them at once in the **Properties** panel. Stimuli cannot be added to or deleted from a test plan study.

{% hint style="warning" %}
Cloning a test plan study copies the stimuli but **loses the test plan information**: the clone has no respondents and shows the stimuli in random order. To reuse a test plan study, import the file again, or export the study and import it, which keeps the test plan. See [Clone, Save, and Import iMotions Studies](https://help.imotions.com/lab/study-setup-and-design/imotions-setup/clone-save-and-import-imotions-studies.md).
{% endhint %}

## Import errors

| Message                                                                                    | Cause                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Either a semi-colon or a comma has to be used as a separator between tokens                | Another character is used as the separator.                                                                                                                                           |
| Line *n* has an invalid format                                                             | The line with the column names has extra spaces, a wrong separator, the first four columns in the wrong order, or a background variable with a reserved name.                         |
| Test plan must contain the four mandatory tokens: name, gender, age and city               | A respondent line has fewer than four values.                                                                                                                                         |
| Invalid format for respondent name found at line *n*                                       | The name contains a character that is not a letter, digit or space.                                                                                                                   |
| Invalid format for gender found at line *n*                                                | The value is not `F`, `M` or `O`.                                                                                                                                                     |
| Invalid format for age group or age found at line *n*                                      | The age is `0`, outside the range 1 to 99, or a range that is not two numbers from 10 to 99 separated by a hyphen.                                                                    |
| Invalid format for city code found at line *n*                                             | The city contains a character such as `/` or `@`.                                                                                                                                     |
| Invalid format for respondent group found at line: *n*                                     | The group is empty or contains a space or punctuation.                                                                                                                                |
| Invalid format for background variable (BG) found at line *n*                              | A background variable value contains punctuation.                                                                                                                                     |
| Line *n* contains duplicate background variables                                           | Two columns have the same background variable name.                                                                                                                                   |
| The text file contains duplicate stimuli names in line *n*                                 | The same stimulus is referenced twice for one respondent.                                                                                                                             |
| There must be at least 1 stimuli for respondent at line *n*                                | The line has respondent values but no stimuli.                                                                                                                                        |
| Stimulus: *path* not found                                                                 | A file is missing from the `Stimuli` folder, or the program of a screen recording does not exist.                                                                                     |
| Unsupported format for stimulus found at line *n*                                          | The name does not match any header line, or the file type cannot be used as a stimulus. Check the spelling and capitalization of website, screen recording and scene recording names. |
| Empty filename for stimulus found at line *n*                                              | Two separators in a row among the stimuli of a respondent line.                                                                                                                       |
| Stimuli could not be read: *name*                                                          | A survey file refers to an image that is missing from its folder.                                                                                                                     |
| The browsed path does not contain a folder by name 'Stimuli', containing necessary stimuli | The `Stimuli` folder is missing, misspelled, or not next to the test plan file.                                                                                                       |
| The Stimuli folder does not contain any stimuli                                            | The `Stimuli` folder is empty.                                                                                                                                                        |
| Recording *name* must define a url/file path                                               | A `WebRecording` or `ScreenRecording` header line ends after the icon field.                                                                                                          |
| Recording *name* icon file *path* does not exist                                           | The icon path in a header line points at a file that is not there.                                                                                                                    |
| Error Reading the 6th option 'Record Screen'                                               | `RecordScreen` is misspelled or has a value other than `True` or `False`.                                                                                                             |
| Error Reading the 7th option 'Record Sensor Data'                                          | `RecordSensorData` is misspelled or has a value other than `True` or `False`.                                                                                                         |

## Example test plans

Both archives contain test plan files with their `Stimuli` folders, ready to import.

{% file src="/files/IKEeFje22O9LaFyVkL63" %}
A simple plan, a plan for websites, a plan for screen recordings that launch a program, a plan for surveys, and a plan that combines websites and surveys
{% endfile %}

{% file src="/files/HwCDa9kJmaMAbEOJghNW" %}
A plan that uses the ExposureTime and ManualAdvance settings
{% endfile %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.imotions.com/lab/study-setup-and-design/imotions-setup/using-a-test-plan-for-study-design.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
