-
Notifications
You must be signed in to change notification settings - Fork 48
Add trials during session
Jack Brookes edited this page Jun 25, 2020
ยท
4 revisions
You can add trials as a session is running ("on-the-fly") if this suits your experimental design. This can be used for staircase designs or similar. To do this, just create a trial on a desired block as needed. First in the below example, let's create some trials before our session starts, as normal.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// add the UXF namespace
using UXF;
public class SessionGenerator : MonoBehaviour
{
// assign this as the first element in the "On Session Begin" event in the Session component inspector
public void GenerateExperiment(Session session)
{
// create block of 20 trials
Block block1 = session.CreateBlock(20);
}
}
Elsewhere, we can create functionality captures participant responses, and stores them in trial.result
. Then when the trial has ended, we can run a method to create a new trial if required, for example based on the trial response.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// add the UXF namespace
using UXF;
public class ExtraTrialCreator : MonoBehaviour
{
// assign this method in the "On Trial End" event in the Session component inspector
public void CreateAndRunNewTrialIfNeeded(Trial trial)
{
// example - create a new trial if participant answer is above 5
int answer = trial.result["answer"];
if (answer > 5)
{
// create new trial with "example" setting assigned to value 1234.
Trial newTrial = trial.block.CreateTrial();
newTrial.settings.SetValue("example", 1234);
// we could also directly start the newly created trial. this will skip past all the trials we had left to go.
newTrial.Begin();
}
else
{
// otherwise, we can end the session...
if (trial == trial.session.LastTrial)
{
trial.session.End();
}
// or start the next trial.
else
{
trial.session.NextTrial.Begin();
}
}
}
}
๐ง Core topics
- ๐ Background
- โจ UXF 2.0
- โ๏ธ Compatibility
- ๐ถ๏ธ Oculus Quest Setup
- ๐ญ Concepts
- ๐ ๏ธ Get started
- ๐ Examples
- ๐ฅ๏ธ Built-in UI
- ๐ Session generation
- โฐ Events
- ๐ Data collection
- โ๏ธ Collect custom data
- ๐ Custom Data Handler
- ๐ Remote Data Collection
- ๐๏ธ WebGL DynamoDB setup
- ๐ Processing DynamoDB CSVs
- ๐ซ HTTP Post Setup
- ๐ง Settings system
- ๐๐ฝ Tracker system
- ๐ Logging system
โ ๏ธ Common issues- ๐ผ๏ธ Multi-scene experiments
- ๐บ Videos
- ๐จโ๐ Full written tutorial
- ๐ฆ Asset links
- ๐จโ๐ซ Unity tutorial links
- ๐ Useful code snippets
- ๐ก Programming ideas
- ๐งฎ Example R processing