From c9d56cb08298f59fe18cd01f5d2f9840e2bae173 Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 1 Nov 2023 09:26:58 +0100 Subject: [PATCH] ENH: Don't check functional groups (speedup) Speedup writing of DICOM segmentation and parametric map objects by disabling functional group checking when writing. --- libsrc/ImageSEGConverter.cpp | 6 +++++- libsrc/ParaMapConverter.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 3e8bf992..dc6734e1 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -421,6 +421,10 @@ namespace dcmqi { CHECK_COND(segdoc->getFrameOfReference().setFrameOfReferenceUID(frameOfRefUIDchar)); } + // Don't check functional groups since its very time consuming and we trust + // ourselves to put together valid datasets + segdoc->setCheckFGOnWrite(OFFalse); + OFCondition writeResult = segdoc->writeDataset(segdocDataset); if(writeResult.bad()){ cerr << "FATAL ERROR: Writing of the SEG dataset failed!"; @@ -482,7 +486,7 @@ namespace dcmqi { pair , string> ImageSEGConverter::dcmSegmentation2itkimage(DcmDataset *segDataset) { DcmSegmentation *segdoc = NULL; - + DcmRLEDecoderRegistration::registerCodecs(); OFCondition cond = DcmSegmentation::loadDataset(*segDataset, segdoc); diff --git a/libsrc/ParaMapConverter.cpp b/libsrc/ParaMapConverter.cpp index a82ff317..ef8da16f 100644 --- a/libsrc/ParaMapConverter.cpp +++ b/libsrc/ParaMapConverter.cpp @@ -445,6 +445,10 @@ namespace dcmqi { pMapDoc->getSeries().setSeriesNumber(metaInfo.getSeriesNumber().c_str()); DcmDataset* output = new DcmDataset(); + + // Don't check functional groups since its very time consuming and we trust + // ourselves to put together valid datasets + pMapDoc->getFunctionalGroups().setCheckOnWrite(OFFalse); CHECK_COND(pMapDoc->writeDataset(*output)); return output; }