Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpsych two trials racing issue? cannot get feedback from last stimuli trial #3497

Open
NanChen5353 opened this issue Feb 2, 2025 · 0 comments

Comments

@NanChen5353
Copy link

NanChen5353 commented Feb 2, 2025

Hi community, just wondering if anyone has a clue on this? Thank you very much!

I tried to display stimuli_screen (displayed every trial in test_stimuli) first and then ask jsych to retrive the data to give feedback to participants in my next trial: feedback_screen, but it seems the timing is a problem here if I set it short now 1500ms for stimuli_screen. Sometimes, for some letters, there no feedback at all. If I set it 5s for stimuli_screen, it is mostly fine, but if I participants respond very late, also run into this issue. I guess it is because jspsych does not have enough time to retrieve the data before the next feedback_screen come along?
or alternatively, how do you give feedback based on the rule of your experiment rather than direct feedback?



`for (var i = 0; i < test_stimuli.length; i++) {
        let stimuli_screen_practice = {
            type: jsPsychCategorizeHtml,
            stimulus: test_stimuli[i].stimulus,
            data: test_stimuli[i].data,
            key_answer: test_stimuli[i].correct_key,
            stimulus_duration: 1500,
            trial_duration: 1500,
            show_feedback_on_timeout: false,
            timeout_message: ' ',
            feedback_duration: 0,
            correct_text: ' ',
            show_stim_with_feedback: false,
            incorrect_text: ' ',
        };





        let feedback_screen_practice = {
            type: jsPsychHtmlKeyboardResponse,
            stimulus: function () {
  
                let last_trial_data = jsPsych.data.get().last(1).values()[0] 

                let response = last_trial_data.response 
                let correct_key = last_trial_data.correct_key 
                let h12AX = last_trial_data.conditionalDetect 



      
                if (response) response = response.toUpperCase();

      
                if (!response) {
                    return "<p style='color:red;'>Time out!</p>";
                }

           
                if (response === correct_key) {
                    return "<p style='color:green;'>Correct!</p>";
                }

     
                if (correct_key === "K" && response === "D" ) {
                    return "<p style='color:red;'>Missed the match!</p>";
                }

                if (correct_key === "D" && response === "K" ) {
                    return "<p style='color:red;'>Not a match!</p>";
                }

                return "<p style='color:red;'>Incorrect press!</p>";
            },

            stimulus_duration: 750,
            trial_duration: 750,
            response_ends_trial: false,

            data: { task: 'feedback', practice: true }
        };


        test.push(stimuli_screen_practice);
        test.push(feedback_screen_practice);
    }

var practice = { timeline: test };
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant