I set pixel value of image with double value and tried to save image as dicom file. I am getting error like this
“Description: itk::ERROR: GDCMImageIO(0573B7B0): A Floating point buffer was passed but the stored pixel type was not specified.This is currently not supported”.
typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
catch (itk::ExceptionObject& error)
std::cerr << "Error: " << error << std::endl;
Can any one help me in this?
Thanks & Regards
Most DICOM modalities doesn’t support double or float precision pixel values, if you really want this you could use the modality “Parametric Map” but I’m unsure if the ImageFileWriter supports this. Usually you can only store pixel values as 16-bit integers and then use intercept/slope parameters to reconstruct the data. Of course you usually get a quantization error when doing this depending on the original data.
Thank you for you help. I will try to reconstruct the data.
Thank you mattias for the help.
I will try to reconstruct the data with parameters.
As I mentioned there are some modalities that supports 32 or 64-bits, “Parametric Map” and perhaps “Secondary Capture”, but I’m uncertain how the ITK image writer works and what the resulting modality is.
Ok . I will also look into it.
Secondary Capture sounds familiar, that is more likely to work than Parametric Map.
@mihail.isakov and @mathieu.malaterre might have more suggestions.
AFAIK, GDCM currently doesn’t support float (0x7fe0,0x0008) and double (0x7fe0,0x0009) pixel data, i do in my production clone, but it is big change.
All the above is correct.
ITK currently only does “16bits floating point buffer”. So you need to use the Rescale Slope/Intercept to get a float16 buffer approximation of your original dataset.
GDCM does not implement support f(read+write) of Parametric Map, this is rather a big change and very few DICOM viewers support them (AFAIK).
Thank you for the information.
Now i am trying to add header tag data for rescale intercept . The writer is throwing exception.
Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at itk.ImageFileWriter<itk::Image<short,2> >.GenerateData(ImageFileWriter<itk::Image<short\,2> >* ) in C:\ITK_4.13_x86_vs17\ITK\include\ITK-4.13\itkImageFileWriter.hxx:line 429
at itk.ImageFileWriter<itk::Image<short,2> >.Write(ImageFileWriter<itk::Image<short\,2> >* ) in C:\ITK_4.13_x86_vs17\ITK\include\ITK-4.13\itkImageFileWriter.hxx:line 363
at itk.ImageFileWriter<itk::Image<short,2> >.Update(ImageFileWriter<itk::Image<short\,2> >* ) in C:\ITK_4.13_x86_vs17\ITK\include\ITK-4.13\itkImageFileWriter.h:line 165
This is the code
using DictionaryType = itk::MetaDataDictionary;
DictionaryType& dictionary = inputImage->GetMetaDataDictionary();
itk::EncapsulateMetaData<std::string>(dictionary, rescaleIntercept, rescaleInterceptValue);
itk::EncapsulateMetaData<std::string>(dictionary, rescaleSlope, rescaleSlopeValue);
I am not able to update only these two tags. Along with it i changed 2 more tags (“0008|0016” and 0018|6032) .Those are getting updated. But not rescale tags.
Any help is appreciated.
Thanks & Regards