How to load dictionaries for private and non-private tags?

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
e.can
Posts: 29
Joined: Tue, 2015-11-03, 14:40

How to load dictionaries for private and non-private tags?

#1 Post by e.can »

Hi guys,

My application uses the following example code to read DICOM files:

Code: Select all

DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
  OFString patientName;
  if (fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())
  {
    cout << "Patient's Name: " << patientName << endl;
  } else
    cerr << "Error: cannot access Patient's Name!" << endl;
} else
  cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
I want to load dicom.dic and private.dic before loading the DICOM file. How can I do this?

I found the following (for private tags only I guess???) code on Stack Overflow, but I am not sure if I should put this before my code:

Code: Select all

DcmDataDictionary& dict = dcmDataDict.wrlock();
dict.loadDictionary(dictionaryFilePath);
dcmDataDict.unlock();

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to load dictionaries for private and non-private tag

#2 Post by J. Riesmeier »

I want to load dicom.dic and private.dic before loading the DICOM file. How can I do this?
My first question would be: Why do you want to load the dictionary file(s) manually?

The sample code you've found on StackOverflow is not wrong but if you want to rely on the default dictionary files (determined during configure or specified by the environment variable DCMDICTPATH), you could also call reloadDictionaries() instead of loadDictionary().

e.can
Posts: 29
Joined: Tue, 2015-11-03, 14:40

Re: How to load dictionaries for private and non-private tag

#3 Post by e.can »

J. Riesmeier wrote:
I want to load dicom.dic and private.dic before loading the DICOM file. How can I do this?
My first question would be: Why do you want to load the dictionary file(s) manually?

The sample code you've found on StackOverflow is not wrong but if you want to rely on the default dictionary files (determined during configure or specified by the environment variable DCMDICTPATH), you could also call reloadDictionaries() instead of loadDictionary().
I don't know if I need to load it manually. I want to load both private/non-private tags from my own defined location. I''ve read the posts related to the environment variables but I don't understand how to do it... :(

I am using Qt and Visual Studio

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How to load dictionaries for private and non-private tag

#4 Post by J. Riesmeier »

You can specify the "data directory", where also the dictionary files are installed, during the configure step. Details can be found in the "datadict.txt" file of the source code package.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest