Switch to unified view

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