Can't add SR into DICOMDIR

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ruben.cruz
Posts: 43
Joined: Fri, 2019-05-03, 15:06

Can't add SR into DICOMDIR

#1 Post by ruben.cruz »

Hi,

we have been working with dcmtk for a while but in the last few day we have a encounter a problem and we just can't find a solution to it.
So, we are receiving some exams, most of them are with TransferSyntax (0002,0010) TransferSyntaxUID 1.2.840.10008.1.2.4.90 from MG Modality, these are fine, but then we have one SR, (0002,0010) TransferSyntaxUID 1.2.840.10008.1.2.1, that fails when we try to add inside our DICOMDIR (AP_GeneralPurposeDVDJPEG2000).
When we try to insert this SR we get this:
theText = 0x00007ff6fec83110 "Storage media application profile violated"

We have been trying to make sure we have all the required tag filled but the error still the same. Any tips?

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

Re: Can't add SR into DICOMDIR

#2 Post by J. Riesmeier »

What is the output in debug mode? You could also check this file with "dcmmkdir --general-dvd-j2k --debug <filename>".

ruben.cruz
Posts: 43
Joined: Fri, 2019-05-03, 15:06

Re: Can't add SR into DICOMDIR

#3 Post by ruben.cruz »

Code: Select all

dcmmkdir.exe --general-dvd-j2k --debug --recurse IMAGES
D: $dcmtk: dcmmkdir v3.6.5 2019-10-28 $
D:
I: determining input files ...
I: creating DICOMDIR file using STD-GEN-DVD-J2K profile: DICOMDIR
I: checking file: IMAGES\IM000000
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="Little Endian Explicit"
I: checking file: IMAGES\IM000001
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000001
I: checking file: IMAGES\IM000002
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000002
I: checking file: IMAGES\IM000003
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000003
I: checking file: IMAGES\IM000004
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000004
I: checking file: IMAGES\IM000005
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000005
I: checking file: IMAGES\IM000006
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000006
I: checking file: IMAGES\IM000007
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000007
I: checking file: IMAGES\IM000008
D: DcmMetaInfo::checkAndReadPreamble() TransferSyntax="Little Endian Explicit"
D: DcmDataset::read() TransferSyntax="JPEG 2000 (Lossless only)"
I: adding file: IMAGES\IM000008
W: 1 file(s) cannot be added to DICOMDIR:
W:   IMAGES\IM000000
I: writing file: DICOMDIR
D: DcmFileFormat::checkMetaHeaderValue() Version of MetaHeader is ok: 0x0001
D: DcmFileFormat::checkMetaHeaderValue() use new generated SOPInstanceUID [1.2.276.0.7230010.3.1.4.948216371.20312.1592900332.980]
D: DcmFileFormat::checkMetaHeaderValue() use new TransferSyntaxUID [Little Endian Explicit] on writing following Dataset
D: DcmFileFormat::validateMetaInfo() found 7 Elements in DcmMetaInfo 'metinf'
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 8 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 7 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 6 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 5 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 4 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 3 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 2 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 8
D: DcmDicomDir::copyRecordPtrToSQ() Testing sub record no. 1 of 1

IMAGES\IM000000 is the Comprehensive Study Report

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

Re: Can't add SR into DICOMDIR

#4 Post by J. Riesmeier »

That's strange. There is no error message or the like...

Could you send the file "IMAGES\IM000000" by email to bugs/at/dcmtk/dot/org (assuming that it does not contain personal data).

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

Re: Can't add SR into DICOMDIR

#5 Post by J. Riesmeier »

Thank you for the sample file. The Comprehensive SR document is rejected by dcmkdir since the VerifyingObserverSequence is missing. For the directory record of type "SR DOCUMENT​", the VerificationDateTime​ (which is stored in an item of this sequence) is needed. See PS3.3 Table F.5-25:
Most recent Date and Time of verification among those​ defined in the Verifying Observer Sequence (0040,A073).​ Required if Verification Flag (0040,A493) is VERIFIED
Actually, the dcmmkdir tool should report this as an error but for some reason the log output was missing. I will fix this. Thank you for the report!

ruben.cruz
Posts: 43
Joined: Fri, 2019-05-03, 15:06

Re: Can't add SR into DICOMDIR

#6 Post by ruben.cruz »

Thank you for your time.

We managed to make it work with what you said. Just struggled a bit into coding the item to be inside a sequence.

Code: Select all

		reqDataset->findAndGetOFString(DCM_VerificationFlag, Verificationflag);
		if (Verificationflag == "VERIFIED") {
			DcmItem* itemSub;
			if (reqDataset->findOrCreateSequenceItem(DCM_VerifyingObserverSequence, itemSub, -2).good()) {
				itemSub->putAndInsertString(DCM_VerificationDateTime, "00000000000000");
			}
		}
we will make a proper VerificationDateTime next, but overall we happy to finally make this SR into the DICOMDIR.

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

Re: Can't add SR into DICOMDIR

#7 Post by J. Riesmeier »

I'm glad I could help. My patch looks like this:

Code: Select all

--- a/dcmdata/libsrc/dcddirif.cc
+++ b/dcmdata/libsrc/dcddirif.cc
@@ -2581,16 +2581,22 @@ OFCondition DicomDirInterface::checkMandatoryAttributes(DcmMetaInfo *metainfo,
                         OFString tmpString;
                         if (compare(getStringFromDataset(dataset, DCM_VerificationFlag, tmpString), "VERIFIED"))
                         {
-                            /* VerificationDateTime is required if verification flag is VERIFIED,
-                               retrieve most recent (= last) entry from VerifyingObserverSequence */
-                            DcmItem *ditem = NULL;
-                            OFCondition l_status = dataset->findAndGetSequenceItem(DCM_VerifyingObserverSequence, ditem, -1 /*last*/);
-                            if (l_status.good())
+                            if (checkExistsWithValue(dataset, DCM_VerifyingObserverSequence, filename))
                             {
-                                if (!checkExistsWithValue(ditem, DCM_VerificationDateTime, filename))
-                                    result = EC_MissingAttribute;
+                                /* VerificationDateTime is required if VerificationFlag is VERIFIED,
+                                   retrieve most recent (= last) entry from VerifyingObserverSequence */
+                                DcmItem *ditem = NULL;
+                                if (dataset->findAndGetSequenceItem(DCM_VerifyingObserverSequence, ditem, -1 /*last*/).good())
+                                {
+                                    if (!checkExistsWithValue(ditem, DCM_VerificationDateTime, filename))
+                                        result = EC_MissingAttribute;
+                                } else {
+                                    /* should never happen */                                                                                                  
+                                    DCMDATA_ERROR("INTERNAL ERROR: cannot get last item of VerifyingObserverSequence");                                        
+                                    result = EC_InternalError;                                                                                                 
+                                }                                                                                                                              
                             } else                                                                                                                             
-                                result = l_status;                                                                                                             
+                                result = EC_MissingAttribute;                                                                                                  
                         }                                                                                                                                      
                     }                                                                                                                                          
                     break;                                                                                                                                     
That means, the invalid SR document is still not accepted (but now an error is reported).

By the way, there are further issues with your sample file. This is the log output of dsrdump:

Code: Select all

W: PerformedProcedureCodeSequence (0040,a372) absent in SRDocumentGeneralModule (type 2)
W: Reading unknown/unsupported CompletionFlag (COMPLETED)
W: VerifyingObserverSequence (0040,a073) absent in SRDocumentGeneralModule (type 1)
W: Reading unknown/unsupported SpecificCharacterSet (ISO 2022 IR 100)
The other issues should also be fixed!

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

Re: Can't add SR into DICOMDIR

#8 Post by J. Riesmeier »

Follow-up: David Clunie's dciodvfy reports even more issues... both minor and major ones.

I hope this sample file has not been created by a real (medical) product :shock:

Post Reply

Who is online

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