immersivecognition / unity-experiment-framework

UXF - Framework for creating human behaviour experiments in Unity
https://immersivecognition.github.io/unity-experiment-framework/
MIT License
221 stars 43 forks source link

How to setup an initial training trial per block #87

Closed A-Ivan closed 3 years ago

A-Ivan commented 3 years ago

Hi @jackbrookes ,

Sorry if I missed this in the documentation, but what would be the recommended way to create a "practice/training" trial which would be the first trial of each block?

Say I want participants to train how to do perform part of a task relevant to a block, so each block participants would begin going through a practice/training scene (the same training scene for all blocks) which would have some aspect specific to that block (relative to some independent variable that is changed). This practice/training Unity scene would be different than the scene used for the actual study trials of the block, in order to minimize learning effects.

The practice/training scene could either end with the participant correctly performing what they are being trained on (some trigger is issued to go to the next trial), or until they feel they have trained enough (in which case they would let the researcher know and the researcher would issue some command, for instance a specific key press, to go to the next trial).

An example of this would be in a VR locomotion study where participants are being evaluated on how well they explore a virtual environment (VE) which is larger than their physical environment. The trials require participants to find a number of objects in the VE, which in one block they can use teleportation and another they can use joystick (the locomotion independent variable) to move across the VE, for instance. An initial trial of each block would allow participants to become familiar with either teleportation or joystick, depending on the block. The VE used to practice would be different (i.e., a house) than the one from the actual trial (i.e., a city).

There are three main questions with this:

  1. How would I set a trial to always be the first of a block and having the option to log or not data from it (or at least to flag that it is a practice trial and data should not be used during evaluation).
  2. How could this practice trial be controlled to end (either via the participant correctly performing the practice task or the researcher issuing a command to move onto the actual study trial)?
  3. Is it possible to have a Unity scene for "actual trials" and another scene for "practice/training"? Or would I have to put everything on a single scene and then instantiate/enable the gameobjects and components respective to that type of trial (practice or actual study trial)?

Thank you. Ivan

jackbrookes commented 3 years ago

How would I set a trial to always be the first of a block and having the option to log or not data from it (or at least to flag that it is a practice trial and data should not be used during evaluation).

You just flag it manually with a setting, e.g. "practice_trial" then make sure "practice_trial" is added under Settings To Log in the Session component inspector to make sure you have a record of which trials are practice.

To create the trial:

var myBlock = session.CreateBlock(10); // 10 trials
myBlock.settings.SetBool("practice_trial", false); // default to false
myBlock.firstTrial.settings.SetBool("practice_trial", true); // first trial is true

Then in your code elsewhere (e.g. in a method called via the On Trial Begin event), you can do something special on practice trial, like load a certain scene. For example

bool practiceTrial = trial.GetBool("practice_trial");
if (practiceTrial)
{
    // load practice scene, etc
}
else
{
    // load normal scene, etc
}

There is no advantage to not logging data from the practice trial, you can just ignore it in your data analysis. If you really don't want it to be included, don't run it as a UXF trial, just run them through practice without starting a UXF trial.

How could this practice trial be controlled to end (either via the participant correctly performing the practice task or the researcher issuing a command to move onto the actual study trial)?

Obviously depends on how you are detecting the correct action, but you just need to end the trial with code:

void Update()
{
    // detect correct action
    bool userPerformedCorrectAction = ???;
    if (userPerformedCorrectAction)
        UXF.Session.instance.CurrentTrial.End();

    // detect F10 key press
    if (Input.GetKeyDown(KeyCode.F10))
        UXF.Session.instance.CurrentTrial.End();

}

For the manual end, I did it with a keypress of F10, but you could also have a UI button with the event hooked up to a method such as session.EndCurrentTrial() or a custom method that you write yourself that also ends the trial.

Is it possible to have a Unity scene for "actual trials" and another scene for "practice/training"? Or would I have to put everything on a single scene and then instantiate/enable the gameobjects and components respective to that type of trial (practice or actual study trial)?

See the multi scene example. UXF places no restrictions on how you do things in Unity, its up to you. You can do it either way, depending on what is more appropriate. You can have some code that loads the required scene based on some setting (see answer 1 above). You could do this:

A-Ivan commented 3 years ago

Hi Jack,

This is really great, thank you for all of the information and the detailed script examples.

Is this information in the documentation? If not, I think it would be a great addition to it as most of the researchers I know always have a practice trial in their studies, and this information would be really useful to know about when using UXF.

Concerning the keypress to move to the next trial. When developing my studies, I like to be able to go through it multiple times to make sure everything is working correctly. Would I be able to use this idea of using a keypress but instead of moving the next trial, using another keypress to go to a previous one? Or would that cause issues with the logging of information or anything else in the UXF's backend, as I would returning to a trial already flagged as complete?

jackbrookes commented 3 years ago

You can add any items to the Wiki that you think are useful, I don't usually put solutions to specific problems on there since there may be several different ways to solve it (e.g. practice trials).

I think there are better ways to test out trials rather than skipping back/forward - you could temporarily generate a series of trials that play through trials you want to test. However, you can replay a trial (I think) but it will overwrite data.