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

3.x/features #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 2
jobs:
build:
working_directory: /tmp/src
docker:
- image: appsilon/ci-base:1.0
steps:
- checkout
- restore_cache:
keys:
- deps1-{{ .Branch }}
- deps1-
- run:
command: |
cd /tmp/src/
ls
cd expfactory.attentionnetworktest
R -e 'devtools::install_deps(dependencies = TRUE)'
- save_cache:
key: deps1-{{ .Branch }}
paths:
- "/usr/local/lib/R/site-library"
- run:
command: |
echo "Installing package expfactory"
R -e "devtools::install_github('expfactory/expfactoryr')"
cd /tmp/src/expfactory.attentionnetworktest
echo "Running devtools checks and tests for expfactory.attentionnetworktest"
R -e 'devtools::check()'
R -e 'devtools::test()'
- store_artifacts:
earcanal marked this conversation as resolved.
Show resolved Hide resolved
path: /tmp/src/expfactory.attentionnetworktest/man/
destination: man
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.Rcheck
.Rproj.user
.Rhistory
.RData
.Ruserdata
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Experiment Factory Experiment
# Attention Network Task

Hi Friend! This is an Experiment that is friendly for use in the [Experiment Factory](https://expfactory.github.io/expfactory). You can run it locally by putting these files in a web server, or use the Experiment Factory to generate a reproducible container. Check out the documentation above for more information, or [post an issue](https://www.github.com/expfactory/expfactory/issues) if you have any questions.
This is an Experiment that is friendly for use in the [Experiment Factory](https://expfactory.github.io/expfactory). You can run it locally by putting these files in a web server, or use the Experiment Factory to generate a reproducible container. Check out the documentation above for more information, or [post an issue](https://www.github.com/expfactory/expfactory/issues) if you have any questions.

![https://expfactory.github.io/expfactory/img/expfactoryticketyellow.png](https://expfactory.github.io/expfactory/img/expfactoryticketyellow.png)

# Processing Data in R

There's an associated **alpha** `R` package for processing the data.

## Installation

```
library(devtools)
install_github('expfactory-experiments/attention-network-task/expfactory.attentionnetworktest')
```
31 changes: 16 additions & 15 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"cognitive_atlas_task_id": "trm_551f0857e1db8",
"instructions":"Respond to the stimuli on the screen.",
"description":"Expfactory experiment",
"url":"https://www.github.com/expfactory-experiments/attention-network-task",
"contributors": [
"Ian Eisenberg",
"Zeynep Enkavi",
"Patrick Bissett",
"Vanessa Sochat",
"Russell Poldrack"
],
"exp_id": "attention-network-task",
"name": "Attention Network Task",
"reference": ["http://www.mitpressjournals.org/doi/pdf/10.1162/089892902317361886"],
"template": "jspsych",
"time": 15
"exp_id": "attention-network-task",
"url": "https://www.github.com/expfactory-experiments/attention-network-task",
"description":"Attention Network Task.",
"instructions": "N/A",
"template":"jspsych",
"cognitive_atlas_task_id": "",
"contributors": [
"Ian Eisenberg",
"Zeynep Enkavi",
"Patrick Bissett",
"Vanessa Sochat",
"Russell Poldrack",
"Paul Sharpe"
],
"time":15,
"reference": ["http://www.mitpressjournals.org/doi/pdf/10.1162/089892902317361886"]
}
192 changes: 98 additions & 94 deletions experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ var getInstructFeedback = function() {

var post_trial_gap = function() {
var curr_trial = jsPsych.progress().current_trial_global
return 3500 - jsPsych.data.getData()[curr_trial - 1].rt - jsPsych.data.getData()[curr_trial - 4].block_duration
}

var get_RT = function() {
var curr_trial = jsPsych.progress().current_trial_global
return jsPsych.data.getData()[curr_trial].rt
return 3500 - jsPsych.data.getData()[curr_trial - 1].block_duration - jsPsych.data.getData()[curr_trial - 4].block_duration
}

var getInstructFeedback = function() {
Expand Down Expand Up @@ -185,7 +180,7 @@ for (l = 0; l < locations.length; l++) {
}
}

/* set up 24 practice trials. Included all nocue up trials, center cue up trials, double cue down trials, and 6 spatial trials (3 up, 3 down) */
/* set up 24 practice trials. Include all nocue up trials, center cue up trials, double cue down trials, and 6 spatial trials (3 up, 3 down) */
var practice_block = jsPsych.randomization.repeat(test_stimuli.slice(0, 12).concat(test_stimuli.slice(
18, 21)).concat(test_stimuli.slice(36, 45)), 1, true);

Expand Down Expand Up @@ -229,7 +224,7 @@ var post_task_block = {
/* define static blocks */
var test_intro_block = {
type: 'poldrack-text',
text: '<div class = centerbox><p class = center-block-text>We will now start the test. Press <strong>enter</strong> to begin.</p></div>',
text: '<div class = centerbox><p class = center-block-text>We will now start the test. Move the mouse pointer off of the screen, then press <strong>enter</strong> to begin.</p></div>',
cont_key: [13],
data: {
trial_id: "intro",
Expand All @@ -244,11 +239,11 @@ var test_intro_block = {

var end_block = {
type: 'poldrack-text',
text: '<div class = centerbox><p class = center-block-text>Thanks for completing this task!</p><p class = center-block-text>Press <strong>enter</strong> to continue.</p></div>',
cont_key: [13],
text: '<div class = centerbox><p class = center-block-text>Thanks for completing this task!</p><p class = center-block-text>Please contact the researcher.</p></div>',
cont_key: ['c'],
data: {
trial_id: "end",
exp_id: 'attention_network_task'
exp_id: 'attention_network_task_2'
},
timing_response: 180000,
timing_post_trial: 0,
Expand All @@ -268,11 +263,16 @@ var feedback_instruct_block = {
timing_response: 180000
};
/// This ensures that the subject does not read through the instructions too quickly. If they do it too quickly, then we will go over the loop again.
if (Practise == 1) {
practice_instructions = '<p class = block-text>After you end instructions we will start with practice. During practice you will receive feedback about whether your responses are correct. You will not receive feedback during the rest of the experiment.</p><p class=block-text>Click <strong>End Instructions</strong>, then move the mouse pointer off of the screen before starting with practice.</p>'
} else {
practice_instructions = '<p class = block-text>There will be no practice trials. You will not receive feedback on your accuracy during the experiment.</p>'
}
var instructions_block = {
type: 'poldrack-instructions',
pages: [
'<div class = centerbox><p class = block-text>In this experiment you will see groups of five arrows and dashes pointing left or right (e.g &larr; &larr; &larr; &larr; &larr;, or &mdash; &mdash; &rarr; &mdash; &mdash;) presented randomly at the top or bottom of the screen.</p><p class = block-text>Your job is to indicate which way the central arrow is pointing by pressing the corresponding arrow key.</p></p></p></div>',
'<div class = centerbox><p class = block-text>Before the arrows and dashes come up, an * will occasionally come up somewhere on the screen.</p><p class = block-text>Irrespective of whether or where the * appears, it is important that you respond as quickly and accurately as possible by pressing the arrow key corresponding to the direction of the center arrow.</p><p class = block-text>After you end instructions we will start with practice. During practice you will receive feedback about whether your responses are correct. You will not receive feedback during the rest of the experiment.</p></div>'
'<div class = centerbox><p class = block-text>In this experiment you will see groups of five arrows and dashes pointing left or right (e.g &larr; &larr; &larr; &larr; &larr;, or &mdash; &mdash; &rarr; &mdash; &mdash;) presented randomly at the top or bottom of the screen.</p><p class = block-text>Your job is to indicate which way the <strong>central arrow</strong> is pointing by pressing the corresponding arrow key.</p></p></p></div>',
'<div class = centerbox><p class = block-text>Start each trial by attending to the cross in the center of the screen. Before the arrows appear, a * may appear somewhere on the screen.</p><p class = block-text>Irrespective of whether or where the * appears, it is important that you <strong>respond as quickly and accurately as possible</strong> by pressing the arrow key corresponding to the direction of the <strong>center arrow</strong>.</p>' + practice_instructions + '</div>'
],
allow_keys: false,
data: {
Expand Down Expand Up @@ -391,98 +391,99 @@ var attention_network_task_experiment = [];
attention_network_task_experiment.push(instruction_node);

/* set up ANT practice */
var trial_num = 0
var block = practice_block
for (i = 0; i < block.data.length; i++) {
var trial_num = trial_num + 1
var first_fixation_gap = Math.floor(Math.random() * 1200) + 400;
var first_fixation = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div>',
is_html: true,
choices: 'none',
data: {

trial_id: 'fixation',
exp_stage: 'practice'
},
timing_post_trial: 0,
timing_stim: first_fixation_gap,
timing_response: first_fixation_gap
}
attention_network_task_experiment.push(first_fixation)

if (block.data[i].cue == 'nocue') {
attention_network_task_experiment.push(no_cue)
} else if (block.data[i].cue == 'center') {
attention_network_task_experiment.push(center_cue)
} else if (block.data[i].cue == 'double') {
attention_network_task_experiment.push(double_cue)
} else {
var spatial_cue = {
if (Practise == 1) {
var trial_num = 0
var block = practice_block
for (i = 0; i < block.data.length; i++) {
var trial_num = trial_num + 1
var first_fixation_gap = Math.floor(Math.random() * 1200) + 400;
var first_fixation = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div><div class = centerbox><div class = ANT_' + block.data[i].flanker_location +
'><div class = ANT_text>*</p></div></div>',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div>',
is_html: true,
choices: 'none',
data: {

trial_id: 'spatialcue',
trial_id: 'fixation',
exp_stage: 'practice'
},
timing_post_trial: 0,
timing_stim: 100,
timing_response: 100
timing_stim: first_fixation_gap,
timing_response: first_fixation_gap
}
attention_network_task_experiment.push(spatial_cue)
}
attention_network_task_experiment.push(first_fixation)

attention_network_task_experiment.push(fixation)

block.data[i].trial_num = trial_num
var attention_network_task_practice_trial = {
type: 'poldrack-categorize',
stimulus: block.stimulus[i],
is_html: true,
key_answer: block.data[i].correct_response,
correct_text: '<div class = centerbox><div style="color:green"; class = center-text>Correct!</div></div>',
incorrect_text: '<div class = centerbox><div style="color:red"; class = center-text>Incorrect</div></div>',
timeout_message: '<div class = centerbox><div class = center-text>Respond faster!</div></div>',
choices: choices,
data: block.data[i],
timing_response: 1700,
timing_stim: 1700,
response_ends_trial: true,
timing_feedback_duration: 1000,
show_stim_with_feedback: false,
timing_post_trial: 0,
on_finish: function() {
jsPsych.data.addDataToLastTrial({
exp_stage: exp_stage
})
if (block.data[i].cue == 'nocue') {
attention_network_task_experiment.push(no_cue)
} else if (block.data[i].cue == 'center') {
attention_network_task_experiment.push(center_cue)
} else if (block.data[i].cue == 'double') {
attention_network_task_experiment.push(double_cue)
} else {
var spatial_cue = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div><div class = centerbox><div class = ANT_' + block.data[i].flanker_location +
'><div class = ANT_text>*</p></div></div>',
is_html: true,
choices: 'none',
data: {

trial_id: 'spatialcue',
exp_stage: 'practice'
},
timing_post_trial: 0,
timing_stim: 100,
timing_response: 100
}
attention_network_task_experiment.push(spatial_cue)
}

attention_network_task_experiment.push(fixation)

block.data[i].trial_num = trial_num
var attention_network_task_practice_trial = {
type: 'poldrack-categorize',
stimulus: block.stimulus[i],
is_html: true,
key_answer: block.data[i].correct_response,
correct_text: '<div class = centerbox><div style="color:green"; class = center-text>Correct!</div></div>',
incorrect_text: '<div class = centerbox><div style="color:red"; class = center-text>Incorrect</div></div>',
timeout_message: '<div class = centerbox><div class = center-text>Respond faster!</div></div>',
choices: choices,
data: block.data[i],
timing_response: 1700,
timing_stim: 1700,
response_ends_trial: true,
timing_feedback_duration: 1000,
show_stim_with_feedback: false,
timing_post_trial: 0,
on_finish: function() {
jsPsych.data.addDataToLastTrial({
exp_stage: exp_stage
})
}
}
}

attention_network_task_experiment.push(attention_network_task_practice_trial)

var last_fixation = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div>',
is_html: true,
choices: 'none',
data: {

trial_id: 'fixation',
exp_stage: 'practice'
},
timing_post_trial: 0,
timing_stim: post_trial_gap,
timing_response: post_trial_gap,
attention_network_task_experiment.push(attention_network_task_practice_trial)

var last_fixation = {
type: 'poldrack-single-stim',
stimulus: '<div class = centerbox><div class = ANT_text>+</div></div>',
is_html: true,
choices: 'none',
data: {

trial_id: 'fixation',
exp_stage: 'practice'
},
timing_post_trial: 0,
timing_stim: post_trial_gap,
timing_response: post_trial_gap,
}
attention_network_task_experiment.push(last_fixation)
}
attention_network_task_experiment.push(last_fixation)
attention_network_task_experiment.push(rest_block)
}

attention_network_task_experiment.push(rest_block)
attention_network_task_experiment.push(test_intro_block);


Expand Down Expand Up @@ -573,7 +574,10 @@ for (b = 0; b < blocks.length; b++) {
attention_network_task_experiment.push(last_fixation)
}
attention_network_task_experiment.push(attention_node)
attention_network_task_experiment.push(rest_block)
if (b < (blocks.length - 1)) // no rest after final block
attention_network_task_experiment.push(rest_block)
}
attention_network_task_experiment.push(post_task_block)
attention_network_task_experiment.push(end_block)
if (PostTask == 1)
attention_network_task_experiment.push(post_task_block)
if (Lab == 1)
attention_network_task_experiment.push(end_block)
2 changes: 2 additions & 0 deletions expfactory.attentionnetworktest/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
17 changes: 17 additions & 0 deletions expfactory.attentionnetworktest/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Package: expfactory.attentionnetworktest
Type: Package
Title: Process Data Generated by The Experiment Factory Attention Network Test
Version: 0.1.0
Author: Paul Sharpe
Maintainer: <paul@miraclefish.com>
Description: Process Data Generated by The Experiment Factory Attention Network Test.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
dplyr,
magrittr,
utils,
expfactory
RoxygenNote: 6.0.1
Suggests: testthat
21 changes: 21 additions & 0 deletions expfactory.attentionnetworktest/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Paul Sharpe, Plymouth University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading