【问题标题】:Error in Reading DICOM File: Number of bytes in PixelData not specified读取 DICOM 文件时出错:未指定 PixelData 中的字节数
【发布时间】:2016-06-27 18:50:16
【问题描述】:

我在R 中使用readDICOMFile 读取DICOM 文件如下:

dcmImages <- readDICOMFile("/home/darshil/Downloads/BREBIX/CT10 ponction foie/DEF. VEINEUX - 107205/IM-0001-0001.dcm",debug = TRUE, pixelData = FALSE)

但是,我收到以下错误:

parsePixelData(fraw[(bstart + dcm$data.seek):fsize], hdr, endian, :
未指定 PixelData 中的字节数;猜测 = 1

如果我输入pixelData=FALSE,则仅读取标题是成功的。但我也想要图像部分。我正在使用来自here 的标准 dicom 文件。 (我现在正在尝试“BREBIX”数据库,但其他数据库给出了同样的错误。)

有什么问题?我找不到此错误的任何参考。

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

编辑

我查看了源代码。结果发现错误来自readDICOMFile 使用的函数parsePixelData。错误是由于以下几行:

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))
        }

具体来说,以下结果给出了“-1”作为答案,这是导致问题的原因:

> with(dcmImages$hdr, length[name == "PixelData"])
[1] "-1"

现在,我该如何处理?由于我使用的是标准文件(上面给出的链接),它应该不会导致问题,对吧?

【问题讨论】:

    标签: r dicom


    【解决方案1】:

    根据您的 DICOM 转储的传输语法,图像被封装并且用于图像的压缩是 JPEG 2000 可逆的(标记 0002:0010 - TransferSyntaxUID - 1.2.840.10008.1.2.4.91)。编码像素数据的封装像素流(在这种情况下为 JPEG 2000 比特流)被分割成一个或多个片段(ITEM Element-FFFE:E000)。每个 ITEM 元素传达其自己的显式长度,并且封装像素流的 ITEM 序列由分隔符终止(ITEM 分隔符 - FFFE:E00D)。

    封装格式的第一个 ITEM 用于基本偏移表,它可能为空。第二个 ITEM 元素将包含第一帧的封装像素流。您可以通过将片段数(基本偏移表的项目数减一)与多帧封装编码的帧数进行比较来检测帧的碎片。

    【讨论】:

    • 你说的大部分我都听不懂。你能告诉我我应该尝试什么来获得解决方案吗?如,我应该在我的代码中更改/添加什么?并简单说明问题是什么?
    • 在DICOM数据集中压缩图像时,压缩后的图像数据不直接存储在Pixel Data属性中。第一帧通常存储在第二个项目(FFFE:E000 标签)中,下一帧存储在第三个项目中,依此类推。用于图像编码的压缩在传输语法属性(标记 0002:0010)中指定。在您的情况下,它使用无损 JPEG2000 压缩。您将需要 JPEG 2000 解码器来解码压缩流。
    【解决方案2】:

    不幸的是,oro.dicom R 包没有解压缩 DICOM 文件的能力。还有其他工具可以执行此任务;例如,DCMTK。我能够使用 dcmdjpeg 命令解压缩 DICOM 文件,然后在 R 中成功读取它。

    library(oro.dicom)
    
    dcmFile <- "images/file.dcm"
    dcm <- readDICOMFile(file.path("~/data", dcmFile), debug = TRUE)
    
    # system("brew install dcmtk")
    cmd <- paste("dcmdjpeg", 
                 file.path("~/data", dcmFile), 
                 file.path("~/data", sub("images", "images_uncompressed", dcmFile)))
    system(cmd)
    dcmFile <- "images_uncompressed/file.dcm"
    dcm <- readDICOMFile(file.path("~/data", dcmFile))
    

    oro.dicom 包将来可能会扩展以包含此功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      相关资源
      最近更新 更多