如何为DICOM文件生成SOPInstance UID? [英] How to generate SOPInstance UID for DICOM file?

查看:337
本文介绍了如何为DICOM文件生成SOPInstance UID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个系统,该系统将能够为PACS创建结构化报告。

I am developing a system which will be able to create structured report for PACS.

很显然,为了创建DICOM实例(包含报告数据的文件),我需要三个UID用于研究,系列和实例。 StudyUID和SeriesUID必须与为其创建报​​告的研究和系列相同。但是对于SOPInstanceUID,我需要生成新的UID。

Obviously in order to create a DICOM instance (file containing Report data), I need three UIDs for Study, Series and Instance. StudyUID and SeriesUID must be the same as that of study and series that report is created for. But for SOPInstanceUID, I need to generate new UID.

我在Pixelmed文档中看到了 getNewSOPInstanceUID 方法,但是我对Pixelmed来源不熟悉。我需要一个算法或Python源。

I have seen getNewSOPInstanceUID method in Pixelmed documentation, but I am not familiar with the Pixelmed source. I need an algorithm or Python source.

推荐答案

我真的建议您放弃你自己如今,大多数语言确实提供了UUID库,因此请不要浪费时间。 Esp。如果您要编写代码来提取MAC地址,那么用便携式 C编写代码可能会非常复杂。

I would really suggest you go away from implementing it yourself. Most language do provide a UUID library these days, do not reinvent the wheel. Esp. if you are going to write code to extract MAC adress, this can be very complex writing it in portable C.

UUID 并不完全适合DICOM定义,因此您需要注册自己的组织根UID,然后只需填充生成的UUID带来了空间和时间的唯一性条件。

UUID do not exactly fit the DICOM definition, so you need to register your own Organisation Root UID, then simply pad with a generated UUID which bring spatial and time uniqueness condition.

YOUR_ORG_ROOT.CONVERTED_UUID

请注意您有64个字节(已经足够了,请参见此处)存储在值表示UI中:

Pay attention that you have 64 bytes (that's plenty already, see here) for storage in Value Representation UI:


  • 将UUID的十六进制表示转换为VR:UI定义 ([0-9。] +)

  • 修剪时要格外小心(您可能会在此操作中引入冗余)

  • 选择简短的组织根

  • 填充为 \0 的垫(0

  • Convert Hexadecimal notation of UUID to VR: UI definition ([0-9.]+)
  • Trim with extreme care (you may introduce redundancy during this operation)
  • Choose a short Org Root
  • Pad with \0 (0 binary) if needed.

最后,由于您使用的是python,请使用uuid lib python-uuid

Finally since you are using python, use uuid lib python-uuid.

以上内容应视为标准中正式定义的替代实现:

The above should be considered an alternate implementation to what is officially defined in the standard:

  • B.2 UUID Derived UID

直接将UUID转换为UID时,必须使用 2.25。根。

When converting directly a UUID to a UID, one must use the "2.25." root.

这篇关于如何为DICOM文件生成SOPInstance UID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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