R中使用readDICOM读取DICOM文件时出错 [英] error in reading a DICOM file using readDICOM in R

查看:76
本文介绍了R中使用readDICOM读取DICOM文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从目录中读取多个DICOM文件。
我安装了oro.dicom软件包,为此使用了readDICOM函数:

I am trying to read multiple DICOM files from a directory. I installed the oro.dicom package and I use readDICOM function for this purpose:

dicom_file <- readDICOM("3_TR2000_300VOLUMES")

但是我收到此错误:

Error in names(hdr) <- c("group", "element", "name", "code", "length",  :
'names' attribute [7] must be the same length as the vector [6]

有人知道吗

谢谢。

推荐答案

我查看了readDICOM函数的源代码
显然,该函数读取一个名为Icon\r的附加文件,这会导致错误。我在目录中看不到该文件,但是R会读取它无论如何,我下载了源代码并对其进行了编辑,以便删除Icon\r文件(只需删除列表中的最后一个文件即可)。我使用了该函数的编辑版本,现在可以使用了。

I looked into the source of the readDICOM function. Apparently this function reads an additional file called Icon\r, which causes the error. I don't see this file in the directory, but R reads it anyway. I downloaded the source and edited it such that the Icon\r file is removed (by simply deleting the last file in the list). I used my edited version of the function, and now it works.

我不确定为什么图标filer文件首先存在,但是搜索它时,我看到了一些关于它的信息此处

I'm not sure why the Icon\r file is there in the first place, but searching for it I saw something about it here.

如果有人有其他解决方案,我将很高兴听到!

If anyone has a different solution I'd be happy to hear!

不需要编辑功能的另一种解决方案-只需在执行readDICOM函数之前添加以下命令即可:

A different solution that does not require editing functions - simply add the following command before executing the readDICOM function:

if (file.exists("Icon\r")) {file.remove("Icon\r")}

这篇关于R中使用readDICOM读取DICOM文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆