2

Did anyone add a private DICOM tag to a DICOM file successfully using ClearCanvas library?

The following code snippet is just what I am trying to add a private tag to the DICOM file dataset. But I can not find it when I open the saved DICOM file by MicroDicom viewer.

DicomTag tag = DicomTag.GetPrivateCreatorTag(0X7FE1, 0X0010); DataSet[tag].SetStringValue("Left");

Does anyone know the reason?

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141

2 Answers2

1

I never used the toolkit but I can see the problem in your code.

You are creating the private tag correctly and also setting its value properly.
But, you are not adding that newly created private tag to dataset.

I am not sure about syntax. You have created a tag. Now, you need to load the file in which you want to add that tag. You access the DICOM dataset instance and add the new tag to its indexer. Then save the file.

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
  • The test code on [github](https://github.com/ClearCanvas/ClearCanvas/blob/master/Dicom/Tests/DicomFileTests.cs#L466) demonstrates adding sequence. – Amit Joshi Mar 10 '20 at 09:42
  • Thanks for your reply. I’ve checked that the private tag will be added to the file dataset automatically when accessing it using the indexer of the DataSet (DataSet[tag]). – HappyMouse2008 Mar 11 '20 at 06:51
0

My colleague found out the reason for me. The code snippet of the creation for the private tag is as following,

new DicomTag((uint)group << 16 | (uint)(element >> 8), "Private Creator", "PrivateCreator", DicomVr.LOvr, false, 1, 1, false);

the element number will shift left 8 bits, so when i set it to 0X0010, the element number will be set to zero. When I change it to 0x0100, the private tag will be found by MicroDicom viewer.