Skip to content

Commit

Permalink
Merge pull request #1 from BilingualAphasia/master
Browse files Browse the repository at this point in the history
Bringing updates to storybook tutorial
  • Loading branch information
cesine committed Dec 3, 2013
2 parents 8f8dcd0 + 8f75898 commit f0b3908
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
39 changes: 29 additions & 10 deletions OPrime-Android-Tutorial/stimuli/create_new_stimuli.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
stimuli <- read.csv(file="sample_stimuli.csv",head=TRUE,sep=",")
stimuli <- read.csv(file="sample_stimuli.csv",head=TRUE,sep=",",blank.lines.skip=T)
images <- stimuli$Image.File
library(tools)
copyimages <- function (imagelist,...) {
setwd("../res/drawable")
file.remove(list.files(pattern=glob2rx("stimulus*")))
setwd("../../stimuli")
j <- 1
setwd("../res/drawable")
file.remove(list.files(pattern=glob2rx("stimulus*")))
setwd("../../stimuli")
j <- 1
for(i in imagelist) {
if (file.exists(i)) {
ext <- (file_ext(i))
file.copy(i, paste("../res/drawable/stimulus_", j, "_nonpublic.", ext, sep=""), overwrite=TRUE)
}
j <- j + 1
#remove tabs and \n
i <- gsub("\t","",i, fixed=TRUE)
i <- gsub("\n","",i, fixed=TRUE)
#if there is no jpeg or png or gif, add .jpg to the file
if(!grepl(".jpg",i) && !grepl(".png",i) && !grepl(".gif",i)){
i <- paste(i,".jpg", sep="")
}
print(i)
if (file.exists(i)) {
ext <- (file_ext(i))
file.copy(i, paste("../res/drawable/stimulus_", j, "_nonpublic.", ext, sep=""), overwrite=TRUE)
print("File copied to Android app")
} else {
print("File not found")
print(i)
}
j <- j + 1
}
}
copyimages(images)
Expand All @@ -23,6 +35,13 @@ file.remove(list.files(pattern=glob2rx("stimulus*")))
setwd("../../stimuli")
j <- 1
for(i in audiolist) {
#replace NA with silence.mp3
i <- gsub("NA","silence.mp3",i, fixed=TRUE)
#if there is no mp3 or wav, add .mp3 to the file
if(!grepl(".mp3",i) && !grepl(".wav",i)){
i <- paste(i,".mp3", sep="")
}

if (file.exists(i)) {
ext <- (file_ext(i))
file.copy(i, paste("../res/raw/stimulus_", j, "_nonpublic.", ext, sep=""), overwrite=TRUE)
Expand Down
2 changes: 1 addition & 1 deletion OPrime-Android-Tutorial/stimuli/sample_stimuli.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Image File,Audio File
test1.jpg,test.wav
test3.jpg,noqatawan.mp3
test4.jpg,qantawan.mp3
test4.jpg,silence.mp3
test12.jpg,qaprinaywanchis.mp3
Binary file added OPrime-Android-Tutorial/stimuli/silence.mp3
Binary file not shown.

0 comments on commit f0b3908

Please sign in to comment.