a b/RadETL/R/imageOrientationConceptId_ImageTable.R
1
#' 'imageOrientationConceptId'
2
#'
3
#' imageOrientationConceptId function will represent direction of each image
4
#'
5
#'
6
#' @param DICOMList you can put it like this and then run the function : DICOMList<-DICOMHeaderList(DICOMFolderPath)
7
#' @import dplyr
8
#' @importFrom magrittr "%>%"
9
#'
10
#'
11
#' @return A list containing direction of each DICOM image
12
#' @examples
13
#' DICOMList<-DICOMHeaderList(DICOMFolderPath)
14
#' imageOrientationConceptId(DICOMList)
15
#' @export
16
17
imageOrientationConceptId<-function(DICOMList){
18
    imageOrientationConceptId<-lapply(DICOMList, function(x){
19
        imageOrientationConceptIdDf<-x[[1]] %>% dplyr::filter(name %in% c('PatientOrientation', 'ImageType', 'SeriesDescription', 'StudyDescription', 'BodyPartExamined')) %>% dplyr::select(value)
20
        colnames(imageOrientationConceptIdDf)<-'imageOrientationConceptId'
21
        imageOrientationConceptIdDf<-sapply(imageOrientationConceptIdDf, function(x){
22
            if(grepl('chest', tolower(imageOrientationConceptIdDf))==T&grepl('P F', imageOrientationConceptIdDf)==T){
23
                return('43591')
24
            }
25
            else if(grepl('chest', tolower(imageOrientationConceptIdDf))==T&grepl('L F', imageOrientationConceptIdDf)==T){
26
                return('43594')
27
            }
28
            else if(grepl('chest', tolower(imageOrientationConceptIdDf))==T){
29
                return('43594')
30
            }
31
            else if(grepl('axial', tolower(imageOrientationConceptIdDf))==T){
32
                return('10514')
33
            }
34
            else if(grepl('AX', imageOrientationConceptIdDf)==T){
35
                return('10514')
36
            }
37
            else if(grepl('DW', imageOrientationConceptIdDf)==T){
38
                return('10514')
39
            }
40
            else if(grepl('FLAIR', imageOrientationConceptIdDf)==T){
41
                return('10514')
42
            }
43
            else if(grepl('Apparent', imageOrientationConceptIdDf)==T){
44
                return('10514')
45
            }
46
            else if(grepl('SA', imageOrientationConceptIdDf)==T){
47
                return('sagittal')
48
            }
49
            else{
50
                return('others')
51
            }
52
        })
53
        imageOrientationConceptIdDf<-as.data.frame(imageOrientationConceptIdDf)
54
        rownames(imageOrientationConceptIdDf)<-c()
55
        colnames(imageOrientationConceptIdDf)<-c('imageOrientationConceptId')
56
        return(imageOrientationConceptIdDf)
57
    })
58
    imageOrientationConceptId<-do.call(rbind, imageOrientationConceptId)
59
    return(imageOrientationConceptId)
60
}