/**************************************** * ConditionalResourcesFrom_List Test *…
- User
/****************************************
- Conditional_Resources_From_List Test *
****************************************/
import { core, data, sound, util, visual, hardware } from './lib/psychojs-2023.1.1.js';
const { PsychoJS } = core;
const { TrialHandler, MultiStairHandler } = data;
const { Scheduler } = util;
//some handy aliases as in the psychopy scripts;
const { abs, sin, cos, PI: pi, sqrt } = Math;
const { round } = util;
// store info about the experiment session:
let expName = 'conditional_resources_from_list'; // from the Builder filename that created this script
let expInfo = {
'participant':
${util.pad(Number.parseFloat(util.randint(0, 999999)).toFixed(0), 6)}, 'group': ["a", "b"], }; // Start code blocks for 'Before Experiment' // Run 'Before Experiment' code from init_resources_code var resource_list = []; // init psychoJS: const psychoJS = new PsychoJS({ debug: true }); // open window: psychoJS.openWindow({ fullscr: false, color: new util.Color([0,0,0]), units: 'height', waitBlanking: true }); // schedule the experiment: psychoJS.schedule(psychoJS.gui.DlgFromDict({ dictionary: expInfo, title: expName })); const flowScheduler = new Scheduler(psychoJS); const dialogCancelScheduler = new Scheduler(psychoJS); psychoJS.scheduleCondition(function() { return (psychoJS.gui.dialogComponent.button === 'OK'); }, flowScheduler, dialogCancelScheduler); // flowScheduler gets run if the participants presses OK flowScheduler.add(updateInfo); // add timeStamp flowScheduler.add(experimentInit); const init_resources_loopLoopScheduler = new Scheduler(psychoJS); flowScheduler.add(init_resources_loopLoopBegin(init_resources_loopLoopScheduler)); flowScheduler.add(init_resources_loopLoopScheduler); flowScheduler.add(init_resources_loopLoopEnd); flowScheduler.add(resource_checker_pbRoutineBegin()); flowScheduler.add(resource_checker_pbRoutineEachFrame()); flowScheduler.add(resource_checker_pbRoutineEnd()); flowScheduler.add(resource_download_completeRoutineBegin()); flowScheduler.add(resource_download_completeRoutineEachFrame()); flowScheduler.add(resource_download_completeRoutineEnd()); const show_images_loopLoopScheduler = new Scheduler(psychoJS); flowScheduler.add(show_images_loopLoopBegin(show_images_loopLoopScheduler)); flowScheduler.add(show_images_loopLoopScheduler); flowScheduler.add(show_images_loopLoopEnd); flowScheduler.add(never_ending_routineRoutineBegin()); flowScheduler.add(never_ending_routineRoutineEachFrame()); flowScheduler.add(never_ending_routineRoutineEnd()); flowScheduler.add(quitPsychoJS, '', true); // quit if user presses Cancel in dialog box: dialogCancelScheduler.add(quitPsychoJS, '', false); psychoJS.start({ expName: expName, expInfo: expInfo, resources: [ // resources: {'name': 'default.png', 'path': 'https://pavlovia.org/assets/default/default.png'}, {'name': 'group_a_stim.csv', 'path': 'group_a_stim.csv'}, {'name': 'group_b_stim.csv', 'path': 'group_b_stim.csv'}, ] }); psychoJS.experimentLogger.setLevel(core.Logger.ServerLevel.EXP); var currentLoop; var frameDur; async function updateInfo() { currentLoop = psychoJS.experiment; // right now there are no loops expInfo['date'] = util.MonotonicClock.getDateStr(); // add a simple timestamp expInfo['expName'] = expName; expInfo['psychopyVersion'] = '2023.1.1'; expInfo['OS'] = window.navigator.platform; // store frame rate of monitor if we can measure it successfully expInfo['frameRate'] = psychoJS.window.getActualFrameRate(); if (typeof expInfo['frameRate'] !== 'undefined') frameDur = 1.0 / Math.round(expInfo['frameRate']); else frameDur = 1.0 / 60.0; // couldn't get a reliable measure so guess // add info from the URL: util.addInfoFromUrl(expInfo);
- Conditional_Resources_From_List Test *
****************************************/
import { core, data, sound, util, visual, hardware } from './lib/psychojs-2023.1.1.js';
const { PsychoJS } = core;
const { TrialHandler, MultiStairHandler } = data;
const { Scheduler } = util;
//some handy aliases as in the psychopy scripts;
const { abs, sin, cos, PI: pi, sqrt } = Math;
const { round } = util;
// store info about the experiment session:
let expName = 'conditional_resources_from_list'; // from the Builder filename that created this script
let expInfo = {
'participant':
- Assistant
Certainly! Here's the updated code block for the
experimentInitfunction:javascriptasync function experimentInit() { // Initialize components for Routine "init_resources" init_resourcesClock = new util.Clock(); const observer_num = parseInt(expInfo["group"]); if (observer_num >= 1 && observer_num <= 20) { stim_file = `observer_${observer_num}.csv`; } else { // handle error or set a default stimulus file if necessary // stim_file = "default_stim.csv"; } console.log("Stim file: " + stim_file) // ... rest of the code }Please note that you will need to change the
expInfoobject at the beginning of the script to allow input for observer number (1-20) instead of just "a" and "b":javascriptlet expInfo = { 'participant': `${util.pad(Number.parseFloat(util.randint(0, 999999)).toFixed(0), 6)}`, 'group': Array.from({length: 20}, (_, i) => i + 1), };