Skip to content

Commit

Permalink
initialize references
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov committed Jun 26, 2024
1 parent 9a072ab commit 5e1d163
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions libsrc/Itk2DicomConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<OFString> instanceUIDs;

IODCommonInstanceReferenceModule &commref = segdoc->getCommonInstanceReference();
OFVector<IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem*> &refseries = commref.getReferencedSeriesItems();

IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem* refseriesItem = new IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem;

OFVector<SOPInstanceReferenceMacro*> &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();
Expand All @@ -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_cnt<srcimgItems.size();src_image_cnt++){
// initialize class UID and series instance UID
ImageSOPInstanceReferenceMacro &instRef = srcimgItems[src_image_cnt]->getImageSOPInstanceReference();
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<OFString> instanceUIDs;

IODCommonInstanceReferenceModule &commref = segdoc->getCommonInstanceReference();
OFVector<IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem*> &refseries = commref.getReferencedSeriesItems();

IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem* refseriesItem = new IODSeriesAndInstanceReferenceMacro::ReferencedSeriesItem;

OFVector<SOPInstanceReferenceMacro*> &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];

Expand Down

0 comments on commit 5e1d163

Please sign in to comment.