From 5e1d163792db82f6cf17e41bece4a6fb4f0f56fc Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Wed, 26 Jun 2024 10:59:21 -0400 Subject: [PATCH] initialize references --- libsrc/Itk2DicomConverter.cpp | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/libsrc/Itk2DicomConverter.cpp b/libsrc/Itk2DicomConverter.cpp index 098d6c08..694cc9e4 100644 --- a/libsrc/Itk2DicomConverter.cpp +++ b/libsrc/Itk2DicomConverter.cpp @@ -109,6 +109,22 @@ namespace dcmqi { delete pixmsr; } + // Iterate over the files and labels available in each file, create a segment for each label, + // initialize segment frames and add to the document + + OFString seriesInstanceUID, classUID; + set instanceUIDs; + + IODCommonInstanceReferenceModule &commref = segdoc->getCommonInstanceReference(); + OFVector &refseries = commref.getReferencedSeriesItems(); + + IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem* refseriesItem = new IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem; + + OFVector &refinstances = refseriesItem->getReferencedInstanceItems(); + + CHECK_COND(dcmDatasets[0]->findAndGetOFString(DCM_SeriesInstanceUID, seriesInstanceUID)); + CHECK_COND(refseriesItem->setSeriesInstanceUID(seriesInstanceUID)); + // Shared FGs: DerivationImageSequence if(!referencesGeometryCheck && dcmDatasets.size() > 1){ FGDerivationImage *fgder = new FGDerivationImage(); @@ -122,26 +138,25 @@ namespace dcmqi { derimgItem->addSourceImageItems(dcmDatasets, CodeSequenceMacro(code_seg.CodeValue,code_seg.CodingSchemeDesignator, code_seg.CodeMeaning), srcimgItems, OFTrue /*skip file errors */); + for(size_t src_image_cnt=0;src_image_cntgetImageSOPInstanceReference(); + OFString instanceUID; + CHECK_COND(instRef.getReferencedSOPClassUID(classUID)); + CHECK_COND(instRef.getReferencedSOPInstanceUID(instanceUID)); + + if(instanceUIDs.find(instanceUID) == instanceUIDs.end()){ + SOPInstanceReferenceMacro *refinstancesItem = new SOPInstanceReferenceMacro(); + CHECK_COND(refinstancesItem->setReferencedSOPClassUID(classUID)); + CHECK_COND(refinstancesItem->setReferencedSOPInstanceUID(instanceUID)); + refinstances.push_back(refinstancesItem); + instanceUIDs.insert(instanceUID); + } + } CHECK_COND(segdoc->addForAllFrames(*fgder)); delete fgder; } - // Iterate over the files and labels available in each file, create a segment for each label, - // initialize segment frames and add to the document - - OFString seriesInstanceUID, classUID; - set instanceUIDs; - - IODCommonInstanceReferenceModule &commref = segdoc->getCommonInstanceReference(); - OFVector &refseries = commref.getReferencedSeriesItems(); - - IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem* refseriesItem = new IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem; - - OFVector &refinstances = refseriesItem->getReferencedInstanceItems(); - - CHECK_COND(dcmDatasets[0]->findAndGetOFString(DCM_SeriesInstanceUID, seriesInstanceUID)); - CHECK_COND(refseriesItem->setSeriesInstanceUID(seriesInstanceUID)); - int uidfound = 0, uidnotfound = 0; Uint8 *frameData = new Uint8[frameSize];