npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neurocog

v1.1.1

Published

![Neurocog.js Icon](./icon.png)

Downloads

8

Readme

Neurocog.js

Neurocog.js Icon

A jsPsych Extension enabling integration with the Gorilla online behavioral experiment platform, designed to extend your jsPsych experiment with new features and capabilities.

🚨 Neurocog.js is now a jsPsych Extension! This means that Neurocog.js v0.4.0+ is only compatible with jsPsych v7.0+. For earlier jsPsych versions, please use Neurocog.js v0.3.9 or earlier. 🚨


Features

Gorilla integration

Facilitates interaction with parts of the Gorilla API. Load and access stimuli, access manipulations, and update stored data while maintaining the same codebase online and offline. The wrapper library detects what context the experiment is running in and makes API calls accordingly.

State management

A global state is maintained outside of the jsPsych instance. While not an advisable for experiment-wide data storage, a state system can be used to direct task logic and add an element of dynamic behavior. Additionally, it could function as temporary data storage.

Error handling & task shutdown

By listening for errors in the browser, this library provides graceful error handling and alerts participants before ending the experiment. This prevents online experiments from hanging or resulting in the complete loss of participant data.

Centralised seeded random number generator

A seeded RNG is provided using the D3.js library.

Installation

jsPsych v7.0+

npm install neurocog
yarn add neurocog

Once installed, refer to the jsPsych guide on Extension usage for instructions to enable the Neurocog.js extension within your existing experiment using jsPsych v7.0+. Refer to Configuration below for further information regaring the expected parameters (params).

Up to jsPsych v7.0

npm install [email protected]
yarn add [email protected]

Configuration

Neurocog.js expects a number of parameters (params) when being initialized. There are also optional parameters (parameters in bold are required):

| Name | Type | Description | | --------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name | string | A human-readable name for the experiment such as "Brain Game" | | studyName | string | A machine-readable name for the experiment plugin such as "brain-game". No whitespace is permitted. | | allowParticipantContact | boolean | Whether or not to show an email address for participants to contact in the case of an error. | | contact | string | The contact email address for the experiment. | | seed | number | A float to act as the seed for the RNG. | | state | key : value | State initialisation parameters. This object is digested as the initial state and is accessible during the experiment using the same keys. While not required, it must be at least defined if state functionality is to be used. | | logging | LogLevel | Set the logging level of the consola logging utility. |

⚠️ Breaking Change (as of v1.1.0): Multiple parameters have been removed and are no longer utilized. This has also been reflected in a number of functions that have been deprecated. This table describes the parameters that have been removed in v1.1.0.

| Name | Type | Description | | --------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ~~manipulations~~ | key : value | A collection of key-value pairs that represent the manipulations configured in Gorilla. The key must be a string, and the value can be a string, boolean, or number. While required, it can be empty. | | ~~resources~~ | key : value | A collection of key-value pairs that represent resources used in the experiment. The key can be used as a unique identifier for accessing the resource in the source code. The value is the relative path to the actual resource. While required, it can be empty. | | ~~stimuli~~ | key : value | A collection of key-value pairs that represent the stimuli used in the experiment. The key can be used as a unique identifier for accessing the stimulus in the source code. The value is the relative path to the actual stimulus. While required, it can be empty. |

Integration

To utilize the Neurocog.js functionality in timeline trials, ensure that the trial object contains the extensions parameter containing the type NeurocogExtension, shown below:

var timelineNode = {
  ...
  extensions: [
    {
      type: NeurocogExtension,
    }
  ],
  ...
}

Check out the experiment in the example/ directory for a simple example.

Gorilla: Manipulations

⚠️ Breaking Change (as of v1.1.0): Manipulations are no longer required to be specified in the Neurocog parameters. Now the getManipulation function takes two arguments, the name, and a default value. If running locally, the default value will always be returned. If running on Gorilla, the Manipulation value specified on Gorilla will be returned.

Accessing Manipulations:

const variableA = jsPsych.extensions.Neurocog.getManipulation("variableA", 2);
console.log(variableA); // The value of the manipulation if specified on Gorilla, otherwise 2

Gorilla: Stimuli

⚠️ Breaking Change (as of v1.1.0): When running an experiment locally, all Stimuli must be located in a stimuli directory alongside the file initializing jsPsych. Stimuli are no longer required to be specified in the Neurocog parameters.

The key for a Stimulus must be the exact file name.

Accessing Stimuli:

const imageSrc = jsPsych.extensions.Neurocog.getStimulus('stimulus.jpg');
console.log(imageA); // 'stimuli/stimulus.jpg' locally or the path to a Gorilla Stimulus

Gorilla: Resources

⚠️ Breaking Change (as of v1.1.0): When running an experiment locally, all Resources must be located in a resources directory alongside the file initializing jsPsych. Resources are no longer required to be specified in the Neurocog parameters.

The key for a Resource must be the exact file name.

Accessing Resources:

const resourceSrc = jsPsych.extensions.Neurocog.getResource('resource.jpg');
console.log(resourceSrc); // 'resource/resource.jpg' or the path to a Gorilla Resource

State management: accessing and updating state variables

Configuring State:

const jsPsych = initJsPsych({
  // ...
  extensions: [
    {
      type: NeurocogExtension,
      params: {
        // ...
        state: {
          counter: 0,
          // ...
        },
        // ...
      }
    }
  ],
  // ...
});

The following methods can be used for interacting with the experiment state throughout the experiment:

| Method | Parameters | Description | | ---------------------------- | --------------------------- | ---------------------------------------- | | getState(key) | key: string | Get the value of a global state variable | | setState(key, value) | key: string, value: any | Set the value of a global state variable |


License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.