Code Monkey home page Code Monkey logo

Comments (11)

igmmgi avatar igmmgi commented on May 27, 2024

Yes, a MWE would help. It has been a while since I worked on this code. But running my example does give me one data line per word in the sentence. Looking at the code, the end_trial function only triggers on the final word (as you observed), but the data to the earlier words in the sentence are saved via this.jsPsych.data.write. What is in the results file at the end?
on_finish: function () {
jsPsych.data.displayData('csv');
}

from jspsych-contrib.

jodeleeuw avatar jodeleeuw commented on May 27, 2024

Looking at the code, the end_trial function only triggers on the final word (as you observed), but the data to the earlier words in the sentence are saved via this.jsPsych.data.write.

I hadn't noticed this before. This isn't technically a supported use case for jsPsych.data.write() because under the current data model we expect there to be exactly one entry per trial. For other plugins that have similar kinds of data we typically store the data in arrays.

from jspsych-contrib.

jkhartshorne avatar jkhartshorne commented on May 27, 2024

I'm fairly confident that's the issue: pushkin-consortium/pushkin-client#38 (comment)

I was making a MWE for posterity. And I'm also working on a pull request that should fix this. Based on the docs, I was planning on using jsPsych.data.addProperties(). @jodeleeuw you wouldn't suggest that?

from jspsych-contrib.

jkhartshorne avatar jkhartshorne commented on May 27, 2024

OK, here's the MWE: https://github.com/jkhartshorne/jspsych-test-spr

The critical bit is

    const jsPsych = initJsPsych({
      on_finish: function() {
        jsPsych.data.displayData();
      },
      on_trial_finish: (data) => console.log(data)
    });

If you watch the console.log, you'll see that when on_trial_finish is triggered, the data object it is passed contains only the final word in the sentence.

from jspsych-contrib.

jodeleeuw avatar jodeleeuw commented on May 27, 2024

No, that will add the data to all trials. Mainly used for things like subject IDs, condition assignment, etc.

I'd recommend modifying the plugin to remove calls to jsPsych.data.write() and instead store the sequence of responses for each variable in arrays. These can be unnested fairly easily in R using tidyr::unnest.

I do think some of the changes we are making to version 8 may allow us to explore more flexible data models. @bjoluc it would be interesting to consider whether to add a method to write a row of data before a trial is finished.

from jspsych-contrib.

jkhartshorne avatar jkhartshorne commented on May 27, 2024

@jodeleeuw -- my turn to complain to you about cross-platform compatibility. Apparently it's not trivial to get canvas installed on an M1 chip.

As I learned here, users of M1s and M2 need to first run

brew install pkg-config cairo pango libpng jpeg giflib librsvg

It may or may not be necessary to also globally install node-gyp using your favorite package manager (yarn or npm, etc.). I did just to check that I could get it installed, so I don't know if it's necessary. I'll add that to the docs and give you a pull request.

from jspsych-contrib.

jkhartshorne avatar jkhartshorne commented on May 27, 2024

I'm not entirely sure how to test this locally, but the tests work. (Or at least they did after I rewrote them.)

#77

from jspsych-contrib.

bjoluc avatar bjoluc commented on May 27, 2024

Apparently it's not trivial to get canvas installed on an M1 chip.

Sadly, it's not trivial to get canvas installed in many circumstances. Canvas is a dependency of @jspsych/config needed for the canvas plugin tests. Terribly wrong decision to include it with the other testing deps in hindsight – I didn't know it was such a trouble maker. We'll remove this in @jspsych/config v2. Until then, let me exclude it manually in this repo, so we don't need to add instructions for it.

it would be interesting to consider whether to add a method to write a row of data before a trial is finished.

@jodeleeuw Interesting idea, but would require some thought and might add a lot of complexity for an edge case (?) that can also be solved by plugin code. Not something I'd like to maintain, I think 🙃

from jspsych-contrib.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.