Chapter 4 Machine learning
4.1 Deep learning
4.1.1 Pulling images from REDCap directly to argodeep
4.1.1.1 Original file names
library(REDCapR)
= "https://redcap.cir.ed.ac.uk/api/"
uri = "" # API token here
token = 1:318
record_list = c("photo", "photo_2", "photo_3", "photo_4")
field_list = c("wound_concerns_arm_2", "questionnaire_1_arm_2",
event_list "questionnaire_2_arm_2", "questionnaire_3_arm_2")
= "wound_raw" # destination directory must exist already
directory
for(record in record_list){
for(field in field_list){
for(event in event_list){
=
result tryCatch({ # suppress breaking error when no image in slot
redcap_download_file_oneshot(
record = record,
field = field,
redcap_uri = uri,
token = token,
event = event,
overwrite = TRUE,
directory = directory
)error=function(e){})
},
}
} }
4.1.1.2 Named from REDCap record ID and event
library(REDCapR)
= "https://redcap.cir.ed.ac.uk/api/"
uri = "" # API token here
token = 1:318
record_list = c("photo", "photo_2", "photo_3", "photo_4")
field_list = c("wound_concerns_arm_2", "questionnaire_1_arm_2",
event_list "questionnaire_2_arm_2", "questionnaire_3_arm_2")
= "wound_named" # destination directory must exist already
directory
for(record in record_list){
for(field in field_list){
for(event in event_list){
= paste0(record, "_", field, "_", event, ".jpg")
file_name =
result tryCatch({
redcap_download_file_oneshot(
record = record,
field = field,
redcap_uri = uri,
token = token,
event = event,
overwrite = TRUE,
directory = directory,
file_name = file_name
)error=function(e){})
},
}
} }