使用 jspsych-react 进行反应的 Jspsych 实验

问题描述

我试图运行 jspsych 实验来为我的项目做出反应。实验目前是关于显示图像的幻灯片。当我运行应用程序时,它在控制台中给我错误,说没有加载插件,在显示图像的第二步之后,它抛出另一个错误,说 undefined 不是对象。我想我已经正确导入了插件,我没有做错地方。我已经发布了我所有的截图。

这是我的 app.js

import React from 'react'
import { Experiment } from 'jspsych-react';
import { timelineFactory } from './timeline';
import callbackImageKeyboardResponsePlugin from       './callbackImageKeyboardResponsePlugin';



function App() {
const callback = (targetID) => console.log(targetID);
const timeline = timelineFactory(callback);
return (
    <div>
        <Experiment
            settings={{ timeline }}
            plugins={{ callbackImageKeyboardResponsePlugin }}
        />

    </div>
  )
 }
export default App

这是我的 timline.js

import { jsPsych } from 'jspsych-react'
import callbackImageKeyboardResponsePlugin from "./callbackImageKeyboardResponsePlugin.js"
const post_trial_gap = function () {
 return Math.floor(Math.random() * jitter) + iti;
};
const stim_duration = 200;
const iti = 300;
const jitter = 200;
const plugin_name = callbackImageKeyboardResponsePlugin;
export function timelineFactory(callback) {
const start_callback = function () {
 callback('start')
};
const stop_callback = function () {
 callback('stop')
};
let targets = [];
var imageNumber;
var fileName;
var toPush;
for (var i = 0; i < 10; i++) {
imageNumber = Math.floor(Math.random() * (901 - 1) + 1);
if (imageNumber <= 9) {
  fileName = "static/00000" + imageNumber + ".jpg";
  toPush = { 'stimulus': fileName };
}
else if (imageNumber > 9 && imageNumber <= 99) {
  fileName = "static/0000" + imageNumber + ".jpg";
  toPush = { 'stimulus': fileName };
}
else {
  fileName = "static/000" + imageNumber + ".jpg";
  toPush = { 'stimulus': fileName };
}
if (targets.includes(toPush)) {
  i -= 1;
}
targets.push(toPush);
}
// Create timeline
const timeline = [];
const welcome_block = {
type: 'callbackImageKeyboardResponsePlugin',stimulus: "In this exercise,you will be shown a series of quickly moving pictures. In between each picture,you will see a <strong>+</strong>. Please focus on this when there is not an image on the screen. This exercise contains imagery that some may find disturbing. User beware. Press any key to begin.",post_trial_gap: 5000,on_start: start_callback
};
timeline.push(welcome_block);
const test_trials = {
stimulus: 'stimulus',type: plugin_name,timeline: targets,trial_duration: function () {
  return jsPsych.randomization.sampleWithoutReplacement([250,300,350,400,450,500,550,600,650,700,750],1)[0];
},stimulus_duration: stim_duration,post_trial_gap: post_trial_gap(),on_start: function () {
  console.log(this)}};
timeline.push(test_trials);
const end_block = {
type: 'callbackImageKeyboardResponsePlugin',stimulus: "Thanks for participating!",post_trial_gap: 500,on_start: stop_callback
};
timeline.push(end_block);
    return timeline;
   }

这是我的错误信息。

enter image description here

如果你需要,我有link github repo

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)