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

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();
	try {
	catch (itk::ExceptionObject & excp)
	std::cerr << "Error reading the series " << std::endl;
	std::cerr << excp << std::endl;

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();?

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.

1 Like

but it is a bit annoying

it will not appear in Release build

#if defined(NDEBUG) && !defined(GDCM_ALWAYS_TRACE_MACRO)
#define gdcmWarningMacro(msg) {}
#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


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, 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(),
        0, 1 );

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