在R中看不到dicom图像

时间:2023-02-01 23:43:59

I am trying to read and see a dicom file. I installed package 'oro.dicom' and was able to read the file with:

我正在尝试阅读并查看dicom文件。我安装了包'oro.dicom'并且能够读取文件:

library(oro.dicom)
abdo <- readDICOMFile("image0.dcm")

extractHeader(abdo$hdr, "Rows")
[1] 2014

extractHeader(abdo$hdr, "Columns")
[1] 2014

extractHeader(abdo$hdr, "Manufacturer", numeric=FALSE)
[1] "...IT Radiology"

However, I am not able to see the image:

但是,我无法看到图像:

image(t(abdo$img), col=grey(0:64/64), axes=FALSE, xlab="", ylab="")
Error in t.default(abdo$img) : argument is not a matrix

The structure command shows following:

结构命令显示如下:

str(abdo$img)
int [1:2014, 1:2014, 1:3] 110 51 99 113 52 101 111 53 102 110 ...

Following works and a graphic box is displayed but it is only an empty box without any x-ray image:

下面的工作和图形框显示,但它只是一个没有任何X射线图像的空盒子:

image(t(abdo$img[[1]]), col=grey(0:64/64), axes=FALSE, xlab="", ylab="")

Why is it not working and how can I correct it? Thanks for your help.

为什么它不起作用,我该如何纠正它?谢谢你的帮助。

EDIT: with CR-MONO1-10-chest.dcm (http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz) I get following error even while reading it:

编辑:使用CR-MONO1-10-chest.dcm(http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz)即使在阅读时我也会收到以下错误:

abdo <- readDICOMFile("CR-MONO1-10-chest.dcm")
Error in readDICOMFile("CR-MONO1-10-chest.dcm") : DICM != DICM

With rasterImage following is the error:

使用rasterImage后面是错误:

rasterImage(as.raster(matrix(abdo[[1:3]])))
Error in rasterImage(as.raster(matrix(abdo[[1:3]]))) : 
  argument "xleft" is missing, with no default

Following is closer but still does not work:

以下是更接近但仍然不起作用:

>      rasterImage(abdo$img, 100, 400, 150, 450)
Error in rgb(t(x[, , 1]), t(x[, , 2]), t(x[, , 3]), maxColorValue = max) : 
  color intensity -30, not in [0,1]

>      rasterImage(abdo$img, 100, 400, 150, 450, interpolate=F)
Error in rgb(t(x[, , 1]), t(x[, , 2]), t(x[, , 3]), maxColorValue = max) : 
  color intensity -30, not in [0,1]
> 

1 个解决方案

#1


1  

This answer is only valid for the open-source file CR-MONO1-10-chest.dcm (http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz). I believe that this file is not a valid DICOM file. According to section 7.1 in Part 10 of the DICOM Standard (available at http://dicom.nema.org) there should be (a) the File Preample of length 128 bytes and (b) the four-byte DICOM Prefix "DICM". The CR-MONO1-10-chest.dcm starts providing information in the first pair of bytes.

此答案仅对开源文件CR-MONO1-10-chest.dcm(http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz)有效。我相信这个文件不是有效的DICOM文件。根据DICOM标准第10部分的7.1节(可从http://dicom.nema.org获得),应该有(a)长度为128字节的文件预采样和(b)四字节DICOM前缀“DICM” 。 CR-MONO1-10-chest.dcm开始在第一对字节中提供信息。

I have added the parameter skipFirst128 = TRUE to readDICOMFile() and this will be available in the next release of oro.dicom. Thus, one could read the file by using

我已将参数skipFirst128 = TRUE添加到readDICOMFile(),这将在oro.dicom的下一个版本中提供。因此,可以通过使用来读取文件

abdo <- readDICOMFile("CR-MONO1-10-chest.dcm", skipFirst128=FALSE, DICM=FALSE)
image(t(abdo$img), col=grey(0:64/64), axes=FALSE, xlab="", ylab="")

Please note that the file was created almost 20 years ago, I hope that files produced in the recent past will not have this problem. Thank-you for bringing this error to my attention. I am always looking for DICOM files that break my code in order to improve it.

请注意,该文件是在大约20年前创建的,我希望最近生成的文件不会出现此问题。感谢您将此错误引起我的注意。我一直在寻找破坏我的代码的DICOM文件,以便改进它。

#1


1  

This answer is only valid for the open-source file CR-MONO1-10-chest.dcm (http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz). I believe that this file is not a valid DICOM file. According to section 7.1 in Part 10 of the DICOM Standard (available at http://dicom.nema.org) there should be (a) the File Preample of length 128 bytes and (b) the four-byte DICOM Prefix "DICM". The CR-MONO1-10-chest.dcm starts providing information in the first pair of bytes.

此答案仅对开源文件CR-MONO1-10-chest.dcm(http://www.barre.nom.fr/medical/samples/files/CR-MONO1-10-chest.gz)有效。我相信这个文件不是有效的DICOM文件。根据DICOM标准第10部分的7.1节(可从http://dicom.nema.org获得),应该有(a)长度为128字节的文件预采样和(b)四字节DICOM前缀“DICM” 。 CR-MONO1-10-chest.dcm开始在第一对字节中提供信息。

I have added the parameter skipFirst128 = TRUE to readDICOMFile() and this will be available in the next release of oro.dicom. Thus, one could read the file by using

我已将参数skipFirst128 = TRUE添加到readDICOMFile(),这将在oro.dicom的下一个版本中提供。因此,可以通过使用来读取文件

abdo <- readDICOMFile("CR-MONO1-10-chest.dcm", skipFirst128=FALSE, DICM=FALSE)
image(t(abdo$img), col=grey(0:64/64), axes=FALSE, xlab="", ylab="")

Please note that the file was created almost 20 years ago, I hope that files produced in the recent past will not have this problem. Thank-you for bringing this error to my attention. I am always looking for DICOM files that break my code in order to improve it.

请注意,该文件是在大约20年前创建的,我希望最近生成的文件不会出现此问题。感谢您将此错误引起我的注意。我一直在寻找破坏我的代码的DICOM文件,以便改进它。