-1

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

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
celia
  • 67
  • 9
  • How can you tell that there are attributes missing? Which attributes are missing? What type of DICOM object (SOP Class) are you trying to create? Is meta.setXXX() setting the attribute values as expected or does it fail? Have you implemented DICOM from scratch or are you using a DICOM toolkit? – Markus Sabin Jul 19 '19 at 09:28
  • I obtain this error: (0008,0030) does not belong to group (0002,eeee) any time I add an attribute. That is why I want to know which attributes are mandatories. I use a DICOM toolkit. Thank you – celia Jul 19 '19 at 10:25

1 Answers1

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".

Markus Sabin
  • 3,916
  • 14
  • 32
  • So, I got two questions: 1.Do I have to add metadata to a dicom object? 2. Do I have to add all the meta-header attributes before adding the ones I want it? Thank you – celia Jul 19 '19 at 10:45
  • 1
    1. Yes 2. Depends on the toolkit, but most probably no. – Markus Sabin Jul 19 '19 at 10:49
  • Can you please show me an example of the creation of a dicom object? I guess all libraries can make dicom objects rigth? I have 3.2.1 and I can`t import data.dicomObject – celia Jul 19 '19 at 11:07
  • https://stackoverflow.com/questions/21087778/how-to-convert-jpg-image-to-dicom-file-using-dcm4che-3-2-1 – Markus Sabin Jul 19 '19 at 11:13
  • That is an old version of the library, rigth now is easy to add some attributes – celia Jul 19 '19 at 12:29
  • Sorry Man your DICO is ainit worth much - I tried it and it given all kinds of Garbage – gpasch Jul 19 '19 at 15:16