Giter Club home page Giter Club logo

Comments (15)

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

Can I see all the source code or access the web page of the experiment?

from jspsych-psychophysics.

kittymimo avatar kittymimo commented on May 29, 2024

Of course! Here is my full script:

<!DOCTYPE html>
<html>
    <head>
        <title>Recherche sur le langage et les &eacute;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.

kurokida avatar kurokida commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

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.

kurokida avatar kurokida commented on May 29, 2024

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.

kittymimo avatar kittymimo commented on May 29, 2024

Yes, I set it to true as I am now using a web server. Thanks!

from jspsych-psychophysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.