读取DICOM文件时出错:未指定PixelData中的字节数 [英] Error in Reading DICOM File: Number of bytes in PixelData not specified
问题描述
我正在使用 R
中的 readDICOMFile
来读取 DICOM
文件如下:
dcmImages<-readDICOMFile( / home / darshil / Downloads / BREBIX / CT10 ponie foie / DEF 。VEINEUX-107205 / IM-0001-0001.dcm,调试= TRUE,pixelData = FALSE)
但是,出现以下错误:
parsePixelData(fraw [(bstart + dcm $ data.seek):fsize],hdr中的错误,endian::
PixelData中的字节数未指定;猜测= 1
如果我放入 pixelData = FALSE
,仅读取标头即可成功,但我还需要Image部分,我使用的是来自
封装格式的第一个ITEM用于基本偏移表,可能为空。第二ITEM元素将包含第一帧的封装像素流。通过比较片段数(基本偏移表的项目数减去一)与多帧封装编码的帧数,可以检测帧的碎片。
I am using readDICOMFile
in R
to read DICOM
file as following:
dcmImages <- readDICOMFile("/home/darshil/Downloads/BREBIX/CT10 ponction foie/DEF. VEINEUX - 107205/IM-0001-0001.dcm",debug = TRUE, pixelData = FALSE)
However, I get following error:
Error in parsePixelData(fraw[(bstart + dcm$data.seek):fsize], hdr, endian, :
Number of bytes in PixelData not specified; guess = 1
If I put pixelData=FALSE
, it is successful in reading only the header. But I also want the Image part. I am using standard dicom files from here. (I am trying "BREBIX" database now but other databases give same error.)
What is the problem? I cannot find any reference for this error.
Full output with debug=TRUE
:
# First 128 bytes of DICOM header =
[1] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[27] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[53] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[79] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[105] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# DICM = TRUE
# 0002 0000 GroupLength UL UL 4 190
# 0002 0001 FileMetaInformationVersion OB OB 2
# 0002 0002 MediaStorageSOPClassUID UI UI 26 1.2.840.10008.5.1.4.1.1.2
# 0002 0003 MediaStorageSOPInstanceUID UI UI 42 1.2.840.113704.1.111.2864.1161868417.2891
# 0002 0010 TransferSyntaxUID UI UI 22 1.2.840.10008.1.2.4.91
# 0002 0012 ImplementationClassUID UI UI 22 1.3.6.1.4.1.19291.2.1
# 0002 0013 ImplementationVersionName SH SH 10 OSIRIX001
# 0002 0016 SourceApplicationEntityTitle AE AE 6 OsiriX
# 0008 0005 SpecificCharacterSet CS CS 10 ISO_IR 100
# 0008 0008 ImageType CS CS 28 ORIGINAL PRIMARY AXIAL HELIX
# 0008 0012 InstanceCreationDate DA DA 8 20061026
# 0008 0013 InstanceCreationTime TM TM 14 151337.000000
# 0008 0016 SOPClassUID UI UI 26 1.2.840.10008.5.1.4.1.1.2
# 0008 0018 SOPInstanceUID UI UI 42 1.2.840.113704.1.111.2864.1161868417.2891
# 0008 0020 StudyDate DA DA 8 20061026
# 0008 0022 AcquisitionDate DA DA 8 20061026
# 0008 0023 ContentDate DA DA 8 20061026
# 0008 0030 StudyTime TM TM 14 141819.000000
# 0008 0032 AcquisitionTime TM TM 14 140519.000000
# 0008 0033 ContentTime TM TM 14 140519.583000
# 0008 0050 AccessionNumber SH SH 2 0
# 0008 0060 Modality CS CS 2 CT
# 0008 0070 Manufacturer LO LO 8 Philips
# 0008 0080 InstitutionName LO LO 4 hY9
# 0008 0090 ReferringPhysiciansName PN PN 10 9D2n76uYj
# 0008 1010 StationName SH SH 6 ctrad
# 0008 1030 StudyDescription LO LO 18 CT10 ponction foie
# 0008 1032 ProcedureCodeSequence SQ SQ 64 Sequence
# FFFE E000 Item UN UN 0 (0008,1032)
# 0008 0100 CodeValue SH SH 8 CTPFOIE (0008,1032)
# 0008 0102 CodingSchemeDesignator SH SH 6 XPLORE (0008,1032)
# 0008 0104 CodeMeaning LO LO 18 CT10 ponction foie (0008,1032)
# 0008 103E SeriesDescription LO LO 12 DEF. VEINEUX
# 0008 1040 InstitutionalDepartmentName LO LO 10 Radiologie
# 0008 1090 ManufacturersModelName LO LO 14 Mx8000 IDT 16
# 0008 1111 ReferencedPerformedProcedureStepSequence SQ SQ 88 Sequence
# FFFE E000 Item UN UN 0 (0008,1111)
# 0008 1150 ReferencedSOPClassUID UI UI 24 1.2.840.10008.3.1.2.3.3 (0008,1111)
# 0008 1155 ReferencedSOPInstanceUID UI UI 40 1.2.840.113704.1.111.2656.1161865075.16 (0008,1111)
# 0010 0010 PatientsName PN PN 6 BREBIX
# 0010 0020 PatientID LO LO 6 XsaDYa
# 0010 1010 PatientsAge AS AS 4 000Y
# 0018 0010 ContrastBolusAgent LO LO 8 CONTRAST
# 0018 0022 ScanOptions CS CS 6 HELIX
# 0018 0050 SliceThickness DS DS 4 2.0
# 0018 0060 kVp DS DS 4 120
# 0018 0088 SpacingBetweenSlices DS DS 4 1.0
# 0018 0090 DataCollectionDiameter DS DS 4 340
# 0018 1020 SoftwareVersions LO LO 6 3.2.0
# 0018 1030 ProtocolName LO LO 24 THORAX-ABD 3 4 Thorax Hx
# 0018 1100 ReconstructionDiameter DS DS 4 340
# 0018 1120 GantryDetectorTilt DS DS 2 0
# 0018 1130 TableHeight DS DS 4 137
# 0018 1140 RotationDirection CS CS 2 CW
# 0018 1151 XrayTubeCurrent IS IS 4 360
# 0018 1152 Exposure IS IS 4 200
# 0018 1160 FilterType SH SH 2 B
# 0018 1210 ConvolutionKernel SH SH 2 B
# 0018 5100 PatientPosition CS CS 4 FFS
# 0020 000D StudyInstanceUID UI UI 42 2.16.840.1.113669.632.20.1211.10000330985
# 0020 000E SeriesInstanceUID UI UI 38 1.2.840.113704.1.111.4848.1161868385.1
# 0020 0010 StudyID SH SH 4 8369
# 0020 0011 SeriesNumber IS IS 6 107205
# 0020 0013 InstanceNumber IS IS 2 1
# 0020 0032 ImagePositionPatient DS DS 14 -180 -52 1479
# 0020 0037 ImageOrientationPatient DS DS 12 1 0 0 0 1 0
# 0020 0052 FrameOfReferenceUID UI UI 38 1.2.840.113704.1.111.4492.1161865106.3
# 0020 1041 SliceLocation DS DS 8 -493.50
# 0020 4000 ImageComments LT LT 58 JPEG 2000 lossless - Version 4.0.2 (c) Image Devices GmbH
# 0028 0002 SamplesperPixel US US 2 1
# 0028 0004 PhotometricInterpretation CS CS 12 MONOCHROME2
# 0028 0010 Rows US US 2 512
# 0028 0011 Columns US US 2 512
# 0028 0030 PixelSpacing DS DS 20 0.6640625 0.6640625
# 0028 0100 BitsAllocated US US 2 16
# 0028 0101 BitsStored US US 2 12
# 0028 0102 HighBit US US 2 11
# 0028 0103 PixelRepresentation US US 2 0
# 0028 1050 WindowCenter DS DS 12 00050 00050
# 0028 1051 WindowWidth DS DS 12 00350 00350
# 0028 1052 RescaleIntercept DS DS 6 -1000
# 0028 1053 RescaleSlope DS DS 2 1
# 0028 2110 LossyImageCompression CS CS 2 01
# 0028 2112 LossyImageCompressionRatio DS DS 8 5.896176
# 0032 1032 RequestingPhysician PN PN 16 MOSIMANN Pascal
# 0032 1060 RequestedProcedureDescription LO LO 18 CT10 ponction foie
# 0040 0007 ScheduledProcedureStepDescription LO LO 18 CT10 ponction foie
# 0040 0008 ScheduledProtocolCodeSequence SQ SQ 64 Sequence
# FFFE E000 Item UN UN 0 (0040,0008)
# 0008 0100 CodeValue SH SH 8 CTPFOIE (0040,0008)
# 0008 0102 CodingSchemeDesignator SH SH 6 XPLORE (0040,0008)
# 0008 0104 CodeMeaning LO LO 18 CT10 ponction foie (0040,0008)
# 0040 0009 ScheduledProcedureStepID SH SH 12 A10026674234
# 0040 0254 PerformedProcedureStepDescription LO LO 18 CT10 ponction foie
# 0040 0260 PerformedProtocolCodeSequence SQ SQ 64 Sequence
# FFFE E000 Item UN UN 0 (0040,0260)
# 0008 0100 CodeValue SH SH 8 CTPFOIE (0040,0260)
# 0008 0102 CodingSchemeDesignator SH SH 6 XPLORE (0040,0260)
# 0008 0104 CodeMeaning LO LO 18 CT10 ponction foie (0040,0260)
# 0040 0275 RequestAttributesSequence SQ SQ 150 Sequence
# FFFE E000 Item UN UN 0 (0040,0275)
# 0040 0007 ScheduledProcedureStepDescription LO LO 18 CT10 ponction foie (0040,0275)
# 0040 0008 ScheduledProtocolCodeSequence SQ SQ 64 Sequence (0040,0275)
# FFFE E000 Item UN UN 0 (0040,0275) (0040,0008)
# 0008 0100 CodeValue SH SH 8 CTPFOIE (0040,0275) (0040,0008)
# 0008 0102 CodingSchemeDesignator SH SH 6 XPLORE (0040,0275) (0040,0008)
# 0008 0104 CodeMeaning LO LO 18 CT10 ponction foie (0040,0275) (0040,0008)
# 0040 0009 ScheduledProcedureStepID SH SH 12 A10026674234 (0040,0275)
# 0040 1001 RequestedProcedureID SH SH 12 A10026674233 (0040,0275)
# 0040 1001 RequestedProcedureID SH SH 12 A10026674233
# 7FE0 0010 PixelData OB OW -1 PixelData
##### Reading PixelData (7FE0,0010) #####
Error in parsePixelData(fraw[(bstart + dcm$data.seek):fsize], hdr, endian, :
Number of bytes in PixelData not specified; guess = 1
EDIT:
I looked at the source code. Turns out error is coming from the function parsePixelData
that is used by readDICOMFile
. Error is due to following lines:
length <- as.numeric(with(hdr, length[name == "PixelData" &
sequence == ""]))
if (length <= 0) {
guess <- 1
stop(paste("Number of bytes in PixelData not specified; guess =",
guess))
}
Specifically, following result gives "-1" as the answer, which is causing the problem:
> with(dcmImages$hdr, length[name == "PixelData"])
[1] "-1"
Now, how do I deal with it? Since I am using the standard files (link given above), it shouldn't cause the problem, right?
According to the transfer syntax of your DICOM dump, image is encapsulated and compression used for the image is JPEG 2000 reversible (Tag 0002:0010 - TransferSyntaxUID - 1.2.840.10008.1.2.4.91). The encapsulated pixel stream (JPEG 2000 bit stream in this case) of encoded pixel data is segmented into one or more Fragments (ITEM Element- FFFE: E000). Each ITEM element conveys its own explicit length and the sequence of ITEM of the encapsulated pixel stream is terminated by a delimiter (ITEM Delimiter - FFFE: E00D).
The first ITEM in the encapsulated format is used for the Basic Offset Table and it may be empty. The second ITEM element will contain the encapsulated pixel stream of first frame. You can detect fragmentation of frames by comparing the number of fragments (the number of Items minus one for the Basic Offset Table) with the number of frames for multi-frame encapsulated encoding.
这篇关于读取DICOM文件时出错:未指定PixelData中的字节数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!