createNewDicomDir writes incomplete DICOMDIR file

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

createNewDicomDir writes incomplete DICOMDIR file

#1 Post by evanyftsai »

Hi,

I am using createNewDicomDir to create DICOMDIR. The file is created, but the content of it seems incomplete. Reading it results in errors. I am wondering what is the right way to use this function?

This is how I make the call:

OFCondition status = dicomdir.createNewDicomDir(DicomDirInterface::AP_DentalRadiograph, convertToStlString(dicomDirFileName).c_str(), DEFAULT_FILESETID);

Is it because of the filesetID setting?

Please advise, thanks a lot!!
Evan

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#2 Post by J. Riesmeier »

Did you also add entries (i.e. Directory Records) to the DICOMDIR? This is done using DicomDirInterface::addDicomFile().

evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

Re: createNewDicomDir writes incomplete DICOMDIR file

#3 Post by evanyftsai »

Yes. This is my implementation:

StlWString dicomDirFileName(m_dicomdirPathName + L"DICOMDIR");

// Create DICOMDIR:
DicomDirInterface dicomdir;
OFCondition status = dicomdir.createNewDicomDir(DicomDirInterface::/*AP_GeneralPurpose*/AP_DentalRadiograph,
convertToStlString(dicomDirFileName).c_str(),
DEFAULT_FILESETID);
if ( !status.good() )
return false;

StlWStringVector dcmFileNames = getAllDcmFileNames();
if ( dcmFileNames.empty() )
{
// No dcm file exists in the folder!
return false;
}

for ( StlWStringVector::iterator ft = dcmFileNames.begin(); ft != dcmFileNames.end(); ++ft )
{
dicomdir.addDicomFile(convertToStlString(*ft).c_str(),
convertToStlString(m_dicomdirPathName).c_str());
}

// Write DICOMDIR:
status = dicomdir.writeDicomDir();
if ( !status.good() )
return false;

return true;



J. Riesmeier wrote:Did you also add entries (i.e. Directory Records) to the DICOMDIR? This is done using DicomDirInterface::addDicomFile().

Thanks,
Evan

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#4 Post by J. Riesmeier »

What does addDicomFile() return?

evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

Re: createNewDicomDir writes incomplete DICOMDIR file

#5 Post by evanyftsai »

It returns OF_error.
J. Riesmeier wrote:What does addDicomFile() return?

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#6 Post by J. Riesmeier »

And what ist the exact error code, i.e. what does OFCondition::code() or OFCondition::text() return? What is the output to the logger?

evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

Re: createNewDicomDir writes incomplete DICOMDIR file

#7 Post by evanyftsai »

It turned out that the problem is invalid character `.' in the file name.

I understand that file names like `0275.dcm' violate DICOM naming convention. However, I am not sure we can enforce this policy with all of our doctors.

Any suggestion?

Thanks,
Evan

J. Riesmeier wrote:And what ist the exact error code, i.e. what does OFCondition::code() or OFCondition::text() return? What is the output to the logger?

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#8 Post by J. Riesmeier »

I understand that file names like `0275.dcm' violate DICOM naming convention.
Right, the "." and the filename extension "dcm" are not allowed.
However, I am not sure we can enforce this policy with all of our doctors.
The filename conventions have nothing to do with the users (doctors). This is a technical question and the doctors will usually not see filenames but patient names :)

evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

Re: createNewDicomDir writes incomplete DICOMDIR file

#9 Post by evanyftsai »

I renamed the files and now I am hitting new errors.

This time it is about invalid SOP.

I tried both DicomDirInterface::AP_GeneralPurpose and DicomDirInterface::AP_DentalRadiograph and got invalid SOP.

I also tried DicomDirInterface::AP_CTandMR, seems to pass the SOP test, but got into problems downstream.

How do you choose this option? I know this DICOM data is valid because I was able to generate valid DICOMDIR out of the same data using other software.

Please advise, thanks!

Evan
J. Riesmeier wrote:
I understand that file names like `0275.dcm' violate DICOM naming convention.
Right, the "." and the filename extension "dcm" are not allowed.
However, I am not sure we can enforce this policy with all of our doctors.
The filename conventions have nothing to do with the users (doctors). This is a technical question and the doctors will usually not see filenames but patient names :)

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#10 Post by J. Riesmeier »

I tried both DicomDirInterface::AP_GeneralPurpose and DicomDirInterface::AP_DentalRadiograph and got invalid SOP.
I also tried DicomDirInterface::AP_CTandMR, seems to pass the SOP test, but got into problems downstream.
Of course, you shouldn't try out which Storage Media Application Profile fits your files but check before in the DICOM standard (part 11).
Each Application Profile has been defined for a particular purpose, e.g. to exchange cath lab films in cardiology on CD (STD-XABC-CD).

evanyftsai
Posts: 26
Joined: Fri, 2015-10-16, 09:18

Re: createNewDicomDir writes incomplete DICOMDIR file

#11 Post by evanyftsai »

Thank you.

I've identified the correct application profile for my application, it's AP_CTandMR. However I am still having problems: DCM_StudyID seems to be non-existent in the scan data. In the code comment it says:

/* StudyID is type 1 in DICOMDIR and type 2 in images */

Could you please advise on what should be a correct DCM_StudyID? Thanks!

Regards,
Evan
J. Riesmeier wrote:
I tried both DicomDirInterface::AP_GeneralPurpose and DicomDirInterface::AP_DentalRadiograph and got invalid SOP.
I also tried DicomDirInterface::AP_CTandMR, seems to pass the SOP test, but got into problems downstream.
Of course, you shouldn't try out which Storage Media Application Profile fits your files but check before in the DICOM standard (part 11).
Each Application Profile has been defined for a particular purpose, e.g. to exchange cath lab films in cardiology on CD (STD-XABC-CD).

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

Re: createNewDicomDir writes incomplete DICOMDIR file

#12 Post by J. Riesmeier »

This is why we have the "invent mode": http://support.dcmtk.org/docs-snapshot/ ... 419f4848d0

Post Reply

Who is online

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