# \<unknown\> Unknown/Unhandle MediaStorage, but Pixel Data element found

**URL:** https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693
**Category:** Uncategorized
**Created:** [March 21, 2019, 12:31pm UTC](https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693 "2019-03-21T12:31:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zandarina](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.itk.org/u/zandarina)
#### Post date: [March 21, 2019, 12:31pm UTC](https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693/1 "2019-03-21T12:31:22Z")

</div>

Dear all,

everytime i write the output of a filter, i get this warning. It doesn´t throw any error, and it writes well, but it is a bit annoying to get this warning as an output for each slice as i like to follow the ouputs of my code and with this it is impossible.

Any idea? Thank you

In C:\Users…\Desktop\itk\Modules\ThirdParty\GDCM\src\gdcm\Source\DataStructureAndEncodingDefinition\gdcmMediaStorage.cxx, line 516, function   
Unknown/Unhandle MediaStorage, but Pixel Data element found

```
	std::string filename = "results/output" + std::to_string(sliceNumber) + ".dcm";

	typedef itk::ImageFileWriter< ImageType > WriterType2d;
	WriterType2d::Pointer writer2d = WriterType2d::New();
	writer2d->SetFileName(filename);
	writer2d->SetInput(connected->GetOutput());
	try {
	writer2d->Update();
	}
	catch (itk::ExceptionObject & excp)
	{
	std::cerr << "Error reading the series " << std::endl;
	std::cerr << excp << std::endl;
	}
```

---

<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: [March 21, 2019, 2:14pm UTC](https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693/2 "2019-03-21T14:14:52Z")

</div>

This sounds like an input problem, not an output problem. Do you have any `Update()` calls before `writer2d->Update();`? Can you add `reader->Update();` near the beginning of your program? Do the warnings appear at `reader->Update();` or `writer2d->Update();`?

---

<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: [March 21, 2019, 3:15pm UTC](https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693/3 "2019-03-21T15:15:05Z")

</div>

IMHO (i guess) the warning can be ignored (at least very often), if the data doesn’t have _Media Storage_ and _Modality_. GDCM takes default - Secondary Capture Storage. Everything is good, no idea why return “false” and give warning in this case, but it doesn’t hurt. Modality will be, i guess, “OT” (other).

/// Attempt to set the MediaStorage from a file:  
/// WARNING: When no MediaStorage & Modality are found BUT a PixelData element is found  
/// then MediaStorage is set to the default SecondaryCaptureImageStorage (return value is  
/// false in this case)

**Edit** : IMHO, it is even better not to try to write MR, CT or whatever modality/storage class to reduce an amount of “bad” DICOM files hanging around. Secondary Capture is good.

---

<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: [March 21, 2019, 6:56pm UTC](https://discourse.itk.org/t/unknown-unknown-unhandle-mediastorage-but-pixel-data-element-found/1693/4 "2019-03-21T18:56:38Z")

</div>

> but it is a bit annoying

it will not appear in Release build

```
#if defined(NDEBUG) && !defined(GDCM_ALWAYS_TRACE_MACRO)
#define gdcmWarningMacro(msg) {}
#else
#define gdcmWarningMacro(msg) \
{ \
   if( gdcm::Trace::GetWarningFlag() ) \
   { \
   std::ostringstream osmacro; \
   osmacro << "Warning: In " __FILE__", line " << __LINE__ \
           << ", function " << GDCM_FUNCTION << "\n" \
           << msg << "\n\n"; \
   std::ostream &_os = gdcm::Trace::GetWarningStream(); \
   _os << osmacro.str() << std::endl; \
   } \
}
#endif //NDEBUG

```

**Edit** :

> Everything is good, no idea why return “false”

Return false seems to be important here, because real media storage will be set by calling [ImageHelper::ComputeMediaStorageFromModality](https://github.com/malaterre/GDCM/blob/eacb9505e42687b9e804a24abace4283e8b9a097/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx#L2636), so Secondary Capture will be refined there

```
bool PixmapWriter::Write()
{
  MediaStorage ms;
  if( !ms.SetFromFile( GetFile() ) )
  {
    // Let's fix some old ACR-NAME stuff:
    ms = ImageHelper::ComputeMediaStorageFromModality( ms.GetModality(),
        PixelData->GetNumberOfDimensions(),
        PixelData->GetPixelFormat(),
        PixelData->GetPhotometricInterpretation(),
        0, 1 );
  }

```

Just for the sake of completeness, all above is still applicable
