DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Thu, 2017-11-23, 00:36

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Wed, 2017-09-13, 15:04 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
I wrote a small test program and I keep getting the error listed in the subject. Here is the code below. I took this from the dcmtk documentation website, but I get the error. Lots of searching on the web has not pointed me in the right direction. Any help would be appreciated. Here is the code:

char uid[100];
DcmFileFormat fileFormat;
DcmDataset *dataset = fileFormat.getDataset(); dataset->putAndInsertUint16(DCM_FileMetaInformationVersion, 0x0001);
dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_PatientName, "Doe^John");

OFCondition status = fileFormat.saveFile("./test.dcm", EXS_LittleEndianExplicit);
if (status.bad())
cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;

No error prints out either. The status appears to be good. I only get the message listed in the subject.


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 16:20 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1874
Location: Oldenburg, Germany
See my answer in the newsgroups (please avoid double postings!).


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 19:13 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
I removed the dataset->putAndInsertUint16(DCM_FileMetaInformationVersion, 0x0001) line from the code. The new program is below. But I still get the same error.

uid[100];
DcmFileFormat fileFormat;
DcmDataset *dataset = fileFormat.getDataset();


dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_PatientName, "Doe^John");


OFCondition status = fileFormat.saveFile("./test.dcm", EXS_LittleEndianImplicit);

if (status.bad())
cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;


After running the code above, I still get the following:

E: DcmFileFormat: Cannot determine Version of MetaHeader

NOTE: I will not post in both areas. I will only post dcmtk postings here. I am using dcmtk-3.6.2.
Thanks in Advance


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 19:21 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1874
Location: Oldenburg, Germany
Are you sure that the data dictionary is loaded? What does dcmDataDict.isDictionaryLoaded() return? What do the various calls to putAndInsertString() return?


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 19:41 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
Is there a very simple example you can point me to in order to save a file. I found a very simple explain to load a file (https://github.com/marcinwol/dcmtk-basic-example).

Thanks in advance.


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 19:43 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1874
Location: Oldenburg, Germany
I tested your code. It works (if the data dictionary "dicom.dic" is loaded correctly).


Top
 Profile  
 
PostPosted: Wed, 2017-09-13, 20:22 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
I found code to load the dicom.dic. That appears to have taken care of the issue:

DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.loadDictionary("/home/Project/dcmtk/dcmtk-3.6.2/dcmdata/data/dicom.dic");
dcmDataDict.unlock();

I no longer get that error in the subject line. Thanks!


Top
 Profile  
 
PostPosted: Thu, 2017-09-14, 06:38 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1874
Location: Oldenburg, Germany
Great, but usually there is no need to load the data dictionary manually. By default (on Unix systems), it is loaded from the installed directory as specified by the "configure --prefix" option. Alternatively, one can specify the environment variable DCMDICTPATH or activate the built-in dictionary (which is also the default on Windows systems). All this is also described (in detail) in the corresponding documentation file.


Top
 Profile  
 
PostPosted: Thu, 2017-09-14, 14:59 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
Thanks! But removing that code causes those errors. So with my install, I must not have set something up so dicom.dic is loaded automatically. I am on a Linux Posix system using cmake to install dcmtk. DCMTK_ENABLE_BUILTIN_DICTIONARY I set to BOOL=ON in the CMakeCache.txt file, and set DCMTK_ENABLE_EXTERNAL_DICTIONARY BOOL=OFF. Is that the correct thing to do? Or is there some other place to set these. My understanding is that CMakeCache.txt can get overwritten.

With this new build and libs installed it is working correctly now. Only issue is, if I put the changes listed above in the correct file, or is there a place to tell the system about the dicom.dic file. Any Thoughts?


Top
 Profile  
 
PostPosted: Thu, 2017-09-14, 18:27 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1874
Location: Oldenburg, Germany
You shouldn't modify the CMakeCache.txt file manually but set the corresponding option within "ccmake" or when calling "cmake".

Quote:
With this new build and libs installed it is working correctly now. Only issue is, if I put the changes listed above in the correct file, or is there a place to tell the system about the dicom.dic file.

Not sure what you mean by that.


Top
 Profile  
 
PostPosted: Thu, 2017-09-14, 19:26 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
I have it working correctly without having to load the dicom.dic in code. It loads automatically now. I made changes to the CMakeCache.txt file in order for the build to include the dicom.dic file and load it automatically. I set the following values in the file:

DCMTK_ENABLE_BUILTIN_DICTIONARY BOOL=ON
DCMTK_ENABLE_EXTERNAL_DICTIONARY BOOL=OFF

You are saying not to do it in CMakeCache.txt, but use cmake or ccmake for those two values. Once I figure out how to do that, I will post for others to see, or if you have an example to do it with either cmake or ccmake that would be appreciated.


Top
 Profile  
 
PostPosted: Fri, 2017-09-15, 00:16 
Offline

Joined: Wed, 2017-09-13, 13:29
Posts: 9
Figured it out. You have to do the following:

cmake -DDCMTK_ENABLE_BUILTIN_DICTIONARY=ON -DDCMTK_ENABLE_EXTERNAL_DICTIONARY=OFF ../dcmtk-3.6.2

I hope this can help others who run into this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group