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

Download this file

31 lines (28 with data), 902 Bytes

 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
#' 'imageId'
#'
#' imageId function will read SOPInstanceUID metadata of all DICOM files read by DICOMHeaderList function
#'
#'
#' @param DICOMList you can put it like this and then run the function : DICOMList<-DICOMHeaderList(DICOMFolderPath)
#' @import digest
#' @import dplyr
#' @importFrom magrittr "%>%"
#'
#'
#' @return A list containing anonymized SOPInstanceUID of DICOM
#' @examples
#' DICOMList<-DICOMHeaderList(DICOMFolderPath)
#' imageId(DICOMList)
#' @export
imageId<-function(DICOMList){
imageId<-lapply(DICOMList, function(x){
imageId<-as.character(x[[1]] %>% dplyr::filter(name=='SOPInstanceUID') %>% dplyr::select(value))
if(imageId=="character(0)" | imageId=="" | imageId=="integer(0)"){
imageId='NA'
}
return(imageId)
})
imageId<-as.data.frame(do.call(rbind, imageId))
colnames(imageId)<-'imageId'
return(imageId)
}