【问题标题】:Multipart WADO-RS dicom data parsingMultipart WADO-RS dicom 数据解析
【发布时间】:2015-12-10 09:51:08
【问题描述】:

我正在使用带有 Content-Type 的 WADO-RS:application/dicom。成功执行请求后,我得到了一个字节流,其中包含一些标头信息和 Multipart 格式的 DICOM 数据。如何使用 C++ 代码解析其中的实际 DICOM 数据?

【问题讨论】:

  • 您是在寻找产品还是在尝试编写代码?
  • 我正在尝试编写 C++ 代码来检索 DIOCM 数据。
  • 您看过 DICOM 规范吗?我看过一些可用的工具吗?
  • 是的。我已经通过了 DICOM PS3.18 2015c - Web Services。我是http通信的新手。所以我的怀疑完全与通过删除内容边界信息将多部分字节流解析为所需数据有关。
  • 好吧,我无法为您找到太多信息。我看到了其他人的帖子,他一直在努力解决这个问题,直到他得到了将文件写入光盘然后将光盘文件解析为标准 dicom 文件的提示。抱歉,我不能提供更多帮助。

标签: c++ http mime-types dicom dicomweb


【解决方案1】:

多部分文件的每个部分都是一个 dicom 实例。每个部分都包含一个内容长度字段,我从内容字段中解码长度。 dicom 文件在内容长度字段结束后的 4 个字节处开始。长度会告诉你 dicom 文件在哪里结束。 下面是一个python sn-p:

for dicm in re.finditer(b'Content-Length:', mime_bytes_msg):

    content_length_index = dicm.end() + 1
    content_length = ''

    dicom_file = open('%s/%s_%d.dcm' % (output_path, dicom_prefix, instance_number), 'wb')
    instance_number += 1
    while mime_bytes_msg[content_length_index:content_length_index + 1].decode('utf-8').isdigit():
        content_length += mime_bytes_msg[content_length_index:content_length_index + 1].decode('utf-8')
        content_length_index += 1

    dicom_start_index = content_length_index + 4
    dicom_file.write(mime_bytes_msg[dicom_start_index:dicom_start_index + int(content_length)])

    dicom_file.close()

【讨论】:

  • 我得到的 Dicom 文件没有 Content-Length 字段。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多