How to fix Assertion failed: slope == (int)slope with GDCM ImageIO while writing images with double/float slope

Hello everyone,

In advance, I hope this question is okay, as it seems to concern GDCM more than ITK itself.

I want to write a 4D series of DICOM images with header data retrieved from another series, basically patching raw image data together with header information for test purposes. Everything works well except that after writing the first volume, the GDCM reports “Assertion failed: slope == (int)slope” which makes sense because the image where the error occurs has a slope of type float or double.

What would be the optimal way to fix this issue in general when writing PET data and possible problems due to their potential float-type slope? Should I iterate over the extracted dictionary array and cast the slope manually? Is there a patch to install or a flag to set in CMake, which I missed?

I am very thankful for any suggestions and resources cause I couldn’t find a definitive fix for this issue.

Edit: I just tried out iterating over it and it solved the problem as expected:

DICOMReaderType::DictionaryArrayType metaDataDictionaryArray = *(dicomSeriesReader->GetMetaDataDictionaryArray());
	for (DICOMReaderType::DictionaryRawPointer dict : metaDataDictionaryArray) {
		itk::MetaDataObject <std::string>::Pointer slope = itk::MetaDataObject < std::string>::New();
		slope->SetMetaDataObjectValue("1");
		dict->Set("0028|1053", slope);
	}

But not sure if this is the optimal way…

1 Like

@mathieu.malaterre or @mihail.isakov might have some suggestions.

1 Like