|
a |
|
b/RadETL/R/radiologyProtocolConceptId_OccurrenceTable.R |
|
|
1 |
#' 'radiologyProtocolConceptId' |
|
|
2 |
#' |
|
|
3 |
#' radiologyProtocolConceptId function indicates protocol&modality of each shoot |
|
|
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 dataframe indicating path protocol&modality of each shoot |
|
|
12 |
#' @examples |
|
|
13 |
#' DICOMList<-DICOMHeaderList(DICOMFolderPath) |
|
|
14 |
#' radiologyProtocolConceptId(DICOMList) |
|
|
15 |
#' @export |
|
|
16 |
|
|
|
17 |
##radiologyProtocolConceptId(BodyPartExamined, StudyDescription, radiologyPhaseConceptId, modality) |
|
|
18 |
|
|
|
19 |
radiologyProtocolConceptId<-function(DICOMList){ |
|
|
20 |
protocolName<-lapply(DICOMList, function(x){ |
|
|
21 |
protocolName<-as.character(x[[1]] %>% dplyr::filter(name %in% c('ProtocolName')) %>% dplyr::select(value)) |
|
|
22 |
if(protocolName=="character(0)" | protocolName==""){ |
|
|
23 |
protocolName='NA' |
|
|
24 |
} |
|
|
25 |
protocolName<-as.data.frame(protocolName) |
|
|
26 |
colnames(protocolName)<-'protocolName' |
|
|
27 |
return(protocolName)}) |
|
|
28 |
protocolName<-do.call(rbind,protocolName) |
|
|
29 |
information<-cbind(anatomicRegion(DICOMList), radiologyOccurrenceId(DICOMList), modalityImage(DICOMList), radiologyPhaseConceptId(DICOMList), imageOrientationConceptId(DICOMList), protocolName) |
|
|
30 |
information<-unique(information) |
|
|
31 |
information<-split(information, information$radiologyOccurrenceId) |
|
|
32 |
information<-lapply(information, function(x){ |
|
|
33 |
anatomicRegion<-data.frame(paste(unique(x$anatomicRegion), collapse=', '), row.names = NULL) |
|
|
34 |
colnames(anatomicRegion)<-'anatomicRegion' |
|
|
35 |
radiologyOccurrenceId<-data.frame(paste(unique(x$radiologyOccurrenceId), collapse=', '), row.names = NULL) |
|
|
36 |
colnames(radiologyOccurrenceId)<-'radiologyOccurrenceId' |
|
|
37 |
radiologyPhaseConceptId<-data.frame(paste(unique(x$radiologyPhaseConceptId), collapse=', '), row.names = NULL) |
|
|
38 |
colnames(radiologyPhaseConceptId)<-'radiologyPhaseConceptId' |
|
|
39 |
modality<-data.frame(paste(unique(x$modality), collapse=', '), row.names = NULL) |
|
|
40 |
colnames(modality)<-'modality' |
|
|
41 |
imageOrientationConceptId<-data.frame(paste(unique(x$imageOrientationConceptId), collapse=', '), row.names = NULL) |
|
|
42 |
colnames(imageOrientationConceptId)<-'imageOrientationConceptId' |
|
|
43 |
protocolName<-data.frame(paste(unique(x$protocolName), collapse=', '), row.names = NULL) |
|
|
44 |
colnames(protocolName)<-'protocolName' |
|
|
45 |
return(cbind(anatomicRegion, radiologyOccurrenceId, radiologyPhaseConceptId, modality, imageOrientationConceptId, protocolName))}) |
|
|
46 |
radiologyProtocolConceptId<-sapply(information, function(x){ |
|
|
47 |
if(grepl('chest', x$anatomicRegion)==T & grepl('DX', x$modality)==T & grepl('43591', x$imageOrientationConceptId)==T & grepl('43594', x$imageOrientationConceptId)==T){ |
|
|
48 |
return('3031526') |
|
|
49 |
} |
|
|
50 |
else if(grepl('chest', x$anatomicRegion)==T & grepl('CR', x$modality)==T & grepl('43591', x$imageOrientationConceptId)==T & grepl('43594', x$imageOrientationConceptId)==T){ |
|
|
51 |
return('3031526') |
|
|
52 |
} |
|
|
53 |
else if(grepl('chest', x$anatomicRegion)==T & grepl('DX', x$modality)==T & grepl('43594', x$imageOrientationConceptId)==T){ |
|
|
54 |
return('3002676') |
|
|
55 |
} |
|
|
56 |
else if(grepl('chest', x$anatomicRegion)==T & grepl('CR', x$modality)==T & grepl('43594', x$imageOrientationConceptId)==T){ |
|
|
57 |
return('3002676') |
|
|
58 |
} |
|
|
59 |
else if(grepl('head', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('5901', x$radiologyPhaseConceptId)==T){ |
|
|
60 |
return('36305291') |
|
|
61 |
} |
|
|
62 |
else if(grepl('head', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('28694', x$radiologyPhaseConceptId)==T){ |
|
|
63 |
return('3002086') |
|
|
64 |
} |
|
|
65 |
else if(grepl('head', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('28833', x$radiologyPhaseConceptId)==T){ |
|
|
66 |
return('3025779') |
|
|
67 |
} |
|
|
68 |
else if(grepl('neck', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('28694', x$radiologyPhaseConceptId)==T & grepl('angio', tolower(x$protocolName))==T){ |
|
|
69 |
return('36304600') |
|
|
70 |
} |
|
|
71 |
else if(grepl('abdomen', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('28833', x$radiologyPhaseConceptId)==T & grepl('11080', x$radiologyPhaseConceptId)==T & grepl('11085', x$radiologyPhaseConceptId)==T & grepl('11081', x$radiologyPhaseConceptId)==T){ |
|
|
72 |
return('21492176') |
|
|
73 |
} |
|
|
74 |
else if(grepl('abdomen', x$anatomicRegion)==T & grepl('CT', x$modality)==T & grepl('28694', x$radiologyPhaseConceptId)==T){ |
|
|
75 |
return('21492176') |
|
|
76 |
} |
|
|
77 |
else if(grepl('abdomen', x$anatomicRegion)==T & grepl('CR', x$modality)==T){ |
|
|
78 |
return('3053099') |
|
|
79 |
} |
|
|
80 |
else if(grepl('abdomen', x$anatomicRegion)==T & grepl('DX', x$modality)==T){ |
|
|
81 |
return('3053099') |
|
|
82 |
} |
|
|
83 |
else if(grepl('head', x$anatomicRegion)==T & grepl('MR', x$modality)==T){ |
|
|
84 |
return('3023655') |
|
|
85 |
} |
|
|
86 |
else { |
|
|
87 |
return('others') |
|
|
88 |
} |
|
|
89 |
}) |
|
|
90 |
radiologyProtocolConceptId<-data.frame(radiologyOccurrenceId=names(radiologyProtocolConceptId), radiologyProtocolConceptId=radiologyProtocolConceptId, row.names = NULL) |
|
|
91 |
return(radiologyProtocolConceptId) |
|
|
92 |
} |