Validate participant files without device ids
parent
87fbbbe402
commit
30ad3cd586
|
@ -173,15 +173,10 @@ validate_event_segments <- function(segments){
|
||||||
return(segments)
|
return(segments)
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_event_segments <- function(segments, participant_data){
|
prepare_event_segments <- function(segments, participant_devices){
|
||||||
participant_devices <- get_devices_ids(participant_data)
|
|
||||||
if(length(participant_devices) == 0)
|
|
||||||
stop("There are no devices in the participant file.")
|
|
||||||
|
|
||||||
new_segments <- segments%>%
|
new_segments <- segments%>%
|
||||||
validate_event_segments() %>%
|
validate_event_segments() %>%
|
||||||
filter(device_id %in% participant_devices)
|
filter(device_id %in% participant_devices)
|
||||||
return(new_segments)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_time_segments <- function(){
|
compute_time_segments <- function(){
|
||||||
|
@ -191,6 +186,11 @@ compute_time_segments <- function(){
|
||||||
participant_file <- snakemake@input[["participant_file"]]
|
participant_file <- snakemake@input[["participant_file"]]
|
||||||
message("Processing ",type, " time segments for ", pid,"'s ", participant_file)
|
message("Processing ",type, " time segments for ", pid,"'s ", participant_file)
|
||||||
|
|
||||||
|
participant_data <- yaml::read_yaml(participant_file)
|
||||||
|
participant_devices <- get_devices_ids(participant_data)
|
||||||
|
if(length(participant_devices) == 0)
|
||||||
|
stop("There are no device ids in this participant file for smartphones or wearables: ", participant_file)
|
||||||
|
|
||||||
if(type == "FREQUENCY"){
|
if(type == "FREQUENCY"){
|
||||||
segments <- read_csv(segments_file, col_types = cols_only(label = "c", length = "i"), trim_ws = TRUE)
|
segments <- read_csv(segments_file, col_types = cols_only(label = "c", length = "i"), trim_ws = TRUE)
|
||||||
new_segments <- prepare_frequency_segments(segments)
|
new_segments <- prepare_frequency_segments(segments)
|
||||||
|
@ -198,9 +198,8 @@ compute_time_segments <- function(){
|
||||||
segments <- read_csv(segments_file, col_types = cols_only(label = "c", start_time = "c",length = "c",repeats_on = "c",repeats_value = "i"), trim_ws = TRUE)
|
segments <- read_csv(segments_file, col_types = cols_only(label = "c", start_time = "c",length = "c",repeats_on = "c",repeats_value = "i"), trim_ws = TRUE)
|
||||||
new_segments <- prepare_periodic_segments(segments)
|
new_segments <- prepare_periodic_segments(segments)
|
||||||
} else if(type == "EVENT"){
|
} else if(type == "EVENT"){
|
||||||
participant_data <- yaml::read_yaml(participant_file)
|
|
||||||
segments <- read_csv(segments_file, col_types = cols_only(label = "c", event_timestamp = "d",length = "c",shift = "c",shift_direction = "i", device_id = "c"), trim_ws = TRUE)
|
segments <- read_csv(segments_file, col_types = cols_only(label = "c", event_timestamp = "d",length = "c",shift = "c",shift_direction = "i", device_id = "c"), trim_ws = TRUE)
|
||||||
new_segments <- prepare_event_segments(segments, participant_data)
|
new_segments <- prepare_event_segments(segments, participant_devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
write.csv(new_segments %>% select(label) %>% distinct(label), snakemake@output[["segments_labels_file"]], row.names = FALSE, quote = FALSE)
|
write.csv(new_segments %>% select(label) %>% distinct(label), snakemake@output[["segments_labels_file"]], row.names = FALSE, quote = FALSE)
|
||||||
|
|
|
@ -100,6 +100,22 @@ load_container_script <- function(stream_container){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_devices_ids <- function(participant_data){
|
||||||
|
devices_ids = c()
|
||||||
|
for(device in participant_data)
|
||||||
|
for(attribute in names(device))
|
||||||
|
if(attribute == "DEVICE_IDS")
|
||||||
|
devices_ids <- c(devices_ids, device[[attribute]])
|
||||||
|
return(devices_ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_participant_file_without_device_ids <- function(participant_file){
|
||||||
|
participant_data <- yaml::read_yaml(participant_file)
|
||||||
|
participant_devices <- get_devices_ids(participant_data)
|
||||||
|
if(length(participant_devices) == 0)
|
||||||
|
stop("There are no device ids in this participant file for smartphones or wearables: ", participant_file)
|
||||||
|
}
|
||||||
|
|
||||||
pull_phone_data <- function(){
|
pull_phone_data <- function(){
|
||||||
participant_file <- snakemake@input[["participant_file"]]
|
participant_file <- snakemake@input[["participant_file"]]
|
||||||
stream_format <- snakemake@input[["stream_format"]]
|
stream_format <- snakemake@input[["stream_format"]]
|
||||||
|
@ -111,6 +127,7 @@ pull_phone_data <- function(){
|
||||||
device_type <- "phone"
|
device_type <- "phone"
|
||||||
output_data_file <- snakemake@output[[1]]
|
output_data_file <- snakemake@output[[1]]
|
||||||
|
|
||||||
|
validate_participant_file_without_device_ids(participant_file)
|
||||||
participant_data <- read_yaml(participant_file)
|
participant_data <- read_yaml(participant_file)
|
||||||
stream_schema <- read_yaml(stream_format)
|
stream_schema <- read_yaml(stream_format)
|
||||||
rapids_schema <- read_yaml(rapids_schema_file)
|
rapids_schema <- read_yaml(rapids_schema_file)
|
||||||
|
|
|
@ -68,6 +68,22 @@ load_container_script <- function(stream_container){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_devices_ids <- function(participant_data){
|
||||||
|
devices_ids = c()
|
||||||
|
for(device in participant_data)
|
||||||
|
for(attribute in names(device))
|
||||||
|
if(attribute == "DEVICE_IDS")
|
||||||
|
devices_ids <- c(devices_ids, device[[attribute]])
|
||||||
|
return(devices_ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_participant_file_without_device_ids <- function(participant_file){
|
||||||
|
participant_data <- yaml::read_yaml(participant_file)
|
||||||
|
participant_devices <- get_devices_ids(participant_data)
|
||||||
|
if(length(participant_devices) == 0)
|
||||||
|
stop("There are no device ids in this participant file for smartphones or wearables: ", participant_file)
|
||||||
|
}
|
||||||
|
|
||||||
pull_wearable_data_main <- function(){
|
pull_wearable_data_main <- function(){
|
||||||
participant_file <- snakemake@input[["participant_file"]]
|
participant_file <- snakemake@input[["participant_file"]]
|
||||||
stream_format <- snakemake@input[["stream_format"]]
|
stream_format <- snakemake@input[["stream_format"]]
|
||||||
|
@ -81,6 +97,7 @@ pull_wearable_data_main <- function(){
|
||||||
output_data_file <- snakemake@output[[1]]
|
output_data_file <- snakemake@output[[1]]
|
||||||
|
|
||||||
|
|
||||||
|
validate_participant_file_without_device_ids(participant_file)
|
||||||
participant_data <- read_yaml(participant_file)
|
participant_data <- read_yaml(participant_file)
|
||||||
stream_schema <- read_yaml(stream_format)
|
stream_schema <- read_yaml(stream_format)
|
||||||
rapids_schema <- read_yaml(rapids_schema_file)
|
rapids_schema <- read_yaml(rapids_schema_file)
|
||||||
|
|
Loading…
Reference in New Issue