-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addition of the Triple Handle Controller plugin for continuous, three-dimensional affective ratings #149
Open
caluap
wants to merge
9
commits into
jspsych:main
Choose a base branch
from
caluap:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Addition of the Triple Handle Controller plugin for continuous, three-dimensional affective ratings #149
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
99aad4d
triple handle controller plugin
caluap 641b2f5
Remove TODO in Readme.md
rl2939 17a9751
Update the Author/Citaitons in Readme.md
rl2939 a90d2d2
Remove install section in documentation.
rl2939 20b9ec9
Add files via upload
rl2939 8df6bcf
Merge pull request #1 from rl2939/patch-1
caluap 225be44
Merge pull request #2 from rl2939/Citations
caluap 341ef49
Merge pull request #3 from rl2939/rl2939-patch-1
caluap 4455afc
Merge pull request #4 from rl2939/Add-more-files
caluap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# triple-handle-controller plugin | ||
|
||
## Overview | ||
|
||
This plugin collects responses to a video file in real time using a game controller. | ||
|
||
## Loading | ||
|
||
### In browser | ||
|
||
```js | ||
<script src="https://unpkg.com/@jspsych-contrib/[email protected]"> | ||
``` | ||
|
||
### Via NPM | ||
|
||
``` | ||
npm install @jspsych-contrib/plugin-triple-handle-controller | ||
``` | ||
|
||
```js | ||
import jsPsychTripleHandleController from "@jspsych-contrib/plugin-triple-handle-controller"; | ||
``` | ||
|
||
## Compatibility | ||
|
||
This extension was tested with jsPsych v8.1.0. | ||
|
||
## Documentation | ||
|
||
The documentaion can be read [here](/docs/index.md). | ||
|
||
## Author / Citation | ||
|
||
Created by [Caluã de Lacerda Pataca](https://www.caluapataca.com) and [Russell Lee](https://github.com/rl2939). | ||
|
||
### Citation | ||
de Lacerda Pataca, C., & Lee, R. (2024, December 8). A jsPsych Plugin for Continuous Real-Time Valence, Arousal, and Dominance Reporting Using a Three-Handle Controller. https://doi.org/10.31234/osf.io/snr5u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# triple-handle-controller | ||
|
||
Current version: 1.0.2. [See version history](https://github.com/jspsych/jsPsych/blob/main/packages/plugin-triple-handle-controller/CHANGELOG.md). | ||
|
||
This plugin displays a video and records inputs from the participant via a game controller. This plugin requires an external game controller with at least one or more analogue input devices, such as a handle or a pressure sensitive button. The recording of data starts when the user presses the record button and ends when the video stops. | ||
|
||
The plugin will record data as indicated by the _rate_ variable (how many times it will record per second). | ||
|
||
## Parameters | ||
|
||
In addition to the [parameters available in all plugins](https://www.jspsych.org/latest/overview/plugins/index.html#parameters-available-in-all-plugins), this plugin accepts the following parameters. Parameters with a default value of _undefined_ must be specified. Other parameters can be left unspecified if the default value is acceptable. | ||
|
||
| Parameter | Type | Default Value | Description | | ||
| ------------- | ------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| title | string | undefined | The title to appear above the video. | | ||
| video_src | string | undefined | The url of the video location. | | ||
| axis_1 | numeric | undefined | The input number of the first axis. | | ||
| axis_2 | numeric | undefined | The input number of the second axis. | | ||
| axis_3 | numeric | undefined | The input number of the third axis. | | ||
| axis_location | complex | ["L", "H", "R"] | An array of three characters which will indicate the placement of each of the three axises on screen. "L" places the axis on the left of the screen, "R" places the axis on the right of the screen, and "H" hides the axis entirely. | | ||
| axes_labels | complex | ["axis1", "axis2", "axis3"] | An array of the three axis names. If an axis is not going to be used, then an empty string ("") can be used in place of the name. | | ||
| axis1_labels | complex | ["low", "neutral", "high"] | An array of labels for axis 1. The label in index 1 appears near the bottom of the axis, the one in index 2 appears near the middle, and the one in index 3 appears near the top. | | ||
| axis2_labels | complex | ["negative", "neutral", "positive"] | An array of labels for axis 2. The label in index 1 appears near the bottom of the axis, the one in index 2 appears near the middle, and the one in index 3 appears near the top. | | ||
| axis3_labels | complex | ["a", "b", "c"] | An array of labels for axis 3. The label in index 1 appears near the bottom of the axis, the one in index 2 appears near the middle, and the one in index 3 appears near the top. | | ||
| rate | numeric | 1000 | Number of miliseconds between each data call. | | ||
|
||
## Data Generated | ||
|
||
In addition to the [default data collected by all plugins](https://www.jspsych.org/latest/overview/plugins/index.html#data-collected-by-all-plugins), this plugin collects the following data for each trial. | ||
|
||
| Name | Type | Value | | ||
| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| data_arrays | array | An array of three arrays, each representing an different input device. Each of the three arrays inside contains a value of the handle taken as often as set in the rate parameter. | | ||
| rate | numeric | Number of miliseconds between each data call. | | ||
| video_src | string | A URL to a copy of the videodata. | | ||
| duration | numeric | The length of the video, in seconds. | | ||
|
||
|
||
|
||
## Examples | ||
|
||
This code runs an experiment involving two levers. | ||
|
||
|
||
``` | ||
const videos = ["Test.webm"]; | ||
|
||
var experiment = [ | ||
{ | ||
type: jsTripleHandleController, | ||
axis_1: 0, | ||
axis_2: 1, | ||
axis_3: 2, | ||
axis_location: ["L", "R", "H"], | ||
axis1_labels: ["No", "Maybe", "Yes"], | ||
axis2_labels: ["0%", "50%", "100%"], | ||
css_clases: ["thc-override"], | ||
axes_labels: ["axis1 (axis 1)", "axis2 (axis 2)", "item 3 (axis 3)"], | ||
title: "Follow the instructions in the video.", | ||
// A monitor refresh rate of 60 Hz means that | ||
// the screen changes every 16.7 ms or higher. | ||
rate: 1000 / 60, //16.777... | ||
}, | ||
]; | ||
|
||
async function createExperiment() { | ||
const videoSrc = `./videos/${videos[0]}`; | ||
experiment[0].video_src = videoSrc; | ||
jsPsych.run(experiment); | ||
} | ||
|
||
createExperiment(); | ||
``` | ||
|
||
## Demo | ||
|
||
See the examples folder. | ||
|
||
The bullet train video (BulletTrainFriction.webm) is from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:BulletTrainFriction.webm), under the [Creative Commons CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/deed.en). |
100 changes: 100 additions & 0 deletions
100
packages/plugin-triple-handle-controller/examples/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title>Axis1/Axis2/Axis3 Measurements</title> | ||
<meta name="description" content="" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
<script src="https://unpkg.com/@jspsych/[email protected]"></script> | ||
<script src="../src/index.js"></script> | ||
<link | ||
href="https://unpkg.com/[email protected]/css/jspsych.css" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<link | ||
rel="icon" | ||
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🧪</text></svg>" | ||
/> | ||
|
||
<style> | ||
@import url("https://fonts.googleapis.com/css2?family=Inter:slnt,[email protected],200..900&display=swap"); | ||
|
||
:root { | ||
--primary: 32, 107, 248; | ||
--paperColor: 255, 253, 245; | ||
--column-width: 720px; | ||
} | ||
|
||
body { | ||
background-color: rgb(var(--paperColor)); | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.jspsych-display-element, | ||
.jspsych-display-element input[type="text"], | ||
.jspsych-btn, | ||
button, | ||
textarea, | ||
p, | ||
* { | ||
font-family: "Inter", sans-serif; | ||
} | ||
|
||
#jspsych-content { | ||
width: 100%; | ||
max-width: unset; | ||
} | ||
|
||
#thc-player { | ||
background-color: black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script> | ||
let jsPsych = initJsPsych({ | ||
on_finish: function () { | ||
jsPsych.data.displayData(); | ||
}, | ||
}); | ||
const subjectId = jsPsych.randomization.randomID(10); | ||
const filename = `${subjectId}.json`; | ||
|
||
const videos = ["BulletTrainFriction.webm"]; | ||
|
||
jsPsych.data.addProperties({ | ||
subject: subjectId, | ||
}); | ||
|
||
let experiment = [ | ||
{ | ||
type: jsTripleHandleController, | ||
axis_1: 0, | ||
axis_2: 1, | ||
axis_3: 2, | ||
axis_location: ["L", "R", "L"], | ||
axis1_labels: ["low", "neutral", "high"], | ||
axis2_labels: ["negative", "neutral", "positive"], | ||
css_clases: ["thc-override"], | ||
axes_labels: ["axis1 (axis 1)", "axis2 (axis 2)", "item 3 (axis 3)"], | ||
title: "Bullet Train Friction", | ||
// A monitor refresh rate of 60 Hz means that | ||
// the screen changes every 16.7 ms or higher. | ||
rate: 1000 / 60, | ||
}, | ||
]; | ||
|
||
async function createExperiment() { | ||
const videoSrc = `./videos/${videos[0]}`; | ||
experiment[0].video_src = videoSrc; | ||
jsPsych.run(experiment); | ||
} | ||
|
||
createExperiment(); | ||
</script> | ||
</body> | ||
</html> |
Binary file added
BIN
+114 KB
packages/plugin-triple-handle-controller/examples/videos/BulletTrainFriction.webm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
{ | ||
"license": "Apache-2.0" | ||
} | ||
"dependencies": { | ||
"prettier": "^2.8.4" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to flesh this out in line with other packages, so it can be integrated via npm