-
Hi Josh and GitHub community, I was just wondering if anyone wouldn’t mind giving me some advice about accessing and storing the data collected using JsPsych? Essentially I’m just wondering how I can look at the data structure which Jspsych uses so that I can set up my database in phpmyadmin accordingly? So for example does jspsych store participant responses in an array in a single key and value pair for the function used or multiple key value pairs for each trial? I think I am particularly confused because i'm unsure which column names the JsPsych package assigns to the data and in turn which column names I should use for my database so that the data can be inserted there. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
I would not recommend storing jsPsych data parsed into columns of a relational database if you're not going to be querying it heavily. By it's nature, the data is messy, and each plugins adds its own field to the object for each trial. What I'd recommend is CREATE TABLE data {
participantID INTEGER NOT NULL,
jsPsychData TEXT NOT NULL,
createdtime DATETIME NOT NULL
} where jsPsychData is the JSON for the experiment. If you have a use case where you really need to add the columns to the db, then let's talk. |
Beta Was this translation helpful? Give feedback.
-
I think @vijaymarupudi's solution is very reasonable. I do store my data in columns to make the export to CSV easier. I use the |
Beta Was this translation helpful? Give feedback.
-
Also, here's a helper library that I wrote that handles the jsPsych -> MySQL pipeline via PHP: |
Beta Was this translation helpful? Give feedback.
-
Hi @jodeleeuw and @vijaymarupudi , Thanks for your responses I really appreciate it, I will try out @jodeleeuw's response as we will ideally need the data in separate columns. Thanks again! :D |
Beta Was this translation helpful? Give feedback.
I think @vijaymarupudi's solution is very reasonable. I do store my data in columns to make the export to CSV easier. I use the
jsPsych.data.get().uniqueNames()
function (docs page) to get a list of all of the columns in the data, and then I create the database structure from those columns. Note that you have to run the experiment to completion (or at least through all of the trials that generate different kinds of data) before calling the method.