Skip to content
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

plugin-meye-config & extension-meye #73

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
17c9349
Add files via upload
AdamVasarhelyi2 Jul 26, 2023
ff25cfe
Delete packages/plugin-meye-config/dist/index.browser.js
AdamVasarhelyi2 Nov 11, 2023
9cb2fdd
Delete packages/extension-meye/dist/index.browser.js
AdamVasarhelyi2 Nov 11, 2023
e736e66
Delete packages/extension-meye/dist/index.browser.js.map
AdamVasarhelyi2 Nov 11, 2023
35c087d
Delete packages/extension-meye/dist/index.browser.min.js
AdamVasarhelyi2 Nov 11, 2023
f3e348a
Delete packages/extension-meye/dist/index.browser.min.js.map
AdamVasarhelyi2 Nov 11, 2023
f0dfa69
Delete packages/extension-meye/dist/index.cjs
AdamVasarhelyi2 Nov 11, 2023
8116578
Delete packages/extension-meye/dist/index.cjs.map
AdamVasarhelyi2 Nov 11, 2023
92f676d
Delete packages/extension-meye/dist/index.js
AdamVasarhelyi2 Nov 11, 2023
0822d04
Delete packages/extension-meye/dist/index.js.map
AdamVasarhelyi2 Nov 11, 2023
e3b0fc8
Delete packages/extension-meye/dist/index.d.ts
AdamVasarhelyi2 Nov 11, 2023
2a0b232
Delete packages/plugin-meye-config/dist/index.browser.js.map
AdamVasarhelyi2 Nov 11, 2023
eff7478
Delete packages/plugin-meye-config/dist/index.browser.min.js
AdamVasarhelyi2 Nov 11, 2023
3ae4066
Delete packages/plugin-meye-config/dist/index.cjs
AdamVasarhelyi2 Nov 11, 2023
d3029e1
Delete packages/plugin-meye-config/dist/index.cjs.map
AdamVasarhelyi2 Nov 11, 2023
d516d00
Delete packages/plugin-meye-config/dist/index.d.ts
AdamVasarhelyi2 Nov 11, 2023
fac0b99
Delete packages/plugin-meye-config/dist/index.js
AdamVasarhelyi2 Nov 11, 2023
3fbd3a0
Delete packages/plugin-meye-config/dist/index.js.map
AdamVasarhelyi2 Nov 11, 2023
28bdca0
Delete packages/plugin-meye-config/dist/index.browser.min.js.map
AdamVasarhelyi2 Nov 11, 2023
ef886dc
Use version 0.0.1 to allow update by changeset
jodeleeuw Jul 9, 2024
4143f52
Use version 0.0.1 to allow update by changeset
jodeleeuw Jul 9, 2024
d7937f5
Change package name to follow contrib convention
jodeleeuw Jul 9, 2024
915fabb
Change package name to follow contrib convention
jodeleeuw Jul 9, 2024
686a3b8
Change plugin global name to match convention
jodeleeuw Jul 9, 2024
5c038ac
Change class name to match convention
jodeleeuw Jul 9, 2024
4383c70
use updated name
jodeleeuw Jul 9, 2024
2ba17df
use updated name
jodeleeuw Jul 9, 2024
cebe98b
Use convention for extension global name
jodeleeuw Jul 9, 2024
48fe57f
Use convention for extension class name
jodeleeuw Jul 9, 2024
534a928
Use updated names
jodeleeuw Jul 9, 2024
6ebb556
Use updated names
jodeleeuw Jul 9, 2024
c08c0e7
Merge remote-tracking branch 'my-fork/main'
Jul 14, 2024
cd023a9
added rule to ignore all dist folders
Jul 14, 2024
1182d07
Updated package-lock.json
Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ coverage/
.vscode/
dist.zip
.idea
dist/
416 changes: 398 additions & 18 deletions package-lock.json

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions packages/extension-meye/LICENSE

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions packages/extension-meye/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# meye extension

## Overview

This extension collects pupillometric data using Meye, a deep-learning model developed by Fabio Carrara. He made it to run on a website for public use at https://www.pupillometry.it/, and this extension adapts it to JsPsych. After calibrating the extension with the meye plugin (which must be a trial called before any trial using the extension), this extension runs in the background when added to any trial thereafter.

Minimum requirements are a 720p 30fps webcam.

## Compatibility

Developed using jsPsych v7.3

## Documentation

Documentation can be found in the /docs folder.

## Author / Citation

Adam Vasarhelyi, Fabio Carrara
52 changes: 52 additions & 0 deletions packages/extension-meye/docs/extension-meye.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# extension-meye

Current version: 1.0.0.

This extension collects pupillometric data using Meye, a deep-learning model developed by Fabio Carrara. He made it to run on a website for public use at https://www.pupillometry.it/, and this extension adapts it to JsPsych. After calibrating the extension with the meye plugin (which must be a trial called before any trial using the extension), this extension runs in the background when added to any trial thereafter.

Minimum requirements are a 720p 30fps webcam.

## Parameters

This extension accepts one parameter. If unspecified, the extension will not collect any data.

| Parameter | Type | Default Value | Description |
| ------------------- | ---------------- | ------------------ | ---------------------------------------- |
| detection_interval | numeric | null | Specifies how often (in ms) the extension takes a snapshot of the user's pupil. |

## Data Generated

This extension collects the following data.

| Name | Type | Value |
| --------- | ------- | ---------------------------------------- |
| pupil_diameter | numeric | The diameter of the user's pupil at the time of snapshot, in pixels relative to the participant's monitor. The participant is assumed to have circular pupils because diameter is reported. |
| blink_prob | numeric | The probability that the user was blinking at the time of snapshot. Is between 0 and 1, where 1 indicates that the extension is certain that the user was blinking. |
| timecode | numeric | The seconds (rounded to three decimal places) since the start of the extension-trial dyad that the snapshot was taken, including the moment a trial starts and ends. Due to javascript, this cannot be perfectly accurate and an error of up to 30ms occurs on the developer's computer. |

## Install

Using the downloaded jspsych-contrib folder:

```js
<script src="jspsych-contrib/packages/extension-meye/dist/index.browser.min.js"></script>
```

## Examples

Ensure that the **plugin** is a trial in the timeline before adding the extension to any trial thereafter.

```javascript
var meyeCalibrate = {
type: jsPsychMeyeConfig,
};

var useExtension = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<img id="some-image" src="some-image.png"/>',
trial_duration: 600,
response_ends_trial: false,
data: { task: 'webcam1', US: 'no'},
extensions: [{ type: jsPsychExtensionMeye, params: {detection_interval: 100} }]
}
```
79 changes: 79 additions & 0 deletions packages/extension-meye/examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="../../plugin-meye-config/dist/index.browser.min.js"></script>
<script src="../dist/index.browser.min.js"></script>
</head>

<body>
<script>
/* initialize jsPsych */
var jsPsych = initJsPsych({
extensions: [{type: jsPsychExtensionMeye}],
on_finish: function() {
jsPsych.data.displayData();
jsPsych.data.get().localSave('csv','TESTDATA.csv');
}
});

/* create timeline */
var timeline = [];
var participant_id = jsPsych.data.getURLVariable('ID');
jsPsych.data.addProperties({participant: participant_id});

var screen_width = window.screen.availHeight;
jsPsych.data.addProperties({screenW: screen_width});

var screen_height = window.screen.availWidth;
jsPsych.data.addProperties({screenH: screen_height});

/* preload images */
var preload = {
type: jsPsychPreload,
images: ['../../plugin-meye-config/img/picture2.png', '../../plugin-meye-config/img/cross.png']
};

timeline.push(preload);

var meyeCalibrate = {
type: jsPsychMeyeConfig
};

const orientblue36 = {
timeline:[
{
type: jsPsychHtmlKeyboardResponse,
stimulus: '<img src="../../plugin-meye-config/img/cross.png" width="50" height="50"/>',
trial_duration: 600,
response_ends_trial: false,
extensions: [{ type: jsPsychExtensionMeye, params: {detection_interval: 100} }]
},
{
type: jsPsychHtmlKeyboardResponse,
stimulus: '<div><img id="Blue" src="../../plugin-meye-config/img/Picture2.png" height="9%" style="position:absolute; top:46%; left:64%"/></div>',
trial_duration: 2000,
data: { task: 'webcam1', US: 'no'},
extensions: [{ type: jsPsychExtensionMeye, params: {detection_interval: 200} }]
}
]
}

var test_procedure = {
timeline: [preload, meyeCalibrate, orientblue36]
};

timeline.push(test_procedure);
jsPsych.run(timeline);

</script>
</body>

</html>
17 changes: 17 additions & 0 deletions packages/extension-meye/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@jspsych-contrib/extension-meye",
"version": "0.0.1",
"description": "This extension collects pupillometric data using mEye, a deep-learning model developed by Fabio Carrara. He made it to run on a website \r for public use at https://www.pupillometry.it/, and this a JsPsych adaptation to make it viable for use in research. After calibration, the extension runs behind the scenes just like any other extension. Webcam quality >= 720p and >= 30fps is recommended.",
"type": "module",
"main": "dist/index.browser.min.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup --config"
},
"keywords": [],
"author": "Adam Vasarhelyi",
"license": "ISC",
"dependencies": {
"@tensorflow/tfjs": ""
}
}
3 changes: 3 additions & 0 deletions packages/extension-meye/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { makeRollupConfig } from "../../node_modules/@jspsych/config/rollup.js";

export default makeRollupConfig("jsPsychExtensionMeye");
Loading