|
a |
|
b/RadETL/R/DICOMHeaderList.R |
|
|
1 |
#' 'DICOMHeaderList' |
|
|
2 |
#' |
|
|
3 |
#' DICOMHeaderList function will read metadata of all DICOM files under DICOMFolderPath |
|
|
4 |
#' |
|
|
5 |
#' |
|
|
6 |
#' @param DICOMFolderPath function will read all of the DICOM files under this pathway |
|
|
7 |
#' @param core you can set CPU core in order to make the computing process fast |
|
|
8 |
#' @import ParallelLogger |
|
|
9 |
#' @importFrom oro.dicom "readDICOM" |
|
|
10 |
#' |
|
|
11 |
#' |
|
|
12 |
#' @return A list containing metadata of DICOM |
|
|
13 |
#' @examples DICOMHeaderList(DICOMFolderPath, core=4) |
|
|
14 |
#' @export |
|
|
15 |
|
|
|
16 |
DICOMHeaderList<-function(DICOMFolderPath, core=4){ |
|
|
17 |
RadiologyFileList<-list.files(path = DICOMFolderPath, full.names=T, recursive=T, pattern='\\.dcm$') |
|
|
18 |
cluster <- ParallelLogger::makeCluster(numberOfThreads = core) |
|
|
19 |
result <- ParallelLogger::clusterApply(cluster, 1:length(RadiologyFileList), function(x) { |
|
|
20 |
tryCatch({FileMetadata<-oro.dicom::readDICOM(RadiologyFileList[x], recursive = T, verbose = F, pixelData = F) |
|
|
21 |
return(FileMetadata$hdr[1])}, |
|
|
22 |
error= function(e) return(list(data.frame(group='NA', element='NA', name='NA', code='NA', length='NA', value='NA', sequence='NA') |
|
|
23 |
))) |
|
|
24 |
}) |
|
|
25 |
return(result) |
|
|
26 |
} |