Skip to content

Commit

Permalink
Merge pull request #73 from lnccbrown/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wasita authored Jan 13, 2020
2 parents 65b8e4b + 38a3744 commit 2b1e56c
Show file tree
Hide file tree
Showing 11 changed files with 3,830 additions and 2,015 deletions.
5,710 changes: 3,731 additions & 1,979 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
"repository": "https://github.com/brown-ccv/neuro-task-starter",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.9.0",
"acorn": "^7.1.0",
"bootstrap": "^4.3.1",
"cross-env": "^6.0.3",
"electron-devtools-installer": "^2.2.4",
"electron-log": "^3.0.9",
"electron-squirrel-startup": "^1.0.0",
"event-marker": "git+https://github.com/brown-ccv/event-marker.git#feat-comname",
"event-marker": "git+https://github.com/brown-ccv/event-marker.git",
"fibers": "^4.0.2",
"jquery": "^3.4.1",
"jspsych-react": "^0.2.2",
"lodash": "^4.17.11",
"node-sass": "^4.13.0",
"popper.js": "^1.16.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"react-scripts": "^3.3.0",
"sass": "^1.24.4",
"typescript": "^3.6.4"
},
"scripts": {
Expand Down Expand Up @@ -67,18 +71,25 @@
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.15.0",
"@typescript-eslint/parser": "^2.15.0",
"babel-eslint": "^10.0.3",
"babel-plugin-macros": "^2.6.1",
"chai": "^4.2.0",
"concurrently": "^4.1.2",
"electron": "6.1.1",
"electron-packager": "^14.0.6",
"electron-rebuild": "^1.8.6",
"eslint": "^6.6.0",
"eslint": "^6.8.0",
"eslint-config-react-app": "^5.1.0",
"eslint-config-standard": "^14",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-flowtype": "^3.13.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^1.7.0",
"eslint-plugin-standard": "^4.0.1",
"require-context.macro": "^1.1.1"
},
Expand Down
46 changes: 23 additions & 23 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,30 @@ const setUpPort = async () => {
}

const handleEventSend = (code) => {
// if (!portAvailable && !SKIP_SENDING_DEV) {
// let message = "Event Marker not connected"
// log.warn(message)
//
// let buttons = ["Quit", "Retry"]
// if (process.env.ELECTRON_START_URL) {
// buttons.push("Continue Anyway")
// }
// dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0})
// .then((resp) => {
// let opt = resp.response
// if (opt == 0) { // quit
// app.exit()
// } else if (opt == 1) { // retry
// setUpPort()
// .then(() => handleEventSend(code))
// } else if (opt == 2) {
if (!portAvailable && !SKIP_SENDING_DEV) {
let message = "Event Marker not connected"
log.warn(message)

let buttons = ["Quit", "Retry"]
if (process.env.ELECTRON_START_URL) {
buttons.push("Continue Anyway")
}
dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0})
.then((resp) => {
let opt = resp.response
if (opt == 0) { // quit
app.exit()
} else if (opt == 1) { // retry
setUpPort()
.then(() => handleEventSend(code))
} else if (opt == 2) {
SKIP_SENDING_DEV = true
// }
// })
//
// } else if (!SKIP_SENDING_DEV) {
// sendToPort(triggerPort, code)
// }
}
})

} else if (!SKIP_SENDING_DEV) {
sendToPort(triggerPort, code)
}
}

// EVENT TRIGGER
Expand Down
4 changes: 2 additions & 2 deletions src/config/experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ let exptBlock1 = deepCopy(defaultBlockSettings)
exptBlock1.probs = ["100%", "100%", "50%", "50%"]
exptBlock1.counterbalance = true
exptBlock1.value = [3, 5, 7]
exptBlock1.effort = [100, 120, 150]
exptBlock1.effort = [50, 100, 200] // default vals were: 100, 120, 150
exptBlock1.keys = ['q', 'p', 'm']
exptBlock1.get_reward = [true, true, true, false]
exptBlock1.num_breaks = 3

// debug settings where there are only 2 trials in main task block
// exptBlock1.probs = ["100%"]
Expand All @@ -22,7 +23,6 @@ exptBlock1.get_reward = [true, true, true, false]
// exptBlock1.get_reward = [true]



export {
exptBlock1
}
6 changes: 4 additions & 2 deletions src/config/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { jsPsych } from 'jspsych-react'
import _ from 'lodash'
import { eventCodes } from './trigger'

const canvasSize = 600
const x25 = canvasSize * 0.25
const x20 = canvasSize * 0.2
Expand Down Expand Up @@ -71,12 +72,13 @@ const defaultBlockSettings = {
repeats_per_condition: 1, // number of times every condition is repeated
is_practice: false,
photodiode_active: false,
num_breaks: 0
}

// high effort timeout
// high effort timeout (in seconds)
const high_effort_time = 25

// how long to countdown
// how long to countdown (in seconds)
const countdownWait = 3

export {
Expand Down
7 changes: 6 additions & 1 deletion src/language/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@
"practice1": "You will begin <b>Practice Trial 1/3</b> in",
"practice2": "You will begin <b>Practice Trial 2/3</b> in",
"practice3": "You will begin <b>Practice Trial 3/3</b> in",
"expt1": "You will begin <b>Main Block </b> in"
"expt1": "You will begin <b>Main Block </b> in",
"post_break_resume": "You will resume the task in"
},
"cumulative_rew": {
"total": "Total:<br>"
},
"break": {
"prompt": "You may now take a break.",
"done": "Press any key to end your break and to resume the task."
},
"payment": {
"earned": "You have earned",
"experimenter": "Please inform the experimenter."
Expand Down
19 changes: 19 additions & 0 deletions src/timelines/breakTrial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// import trials
import { lang } from '../config/main'
import breakScreen from '../trials/breakScreen'
import buildCountdown from '../trials/countdown'

const breakTrial = () => {

let timeline = [
breakScreen(),
buildCountdown(lang.countdown.post_break_resume, 3)
]

return {
type: 'html_keyboard_response',
timeline: timeline
}
}

export default breakTrial
8 changes: 8 additions & 0 deletions src/timelines/taskBlock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import taskTrial from './taskTrial'
import breakTrial from './breakTrial'
import { generateStartingOpts } from '../lib/taskUtils'

const taskBlock = (blockSettings) => {
Expand All @@ -14,6 +15,13 @@ const taskBlock = (blockSettings) => {
// timeline = loop through trials
let timeline = startingOpts.map( (opt) => taskTrial(blockSettings, blockDetails, opt))

if (blockSettings.num_breaks > 0) {
let breakInterval = Math.floor(timeline.length / (blockSettings.num_breaks + 1))
for (let iBreak = 1; iBreak < blockSettings.num_breaks + 1; iBreak++) {
timeline.splice(iBreak*breakInterval, 0, breakTrial())
}
}

return {
type: 'html_keyboard_response',
timeline: timeline
Expand Down
4 changes: 2 additions & 2 deletions src/timelines/taskTrial.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const taskTrial = (blockSettings, blockDetails, opts) => {
// timeline
let timeline = [
// show condition
fixation(500), // need ITI of ~500 btwn trials
rewardProbability(500, blockSettings, opts),
fixation(300), // need ITI of ~500 btwn trials
rewardProbability(1000, blockSettings, opts),
frameSpike(700, blockSettings, opts, trialDetails),
costBenefits(1500, blockSettings, opts, trialDetails),
choice(5000, blockSettings, opts),
Expand Down
19 changes: 19 additions & 0 deletions src/trials/breakScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { lang } from '../config/main'
import { baseStimulus } from '../lib/markup/stimuli'

const breakScreen = () => {
let stimulus = baseStimulus(`
<div class='instructions'>
<h1>${lang.break.prompt}
</div>
`, true)

return {
type: 'html_keyboard_response',
stimulus: stimulus,
prompt: lang.break.done,
response_ends_trial: true
}
}

export default breakScreen
1 change: 0 additions & 1 deletion src/trials/quizTrials.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const quizPrompts = [

// Quiz Trial
const quiz = (blockSettings) => {
console.log(blockSettings.quiz)

const preamble = `<div class="quiz_container">
<h3>${lang.quiz.respond_correctly}</h3>
Expand Down

0 comments on commit 2b1e56c

Please sign in to comment.