Getting timestamps for stimulus presentations

558 views
Skip to first unread message

Nastasia Griffioen

unread,
Aug 17, 2016, 5:27:34 PM8/17/16
to jsPsych
Hi all,

I'm trying to create a task in which a stimulus is repeatedly presented in a certain rhythm (that's the part that I've got down), and where the participant is asked to press a key (e.g. the spacebar) synchronously to the rhythm represented by the stimulus. The only way I can think of implementing this is using timestamps (i.e. comparing the timestamp of the stimulus presentation to the response's timestamp) in order to be able to assess whether the participant's response rhythm resembles the actual stimulus rhythm.

So my question is: is it possible to get timestamps for presented stimuli in jsPsych? If so, I'd love to know how!

Thanks in advance.

~Nastasia

Josh de Leeuw

unread,
Aug 17, 2016, 5:50:36 PM8/17/16
to Nastasia Griffioen, jsPsych
Hi, Nastasia.

What kind of stimuli are you presenting? There are a couple ways that you could solve this problem, but it depends on the stimuli.

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/4a555c00-8f1b-4987-a715-2d0e98140bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nastasia Griffioen

unread,
Aug 18, 2016, 2:06:51 AM8/18/16
to jsPsych

Hi Josh,

I'm actually presenting a very simple visual one; a circle (which appears and disappears with certain rhythm).

~Nastasia


Op woensdag 17 augustus 2016 23:50:36 UTC+2 schreef Josh de Leeuw:

Nastasia Griffioen

unread,
Aug 18, 2016, 2:27:23 AM8/18/16
to jsPsych
I believe I've found a solution to (at least part of) my problem. I've used  jsPsych.data.addDataToLastTrial  to append the timestamp created by (new Date).toISOString().replace(/z|t/gi,' ').trim(); for every trial.

For others who might find this useful to know, my script looks like this, atm:

var stimulus = {
      type: 'single-stim',
      stimulus: "img/circle.jpg",
      timing_response: 500,
      response_ends_trial: false,
      timing_post_trial: post_trial_gap,
      on_finish: function(timestamp){
          var timestamp = (new Date).toISOString().replace(/z|t/gi,' ').trim();
          jsPsych.data.addDataToLastTrial({timestamp});
      }
  }


Op donderdag 18 augustus 2016 08:06:51 UTC+2 schreef Nastasia Griffioen:

Josh de Leeuw

unread,
Aug 18, 2016, 2:43:19 PM8/18/16
to Nastasia Griffioen, jsPsych
This method will indeed add a timestamp, but it will be a timestamp of when the trial ended and not when the stimulus was displayed.

In some sense, what you want is already implemented in the library. The 'rt' data field is the difference between when the stimulus was presented (as estimated by JavaScript) and when the participant responded. So the close the RT values are to 0, the more synchronous the response is.

The problem with relying on RT is that it won't capture a response that is made before the stimulus is presented, which may very well happen if you are presenting stimuli rhythmically.

One solution might be to use the animation plugin. This could present stimuli at fixed intervals, and the plugin automatically records the presentation time and response time of all stimuli and any responses. (http://docs.jspsych.org/plugins/jspsych-animation/). However it won't work if you need to present a rhythm that is not made up of a fixed interval. If that's the case I can chime in with some more thoughts on how to do it.

Nastasia Griffioen

unread,
Aug 19, 2016, 5:39:21 AM8/19/16
to jsPsych, nastasia....@gmail.com

Hi Josh,

Thanks for your help! Since the reaction times aren't as strict (we just need a rough measure), I'm not worried about the stimulus timestamp representing the ending time of the stimulus.
But perhaps using the animation plugin might indeed solve my current problem (which is that I'm not being able to access the timestamp variables when trying to create a difference variable), so I might definitely try that one out.

~Nastasia


Op donderdag 18 augustus 2016 20:43:19 UTC+2 schreef Josh de Leeuw:
Reply all
Reply to author
Forward
0 new messages