- //fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
- // gdcm1.3 syntax. Sorry !
- fileToBuild->InsertEntryString(str.str(),0x0028,0x0002, "UI"); // Samples per Pixel
-
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0002,"US"); // Samples per Pixel
+
+// The image may be displayed uncorectly if these fields are missing
+
+ // Set the Pixel Aspect Ratio, if any
+ std::string par = f->GetEntryString(0x0028,0x0034);
+ std::cerr <<"Pixel Aspect Ratio [" << par << "]" << std::endl;
+ if ( par != GDCM_NAME_SPACE::GDCM_UNFOUND )
+ fileToBuild->InsertEntryString(par,0x0028,0x0034,"IS"); // Pixel Aspect Ratio
+
+ // Set the Modality, if any
+ std::string modality = f->GetEntryString(0x0008,0x0060);
+ std::cerr <<"Modality [" << modality << "]" << std::endl;
+ if ( modality != GDCM_NAME_SPACE::GDCM_UNFOUND )
+ fileToBuild->InsertEntryString(modality,0x0008,0x0060,"CS"); // Modality
+
+ // Set the Media Storage SOP Class UID, if any
+ std::string mssop = f->GetEntryString(0x0002,0x0002);
+ std::cerr <<"Media Storage SOP Class UID [" << mssop << "]" << std::endl;
+ if ( mssop != GDCM_NAME_SPACE::GDCM_UNFOUND )
+ fileToBuild->InsertEntryString(mssop,0x0002,0x0002,"UI"); // Media Storage SOP Class UID
+
+ // This one is mandatory to deal with Pixel Aspect Ratio, in ultrasound images !
+ // Set the SOP Class UID, if any
+ std::string sop = f->GetEntryString(0x0008,0x0016);
+ std::cerr <<"SOP Class UID [" << sop << "]" << std::endl;
+ if ( sop != GDCM_NAME_SPACE::GDCM_UNFOUND )
+ fileToBuild->InsertEntryString(sop,0x0008,0x0016,"UI"); // SOP Class UID
+