在 R 中提取 dicom headers

Extracting dicom headers in R

我想在这里使用这个数据集

https://mri.radiology.uiowa.edu/VHDicom/VHMCT1mm/VHMCT1mm_Head.tar.gz

测试 R 中的 oro.dicom 包。

我试试代码

dcmImages <- readDICOM("C:\Users\Host\Documents\SCANS\Head", verbose = TRUE,
                       recursive = TRUE)

然后我像这样尝试 extractHeader 函数

extractHeader(dcmImages$hdr, string="InstitutionName")

我得到了一堆 NA。但是,我可以清楚地看到我 运行 这个

dcmImages$hdr

我在控制台看到机构名称列为国家医学图书馆。是什么导致了差异?

更新:最终下面的答案开始起作用,但以前不是,我不确定为什么。我在 Windows 10 OS 并且我将 R 从 3.5.3 更新到 3.6 然后它开始工作但是当 运行 宁 readDICOM函数。但是,我现在有 headers 的输出,而不是 NAs

尝试:

library(oro.dicom)
dcmImages <- readDICOM("/<my path>/Head", verbose = TRUE, recursive = TRUE)
extractHeader(dcmImages$hdr, string="InstitutionName", numeric=FALSE)

(数字的默认值为 TRUE,当 TRUE 时值将转换为数字。)

R> extractHeader(dcmImages$hdr, string="InstitutionName", numeric=FALSE)
  [1] "National Library of Medicine" "National Library of Medicine" "National Library of Medicine"
  [4] "National Library of Medicine" "National Library of Medicine" "National Library of Medicine"
  [7] "National Library of Medicine" "National Library of Medicine" "National Library of Medicine"
 [10] "National Library of Medicine" "National Library of Medicine" "National Library of Medicine"