How can I add metadata to a dicom file?

风流意气都作罢 提交于 2019-12-25 18:17:32

问题


This is in continuation with other question. I am trying to obtained a dicom file from a jpg image and some metadata I writte myself in the java program. I have this code for adding metadata but it seems to be incomplete, so I don´t know what else I need to include.

I tried a simple code adding some attributes but I get some errors, so I found that there are some mandatory tags.

Attributes attribs = new Attributes();

attribs.setString(Tag.StudyDate, VR.DA, "20110404"); attribs.setString(Tag.StudyTime, VR.TM, "15");

After that I tried this but I still missing some attributes:

meta.setInt(Tag.FileMetaInformationGroupLength, VR.UL, data.length);
meta.setString(Tag.TransferSyntaxUID, VR.UI, "1.2.840.10008.1.2.1");

Thank you


回答1:


With the information you are providing (see comment), I suspect that the following situation applies:

DICOM files have two main components:

  • The Meta-Header describing the encoding (and other META aspects) of the DICOM object
  • The DICOM object (dataset) itself consisting of "header data" and "pixel data" (in fact, pixel data is just a particular attribute, so "header data" and "pixel data" is kind of colloquial language.

All attributes of the meta header belong to group 0x0002. The error message says that you are trying to write attributes belonging to the dataset to the metadata which is not allowed.

I cannot tell more because the code you posted does not tell where the "Attributes" object belongs to. But apparently, you are somewhere trying to add "Attributes" to "meta".

About "Which attributes are mandatory": Quite a lot, and this depends on the type of object you are creating, i.e. whether it is Computed Radiography, Endoscopic Video, ...

DICOM Part 3 is your reference to obtain mandatory an optional attribute for a particular type of object which DICOM refers to as "SOP Class".



来源:https://stackoverflow.com/questions/57109206/how-can-i-add-metadata-to-a-dicom-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!