Hi!
I've only recently started using JsPsych and am really liking it so far. Because I have no prior experience using Javascript, as I've mostly used Python or Matlab as a programming language, I have a few questions which are intertwined that I cannot easily solve in this language because I am slightly lacking the conceptual capacity at the moment, but all are perhaps trivial for the veteran jsPsych coder. Maybe other users will also find the answers to these questions useful which is why I’ve tried making them clear as possible :)
Down below is the code for my stimuli presentation:
I have a var trial_seq_low and trial_seq_high.
The task sequence is as follows - at the beginning of every trial a stimuli (white box) is shown for 250ms which then disappears. After this, a timing_post_trial is defined which changes from trial to trial. The participants are asked to respond as fast as possible after the box gets presented with the response being collected until the end of the timing_post_trial.
So:
|stimulus onset (250ms)| (we gather their RT from onset of presentation)
|post stimulus interval (1000 to 2500ms)| (and should gather it until the end of the post stimulus interval)
|repeat 5x|
This is repeated five times in one sequence. The problem is, if I set the timing_response (allow_resp1 to 5 in the code below) to the desired amount of time, the stimulus stays on for longer than the 250ms.
1. How can I change this such that the stimuli would indeed be presented for 250ms and I would still collect the RT from onset (begin of 250ms) to end of the post_stimulus interval which would be considered as the RT for the first trial?
3. In addition, I would like to give them visual feedback together with the prompt (OK arrow or NO arrow). How can this most easily be done? So a constant prompt once the sequence starts with just the number of points changing together with an OK or NO arrow (depending on their RT accuracy) appearing following their response?
As mentioned above, I have a trial_seq_low and _high version.
In one round, they are exposed to the low and high condition, with an additional screen appearing at the end of each round where they would see their cumulative score.
final_points = points_low + points_high;
var total_points = {
type: 'single-stim',
stimulus: final_points,
timing_stim: 2000,
response_ends_trial: false,
timing_post_trial: 0,
timing_response: 1
};
I define the points_low and points_high as variables outside the stim objects before either are started and define the final_points after them. This doesn’t work, however, as it stays 0 all the time.
Should the stimulus in total_points be a function with points_low and points_high as inputs? I’m slightly confused by the scope of variable definitions and sequence flow in Javascript that’s why I’m having this trivial problem.
3. Or how can I present the total number of points in a new trial gathered within two previous trial sequences?
And finally - I have an array of arrays (see below) which is used to determine the onset times and post_stimulus times. I shuffle the array through indexing for each participant in the beginning.
How can I change the post_stimulus_delay and timing_response based on the row - so that what is considered delay1 through 5 and allow_resp1 through 5 would depend on the row in which the task currently is? In Matlab or Python, I would simply create a for loop of 15 trials (I have 15 arrays) and assign the allow_resp and delay variables with indexing and then run the trial_seq_low and _high sequences 15 times with different values, but I’m not sure where to put the for loop or how this would work in this case as in the timeline just the object gets added? The most brute force way I can imagine is to just initialize that amount of variables and push all of them to the timeline (which is also what I'll have to resort to if I don't find a more elegant solution).
var sequences = [[1000, 3500, 4750, 7000, 8500],
[2750, 3750, 5000, 6500, 8250],
[1000, 2250, 6000, 7000, 8500],
[1250, 2500, 5000, 6500, 7750],
[750, 2000, 4000, 5500, 6750],
[2000, 3000, 4500, 6250, 7750],
[750, 2250, 3250, 5000, 6750],
[1000, 3250, 4250, 5750, 8750],
[1250, 4500, 5750, 7500, 8750],
[1750, 2750, 5750, 6750, 8000],
[1500, 2750, 4500, 6000, 7500],
[2500, 4000, 5000, 6500, 8000],
[3250, 4250, 5750, 7750, 8750],
[750, 3000, 4000, 5750, 6750],
[1000, 2250, 5500, 7250, 8750]];
I'm sorry for the long post, I realize these questions are probably very trivial and can be resolved relatively quickly, but I cannot find suitable answers for them.
I look forward to your response and am very grateful for them!
Best
--
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/ea611ca2-b6b7-4d55-bdfd-1efe46baa122%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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/f384d330-8012-42e1-a706-1e8397386aa9%40googlegroups.com.
I have one final question:
How could one modify the single-stim plugin such that you're able to accept multiple key responses per one trial after which different events happen.
I've created an adapted version of the single-stim plugin now such that following a response, you are either flashed a green or red arrow immediately after your response (a picture prompt with immediate updating), depending on your speed. In addition to this, your score constantly updates at the end of the each trial as a usual prompt.
What the final functionality should include is that, after the presentation of the stimuli, if you press a button more than once within one trial, you would be presented with a red arrow each time.
The way the single-stim works is that it accepts only one response for one trial.
I've tried adapting the parts of code from the multi-stim-multi-response such that I would be able to do that but without success.
An alternative that comes to mind would be an additional parameter within the plugin, where I would have a callback function similar to the ones that you've already implemented where it would do conceptually the same thing as "on_data_update" but here it would be "after_each_keypress"
Do you have any suggestions? Much thanks
--
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/89fd257f-4598-4cab-a564-f114a25fa940%40googlegroups.com.
I've set "persist" to true so that it's responsive to multiple key presses.
Within my plugin, I've adapted the code such that, after each key press, a 'picture prompt' gets shown.
There are two things I would like to add here and that I haven't figured out how to do. I have tried a lot of things to get this working and none of them worked so far.
var after_response = function(info) {
if (!trial.is_html) {
display_element.append($('<img>', {
src: trial.pic_prompt,
id: 'jspsych-single-stim-pic-prompt'
}));
} else {
display_element.append($('<div>', {
html: trial.pic_prompt,
id: 'jspsych-single-stim-pic-prompt'
}));
}
if (trial.timing_stim > 0) {
t8 = setTimeout(function () {
$('#jspsych-single-stim-pic-prompt').css('visibility', 'hidden');
}, trial.timing_stim);
setTimeoutHandlers.push(t8);
}
// after a valid response, the stimulus will have the CSS class 'responded'
// which can be used to provide visual feedback that a response was recorded
$("#jspsych-single-stim-stimulus").addClass('responded');
After 2 or more keypresses, the picture prompt always stays on screen. So when I press a key for the first time, the picture prompt appears and dissappears as written in the code (and working as intended), but after the next keypress it appears and stays on until the end of a trial (does this have to do with the timeout?). I'm not sure how to adapt the code such that after each keypress, the picture prompt will appear and dissappear as after the first keypress.
In addition, if there are 2 or more keypresses per trial, I would like for the picture used in the picture prompt to change together with the points that are being generally added up (a variable dynamically changing inside a function in the prompt) as a consequence of 2 or more keypresses per trial.
In pseudocode, I would essentially want to do:
if number of keypresses >= 2
picture propmt = incorrect.jpg
variable in the normal prompt denoting points = variable - 10
I don't know how I can pass the change from the .js plugin file to the .html file where the picture prompt .jpg is defined and the variable for the normal prompt is being updated.
I would really appreciate advice on this, because I have no idea how to implement that at the moment. I've tried a lot of different things but none work.
--
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/3f56e016-bbd6-41c6-be7d-60f54493fa06%40googlegroups.com.