Comments (15)
Sorry to keep you waiting.
I changed the plugin file.
Please change the branch of my repository from master to dev and download the plugin file.
(If you can't understand this instruction, please let me know)
With the new file, you can specify the trial_ends_after_audio property as follows:
const sound_test = {
type: 'psychophysics',
stimuli: [
{
obj_type: 'sound',
file: xxx,
trial_ends_after_audio: true
}
],
choices: ['y', 'n'],
prompt: 'Press the Y or N key to respond.',
canvas_height: 500
}
The trial_ends_after_audio property can be specified in each stimulus object.
from jspsych-psychophysics.
Hi,
Thanks so much for your help with this. I successfully downloaded the plugin file. However, when I add the line trial_ends_after_audio: true
, I get this error: "ReferenceError: Cannot access uninitialized variable." Here is the script I used:
var retroaction = {
type: 'psychophysics',
stimuli: [
{
obj_type: 'image',
file: "img/x.png",
startX:200
},
{
obj_type: 'sound',
file: jsPsych.timelineVariable('phrase'),
trial_ends_after_audio: true
},
{
obj_type: 'image',
file: jsPsych.timelineVariable('bonne_reponse'),
startX: 625
},
],
background_color: "FFFFFF",
choices: jsPsych.NO_KEYS,
on_start: function(retroaction) {
if (jsPsych.data.getLastTrialData().values()[0].accuracy == true) {
retroaction.stimuli[0].file = "img/crochet.png";
}
}
}
Thanks!
Catherine
from jspsych-psychophysics.
I'm sorry, but I don't have time to go into detail right now.
Please check to see if you are referring to the old file.
Then could you clear your browser's cache data?
from jspsych-psychophysics.
Thanks for your answer. I tried what you said but I still get the same error. I'll try to find another way to end the trial. Please let me know if you think of something. Thanks again for your help!
from jspsych-psychophysics.
Thank you for your reply.
Could you run this program?
https://www.hes.kyushu-u.ac.jp/~bunshin/test/trial_ends_after_audio_test.html
This is a sample program which uses the trial_ends_after_audio_test property.
Then, could you confirm that line 125 of the new plugin file says the following?
trial_ends_after_audio: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Trial ends after audio',
default: false,
description: 'If true, then the trial will end as soon as the audio file finishes playing.'
},
from jspsych-psychophysics.
Hi,
The program seems to work (it stops after the speech joke), and I confirm that lines 125-130 are correct.
Thanks,
Catherine
from jspsych-psychophysics.
I'm sorry for keeping you wait.
You wrote that you had received the error: "ReferenceError: Cannot access uninitialized variable."
What was the source code of the line with this error?
Was the line trial_ends_after_audio: true
?
from jspsych-psychophysics.
Hi,
Thanks again very much for your help, I really appreciate it.
The line is stim.audio.addEventListener('ended', end_trial);
(line 422 in the plugin).
Thanks,
Catherine
from jspsych-psychophysics.
Can I see all the source code or access the web page of the experiment?
from jspsych-psychophysics.
Of course! Here is my full script:
<!DOCTYPE html>
<html>
<head>
<title>Recherche sur le langage et les émotions</title>
<script src="jspsych-6.1.0/jspsych.js"></script>
<script src="jspsych-6.1.0/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jspsych-6.1.0/plugins/jspsych-audio-keyboard-response.js"></script>
<script src="jspsych-6.1.0/plugins/jspsych-psychophysics.js"></script>
<script src="stimuli.js"></script>
<link href="jspsych-6.1.0/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body></body>
<script>
var timeline = [];
var audio = [];
for (var i=0; i<stimuli.length; i++) {
audio.push(stimuli[i].phrase);
}
var images = [];
for (var i=0; i<stimuli.length; i++) {
images.push(stimuli[i].image1);
}
for (var i=0; i<stimuli.length; i++) {
images.push(stimuli[i].image2);
}
for (var i=0; i<stimuli.length; i++) {
images.push(stimuli[i].bonne_reponse);
}
images.push('img/x.png', 'img/crochet.png');
var instructions = {
type: 'html-keyboard-response',
stimulus: 'Instructions'
}
timeline.push(instructions);
var phrase = {
type: 'audio-keyboard-response',
stimulus: jsPsych.timelineVariable('phrase'),
prompt: '<span style="font-size:40px;">+</span>',
choices: jsPsych.NO_KEYS,
trial_ends_after_audio: true
}
var image = {
timeline: [
{
type: 'psychophysics',
stimuli: [
{
obj_type: 'image',
file: jsPsych.timelineVariable('image1'),
startX: 500
},
{
obj_type: 'image',
file: jsPsych.timelineVariable('image2'),
startX: 750
},
],
background_color: "FFFFFF",
choices: [37, 39],
data: {
correct_response: 37,
},
on_finish: function(data) {
var bonne_reponse = false;
if (data.correct_response == data.key_press) {
bonne_reponse = true;
}
data.accuracy = bonne_reponse;
}
}
]
}
var retroaction = {
type: 'psychophysics',
stimuli: [
{
obj_type: 'image',
file: "img/x.png",
startX:200
},
{
obj_type: 'sound',
file: jsPsych.timelineVariable('phrase'),
trial_ends_after_audio: true
},
{
obj_type: 'image',
file: jsPsych.timelineVariable('bonne_reponse'),
startX: 625
},
],
background_color: "FFFFFF",
choices: jsPsych.NO_KEYS,
on_start: function(retroaction) {
if (jsPsych.data.getLastTrialData().values()[0].accuracy == true) {
retroaction.stimuli[0].file = "img/crochet.png";
}
}
}
var procedure = {
timeline: [phrase, image, retroaction],
timeline_variables: stimuli
}
timeline.push(procedure);
var fin = {
type: 'html-keyboard-response',
stimulus: 'Merci!'
}
timeline.push(fin);
jsPsych.init({
timeline: timeline,
preload_audio: audio,
preload_images: images,
use_webaudio: false,
on_finish: function() {
jsPsych.data.displayData();
}
})
</script>
</html>
Do you need anything else?
from jspsych-psychophysics.
Is there a reason you set the use_webaudio property to false?
I'm not sure if this property is related to the problem or not, but you should set it to true.
from jspsych-psychophysics.
This is the sample program where the use_webaudio was set as false.
https://www.hes.kyushu-u.ac.jp/~bunshin/test/trial_ends_after_audio_test_without_webaudio.html
Then, the trial_ends_after_audio property did not work.
You need to set the use_webaudio property to true
from jspsych-psychophysics.
Hi,
Thanks a lot for your help with this. This is the reason I had use_webaudio
set to false: https://groups.google.com/g/jspsych/c/eth7QtLghvY/m/85lucGueDAAJ. But I tried using GitHub as a web server as they suggested and now everything seems to be working!
Thanks!
from jspsych-psychophysics.
Thank you for your reply.
The use_webaudio property should be true for precise presentation of stimuli although you have to use a web server.
from jspsych-psychophysics.
Yes, I set it to true as I am now using a web server. Thanks!
from jspsych-psychophysics.
Related Issues (20)
- event handlers compatible with gabor parameters HOT 3
- Simulation mode for psychophysics HOT 2
- Wrong X,Y coordinates for gabor stimuli HOT 2
- Change image interactively HOT 12
- Coordinate problem about simultaneously using "key" and "button" response type HOT 5
- Define sequence of stimulus and indicate duration in both ms and frames HOT 5
- Prolem with object 'sound' HOT 2
- slider response HOT 1
- compatibility with pavlovia
- Precise timing and different screen refresh rates HOT 1
- npm for the plugin? HOT 7
- canvas height and jspsych-content mismatch HOT 2
- Concurrent presentation of images and sounds HOT 4
- Pre-load stimuli HOT 3
- Recolour SVG image HOT 5
- trouble importing npm plugin HOT 3
- Making text stimuli bold and coloured HOT 2
- Laptop and mobile phone compatibility HOT 4
- End the visual stimuli by key response, but make the auditory stimuli keep playing HOT 10
- Dragging one image using mouse_drawing while keeping another image HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jspsych-psychophysics.