From 47438101c70c750ccdcb19df4816169a87fc6c1d Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 1 Jul 2003 09:29:56 +0000 Subject: [PATCH] Now GetXImagePosition, GetYImagePosition, GetZImagePosition deal with old ACR-NEMA images --- src/gdcmHeader.cxx | 66 ++++++++++++++++++++++++++++++---------------- src/gdcmHeader.h | 6 ++--- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 3e874633..f94d9dc1 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.71 2003/06/26 13:07:01 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.72 2003/07/01 09:29:56 jpr Exp $ #include #include @@ -1044,6 +1044,13 @@ gdcmElValue* gdcmHeader::NewElValueByNumber(guint16 Group, guint16 Elem) { */ int gdcmHeader::ReplaceOrCreateByNumber(string Value, guint16 Group, guint16 Elem ) { + // TODO : FIXME JPRx + // curieux, non ? + // on (je) cree une Elvalue ne contenant pas de valeur + // on l'ajoute au ElValSet + // on affecte une valeur a cette ElValue a l'interieur du ElValSet + // --> devrait pouvoir etre fait + simplement ??? + gdcmElValue* nvElValue=NewElValueByNumber(Group, Elem); PubElValSet.Add(nvElValue); PubElValSet.SetElValueByNumber(Value, Group, Elem); @@ -1904,12 +1911,16 @@ float gdcmHeader::GetXImagePosition(void) { string StrImPos = GetPubElValByNumber(0x0020,0x0032); if (StrImPos == "gdcm::Unfound") { - dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position Patient"); - string StrSliceLoc = GetPubElValByNumber(0x0020,0x1041); - if (StrSliceLoc == "gdcm::Unfound") { - dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Slice Location"); - // How to tell the caller nothing was found? - } + dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position Patient (0020,0032)"); + StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + if (StrImPos == "gdcm::Unfound") { + dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position (RET) (0020,0030)"); + string StrSliceLoc = GetPubElValByNumber(0x0020,0x1041); // for *very* old ACR-NEMA images + if (StrSliceLoc == "gdcm::Unfound") { + dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Slice Location (0020,1041)"); + // How to tell the caller nothing was found? + } + } return 0.; } if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) @@ -1932,16 +1943,16 @@ float gdcmHeader::GetYImagePosition(void) { string StrImPos = GetPubElValByNumber(0x0020,0x0032); if (StrImPos == "gdcm::Unfound") { - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient"); - string StrSliceLoc = GetPubElValByNumber(0x0020,0x1041); - if (StrSliceLoc == "gdcm::Unfound") { - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Slice Location"); - // How to tell the caller nothing was found? - string StrLocation = GetPubElValByNumber(0x0020,0x0050); + dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient (0020,0032)"); + StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + if (StrImPos == "gdcm::Unfound") { + dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position (RET) (0020,0030)"); + string StrSliceLoc = GetPubElValByNumber(0x0020,0x1041); // for *very* old ACR-NEMA images if (StrSliceLoc == "gdcm::Unfound") { - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Slice Location"); - } - } + dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Slice Location (0020,1041)"); + // How to tell the caller nothing was found? + } + } return 0.; } if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) @@ -1968,29 +1979,38 @@ float gdcmHeader::GetZImagePosition(void) { string StrImPos = GetPubElValByNumber(0x0020,0x0032); if (StrImPos != "gdcm::Unfound") { if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position Patient"); + dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position Patient (0020,0032)"); return 0.; // bug in the element 0x0020,0x0032 } else { return zImPos; } } - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient"); - - string StrSliceLocation = GetPubElValByNumber(0x0020,0x1041); + + StrImPos = GetPubElValByNumber(0x0020,0x0030); // For ACR-NEMA images + if (StrImPos != "gdcm::Unfound") { + if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { + dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); + return 0.; // bug in the element 0x0020,0x0032 + } else { + return zImPos; + } + } + + string StrSliceLocation = GetPubElValByNumber(0x0020,0x1041);// for *very* old ACR-NEMA images if (StrSliceLocation != "gdcm::Unfound") { if( sscanf( StrSliceLocation.c_str(), "%f", &zImPos) !=1) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Slice Location"); + dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Slice Location (0020,1041)"); return 0.; // bug in the element 0x0020,0x1041 } else { return zImPos; } } - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Slice Location"); + dbg.Verbose(0, "gdcmHeader::GetZImagePosition: unfound Slice Location (0020,1041)"); string StrLocation = GetPubElValByNumber(0x0020,0x0050); if (StrLocation != "gdcm::Unfound") { if( sscanf( StrLocation.c_str(), "%f", &zImPos) !=1) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Location"); + dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Location (0020,0050)"); return 0.; // bug in the element 0x0020,0x0050 } else { return zImPos; diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 7d0249c2..aeae71a5 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.29 2003/06/26 13:07:01 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.30 2003/07/01 09:29:56 jpr Exp $ #ifndef GDCMHEADER_H #define GDCMHEADER_H @@ -163,14 +163,14 @@ public: int SetPubElValByName (std::string content, std::string TagName); int SetShaElValByName (std::string content, std::string ShadowTagName); + int SetPubElValByNumber(std::string content, guint16 group, guint16 element); - int SetShaElValByNumber(std::string content, guint16 group, guint16 element); int SetPubElValLengthByNumber(guint32 lgr, guint16 group, guint16 element); int ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem); - int ReplaceOrCreateByNumber(char * Value, guint16 Group, guint16 Elem); + int ReplaceOrCreateByNumber( char * Value, guint16 Group, guint16 Elem); int GetXSize(void); int GetYSize(void); -- 2.45.1