2
votes

I would like to read DICOM private tags. These private tags are under hexadecimal tag x7fe11001.
I know one of the pydicom configurations that read till pixel data starts (so the memory is not loaded up).

pydicom.dcmread(raw, defer_size="2 MB", stop_before_pixels=True)

But the private tags I am trying to read are after the pixel data. So I am ending loading complete file in memory which is not optimal. What are the other ways to read it in an optimal way?
I know there is a config param for the above method, called specific_tags. But I could not find any examples of how to use it.

Any suggestions to read DICOM metadata without loading pixel data into memory would be awesome.

1

1 Answers

3
votes

You are right, specific_tags is the correct way to do this:

ds = pydicom.dcmread(raw, specific_tags=[Tag(0x7fe1, 0x1001)]

In this case, ds shall contain only your private tag and the Specific Character Set tag (which is always read).
As DICOM is a sequential format, the other tags still have to be skipped over one by one, but their value is not read.
Note that you can put any number of tags into the specific_tags argument.