- sw = 4321; // on est sur Sun ou SGI
- }
-
- rewind(e->fp); // les info commencent au debut
- e->offsetCourant=0;
- return (sw);
-}
-
-void gdcmHeader::_setAcrLibido() {
-
- _ID_DCM_ELEM * ple;
- PLIST_ELEMENT plelem;
- PLIST pl;
-
- // Positionnement ACR_LIBIDO
- if(DEBUG) printf("Entree ds _setAcrLibido\n");
-
- filetype = ACR_LIBIDO = 0;
- if ( filetype != TrueDicom) {
- // Recognition Code --> n'existe plus en DICOM V3 ...
-
- pl = e->plist;
- plelem = IdLstFirst(pl);
- while (plelem) {
- ple= IdLstPtrObj(plelem);
- if(DEBUG) printf("gr %04x Num %04x\n", ple->Gr, ple->Num);
- if(ple->Gr > 0x0008) break; // On a depasse
- if(ple->Gr == 0x0008) {
- if(ple->Num > 0x0010) break; // On a depasse
- if(ple->Num == 0x0010) {
- if ( (memcmp(ple->valeurElem,"ACRNEMA_LIBIDO",14)==0)
- // si c'est egal
- || (memcmp(ple->valeurElem,"CANRME_AILIBOD",14)==0)) {
- // en cas d'objet ACRLibido fait sr 1 autre machine)
- e->ACR_LIBIDO =1;
- } // fin if memcmp
- break;
- } // fin if ple->Num==0x0010
- } // fin ple->Gr==0x0008
- plelem = IdLstNext(plelem);
- } // fin while
- } // fin if TrueDicom
-
- return;
-}
-
-/* =======================================================================
-* _IdDcmRecupLgr
-*
-* ACR-NEMA : On a toujours
-* GroupNumber (2 Octets)
-* ElementNumber (2 Octets)
-* ElementSize (4 Octets)
-*
-*
-* DICOM : On peut avoir (implicit Value Representation)
-* GroupNumber (2 Octets)
-* ElementNumber (2 Octets)
-* ElementSize (4 Octets)
-*
-* On peut avoir (explicit Value Representation)
-* GroupNumber (2 Octets)
-* ElementNumber (2 Octets)
-* ValueRepresentation (2 Octets)
-* ElementSize (2 Octets)
-*
-* ATTENTION : dans le cas ou ValueRepresentation = OB, OW, SQ, UN
-* GroupNumber (2 Octets)
-* ElementNumber (2 Octets)
-* ValueRepresentation (2 Octets)
-* zone reservee (2 Octets)
-* ElementSize (4 Octets)
-*
-*
-* ======================================================================= */
-/**
- * \ingroup dcm
- * \brief recupere la longueur d'un champ DICOM.
- * (le fichier doit deja avoir ete ouvert,
- * _IdAcrCheckSwap(ID_DCM_HDR *e) avoir ete appele)
- * et la partie 'group' ainsi que la partie 'elem'
- * de l'acr_element doivent avoir ete lues.
- * @param sw code swap
- * @param skippedLength pointeur sur nombre d'octets que l'on a saute qd la lecture est finie
- * @param longueurLue pointeur sur longueur (en nombre d'octets) effectivement lue
-
- * @return longueur retenue pour le champ
- */
-
-static guint32 _IdDcmRecupLgr(ID_DCM_HDR *e, int sw, int *skippedLength, int *longueurLue) {
-guint32 l_gr;
-unsigned short int l_gr_2;
-int i, trouve;
-char VR[5];
-int lgrLue;
-
-/*
- * ATTENTION :
-*/
-
-int nbCode=26; // nombre d'elements dans la table de type DICOM_VR definie dans dicom.c
-
-/* ================ */
-
-// ID_DCM_HDR *e sert uniquement de passe-plat pour __ExplicitVR
-
-
-if (e->__ExplicitVR == 1) {
- lgrLue=fread (&VR, (size_t)2,(size_t)1, e->fp);
- VR[2]=0;
-
- // ATTENTION :
- // Ce n'est pas parce qu'on a trouve UL la premiere fois qu'on respecte
- // Explicit VR tout le temps
- // (cf e=film ...)
-
- for(i=0,trouve=0;i<nbCode;i++) {
- if(memcmp(_ID_dicom_vr[i].dicom_VR,VR,(size_t)2)==0) {
- (e->pleCourant)->VR=_ID_dicom_vr[i].dicom_VR;
- trouve=1;
- break;
- }
- }
-
- if ( trouve == 0) {
-
- // On est mal : implicit VR repere
- // mais ce n'est pas un code connu ...
- // On reconstitue la longueur
-
- if(DEBUG) printf("IdDcmRecupLgr : Explicit VR, mais pas trouve de code connu\n");
- memcpy(&l_gr, VR,(size_t)2);
-
- lgrLue=fread ( ((char*)&l_gr)+2, (size_t)2, (size_t)1, e->fp);
-
- if(sw) l_gr = _IdDcmSWAP_LONG(((guint32)l_gr),sw);
-
- if(DEBUG) printf("IdDcmRecupLgr : lgr deduite : %08x , %d\n",l_gr,l_gr);
-
- *longueurLue=l_gr;
- if ( (int)l_gr == -1) {
- l_gr=0;
- }
- *skippedLength = 4;
- if (DEBUG) printf(" 1 : lgr %08x (%d )skippedLength %d\n",l_gr,l_gr, *skippedLength);
- return(l_gr);
- }
-
- // On repart dans la sequence 'sensee'
-
- if(DEBUG) printf("VR : [%01x , %01x] (%c%c) en position %d du tableau\n", VR[0],VR[1],VR[0],VR[1],i);
- //printf(" %d , %s\n", i,_ID_dicom_vr[i].dicom_VR);
-
- if (
- (!memcmp( VR,"OB",(size_t)2 )) ||
- (!memcmp( VR,"OW",(size_t)2 )) ||
- (!memcmp( VR,"SQ",(size_t)2 )) ||
- (!memcmp( VR,"UN",(size_t)2 )) ) {
-
- // les 2 octets suivants sont reserves
-
- if(DEBUG) printf("IdDcmRecupLgr : les 2 octets suivants sont reserves\n");
- //on les saute
- fseek(e->fp, 2L,SEEK_CUR);
-
- //on lit la lgr sur QUATRE octets
-
- lgrLue=fread (&l_gr, (size_t)4,(size_t)1, e->fp);
-
- if(sw) l_gr = _IdDcmSWAP_LONG(((guint32)l_gr),sw);
- *skippedLength = 8;
-
- } else {
- //on lit la lgr sur DEUX octets
-
- lgrLue=fread (&l_gr_2, (size_t)2,(size_t)1, e->fp);
-
- if(sw) l_gr_2 = _IdDcmSWAP_SHORT((unsigned short)l_gr_2,sw);
-
- *longueurLue=l_gr_2;
-
-
- if ( l_gr_2 == 0xffff) {
- l_gr = 0;
- } else {
- l_gr = l_gr_2;
- }
- *skippedLength = 4;
- }
- } else { // Explicit VR = 0
-
- //on lit la lgr sur QUATRE octets
-
- lgrLue=fread (&l_gr, (size_t)4,(size_t)1, e->fp);
-
- if(sw)l_gr=_IdDcmSWAP_LONG(((long)l_gr),sw);
- *skippedLength = 4;
- }
-
- *longueurLue=l_gr;
-
- // Traitement des curiosites sur la longueur
+ {
+ return zImPos;
+ }
+ }
+
+ std::string strSliceLocation = GetEntryByNumber(0x0020,0x1041); // for *very* old ACR-NEMA images
+ if ( strSliceLocation != GDCM_UNFOUND )
+ {
+ if( sscanf( strSliceLocation.c_str(), "%f", &zImPos) != 1)
+ {
+ dbg.Verbose(0, "Header::GetZImagePosition: wrong Slice Location (0020,1041)");
+ return 0.; // bug in the element 0x0020,0x1041
+ }
+ else
+ {
+ return zImPos;
+ }
+ }
+ dbg.Verbose(0, "Header::GetZImagePosition: unfound Slice Location (0020,1041)");
+
+ std::string strLocation = GetEntryByNumber(0x0020,0x0050);
+ if ( strLocation != GDCM_UNFOUND )
+ {
+ if( sscanf( strLocation.c_str(), "%f", &zImPos) != 1)
+ {
+ dbg.Verbose(0, "Header::GetZImagePosition: wrong Location (0020,0050)");
+ return 0.; // bug in the element 0x0020,0x0050
+ }
+ else
+ {
+ return zImPos;
+ }
+ }
+ dbg.Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)");
+
+ return 0.; // Hopeless
+}
+
+/**
+ * \brief gets the info from 0020,0013 : Image Number else 0.
+ * @return image number
+ */
+int Header::GetImageNumber()
+{
+ // The function i atoi() takes the address of an area of memory as
+ // parameter and converts the string stored at that location to an integer
+ // using the external decimal to internal binary conversion rules. This may
+ // be preferable to sscanf() since atoi() is a much smaller, simpler and
+ // faster function. sscanf() can do all possible conversions whereas
+ // atoi() can only do single decimal integer conversions.
+ //0020 0013 IS REL Image Number
+ std::string strImNumber = GetEntryByNumber(0x0020,0x0013);
+ if ( strImNumber != GDCM_UNFOUND )
+ {
+ return atoi( strImNumber.c_str() );
+ }
+ return 0; //Hopeless
+}
+
+/**
+ * \brief gets the info from 0008,0060 : Modality
+ * @return Modality Type
+ */
+ModalityType Header::GetModality()
+{
+ // 0008 0060 CS ID Modality
+ std::string strModality = GetEntryByNumber(0x0008,0x0060);
+ if ( strModality != GDCM_UNFOUND )
+ {
+ if ( strModality.find("AU") < strModality.length()) return AU;
+ else if ( strModality.find("AS") < strModality.length()) return AS;
+ else if ( strModality.find("BI") < strModality.length()) return BI;
+ else if ( strModality.find("CF") < strModality.length()) return CF;
+ else if ( strModality.find("CP") < strModality.length()) return CP;
+ else if ( strModality.find("CR") < strModality.length()) return CR;
+ else if ( strModality.find("CT") < strModality.length()) return CT;
+ else if ( strModality.find("CS") < strModality.length()) return CS;
+ else if ( strModality.find("DD") < strModality.length()) return DD;
+ else if ( strModality.find("DF") < strModality.length()) return DF;
+ else if ( strModality.find("DG") < strModality.length()) return DG;
+ else if ( strModality.find("DM") < strModality.length()) return DM;
+ else if ( strModality.find("DS") < strModality.length()) return DS;
+ else if ( strModality.find("DX") < strModality.length()) return DX;
+ else if ( strModality.find("ECG") < strModality.length()) return ECG;
+ else if ( strModality.find("EPS") < strModality.length()) return EPS;
+ else if ( strModality.find("FA") < strModality.length()) return FA;
+ else if ( strModality.find("FS") < strModality.length()) return FS;
+ else if ( strModality.find("HC") < strModality.length()) return HC;
+ else if ( strModality.find("HD") < strModality.length()) return HD;
+ else if ( strModality.find("LP") < strModality.length()) return LP;
+ else if ( strModality.find("LS") < strModality.length()) return LS;
+ else if ( strModality.find("MA") < strModality.length()) return MA;
+ else if ( strModality.find("MR") < strModality.length()) return MR;
+ else if ( strModality.find("NM") < strModality.length()) return NM;
+ else if ( strModality.find("OT") < strModality.length()) return OT;
+ else if ( strModality.find("PT") < strModality.length()) return PT;
+ else if ( strModality.find("RF") < strModality.length()) return RF;
+ else if ( strModality.find("RG") < strModality.length()) return RG;
+ else if ( strModality.find("RTDOSE") < strModality.length()) return RTDOSE;
+ else if ( strModality.find("RTIMAGE") < strModality.length()) return RTIMAGE;
+ else if ( strModality.find("RTPLAN") < strModality.length()) return RTPLAN;
+ else if ( strModality.find("RTSTRUCT") < strModality.length()) return RTSTRUCT;
+ else if ( strModality.find("SM") < strModality.length()) return SM;
+ else if ( strModality.find("ST") < strModality.length()) return ST;
+ else if ( strModality.find("TG") < strModality.length()) return TG;
+ else if ( strModality.find("US") < strModality.length()) return US;
+ else if ( strModality.find("VF") < strModality.length()) return VF;
+ else if ( strModality.find("XA") < strModality.length()) return XA;
+ else if ( strModality.find("XC") < strModality.length()) return XC;
+
+ else
+ {
+ /// \todo throw error return value ???
+ /// specified <> unknow in our database
+ return Unknow;
+ }
+ }
+
+ return Unknow;
+}
+
+/**
+ * \brief Retrieve the number of Bits Stored (actually used)
+ * (as opposite to number of Bits Allocated)
+ * @return The encountered number of Bits Stored, 0 by default.
+ * 0 means the file is NOT USABLE. The caller has to check it !
+ */
+int Header::GetBitsStored()
+{
+ std::string strSize = GetEntryByNumber( 0x0028, 0x0101 );
+ if ( strSize == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetBitsStored: this is supposed to "
+ "be mandatory");
+ return 0; // It's supposed to be mandatory
+ // the caller will have to check
+ }
+ return atoi( strSize.c_str() );
+}
+
+/**
+ * \brief Retrieve the high bit position.
+ * \warning The method defaults to 0 when information is absent.
+ * The responsability of checking this value is left to the caller.
+ * @return The high bit positin when present. 0 when absent.
+ */
+int Header::GetHighBitPosition()
+{
+ std::string strSize = GetEntryByNumber( 0x0028, 0x0102 );
+ if ( strSize == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetHighBitPosition: this is supposed "
+ "to be mandatory");
+ return 0;
+ }
+ return atoi( strSize.c_str() );
+}
+
+/**
+ * \brief Check wether the pixels are signed or UNsigned data.
+ * \warning The method defaults to false (UNsigned) when information is absent.
+ * The responsability of checking this value is left to the caller.
+ * @return True when signed, false when UNsigned
+ */
+bool Header::IsSignedPixelData()
+{
+ std::string strSize = GetEntryByNumber( 0x0028, 0x0103 );
+ if ( strSize == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::IsSignedPixelData: this is supposed "
+ "to be mandatory");
+ return false;
+ }
+ int sign = atoi( strSize.c_str() );
+ if ( sign == 0 )
+ {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * \brief Retrieve the number of Bits Allocated
+ * (8, 12 -compacted ACR-NEMA files, 16, ...)
+ * @return The encountered number of Bits Allocated, 0 by default.
+ * 0 means the file is NOT USABLE. The caller has to check it !
+ */
+int Header::GetBitsAllocated()
+{
+ std::string strSize = GetEntryByNumber(0x0028,0x0100);
+ if ( strSize == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetBitsStored: this is supposed to "
+ "be mandatory");
+ return 0; // It's supposed to be mandatory
+ // the caller will have to check
+ }
+ return atoi( strSize.c_str() );
+}
+
+/**
+ * \brief Retrieve the number of Samples Per Pixel
+ * (1 : gray level, 3 : RGB -1 or 3 Planes-)
+ * @return The encountered number of Samples Per Pixel, 1 by default.
+ * (Gray level Pixels)
+ */
+int Header::GetSamplesPerPixel()
+{
+ std::string strSize = GetEntryByNumber(0x0028,0x0002);
+ if ( strSize == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetBitsStored: this is supposed to "
+ "be mandatory");
+ return 1; // Well, it's supposed to be mandatory ...
+ // but sometimes it's missing : *we* assume Gray pixels
+ }
+ return atoi( strSize.c_str() );
+}
+
+/**
+ * \brief Check wether this a monochrome picture or not by accessing
+ * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return true when "MONOCHROME1" or "MONOCHROME2". False otherwise.
+ */
+bool Header::IsMonochrome()
+{
+ std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+ if ( PhotometricInterp == "MONOCHROME1 "
+ || PhotometricInterp == "MONOCHROME2 " )
+ {
+ return true;
+ }
+ if ( PhotometricInterp == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::IsMonochrome: absent Photometric "
+ "Interpretation");
+ }
+ return false;
+}
+
+/**
+ * \brief Check wether this a "PALETTE COLOR" picture or not by accessing
+ * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return true when "PALETTE COLOR". False otherwise.
+ */
+bool Header::IsPaletteColor()
+{
+ std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+ if ( PhotometricInterp == "PALETTE COLOR " )
+ {
+ return true;
+ }
+ if ( PhotometricInterp == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::IsPaletteColor: absent Photometric "
+ "Interpretation");
+ }
+ return false;
+}
+
+/**
+ * \brief Check wether this a "YBR_FULL" color picture or not by accessing
+ * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
+ * @return true when "YBR_FULL". False otherwise.
+ */
+bool Header::IsYBRFull()
+{
+ std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 );
+ if ( PhotometricInterp == "YBR_FULL" )
+ {
+ return true;
+ }
+ if ( PhotometricInterp == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::IsYBRFull: absent Photometric "
+ "Interpretation");
+ }
+ return false;
+}
+
+/**
+ * \brief Retrieve the Planar Configuration for RGB images
+ * (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane)
+ * @return The encountered Planar Configuration, 0 by default.
+ */
+int Header::GetPlanarConfiguration()
+{
+ std::string strSize = GetEntryByNumber(0x0028,0x0006);
+ if ( strSize == GDCM_UNFOUND )
+ {
+ return 0;
+ }
+ return atoi( strSize.c_str() );
+}
+
+/**
+ * \brief Return the size (in bytes) of a single pixel of data.
+ * @return The size in bytes of a single pixel of data; 0 by default
+ * 0 means the file is NOT USABLE; the caller will have to check
+ */
+int Header::GetPixelSize()
+{
+ // 0028 0100 US IMG Bits Allocated
+ // (in order no to be messed up by old RGB images)
+ // if (Header::GetEntryByNumber(0x0028,0x0100) == "24")
+ // return 3;
+
+ std::string pixelType = GetPixelType();
+ if ( pixelType == "8U" || pixelType == "8S" )
+ {
+ return 1;
+ }
+ if ( pixelType == "16U" || pixelType == "16S")
+ {
+ return 2;
+ }
+ if ( pixelType == "32U" || pixelType == "32S")
+ {
+ return 4;
+ }
+ if ( pixelType == "FD" )
+ {
+ return 8;
+ }
+ dbg.Verbose(0, "Header::GetPixelSize: Unknown pixel type");
+ return 0;
+}
+
+/**
+ * \brief Build the Pixel Type of the image.
+ * Possible values are:
+ * - 8U unsigned 8 bit,
+ * - 8S signed 8 bit,
+ * - 16U unsigned 16 bit,
+ * - 16S signed 16 bit,
+ * - 32U unsigned 32 bit,
+ * - 32S signed 32 bit,
+ * - FD floating double 64 bits (Not kosher DICOM, but so usefull!)
+ * \warning 12 bit images appear as 16 bit.
+ * 24 bit images appear as 8 bit
+ * @return 0S if nothing found. NOT USABLE file. The caller has to check
+ */
+std::string Header::GetPixelType()
+{
+ std::string bitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated
+ if ( bitsAlloc == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetPixelType: unfound Bits Allocated");
+ bitsAlloc = "16";
+ }
+
+ if ( bitsAlloc == "64" )
+ {
+ return "FD";
+ }
+ if ( bitsAlloc == "12" )
+ {
+ // It will be unpacked
+ bitsAlloc = "16";
+ }
+ else if ( bitsAlloc == "24" )
+ {
+ // (in order no to be messed up
+ bitsAlloc = "8"; // by old RGB images)
+ }
+
+ std::string sign = GetEntryByNumber(0x0028, 0x0103);//"Pixel Representation"
+
+ if (sign == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetPixelType: unfound Pixel Representation");
+ bitsAlloc = "0";
+ }
+ if ( sign == "0" )
+ {
+ sign = "U";
+ }
+ else
+ {
+ sign = "S";
+ }
+ return bitsAlloc + sign;
+}
+
+
+/**
+ * \brief Recover the offset (from the beginning of the file)
+ * of *image* pixels (not *icone image* pixels, if any !)
+ * @return Pixel Offset
+ */
+size_t Header::GetPixelOffset()
+{
+ DocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel);
+ if ( pxlElement )
+ {
+ return pxlElement->GetOffset();
+ }
+ else
+ {
+#ifdef GDCM_DEBUG
+ std::cout << "Big trouble : Pixel Element ("
+ << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
+ << std::endl;
+#endif //GDCM_DEBUG
+ return 0;
+ }
+}
+
+/// \todo TODO : unify those two (previous one and next one)
+/**
+ * \brief Recover the pixel area length (in Bytes)
+ * @return Pixel Element Length, as stored in the header
+ * (NOT the memory space necessary to hold the Pixels
+ * -in case of embeded compressed image-)
+ * 0 : NOT USABLE file. The caller has to check.
+ */
+size_t Header::GetPixelAreaLength()
+{
+ DocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel);
+ if ( pxlElement )
+ {
+ return pxlElement->GetLength();
+ }
+ else
+ {
+#ifdef GDCM_DEBUG
+ std::cout << "Big trouble : Pixel Element ("
+ << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
+ << std::endl;
+#endif //GDCM_DEBUG
+ return 0;
+ }
+}
+
+/**
+ * \brief tells us if LUT are used
+ * \warning Right now, 'Segmented xxx Palette Color Lookup Table Data'
+ * are NOT considered as LUT, since nobody knows
+ * how to deal with them
+ * Please warn me if you know sbdy that *does* know ... jprx
+ * @return true if LUT Descriptors and LUT Tables were found
+ */
+bool Header::HasLUT()
+{
+ // Check the presence of the LUT Descriptors, and LUT Tables
+ // LutDescriptorRed
+ if ( !GetDocEntryByNumber(0x0028,0x1101) )
+ {
+ return false;
+ }
+ // LutDescriptorGreen
+ if ( !GetDocEntryByNumber(0x0028,0x1102) )
+ {
+ return false;
+ }
+ // LutDescriptorBlue
+ if ( !GetDocEntryByNumber(0x0028,0x1103) )
+ {
+ return false;
+ }
+ // Red Palette Color Lookup Table Data
+ if ( !GetDocEntryByNumber(0x0028,0x1201) )
+ {
+ return false;
+ }
+ // Green Palette Color Lookup Table Data
+ if ( !GetDocEntryByNumber(0x0028,0x1202) )
+ {
+ return false;
+ }
+ // Blue Palette Color Lookup Table Data
+ if ( !GetDocEntryByNumber(0x0028,0x1203) )
+ {
+ return false;
+ }
+
+ // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent)
+ // NOT taken into account, but we don't know how to use it ...
+ return true;
+}
+
+/**
+ * \brief gets the info from 0028,1101 : Lookup Table Desc-Red
+ * else 0
+ * @return Lookup Table number of Bits , 0 by default
+ * when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
+ * @ return bit number of each LUT item
+ */
+int Header::GetLUTNbits()
+{
+ std::vector<std::string> tokens;
+ int lutNbits;
+
+ //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red
+ // = Lookup Table Desc-Blue
+ // Consistency already checked in GetLUTLength
+ std::string lutDescription = GetEntryByNumber(0x0028,0x1101);
+ if ( lutDescription == GDCM_UNFOUND )
+ {
+ return 0;
+ }
+
+ tokens.clear(); // clean any previous value
+ Util::Tokenize ( lutDescription, tokens, "\\" );
+ //LutLength=atoi(tokens[0].c_str());
+ //LutDepth=atoi(tokens[1].c_str());
+
+ lutNbits = atoi( tokens[2].c_str() );
+ tokens.clear();
+
+ return lutNbits;
+}
+
+/**
+ * \brief Accesses the info from 0002,0010 : Transfert Syntax and TS
+ * else 1.
+ * @return The full Transfert Syntax Name (as opposed to Transfert Syntax UID)
+ */
+std::string Header::GetTransfertSyntaxName()
+{
+ // use the TS (TS : Transfert Syntax)
+ std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010);
+
+ if ( transfertSyntax == GDCM_NOTLOADED )
+ {
+ std::cout << "Transfert Syntax not loaded. " << std::endl
+ << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+ << std::endl;
+ return "Uncompressed ACR-NEMA";
+ }
+ if ( transfertSyntax == GDCM_UNFOUND )
+ {
+ dbg.Verbose(0, "Header::GetTransfertSyntaxName:"
+ " unfound Transfert Syntax (0002,0010)");
+ return "Uncompressed ACR-NEMA";
+ }
+
+ while ( ! isdigit(transfertSyntax[transfertSyntax.length()-1]) )
+ {
+ transfertSyntax.erase(transfertSyntax.length()-1, 1);
+ }
+ // we do it only when we need it
+ TS* ts = Global::GetTS();
+ std::string tsName = ts->GetValue( transfertSyntax );
+
+ //delete ts; /// \todo Seg Fault when deleted ?!
+ return tsName;
+}
+
+/**
+ * \brief Sets the Pixel Area size in the Header
+ * --> not-for-rats function
+ * @param ImageDataSize new Pixel Area Size
+ * warning : nothing else is checked
+ */
+void Header::SetImageDataSize(size_t ImageDataSize)
+{
+ ///FIXME I don't understand this code wh ydo we set two times 'car' ?
+ std::string car = Util::Format("%d", ImageDataSize);
+
+ DocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
+ a->SetLength(ImageDataSize);
+
+ ImageDataSize += 8;
+ car = Util::Format("%d", ImageDataSize);
+
+ SetEntryByNumber(car, GrPixel, NumPixel);
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
+/**
+ * \brief anonymize a Header (removes Patient's personal info)
+ * (read the code to see which ones ...)
+ */
+bool Header::AnonymizeHeader()
+{
+ // If exist, replace by spaces
+ SetEntryByNumber (" ",0x0010, 0x2154); // Telephone
+ SetEntryByNumber (" ",0x0010, 0x1040); // Adress
+ SetEntryByNumber (" ",0x0010, 0x0020); // Patient ID
+
+ DocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);