Beispiel #1
0
    /// <summary>
    /// generates the trials and blocks for the session
    /// </summary>
    /// <param name="experimentSession"></param>

    /// <summary>
    /// Example method presenting a stimulus to a user
    /// </summary>
    /// <param name="trial"></param>
    public void PresentStimulus(Trial trial)
    {
        // we can call this function via the event "On Trial Begin", which is called when the trial starts
        // here we can imagine presentation of some stimulus
        session = trial.session;
        Debug.Log(string.Format("Start trial {0}", trial.number));
        double angle      = trial.settings.GetDouble("angle");
        float  targetSize = (float)trial.settings.GetDouble("targetSize");

        Debug.Log(string.Format("trial rotation: {0} ", angle));
        Debug.Log(string.Format("trial target size: {0} ", targetSize));


        // we can access our settings to (e.g.) modify our scene
        // for more information about retrieving settings see the documentation

        //float size = trial.settings.GetFloat("size");
        //Debug.LogFormat("The 'size' for this trial is: {0}", size);

        // record custom values...
        //string observation = UnityEngine.Random.value.ToString();
        //Debug.Log(string.Format("We observed: {0}", observation));
        //trial.result["some_variable"] = observation;

        // end trial and prepare next trial in 1 second
        hackyEndTrialToggle = true;
        Invoke("EndAndPrepare", 15);
    }
Beispiel #2
0
    /// <summary>
    /// generates the trials and blocks for the session
    /// </summary>
    /// <param name="experimentSession"></param>
    public void GenerateExperiment(Session experimentSession)
    {
        // save reference to session
        session = experimentSession;
        // This function can be called using the Session inspector OnSessionBegin() event, or otherwise


        // / In the StreamingAssets folder we have a several .json files that contain settings, e.g.
        // / that looks like this:
        //
        //  {
        //
        //  "n_practice_trials": 5,
        //  "n_main_trials": 10,
        //  "size": 1
        //
        //  }
        //

        /* You can add any new settings to the JSON file
         * it will automatically be loaded into the settings property
         * of an ExperimentSession component as .settings */

        // create our blocks & trials

        // retrieve the n_practice_trials setting, which was loaded from our .json file
        int numPracticeTrials = session.settings.GetInt("n_practice_trials");
        // create block 1
        Block practiceBlock = session.CreateBlock(numPracticeTrials);

        practiceBlock.settings.SetValue("practice", true);

        // retrieve the n_main_trials setting, which was loaded from our .json file into our session settings
        int numMainTrials = session.settings.GetInt("n_main_trials");
        // create block 2
        Block mainBlock = session.CreateBlock(numMainTrials); // block 2

        // here we set a setting for the 2nd trial of the main block as an example.
        mainBlock.GetRelativeTrial(2).settings.SetValue("size", 10);
        mainBlock.GetRelativeTrial(1).settings.SetValue("color", Color.red);
    }
Beispiel #3
0
        public void GenerateExperiment(Session experimentSession)
        {
            // save reference to session
            session = experimentSession;
            // This function can be called using the Session inspector OnSessionBegin() event, or otherwise

            // retrieve the n_practice_trials setting, which was loaded from our .json file
            int numPracticeTrials = session.settings.GetInt("n_practice_trials");
            // create block 1
            Block practiceBlock = session.CreateBlock(numPracticeTrials);

            practiceBlock.settings.SetValue("practice", true);

            // retrieve the n_main_trials setting, which was loaded from our .json file into our session settings
            int numMainTrials = session.settings.GetInt("n_main_trials");
            // create block 2
            Block mainBlock = session.CreateBlock(numMainTrials); // block 2

            // here we set a setting for the 2nd trial of the main block as an example.
            mainBlock.GetRelativeTrial(2).settings.SetValue("size", 10);
            mainBlock.GetRelativeTrial(1).settings.SetValue("color", Color.red);
        }
Beispiel #4
0
    /// <summary>
    /// Example method presenting a stimulus to a user
    /// </summary>
    /// <param name="trial"></param>
    public void PresentStimulus(Trial trial)
    {
        // we can call this function via the event "On Trial Begin", which is called when the trial starts
        // here we can imagine presentation of some stimulus

        Debug.Log("Running trial!");
        session = trial.session;

        // we can access our settings to (e.g.) modify our scene
        // for more information about retrieving settings see the documentation

        //float size = trial.settings.GetFloat("size");
        //Debug.LogFormat("The 'size' for this trial is: {0}", size);

        // record custom values...
        //string observation = UnityEngine.Random.value.ToString();
        //Debug.Log(string.Format("We observed: {0}", observation));
        //trial.result["some_variable"] = observation;

        // end trial and prepare next trial in 1 second
        Invoke("EndAndPrepare", 1);
    }
 // Call whenever a new experimentation session is launched
 public void ExperimentSessionBegin(UXF.Session experimentSession)
 {
     ApollonEngine.Instance.ExperimentSessionBegin(experimentSession);
 }
 public void Init(UXF.Session session)
 {
     this.session = session;
     mainBlock    = session.CreateBlock();
 }
Beispiel #7
0
        }         /* DoBlockConfiguration() */

        public void DoSessionConfiguration(UXF.Session session)
        {
            // retrieve the block sequence, which was loaded from our .json file
            System.Collections.Generic.List <string> seq = session.settings.GetStringList("block_sequence");

            // iterate over seq
            UXF.Settings pattern_settings = new UXF.Settings(session.settings.GetDict("block_pattern"));
            foreach (var item in seq.Select((pattern, index) => new { index, pattern }))
            {
                // extract pattern dictionary
                UXF.Settings current_pattern_settings = new UXF.Settings(pattern_settings.GetDict(item.pattern));

                // create block
                UXF.Block block = session.CreateBlock(current_pattern_settings.GetStringList("trial_sequence").Count);

                // assign settings
                block.settings.SetValue("current_pattern", item.pattern);
                block.settings.SetValue("is_practice_condition", current_pattern_settings.GetBool("is_practice_condition"));

                // call child configuration
                this.DoBlockConfiguration(block, current_pattern_settings.GetStringList("trial_sequence"));

                // suffle it !
                if (current_pattern_settings.GetBool("is_sequence_randomized"))
                {
                    block.trials.Shuffle();
                }
            } /* foreach() */

            // retrieve the inter trial setting, which was loaded from our .json file
            if (session.settings.Keys.ToList().Contains("trial_inter_sleep_duration_ms"))
            {
                this._trial_sleep_duration = session.settings.GetFloat("trial_inter_sleep_duration_ms");
            }
            else
            {
                // log
                UnityEngine.Debug.LogWarning(
                    "<color=Orange>Info: </color> ApollonAbstractExperimentProfile.onExperimentTrialEnd() : could not find settings with key [trial_inter_sleep_duration_ms], set to default value :"
                    + this._trial_sleep_duration
                    );
            }

            if (session.settings.Keys.ToList().Contains("trial_final_fade_in_duration_ms"))
            {
                this._trial_fade_in_duration = session.settings.GetFloat("trial_final_fade_in_duration_ms");
            }
            else
            {
                // log
                UnityEngine.Debug.LogWarning(
                    "<color=Orange>Info: </color> ApollonAbstractExperimentProfile.onExperimentTrialEnd() : could not find settings with key [trial_final_fade_in_duration_ms], set to default value :"
                    + this._trial_fade_in_duration
                    );
            } /* if() */

            if (session.settings.Keys.ToList().Contains("trial_initial_fade_out_duration_ms"))
            {
                this._trial_fade_out_duration = session.settings.GetFloat("trial_initial_fade_out_duration_ms");
            }
            else
            {
                // log
                UnityEngine.Debug.LogWarning(
                    "<color=Orange>Info: </color> ApollonAbstractExperimentProfile.onExperimentTrialEnd() : could not find settings with key [trial_initial_fade_out_duration_ms], set to default value :"
                    + this._trial_fade_out_duration
                    );
            } /* if() */
        }     /* DoSessionConfiguration() */