# Unable to write dicom file with double values

**URL:** https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299
**Category:** Beginner Questions
**Created:** [October 4, 2019, 10:30am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299 "2019-10-04T10:30:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Hasna\_R](https://discourse.itk.org/user_avatar/discourse.itk.org/hasna_r/32/1020_2.png) [@Hasna\_R](https://discourse.itk.org/u/Hasna_R)
#### Post date: [October 4, 2019, 10:30am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/1 "2019-10-04T10:30:44Z")

</div>

Hi,  
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();  
writer-\>SetFileName(“D:\testdicom.dcm”);  
writer-\>SetImageIO(itk::GDCMImageIO::New());  
writer-\>SetInput(dicomData);  
try  
{  
writer-\>Update();  
}  
catch (itk::ExceptionObject& error)  
{  
std::cerr \<\< "Error: " \<\< error \<\< std::endl;  
}

Can any one help me in this?

Thanks & Regards  
Hasna

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [October 4, 2019, 11:20am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/2 "2019-10-04T11:20:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hasna\_R](https://discourse.itk.org/user_avatar/discourse.itk.org/hasna_r/32/1020_2.png) [@Hasna\_R](https://discourse.itk.org/u/Hasna_R)
#### Post date: [October 4, 2019, 11:33am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/3 "2019-10-04T11:33:43Z")

</div>

> [@Hasna\_R](#):
>
> A Floating point buffer was passed but the stored pixel type was not specified.This is currently not supported

Thank you for you help. I will try to reconstruct the data.

---

<div class="post-metadata">

### Author: ![Hasna\_R](https://discourse.itk.org/user_avatar/discourse.itk.org/hasna_r/32/1020_2.png) [@Hasna\_R](https://discourse.itk.org/u/Hasna_R)
#### Post date: [October 4, 2019, 11:34am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/4 "2019-10-04T11:34:37Z")

</div>

Thank you mattias for the help.  
I will try to reconstruct the data with parameters.

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [October 4, 2019, 11:47am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/5 "2019-10-04T11:47:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Hasna\_R](https://discourse.itk.org/user_avatar/discourse.itk.org/hasna_r/32/1020_2.png) [@Hasna\_R](https://discourse.itk.org/u/Hasna_R)
#### Post date: [October 4, 2019, 12:21pm UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/6 "2019-10-04T12:21:25Z")

</div>

Ok . I will also look into it.

Thank you.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [October 4, 2019, 2:14pm UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/7 "2019-10-04T14:14:33Z")

</div>

_Secondary Capture_ sounds familiar, that is more likely to work than _Parametric Map_.

@mihail.isakov and @mathieu.malaterre might have more suggestions.

---

<div class="post-metadata">

### Author: ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)
#### Post date: [October 4, 2019, 9:52pm UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/8 "2019-10-04T21:52:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mathieu.malaterre](https://discourse.itk.org/user_avatar/discourse.itk.org/mathieu.malaterre/32/205_2.png) [@mathieu.malaterre](https://discourse.itk.org/u/mathieu.malaterre)
#### Post date: [October 7, 2019, 7:13am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/9 "2019-10-07T07:13:13Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Hasna\_R](https://discourse.itk.org/user_avatar/discourse.itk.org/hasna_r/32/1020_2.png) [@Hasna\_R](https://discourse.itk.org/u/Hasna_R)
#### Post date: [October 9, 2019, 10:23am UTC](https://discourse.itk.org/t/unable-to-write-dicom-file-with-double-values/2299/10 "2019-10-09T10:23:33Z")

</div>

Thank you for the information.  
Now i am trying to add header tag data for rescale intercept . The writer is throwing exception.

```nohighlight
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

```auto
using DictionaryType = itk::MetaDataDictionary; 
	DictionaryType& dictionary = inputImage->GetMetaDataDictionary();

 std::string rescaleIntercept("0028|1052");
		std::string rescaleInterceptValue("0");
		itk::EncapsulateMetaData<std::string>(dictionary, rescaleIntercept, rescaleInterceptValue);

		std::string rescaleSlope("0028|1053");
		std::string rescaleSlopeValue("1000");
		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  
Hasna
