Load pre-generated trial orders

531 views
Skip to first unread message

nicholas...@brown.edu

unread,
Mar 26, 2015, 4:37:20 PM3/26/15
to jsp...@googlegroups.com
Hi,

I'm new to javascript and am liking jsPsych so far but I had a question about loading data from file into an experiment. I have an experiment where we have pregenerated lists of stimuli and associated feedback and I'd like to be able to read these from file and pass through to jsPsych. Is this something that's feasible? It doesn't look there is a jsPsych module that can handle this.

thanks so much!
Nick

Josh de Leeuw

unread,
Mar 26, 2015, 5:35:04 PM3/26/15
to nicholas...@brown.edu, jsp...@googlegroups.com
There's nothing built into the library to do this yet. Depending on the format of your file, it might not be too difficult to write some extra code to take your file and turn it into a jspsych compatible experiment description. You could look into using an AJAX request to do that: http://stackoverflow.com/questions/24530977/read-text-file-on-server-into-array-javascript

However, if the file never changes, it might just be easier to convert the file into a JavaScript variable that you put into the experiment script. Or into a separate file that you also reference from the experiment script. Depending on format, the easiest way to do this might be to find a program that will convert your file into a JSON-string, which you can the read into JavaScript with JSON.parse().

If you provide some more details about the file structure, I might be able to give more specific advice.


--
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/ddfeea66-6987-4eb2-b144-2a997a62f510%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas Franklin

unread,
Mar 26, 2015, 5:50:14 PM3/26/15
to Josh de Leeuw, jsp...@googlegroups.com
Thanks. 


The file is static throughout the course of the experiment, and right now, I have it as a csv file. The file is meant to encode an 2-d array of integers, where each row corresponds to a trial, each column an action a subject can take and the integer is corresponds to a specific image number.

It sounds like the the easiest thing to do would be to convert to a JSON string?

Thanks,
Nick



Nicholas Franklin
PhD student, Brown University

Josh de Leeuw

unread,
Mar 26, 2015, 9:03:59 PM3/26/15
to Nicholas Franklin, jsp...@googlegroups.com
Yes, I think so. Though you might take a look at this library: http://papaparse.com/

--Josh
Reply all
Reply to author
Forward
0 new messages