LUIDA Docs
ComponentsUnity templateEditor windows

Configure experiment automation › Experiment Variables

Tab 1 of the LUIDA automation window. Declare within-subjects and between-subjects variables; the trial count is auto-calculated.

These pages are not yet fully reviewed. The LUIDA team is continuing to review and improve them. If you find anything wrong on these pages, or have questions that aren't resolved by reading them, please ask or report to the LUIDA team.

LUIDA › Configure experiment automation › Experiment Variables is the first of three tabs. It's where you declare the experimental variables — within-subjects (vary across trials within one participant) and between-subjects (vary across participants but stay constant within one session) — and where the editor calculates how many trials each session will run.

This is usually the first tab you fill in for a new scene, because the State Machine tab's trial loop and the State-listening Items grid both reference variable values that don't exist until you declare them here.

Screenshot pending — the Experiment Variables tab with one within-subjects variable (text with values Red, Blue) and one between-subjects variable (order with values RB, BR).

Two sections, same fields

The tab has two parallel forms:

  • Variables for Within-Subject Conditions — what changes from trial to trial for the same participant.
  • Variables for Between-Subject Conditions — what differs between participants but stays constant within a session.

For an introduction to the distinction (and why it matters for analysis), see Concepts → Within vs. between subjects.

Each section is a list. Add a row with + Add Variable, fill in the four fields below, and the editor writes the values into Assets/_Experiment_/Settings/ExperimentVariables/<SceneName>.js.

Fields per variable

FieldTypeWhat it controls
NamestringThe variable's identifier. This is the key you'll look up as CONDITION["<name>"] in your scripts. Use a stable, code-friendly name (e.g., fontColor, depth, not Font Color!).
Valuescomma-separated listThe full set of values the variable can take. Order matters when isRandom is unchecked. Example: Red, Blue or near, far.
isRandomcheckboxIf checked, trials draw values in randomized order each session. If unchecked, the order is exactly the list in Values. For between-subjects variables, this checkbox is currently forced to true — each session is randomly assigned one value.
Trials Count per Conditioninteger ≥ 1How many trials per condition combination. The total trial count is `(product of within-subjects

Between-subjects assignment is currently always random. Future LUIDA versions plan to let you assign between-subjects values based on pre-session questionnaire answers (e.g., counterbalance condition based on participant demographics), but for now: random, with optional debugValue overrides via isTestMode.

How the trial count is calculated

Suppose you declare:

  • Within-subjects text with values Red, Blue (|Values| = 2)
  • Within-subjects font with values R, B (|Values| = 2)
  • Trials Count per Condition = 5

Then each session runs 2 × 2 × 5 = 20 trials — the cross-product of within-subjects values multiplied by the per-condition repetition count. Between-subjects variables don't multiply the count (they affect which between-subjects value is fixed for the session, not how many trials happen).

The editor displays this calculation live on the right side of the tab as you edit values. Use it to sanity-check that a 20-minute session isn't going to balloon into 4 hours of trials.

Screenshot pending — the Variables tab showing the auto-calculated trial count "20 trials per session" on the right side after the two within variables and Trials Count per Condition = 5 are set.

How to access values at runtime

In any state-listening action's Customized Action code block (or in your data calculator script), the active values are exposed as:

  • CONDITION["<name>"] — the current trial's values for this trial. Within-subjects values change every trial; between-subjects values stay the same for the whole session.
  • Look at Reference → Variables for the full lifecycle (when values are populated, when they refresh, what to do outside of trial states).

A typical use inside a Customized Action on Trial - Start:

const text = CONDITION["text"];   // "Red" or "Blue"
const font = CONDITION["font"];   // "R" or "B"

SetText(text);
SetChildPosition("Stimulus", 0, 1.5, 0);
ShowItem();

Where it gets stored

The tab writes to:

Assets/_Experiment_/Settings/ExperimentVariables/<SceneName>.js

…which is loaded by the LUIDA-ExpManagers prefab's ConditionManager at session start. The file is plain JavaScript — you can read it for debugging, but always edit it through this tab, never by hand (the editor regenerates the file on save).

Saving and reloading

Click Apply at the bottom of the tab to flush changes to disk. If you edit the file directly and Unity reloads, the editor will re-read on next focus. The auto-calculated trial count refreshes as you type.

Common pitfalls

  • Misspelled Name. CONDITION["FontColor"] returns undefined if the variable was declared as fontColor. Names are case-sensitive.
  • Whitespace in Values. Red, Blue and Red,Blue both work — leading and trailing spaces are trimmed — but "Red","Blue" doesn't (you don't need quotes). When in doubt, no quotes, no extra symbols.
  • Setting isRandom=false and expecting per-participant randomization. If the box is unchecked, the same trial order is used every session. Re-check it if you wanted randomization.
  • Forgetting to update Trials Count per Condition. A change in Values doesn't reset the count; it stays at whatever you last set.

Where to go next