Skip to content

Commit

Permalink
too many changes to list. basically got each assessment to it's minim…
Browse files Browse the repository at this point in the history
…ally viable working version
  • Loading branch information
hanayik committed Feb 17, 2017
1 parent 0207b34 commit dd01f8f
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 14 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# Discourse Assessments

These assessments have been used in past research studies on speech output abilities after stroke. They are designed to engage participants in fluent speech production rather than simply naming or repeating.

### Making a PBJ

The participant is shown an image of a peanut-butter and jelly sandwich and is asked to describe how they would make the sandwich in a step by step manner.

### Picnic Scene Description

The picnic scene is from the Western Aphasia Battery. The participant is asked to describe as many elements in the scene as possible. They may tell a story about what is happening or simply describe the picture in a list-wise manner.

### Broken Window Description

The broken window description assessment is used to get participants to describe the order of events from one image to the next (there's a set of 4). They should try to tell a story about what has happened to the window.

### Telling the Story of Cinderella

Participants view images from the cinderella storybook and then attempt to narrate the story on their own without the pictures as a guide. The pictures can be "flipped" through by using the left and right arrow keys on the keyboard.



##### Credits
icon credit: http://www.flaticon.com/authors/popcorns-arts

##### Disclaimer
I do not own the picture contents of any assessment material. Everything is provided free of charge and without guarantee of usability and accuracy (although I do try to make sure things work very well!). All images were found online using google searches. You can find anything on the web!
227 changes: 214 additions & 13 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,26 @@ var beepSound = path.join(__dirname, 'assets', 'beep.wav')
var exp = new experiment('discourse')
// construct a new ffmpeg recording object
var rec = new ff()
var timeoutTime = 30 // in seconds
var pbjTimeoutID
var pbjTimeoutTime = 1000*60*5 // 1000ms * 60s * 5min
var brokenWindowTimeoutID
var brokenWindowTimeoutTime = 1000*60*5
var picnicSceneTimeoutID
var picnicSceneTimeoutTime = 1000*60*2
var cinderellaTimeoutID
var cinderellaTimeoutTime = 1000*60*5
exp.getRootPath()
exp.getMediaPath()
var brokenWindowImg = path.resolve(exp.mediapath, 'brokenWindow.png')
console.log(brokenWindowImg)
var picnicSceneImg = path.resolve(exp.mediapath, 'picnic.jpg')
var pbjImg = path.resolve(exp.mediapath, 'pbj.png')
var cinderellaImgFolder = path.join(exp.mediapath, 'cinderellaImgs')
cinderellaImgs = fs.readdirSync(cinderellaImgFolder).sort(naturalSort())
var cinderellaImgs = fs.readdirSync(cinderellaImgFolder).sort(naturalSort())
var maxNumCinderellaImgs = cinderellaImgs.length
var cinderellaImgIdx = 0
var cinderellaStartHasBeenClicked = false
var cinderellaRecordingHasStarted = false
var assessment = ''
lowLag.init(); // init audio functions
//console.log(cinderellaImgs)
Expand Down Expand Up @@ -120,7 +132,7 @@ function ff() {
this.screenDeviceID = '1', // macOS only
this.videoSize = '1280x720', // output video dimensions
this.videoCodec = 'libx264', // encoding codec
this.recQuality = '30', //0-60 (0 = perfect quality but HUGE files)
this.recQuality = '20', //0-60 (0 = perfect quality but HUGE files)
this.preset = 'ultrafast',
this.videoExt = '.mp4',
// filter is for picture in picture effect
Expand All @@ -144,6 +156,15 @@ function ff() {
}
return sessID
},
this.getAssessmentType = function () {
var assessmentType = document.getElementById("assessmentID").value
if (assessmentType === '') {
console.log ('assessment field is blank')
alert('Assessment field is blank!')
} else {
return assessmentType
}
},
this.datestamp = getDateStamp(),
this.makeOutputFolder = function () {
outpath = path.join(app.getPath('userData'), 'video')
Expand All @@ -154,7 +175,7 @@ function ff() {
return outpath
}
this.outputFilename = function() {
return path.join(this.makeOutputFolder(), this.getSubjID()+'_'+this.getSessID()+'_'+getDateStamp()+this.videoExt)
return path.join(this.makeOutputFolder(), this.getSubjID()+'_'+this.getSessID()+'_'+this.getAssessmentType()+'_'+getDateStamp()+this.videoExt)
},
this.getFramerate = function () {
if (sys.isMacBook == true){
Expand Down Expand Up @@ -252,7 +273,55 @@ function clearScreen() {


// show text instructions on screen
function showInstructions(txt) {
function showBrokenWindowInstructions(txt) {
clearScreen()
rec.startRec()
var textDiv = document.createElement("div")
textDiv.style.textAlign = 'center'
var p = document.createElement("p")
var txtNode = document.createTextNode(txt)
p.appendChild(txtNode)
textDiv.appendChild(p)
var lineBreak = document.createElement("br")
var btnDiv = document.createElement("div")
var startBtn = document.createElement("button")
var startBtnTxt = document.createTextNode("Start")
startBtn.appendChild(startBtnTxt)
startBtn.onclick = showBrokenWindowImg
btnDiv.appendChild(startBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
content.appendChild(btnDiv)
return getTime()
}



function showPicnicSceneInstructions(txt) {
clearScreen()
rec.startRec()
var textDiv = document.createElement("div")
textDiv.style.textAlign = 'center'
var p = document.createElement("p")
var txtNode = document.createTextNode(txt)
p.appendChild(txtNode)
textDiv.appendChild(p)
var lineBreak = document.createElement("br")
var btnDiv = document.createElement("div")
var startBtn = document.createElement("button")
var startBtnTxt = document.createTextNode("Start")
startBtn.appendChild(startBtnTxt)
startBtn.onclick = showPicnicSceneImg
btnDiv.appendChild(startBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
content.appendChild(btnDiv)
return getTime()
}



function showPbjInstructions(txt) {
clearScreen()
rec.startRec()
var textDiv = document.createElement("div")
Expand All @@ -266,7 +335,30 @@ function showInstructions(txt) {
var startBtn = document.createElement("button")
var startBtnTxt = document.createTextNode("Start")
startBtn.appendChild(startBtnTxt)
startBtn.onclick = showNextTrial
startBtn.onclick = showPbjImg
btnDiv.appendChild(startBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
content.appendChild(btnDiv)
return getTime()
}



function showCinderellaStoryInstructions(txt) {
clearScreen()
var textDiv = document.createElement("div")
textDiv.style.textAlign = 'center'
var p = document.createElement("p")
var txtNode = document.createTextNode(txt)
p.appendChild(txtNode)
textDiv.appendChild(p)
var lineBreak = document.createElement("br")
var btnDiv = document.createElement("div")
var startBtn = document.createElement("button")
var startBtnTxt = document.createTextNode("Start")
startBtn.appendChild(startBtnTxt)
startBtn.onclick = showCinderellaImg
btnDiv.appendChild(startBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
Expand All @@ -275,16 +367,116 @@ function showInstructions(txt) {
}


// show single image on screen
function showImage(imgPath) {

function showPbjImg() {
clearScreen()
var imageEl = document.createElement("img")
imageEl.src = pbjImg
content.appendChild(imageEl)
clearTimeout(pbjTimeoutID)
pbjTimeoutID = setTimeout(clearScreenAndStopRecording, pbjTimeoutTime)
return getTime()
}



function showPicnicSceneImg() {
clearScreen()
var imageEl = document.createElement("img")
imageEl.src = imgPath
imageEl.src = picnicSceneImg
content.appendChild(imageEl)
clearTimeout(picnicSceneTimeoutID)
picnicSceneTimeoutID = setTimeout(clearScreenAndStopRecording, picnicSceneTimeoutTime)
return getTime()
}



function showBrokenWindowImg() {
clearScreen()
var imageEl = document.createElement("img")
imageEl.src = brokenWindowImg
content.appendChild(imageEl)
clearTimeout(brokenWindowTimeoutID)
brokenWindowTimeoutID = setTimeout(clearScreenAndStopRecording, brokenWindowTimeoutTime)
return getTime()
}



function showCinderellaImg() {
if (!cinderellaStartHasBeenClicked) {
cinderellaStartHasBeenClicked = true
}
clearScreen()
if (cinderellaImgIdx <= maxNumCinderellaImgs-1) {
var imageEl = document.createElement("img")
imageEl.src = path.join(cinderellaImgFolder, cinderellaImgs[cinderellaImgIdx])
content.appendChild(imageEl)
return getTime()
} else {
var textDiv = document.createElement("div")
textDiv.style.textAlign = 'center'
var p = document.createElement("p")
var txtNode = document.createTextNode("That was the last picture!")
p.appendChild(txtNode)
textDiv.appendChild(p)
var lineBreak = document.createElement("br")
var btnDiv = document.createElement("div")
var cinderellaBtn = document.createElement("button")
var cinderellaBtnTxt = document.createTextNode("Tell the story")
cinderellaBtn.appendChild(cinderellaBtnTxt)
cinderellaBtn.onclick = startCinderellaRecording
btnDiv.appendChild(cinderellaBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
content.appendChild(btnDiv)
}
}



function startCinderellaRecording() {
clearScreen()
var textDiv = document.createElement("div")
textDiv.style.textAlign = 'center'
var p = document.createElement("p")
var txtNode = document.createTextNode("Tell the story of Cinderella without the pictures.")
p.appendChild(txtNode)
textDiv.appendChild(p)
var lineBreak = document.createElement("br")
var btnDiv = document.createElement("div")
var cinderellaFinishBtn = document.createElement("button")
var cinderellaFinishBtnTxt = document.createTextNode("Click to finish")
cinderellaFinishBtn.appendChild(cinderellaFinishBtnTxt)
cinderellaFinishBtn.onclick = stopRecordingAndShowNav
btnDiv.appendChild(cinderellaFinishBtn)
content.appendChild(textDiv)
content.appendChild(lineBreak)
content.appendChild(btnDiv)
stopWebCamPreview()
rec.startRec()
cinderellaRecordingHasStarted = true
}



function stopRecordingAndShowNav() {
clearScreen()
rec.stopRec()
openNav()
}



function clearScreenAndStopRecording() {
clearScreen()
rec.stopRec()
openNav()
}



// load experiment module js file. All experiments are written in js, no separate html file
function loadJS (ID) {
if (!document.getElementById(ID +'JS')) {
Expand Down Expand Up @@ -405,10 +597,20 @@ function updateKeys() {
keys.rt = 0
console.log("key: " + keys.key)
if (keys.key === 'ArrowRight') {
showNextTrial()
if (assessment === 'cinderellaStory') {
if (!cinderellaRecordingHasStarted) {
cinderellaImgIdx += 1
showCinderellaImg()
}
}
}
if (keys.key === 'ArrowLeft') {
showPreviousTrial()
if (assessment === 'cinderellaStory') {
if (!cinderellaRecordingHasStarted) {
cinderellaImgIdx -= 1
showCinderellaImg()
}
}
}
}

Expand Down Expand Up @@ -466,14 +668,13 @@ function checkForEscape() {
// unloadJS(exp.name)
clearScreen()
rec.stopRec()
clearTimeout(trialTimeoutID)
}
}

function getStarted() {
var subjID = document.getElementById("subjID").value
var sessID = document.getElementById("sessID").value
var assessment = document.getElementById("assessmentID").value
assessment = document.getElementById("assessmentID").value
console.log("assessment chosen: ", assessment)
if (subjID === '' || sessID === '' || assessment === '') {
console.log ('subject and/or session is blank')
Expand Down
Binary file added icon.icns
Binary file not shown.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron app.js",
"build-mac": "electron-packager . --out=dist --platform=darwin --overwrite --tmpdir=false"
"build-mac": "electron-packager . --out=dist --icon ./icon.icns --platform=darwin --overwrite --tmpdir=false"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit dd01f8f

Please sign in to comment.