예제 #1
0
        public void Generate(Session session)
        {
            double[] angles      = new double[] { 0, 45, 90 };
            double[] targetSizes = new double[] { .004, .015, .020 };

            int numPracticeTrials = 3;
            // create two blocks
            Block dummyBlock    = session.CreateBlock(1);
            Block practiceBlock = session.CreateBlock(numPracticeTrials);
            Block block         = session.CreateBlock(angles.Length * targetSizes.Length);

            Trial trial = dummyBlock.trials[0];

            trial.settings.SetValue("angle", 0);
            trial.settings.SetValue("targetSize", 0);

            MakePracticeTrials(practiceBlock, angles);
            MakeTrials(block, angles, targetSizes);
            Debug.Log(block.trials);
        }
예제 #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);
    }
예제 #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);
        }
 public void Init(UXF.Session session)
 {
     this.session = session;
     mainBlock    = session.CreateBlock();
 }
예제 #5
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() */