[58c332]: / RadETL / R / anatomicRegion_OccurrenceTable.R

Download this file

49 lines (46 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#' 'anatomicRegion'
#'
#' anatomicRegion function represents anatomic region of each shoot
#'
#'
#' @param DICOMList you can put it like this and then run the function : DICOMList<-anatomicRegion(DICOMFolderPath)
#' @import dplyr
#' @importFrom magrittr "%>%"
#'
#'
#' @return A dataframe representing anatomic region of each shoot
#' @examples
#' DICOMList<-DICOMHeaderList(DICOMFolderPath)
#' anatomicRegion(DICOMList)
#' @export
anatomicRegion<-function(DICOMList){
anatomicRegion<-lapply(DICOMList, function(x){
anatomicRegion<-x[[1]]%>%filter(name %in% c('BodyPartExamined', 'StudyDescription', 'SeriesDescription')) %>% select(value)
colnames(anatomicRegion)<-'anatomicRegion'
anatomicRegion<-sapply(anatomicRegion, function(x){
if(grepl('chest', tolower(anatomicRegion))==T){
return('chest')
}
else if(grepl('head', tolower(anatomicRegion))==T){
return('head')
}
else if(grepl('brain', tolower(anatomicRegion))==T){
return('head')
}
else if(grepl('neck', tolower(anatomicRegion))==T){
return('neck')
}
else if(grepl('abdomen', tolower(anatomicRegion))==T){
return('abdomen')
}
else{
return('others')
}
})
anatomicRegion<-as.data.frame(anatomicRegion)
rownames(anatomicRegion)<-c()
colnames(anatomicRegion)<-c('anatomicRegion')
return(anatomicRegion)})
anatomicRegion<-do.call(rbind, anatomicRegion)
return(anatomicRegion)
}