#include <gdcmHeaderHelper.h>
Inheritance diagram for gdcmHeaderHelper:

Public Member Functions | |
| gdcmHeaderHelper () | |
| constructor | |
| gdcmHeaderHelper (const char *filename, bool exception_on_error=false, bool enable_sequences=false, bool ignore_shadow=false) | |
| constructor | |
| int | GetPixelSize () |
| Returns the size (in bytes) of a single pixel of data. | |
| std::string | GetPixelType () |
| 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 Double,. | |
| float | GetXSpacing () |
| gets the info from 0028,0030 : Pixel Spacing else 1. | |
| float | GetYSpacing () |
| gets the info from 0028,0030 : Pixel Spacing else 1. | |
| float | GetZSpacing () |
| gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1. | |
| float | GetRescaleIntercept () |
| gets the info from 0028,1052 : Rescale Intercept | |
| float | GetRescaleSlope () |
| gets the info from 0028,1053 : Rescale Slope | |
| int | GetNumberOfScalarComponents () |
| This function is intended to user who doesn't want to have to manage a LUT and expects to get an RBG Pixel image (or a monochrome one ...). | |
| int | GetNumberOfScalarComponentsRaw () |
| This function is intended to user that DOESN'T want get RGB pixels image when it's stored as a PALETTE COLOR image \ - the (vtk) user is supposed to know how deal with LUTs -. | |
| std::string | GetStudyUID () |
| gets the info from 0020,000d : Study Instance UID | |
| std::string | GetSeriesUID () |
| gets the info from 0020,000e : Series Instance UID | |
| std::string | GetClassUID () |
| gets the info from 0008,0016 : SOP Class UID | |
| std::string | GetInstanceUID () |
| gets the info from 0008,0018 : SOP Instance UID | |
| float | GetXOrigin () |
| gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0. | |
| float | GetYOrigin () |
| gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0. | |
| float | GetZOrigin () |
| gets the info from 0020,0032 : Image Position Patient \ else from 0020,0030 : Image Position (RET) \ else from 0020,1041 : Slice Location \ else from 0020,0050 : Location \ else 0. | |
| int | GetImageNumber () |
| gets the info from 0020,0013 : Image Number \ else 0. | |
| ModalityType | GetModality () |
| gets the info from 0008,0060 : Modality | |
| void | GetImageOrientationPatient (float *iop) |
| gets the info from 0020,0037 : Image Orientation Patient | |
| virtual bool | IsReadable (void) |
| This predicate, based on hopefully reasonable heuristics, decides whether or not the current gdcmParser was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File. | |
| bool | IsJPEGBaseLineProcess1TransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGBaseLineProcess1 one. | |
| bool | IsJPEGExtendedProcess2_4TransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGExtendedProcess2-4 one. | |
| bool | IsJPEGExtendedProcess3_5TransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGExtendeProcess3-5 one. | |
| bool | IsJPEGSpectralSelectionProcess6_8TransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGSpectralSelectionProcess6-8 one. | |
| bool | IsRLELossLessTransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a RLE Lossless one. | |
| bool | IsJPEGLossless (void) |
| Determines if Transfer Syntax was already encountered and if it corresponds to a JPEG Lossless one. | |
| bool | IsJPEG2000 (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEG2000 one. | |
| bool | IsDicomV3 (void) |
| Predicate for dicom version 3 file. | |
| int | GetXSize (void) |
| Retrieve the number of columns of image. | |
| int | GetYSize (void) |
| Retrieve the number of lines of image. | |
| int | GetZSize (void) |
| Retrieve the number of planes of volume or the number of frames of a multiframe. | |
| int | GetBitsStored (void) |
| Retrieve the number of Bits Stored (actually used) (as opposite to number of Bits Allocated). | |
| int | GetBitsAllocated (void) |
| Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files, 16, ...). | |
| int | GetSamplesPerPixel (void) |
| Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB -1 or 3 Planes-). | |
| int | GetPlanarConfiguration (void) |
| Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane). | |
| size_t | GetPixelOffset (void) |
| Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !). | |
| size_t | GetPixelAreaLength (void) |
| Recover the pixel area length (in Bytes). | |
| bool | HasLUT (void) |
| tells us if LUT are used | |
| int | GetLUTNbits (void) |
| gets the info from 0028,1101 : Lookup Table Desc-Red else 0 | |
| unsigned char * | GetLUTRGBA (void) |
| builts Red/Green/Blue/Alpha LUT from Header when (0028,0004),Photometric Interpretation = [PALETTE COLOR ] and (0028,1101),(0028,1102),(0028,1102) -xxx Palette Color Lookup Table Descriptor - are found and (0028,1201),(0028,1202),(0028,1202) -xxx Palette Color Lookup Table Data - are found | |
| std::string | GetTransfertSyntaxName (void) |
| gets the info from 0002,0010 : Transfert Syntax and gdcmTS else 1. | |
| virtual std::string | GetEntryByNumber (guint16 group, guint16 element) |
| Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value representation of a given tag. | |
| virtual std::string | GetEntryVRByNumber (guint16 group, guint16 element) |
| Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value representation of a given tag.. | |
| virtual std::string | GetEntryByName (std::string tagName) |
| Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value of a given tag. | |
| virtual std::string | GetEntryVRByName (std::string tagName) |
| Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value representation of a given tag. | |
| virtual bool | SetEntryByNumber (std::string content, guint16 group, guint16 element) |
| Accesses an existing gdcmHeaderEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
| virtual bool | SetEntryByName (std::string content, std::string tagName) |
| Sets the value (string) of the Header Entry (Dicom Element). | |
| virtual bool | SetEntryLengthByNumber (guint32 l, guint16 group, guint16 element) |
| Accesses an existing gdcmHeaderEntry (i.e. a Dicom Element) in the PubHeaderEntrySet of this instance through it's (group, element) and modifies it's length with the given value. | |
| virtual void | UpdateShaEntries (void) |
| Update the entries with the shadow dictionary. Only non even entries are analyzed. | |
| void | SetImageDataSize (size_t ExpectedSize) |
| Sets the Pixel Area size in the Header --> not-for-rats function. | |
| bool | operator< (gdcmHeader &header) |
| compares 2 Headers, according to DICOMDIR rules --> not-for-rats function | |
| void | SetPrintLevel (int level) |
| Sets the print level for the Dicom Header. | |
| virtual void | Print (std::ostream &os=std::cout) |
| virtual void | PrintEntry (std::ostream &os=std::cout) |
| Prints the Header Entries (Dicom Elements) both from the H Table and the chained list. | |
| virtual void | PrintPubDict (std::ostream &os=std::cout) |
| Prints The Dict Entries of THE public Dicom Dictionnry. | |
| virtual void | PrintShaDict (std::ostream &os=std::cout) |
| Prints The Dict Entries of THE shadow Dicom Dictionnry. | |
| std::string | GetFileName (void) |
| gdcmDict * | GetPubDict (void) |
| Get the public dictionary used. | |
| gdcmDict * | GetShaDict (void) |
| Get the shadow dictionary used. | |
| bool | SetShaDict (gdcmDict *dict) |
| Set the shadow dictionary used. | |
| bool | SetShaDict (DictKey dictName) |
| Set the shadow dictionary used. | |
| bool | IsImplicitVRLittleEndianTransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a ImplicitVRLittleEndian one. | |
| bool | IsExplicitVRLittleEndianTransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a ExplicitVRLittleEndian one. | |
| bool | IsDeflatedExplicitVRLittleEndianTransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a DeflatedExplicitVRLittleEndian one. | |
| bool | IsExplicitVRBigEndianTransferSyntax (void) |
| Determines if the Transfer Syntax was already encountered and if it corresponds to a Explicit VR Big Endian one. | |
| FileType | GetFileType (void) |
| returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) | |
| TagHeaderEntryHT & | GetEntry (void) |
| returns a ref to the Dicom Header H table (multimap) return the Dicom Header H table | |
| ListTag & | GetListEntry (void) |
| returns a ref to the Dicom Header chained list return the Dicom Header chained list | |
| FILE * | OpenFile (bool exception_on_error=false) throw (gdcmFileError) |
| opens the file | |
| bool | CloseFile (void) |
| closes the file | |
| virtual bool | Write (FILE *, FileType) |
| bool | ReplaceOrCreateByNumber (std::string Value, guint16 Group, guint16 Elem) |
| Modifies the value of a given Header Entry (Dicom Element) if it exists; Creates it with the given value if it doesn't. | |
| bool | ReplaceOrCreateByNumber (char *Value, guint16 Group, guint16 Elem) |
| Modifies the value of a given Header Entry (Dicom Element) if it exists; Creates it with the given value if it doesn't. | |
| bool | ReplaceIfExistByNumber (char *Value, guint16 Group, guint16 Elem) |
| Set a new value if the invoked element exists Seems to be useless !!! | |
| int | GetSwapCode (void) |
| guint16 | GetGrPixel (void) |
| guint16 | GetNumPixel (void) |
| guint16 | SwapShort (guint16) |
| Swaps the bytes so they agree with the processor order. | |
| guint32 | SwapLong (guint32) |
| Swaps back the bytes of 4-byte long integer accordingly to processor order. | |
| guint16 | UnswapShort (guint16) |
| Unswaps the bytes so they agree with the processor order. | |
| guint32 | UnswapLong (guint32) |
| Unswaps back the bytes of 4-byte long integer accordingly to processor order. | |
Protected Member Functions | |
| int | write (std::ostream &) |
| int | anonymize (std::ostream &) |
| bool | anonymizeHeader (void) |
| anonymize a Header (removes Patient's personal info) (read the code to see which ones ...) | |
| int | CheckIfEntryExistByNumber (guint16 Group, guint16 Elem) |
| Checks if a given Dicom Element exists within the H table. | |
| virtual size_t | GetEntryOffsetByNumber (guint16 Group, guint16 Elem) |
| Gets (from Header) the offset of a 'non string' element value (LoadElementValues has already be executed). | |
| virtual void * | GetEntryVoidAreaByNumber (guint16 Group, guint16 Elem) |
| Gets (from Header) a 'non string' element value (LoadElementValues has already be executed). | |
| virtual void * | LoadEntryVoidArea (guint16 Group, guint16 Element) |
| Loads (from disk) the element content when a string is not suitable. | |
| virtual bool | SetEntryVoidAreaByNumber (void *a, guint16 Group, guint16 Elem) |
| Sets a 'non string' value to a given Dicom Element. | |
| gdcmHeaderEntry * | GetHeaderEntryByNumber (guint16 group, guint16 element) |
| retrieves a Dicom Element (the first one) using (group, element) | |
| gdcmHeaderEntry * | GetHeaderEntryByName (std::string Name) |
| Searches within the Header Entries for a Dicom Element of a given tag. | |
| IterHT | GetHeaderEntrySameNumber (guint16 group, guint16 element) |
| retrieves the Dicom Elements (all of them) using (group, element) | |
| void | LoadHeaderEntrySafe (gdcmHeaderEntry *) |
| Loads the element while preserving the current underlying file position indicator as opposed to to LoadHeaderEntry that modifies it. | |
| void | UpdateGroupLength (bool SkipSequence=false, FileType type=ImplicitVR) |
| Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader. | |
| void | WriteEntries (FILE *_fp, FileType type) |
| writes on disc according to the requested format (ACR-NEMA, ExplicitVR, ImplicitVR) the image | |
Protected Attributes | |
| FILE * | fp |
| FileType | filetype |
| TagHeaderEntryHT | tagHT |
| ListTag | listEntries |
| int | enableSequences |
| int | printLevel |
| guint16 | GrPixel |
| guint16 | NumPixel |
| int | countGrPixel |
Static Protected Attributes | |
| const unsigned int | HEADER_LENGTH_TO_READ = 256 |
| const unsigned int | MAX_SIZE_LOAD_ELEMENT_VALUE = 4096 |
| const unsigned int | MAX_SIZE_PRINT_ELEMENT_VALUE = 64 |
|
|
constructor
Definition at line 18 of file gdcmHeaderHelper.cxx.
00018 : gdcmHeader( ) { 00019 00020 } |
|
||||||||||||||||||||
|
constructor
Definition at line 33 of file gdcmHeaderHelper.cxx.
00037 : gdcmHeader( InFilename, 00038 exception_on_error, 00039 enable_sequences, 00040 ignore_shadow) 00041 { 00042 } |
|
|
|
|
|
anonymize a Header (removes Patient's personal info) (read the code to see which ones ...)
Definition at line 795 of file gdcmHeader.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), gdcmParser::GetHeaderEntryByNumber(), gdcmParser::ReplaceIfExistByNumber(), and gdcmParser::ReplaceOrCreateByNumber().
00795 {
00796
00797 gdcmHeaderEntry *patientNameHE = GetHeaderEntryByNumber (0x0010, 0x0010);
00798 // gdcmHeaderEntry *patientIDHE = GetHeaderEntryByNumber (0x0010, 0x0020);
00799
00800 ReplaceIfExistByNumber (" ",0x0010, 0x2154); // Telephone
00801 ReplaceIfExistByNumber (" ",0x0010, 0x1040); // Adress
00802 ReplaceIfExistByNumber (" ",0x0010, 0x0020); // Patient ID
00803
00804 if (patientNameHE) {
00805 std::string StudyInstanceUID = GetEntryByNumber (0x0020, 0x000d);
00806 if (StudyInstanceUID !=GDCM_UNFOUND)
00807 ReplaceOrCreateByNumber(StudyInstanceUID, 0x0010, 0x0010);
00808 else
00809 ReplaceOrCreateByNumber("anonymised", 0x0010, 0x0010);
00810 }
00811
00812 // Just for fun :-(
00813 // (if any) remove or replace
00814
00815 //0008 0012 DA ID Instance Creation Date
00816 //0008 0020 DA ID Study Date
00817 //0008 0021 DA ID Series Date
00818 //0008 0022 DA ID Acquisition Date
00819 //0008 0023 DA ID Content Date
00820 //0008 0024 DA ID Overlay Date
00821 //0008 0025 DA ID Curve Date
00822 //0008 002a DT ID Acquisition Datetime
00823 //0018 9074 DT ACQ Frame Acquisition Datetime
00824 //0018 9151 DT ACQ Frame Reference Datetime
00825 //0018 a002 DT ACQ Contribution Date Time
00826 //0020 3403 SH REL Modified Image Date (RET)
00827 //0032 0032 DA SDY Study Verified Date
00828 //0032 0034 DA SDY Study Read Date
00829 //0032 1000 DA SDY Scheduled Study Start Date
00830 //0032 1010 DA SDY Scheduled Study Stop Date
00831 //0032 1040 DA SDY Study Arrival Date
00832 //0032 1050 DA SDY Study Completion Date
00833 //0038 001a DA VIS Scheduled Admission Date
00834 //0038 001c DA VIS Scheduled Discharge Date
00835 //0038 0020 DA VIS Admitting Date
00836 //0038 0030 DA VIS Discharge Date
00837 //0040 0002 DA PRC Scheduled Procedure Step Start Date
00838 //0040 0004 DA PRC Scheduled Procedure Step End Date
00839 //0040 0244 DA PRC Performed Procedure Step Start Date
00840 //0040 0250 DA PRC Performed Procedure Step End Date
00841 //0040 2004 DA PRC Issue Date of Imaging Service Request
00842 //0040 4005 DT PRC Scheduled Procedure Step Start Date and Time
00843 //0040 4011 DT PRC Expected Completion Date and Time
00844 //0040 a030 DT PRC Verification Date Time
00845 //0040 a032 DT PRC Observation Date Time
00846 //0040 a120 DT PRC DateTime
00847 //0040 a121 DA PRC Date
00848 //0040 a13a DT PRC Referenced Datetime
00849 //0070 0082 DA ??? Presentation Creation Date
00850 //0100 0420 DT ??? SOP Autorization Date and Time
00851 //0400 0105 DT ??? Digital Signature DateTime
00852 //2100 0040 DA PJ Creation Date
00853 //3006 0008 DA SSET Structure Set Date
00854 //3008 0024 DA ??? Treatment Control Point Date
00855 //3008 0054 DA ??? First Treatment Date
00856 //3008 0056 DA ??? Most Recent Treatment Date
00857 //3008 0162 DA ??? Safe Position Exit Date
00858 //3008 0166 DA ??? Safe Position Return Date
00859 //3008 0250 DA ??? Treatment Date
00860 //300a 0006 DA RT RT Plan Date
00861 //300a 022c DA RT Air Kerma Rate Reference Date
00862 //300e 0004 DA RT Review Date
00863 return true;
00864 }
|
|
||||||||||||
|
Checks if a given Dicom Element exists within the H table.
Definition at line 509 of file gdcmParser.cxx. References gdcmParser::tagHT, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmParser::ReplaceOrCreateByNumber().
00509 {
00510 std::string key = gdcmDictEntry::TranslateToKey(group, element );
00511 return (tagHT.count(key));
00512 }
|
|
|
closes the file
Definition at line 365 of file gdcmParser.cxx. References gdcmParser::fp. Referenced by gdcmParser::gdcmParser(), gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00365 {
00366 int closed = fclose(fp);
00367 fp = (FILE *)0;
00368 if (! closed)
00369 return false;
00370 return true;
00371 }
|
|
|
Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files, 16, ...).
Definition at line 336 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by gdcmFile::gdcm_read_RLE_file(), and gdcmFile::ReadPixelData().
00336 {
00337 std::string StrSize = GetEntryByNumber(0x0028,0x0100);
00338 if (StrSize == GDCM_UNFOUND)
00339 return 0; // It's supposed to be mandatory
00340 // the caller will have to check
00341 return atoi(StrSize.c_str());
00342 }
|
|
|
Retrieve the number of Bits Stored (actually used) (as opposite to number of Bits Allocated).
Definition at line 321 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by gdcmFile::ReadPixelData().
00321 {
00322 std::string StrSize = GetEntryByNumber(0x0028,0x0101);
00323 if (StrSize == GDCM_UNFOUND)
00324 return 0; // It's supposed to be mandatory
00325 // the caller will have to check
00326 return atoi(StrSize.c_str());
00327 }
|
|
|
gets the info from 0008,0016 : SOP Class UID
Definition at line 325 of file gdcmHeaderHelper.cxx. References gdcmHeader::GetEntryByNumber().
00325 {
00326 return GetEntryByNumber(0x0008,0x0016); //0008 0016 UI ID SOP Class UID
00327 }
|
|
|
returns a ref to the Dicom Header H table (multimap) return the Dicom Header H table
Definition at line 80 of file gdcmParser.h. References TagHeaderEntryHT. Referenced by gdcmHeader::gdcmHeader(), and gdcmFile::WriteBase().
00080 { return tagHT; };
|
|
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value of a given tag.
Reimplemented from gdcmParser. Definition at line 90 of file gdcmHeader.h. References gdcmParser::GetEntryByName().
00091 { return(gdcmParser::GetEntryByName(tagName)); }
|
|
||||||||||||
|
||||||||||||
|
Gets (from Header) the offset of a 'non string' element value (LoadElementValues has already be executed).
Definition at line 695 of file gdcmParser.cxx. References dbg, gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetOffset(), and gdcmDebug::Verbose().
00696 {
00697 gdcmHeaderEntry* Entry = GetHeaderEntryByNumber(Group, Elem);
00698 if (!Entry)
00699 {
00700 dbg.Verbose(1, "gdcmParser::GetHeaderEntryByNumber",
00701 "failed to Locate gdcmHeaderEntry");
00702 return (size_t)0;
00703 }
00704 return Entry->GetOffset();
00705 }
|
|
||||||||||||
|
Gets (from Header) a 'non string' element value (LoadElementValues has already be executed).
Definition at line 715 of file gdcmParser.cxx. References dbg, gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetVoidArea(), and gdcmDebug::Verbose(). Referenced by gdcmHeader::GetLUTRGBA().
00716 {
00717 gdcmHeaderEntry* Entry = GetHeaderEntryByNumber(Group, Elem);
00718 if (!Entry)
00719 {
00720 dbg.Verbose(1, "gdcmParser::GetHeaderEntryByNumber",
00721 "failed to Locate gdcmHeaderEntry");
00722 return (NULL);
00723 }
00724 return Entry->GetVoidArea();
00725 }
|
|
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value representation of a given tag. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type.
Reimplemented from gdcmParser. Definition at line 92 of file gdcmHeader.h. References gdcmParser::GetEntryVRByName().
00093 { return(gdcmParser::GetEntryVRByName(tagName)); }
|
|
||||||||||||
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the element value representation of a given tag.. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type.
Reimplemented from gdcmParser. Definition at line 87 of file gdcmHeader.h. References gdcmParser::GetEntryVRByNumber().
00088 { return(gdcmParser::GetEntryVRByNumber(group,element)); }
|
|
|
Definition at line 58 of file gdcmParser.h. Referenced by gdcmDicomDir::GetPath(), and gdcmDicomDir::SetElement().
00058 {return filename;}
|
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 315 of file gdcmParser.cxx. References gdcmParser::filetype, and FileType. Referenced by gdcmFile::WriteBase().
00315 {
00316 return(filetype);
00317 }
|
|
|
Definition at line 102 of file gdcmParser.h. Referenced by gdcmFile::WriteBase().
00102 {return GrPixel;}
|
|
|
Searches within the Header Entries for a Dicom Element of a given tag.
Definition at line 829 of file gdcmParser.cxx. References gdcmDict::GetDictEntryByName(), gdcmDictEntry::GetElement(), gdcmDictEntry::GetGroup(), gdcmParser::GetHeaderEntryByNumber(), and gdcmParser::RefPubDict.
00829 {
00830 gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
00831 if( dictEntry == NULL)
00832 return NULL;
00833
00834 return(GetHeaderEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement()));
00835 }
|
|
||||||||||||
|
retrieves a Dicom Element (the first one) using (group, element)
Definition at line 848 of file gdcmParser.cxx. References gdcmParser::tagHT, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmHeader::anonymizeHeader(), gdcmParser::GetEntryOffsetByNumber(), gdcmParser::GetEntryVoidAreaByNumber(), gdcmParser::GetEntryVRByName(), gdcmParser::GetEntryVRByNumber(), gdcmParser::GetHeaderEntryByName(), gdcmHeader::HasLUT(), gdcmParser::IsDeflatedExplicitVRLittleEndianTransferSyntax(), gdcmHeader::IsDicomV3(), gdcmParser::IsExplicitVRBigEndianTransferSyntax(), gdcmParser::IsExplicitVRLittleEndianTransferSyntax(), gdcmParser::IsImplicitVRLittleEndianTransferSyntax(), gdcmHeader::IsJPEG2000(), gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(), gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(), gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(), gdcmHeader::IsJPEGLossless(), gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(), gdcmHeader::IsReadable(), gdcmHeader::IsRLELossLessTransferSyntax(), gdcmParser::LoadEntryVoidArea(), gdcmHeader::SetImageDataSize(), and gdcmParser::UpdateGroupLength().
00849 {
00850 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
00851 if ( ! tagHT.count(key))
00852 return NULL;
00853 return tagHT.find(key)->second;
00854 }
|
|
||||||||||||
|
retrieves the Dicom Elements (all of them) using (group, element)
Definition at line 864 of file gdcmParser.cxx. References IterHT, gdcmParser::tagHT, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmHeader::GetPixelAreaLength(), and gdcmHeader::GetPixelOffset().
00864 {
00865 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
00866 return (tagHT.equal_range(key));
00867 }
|
|
|
gets the info from 0020,0013 : Image Number \ else 0.
Definition at line 463 of file gdcmHeaderHelper.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber().
00463 {
00464 //The function i atoi() takes the address of an area of memory as parameter and converts
00465 //the string stored at that location to an integer using the external decimal to internal
00466 //binary conversion rules. This may be preferable to sscanf() since atoi() is a much smaller,
00467 // simpler and faster function. sscanf() can do all possible conversions whereas atoi() can
00468 //only do single decimal integer conversions.
00469 std::string StrImNumber = GetEntryByNumber(0x0020,0x0013); //0020 0013 IS REL Image Number
00470 if (StrImNumber != GDCM_UNFOUND) {
00471 return atoi( StrImNumber.c_str() );
00472 }
00473 return 0; //Hopeless
00474 }
|
|
|
gets the info from 0020,0037 : Image Orientation Patient
Definition at line 541 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00541 {
00542
00543 //iop is supposed to be float[6]
00544 iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0;
00545
00546 std::string StrImOriPat = GetEntryByNumber(0x0020,0x0037); // 0020 0037 DS REL Image Orientation (Patient)
00547 if (StrImOriPat != GDCM_UNFOUND) {
00548 if( sscanf( StrImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
00549 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6) {
00550 dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0037)");
00551 return ; // bug in the element 0x0020,0x0037
00552 }
00553 else
00554 return ;
00555 }
00556
00557 //For ACR-NEMA
00558 StrImOriPat = GetEntryByNumber(0x0020,0x0035); //0020 0035 DS REL Image Orientation (RET)
00559 if (StrImOriPat != GDCM_UNFOUND) {
00560 if( sscanf( StrImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
00561 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6) {
00562 dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0035)");
00563 return ; // bug in the element 0x0020,0x0035
00564 }
00565 else
00566 return ;
00567 }
00568 }
|
|
|
gets the info from 0008,0018 : SOP Instance UID
Definition at line 335 of file gdcmHeaderHelper.cxx. References gdcmHeader::GetEntryByNumber().
00335 {
00336 return GetEntryByNumber(0x0008,0x0018); //0008 0018 UI ID SOP Instance UID
00337 }
|
|
|
returns a ref to the Dicom Header chained list return the Dicom Header chained list
Definition at line 87 of file gdcmParser.h. References ListTag. Referenced by gdcmDicomDir::CreateDicomDir(), gdcmDicomDir::gdcmDicomDir(), and gdcmParser::LoadHeaderEntries().
00087 { return listEntries; };
|
|
|
gets the info from 0028,1101 : Lookup Table Desc-Red else 0
Definition at line 538 of file gdcmHeader.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and Tokenize().
00538 {
00539 std::vector<std::string> tokens;
00540 //int LutLength;
00541 //int LutDepth;
00542 int LutNbits;
00543 //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red = Lookup Table Desc-Blue
00544 // Consistency already checked in GetLUTLength
00545 std::string LutDescription = GetEntryByNumber(0x0028,0x1101);
00546 if (LutDescription == GDCM_UNFOUND)
00547 return 0;
00548 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00549 Tokenize (LutDescription, tokens, "\\");
00550 //LutLength=atoi(tokens[0].c_str());
00551 //LutDepth=atoi(tokens[1].c_str());
00552 LutNbits=atoi(tokens[2].c_str());
00553 tokens.clear();
00554 return LutNbits;
00555 }
|
|
|
builts Red/Green/Blue/Alpha LUT from Header when (0028,0004),Photometric Interpretation = [PALETTE COLOR ] and (0028,1101),(0028,1102),(0028,1102) -xxx Palette Color Lookup Table Descriptor - are found and (0028,1201),(0028,1202),(0028,1202) -xxx Palette Color Lookup Table Data - are found
Definition at line 573 of file gdcmHeader.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), gdcmParser::GetEntryVoidAreaByNumber(), and Tokenize(). Referenced by gdcmFile::GetImageDataIntoVector().
00573 {
00574 // Not so easy : see
00575 // http://www.barre.nom.fr/medical/dicom2/limitations.html#Color%20Lookup%20Tables
00576
00577 // if Photometric Interpretation # PALETTE COLOR, no LUT to be done
00578 if (GetEntryByNumber(0x0028,0x0004) != "PALETTE COLOR ") {
00579 return NULL;
00580 }
00581 int lengthR, debR, nbitsR;
00582 int lengthG, debG, nbitsG;
00583 int lengthB, debB, nbitsB;
00584
00585 // Get info from Lut Descriptors
00586 // (the 3 LUT descriptors may be different)
00587 std::string LutDescriptionR = GetEntryByNumber(0x0028,0x1101);
00588 if (LutDescriptionR == GDCM_UNFOUND)
00589 return NULL;
00590 std::string LutDescriptionG = GetEntryByNumber(0x0028,0x1102);
00591 if (LutDescriptionG == GDCM_UNFOUND)
00592 return NULL;
00593 std::string LutDescriptionB = GetEntryByNumber(0x0028,0x1103);
00594 if (LutDescriptionB == GDCM_UNFOUND)
00595 return NULL;
00596
00597 std::vector<std::string> tokens;
00598
00599 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00600 Tokenize (LutDescriptionR, tokens, "\\");
00601 lengthR=atoi(tokens[0].c_str()); // Red LUT length in Bytes
00602 debR =atoi(tokens[1].c_str()); // subscript of the first Lut Value
00603 nbitsR =atoi(tokens[2].c_str()); // Lut item size (in Bits)
00604 tokens.clear();
00605
00606 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00607 Tokenize (LutDescriptionG, tokens, "\\");
00608 lengthG=atoi(tokens[0].c_str()); // Green LUT length in Bytes
00609 debG =atoi(tokens[1].c_str()); // subscript of the first Lut Value
00610 nbitsG =atoi(tokens[2].c_str()); // Lut item size (in Bits)
00611 tokens.clear();
00612
00613 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00614 Tokenize (LutDescriptionB, tokens, "\\");
00615 lengthB=atoi(tokens[0].c_str()); // Blue LUT length in Bytes
00616 debB =atoi(tokens[1].c_str()); // subscript of the first Lut Value
00617 nbitsB =atoi(tokens[2].c_str()); // Lut item size (in Bits)
00618 tokens.clear();
00619
00620 // Load LUTs into memory, (as they were stored on disk)
00621 unsigned char *lutR = (unsigned char *)
00622 GetEntryVoidAreaByNumber(0x0028,0x1201);
00623 unsigned char *lutG = (unsigned char *)
00624 GetEntryVoidAreaByNumber(0x0028,0x1202);
00625 unsigned char *lutB = (unsigned char *)
00626 GetEntryVoidAreaByNumber(0x0028,0x1203);
00627
00628 if (!lutR || !lutG || !lutB ) {
00629 return NULL;
00630 }
00631 // forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT
00632
00633 unsigned char *LUTRGBA = (unsigned char *)calloc(1024,1); // 256 * 4 (R, G, B, Alpha)
00634 if (!LUTRGBA) {
00635 return NULL;
00636 }
00637 memset(LUTRGBA, 0, 1024);
00638 // Bits Allocated
00639 int nb;
00640 std::string str_nb = GetEntryByNumber(0x0028,0x0100);
00641 if (str_nb == GDCM_UNFOUND ) {
00642 nb = 16;
00643 } else {
00644 nb = atoi(str_nb.c_str() );
00645 }
00646 int mult;
00647
00648 if (nbitsR==16 && nb==8) // when LUT item size is different than pixel size
00649 mult=2; // high byte must be = low byte
00650 else // See PS 3.3-2003 C.11.1.1.2 p 619
00651 mult=1;
00652
00653 // if we get a black image, let's just remove the '+1'
00654 // from 'i*mult+1' and check again
00655 // if it works, we shall have to check the 3 Palettes
00656 // to see which byte is ==0 (first one, or second one)
00657 // and fix the code
00658 // We give up the checking to avoid some (useless ?)overhead
00659 // (optimistic asumption)
00660 unsigned char *a;
00661 int i;
00662
00663 a = LUTRGBA+0;
00664 for(i=0;i<lengthR;i++) {
00665 *a = lutR[i*mult+1];
00666 a+=4;
00667 }
00668 a = LUTRGBA+1;
00669 for(i=0;i<lengthG;i++) {
00670 *a = lutG[i*mult+1];
00671 a+=4;
00672 }
00673 a = LUTRGBA+2;
00674 for(i=0;i<lengthB;i++) {
00675 *a = lutB[i*mult+1];
00676 a+=4;
00677 }
00678 a = LUTRGBA+3;
00679 for(i=0;i<256;i++) {
00680 *a = 1; // Alpha component
00681 a+=4;
00682 }
00683
00684 //How to free the now useless LUTs?
00685 //free(LutR); free(LutB); free(LutG); // Seg Fault when used
00686 return(LUTRGBA);
00687 }
|
|
|
gets the info from 0008,0060 : Modality
Definition at line 481 of file gdcmHeaderHelper.cxx. References AS, AU, BI, CF, CP, CR, CS, CT, DD, DF, DG, DM, DS, DX, ECG, EPS, FA, FS, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), HC, HD, LP, LS, MA, ModalityType, MR, NM, OT, PT, RF, RG, RTDOSE, RTIMAGE, RTPLAN, RTSTRUCT, SM, ST, TG, Unknow, US, VF, XA, and XC.
00481 {
00482 std::string StrModality = GetEntryByNumber(0x0008,0x0060); //0008 0060 CS ID Modality
00483 if (StrModality != GDCM_UNFOUND) {
00484 if ( StrModality.find("AU") < StrModality.length()) return AU;
00485 else if ( StrModality.find("AS") < StrModality.length()) return AS;
00486 else if ( StrModality.find("BI") < StrModality.length()) return BI;
00487 else if ( StrModality.find("CF") < StrModality.length()) return CF;
00488 else if ( StrModality.find("CP") < StrModality.length()) return CP;
00489 else if ( StrModality.find("CR") < StrModality.length()) return CR;
00490 else if ( StrModality.find("CT") < StrModality.length()) return CT;
00491 else if ( StrModality.find("CS") < StrModality.length()) return CS;
00492 else if ( StrModality.find("DD") < StrModality.length()) return DD;
00493 else if ( StrModality.find("DF") < StrModality.length()) return DF;
00494 else if ( StrModality.find("DG") < StrModality.length()) return DG;
00495 else if ( StrModality.find("DM") < StrModality.length()) return DM;
00496 else if ( StrModality.find("DS") < StrModality.length()) return DS;
00497 else if ( StrModality.find("DX") < StrModality.length()) return DX;
00498 else if ( StrModality.find("ECG") < StrModality.length()) return ECG;
00499 else if ( StrModality.find("EPS") < StrModality.length()) return EPS;
00500 else if ( StrModality.find("FA") < StrModality.length()) return FA;
00501 else if ( StrModality.find("FS") < StrModality.length()) return FS;
00502 else if ( StrModality.find("HC") < StrModality.length()) return HC;
00503 else if ( StrModality.find("HD") < StrModality.length()) return HD;
00504 else if ( StrModality.find("LP") < StrModality.length()) return LP;
00505 else if ( StrModality.find("LS") < StrModality.length()) return LS;
00506 else if ( StrModality.find("MA") < StrModality.length()) return MA;
00507 else if ( StrModality.find("MR") < StrModality.length()) return MR;
00508 else if ( StrModality.find("NM") < StrModality.length()) return NM;
00509 else if ( StrModality.find("OT") < StrModality.length()) return OT;
00510 else if ( StrModality.find("PT") < StrModality.length()) return PT;
00511 else if ( StrModality.find("RF") < StrModality.length()) return RF;
00512 else if ( StrModality.find("RG") < StrModality.length()) return RG;
00513 else if ( StrModality.find("RTDOSE") < StrModality.length()) return RTDOSE;
00514 else if ( StrModality.find("RTIMAGE") < StrModality.length()) return RTIMAGE;
00515 else if ( StrModality.find("RTPLAN") < StrModality.length()) return RTPLAN;
00516 else if ( StrModality.find("RTSTRUCT")< StrModality.length()) return RTSTRUCT;
00517 else if ( StrModality.find("SM") < StrModality.length()) return SM;
00518 else if ( StrModality.find("ST") < StrModality.length()) return ST;
00519 else if ( StrModality.find("TG") < StrModality.length()) return TG;
00520 else if ( StrModality.find("US") < StrModality.length()) return US;
00521 else if ( StrModality.find("VF") < StrModality.length()) return VF;
00522 else if ( StrModality.find("XA") < StrModality.length()) return XA;
00523 else if ( StrModality.find("XC") < StrModality.length()) return XC;
00524
00525 else
00526 {
00527 //throw error return value ???
00528 // specified <> unknow in our database
00529 return Unknow;
00530 }
00531 }
00532 return Unknow;
00533 }
|
|
|
This function is intended to user who doesn't want to have to manage a LUT and expects to get an RBG Pixel image (or a monochrome one ...).
Definition at line 248 of file gdcmHeaderHelper.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), gdcmHeader::GetSamplesPerPixel(), and gdcmHeader::HasLUT().
00248 {
00249 if (GetSamplesPerPixel() ==3)
00250 return 3;
00251
00252 // 0028 0100 US IMG Bits Allocated
00253 // (in order no to be messed up by old RGB images)
00254 if (gdcmHeader::GetEntryByNumber(0x0028,0x0100) == "24")
00255 return 3;
00256
00257 std::string PhotometricInterpretation =
00258 gdcmHeader::GetEntryByNumber(0x0028,0x0004);
00259
00260 if ( ( PhotometricInterpretation == "PALETTE COLOR ") ) {
00261 if (HasLUT()) // PALETTE COLOR is NOT enough
00262 return 3;
00263 else
00264 return 1;
00265 }
00266
00267 //beware of trailing space at end of string
00268 if (PhotometricInterpretation.find(GDCM_UNFOUND) <
00269 PhotometricInterpretation.length() ||
00270 PhotometricInterpretation.find("MONOCHROME1") <
00271 PhotometricInterpretation.length() ||
00272 PhotometricInterpretation.find("MONOCHROME2") <
00273 PhotometricInterpretation.length() )
00274 return 1;
00275 else
00276 // we assume that *all* kinds of YBR are dealt with
00277 return 3;
00278 }
|
|
|
This function is intended to user that DOESN'T want get RGB pixels image when it's stored as a PALETTE COLOR image \ - the (vtk) user is supposed to know how deal with LUTs -.
Definition at line 288 of file gdcmHeaderHelper.cxx. References gdcmHeader::GetEntryByNumber(), and gdcmHeader::GetSamplesPerPixel().
00288 {
00289
00290 // 0028 0100 US IMG Bits Allocated
00291 // (in order no to be messed up by old RGB images)
00292 if (gdcmHeader::GetEntryByNumber(0x0028,0x0100) == "24")
00293 return 3;
00294
00295 // we assume that *all* kinds of YBR are dealt with
00296 return GetSamplesPerPixel();
00297 }
|
|
|
Definition at line 103 of file gdcmParser.h. Referenced by gdcmFile::WriteBase().
00103 {return NumPixel;}
|
|
|
Recover the pixel area length (in Bytes).
Definition at line 476 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntrySameNumber(), gdcmHeaderEntry::GetLength(), IterHT, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmFile::ReadPixelData().
00476 {
00477
00478 IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);
00479 TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
00480 gdcmHeaderEntry* PixelElement;
00481
00482 if (countGrPixel==1)
00483 PixelElement = (it.first)->second;
00484 else
00485 PixelElement = (++it.first)->second;
00486
00487 if (PixelElement) {
00488 return PixelElement->GetLength();
00489 } else {
00490 /* std::cout << "Big trouble : Pixel Element ("
00491 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
00492 << std::endl;*/
00493 return 0;
00494 }
00495 }
|
|
|
Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !).
Definition at line 440 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntrySameNumber(), gdcmHeaderEntry::GetOffset(), IterHT, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00440 {
00441 //
00442 // If the element (0x0088,0x0200) 'icone image sequence' is found
00443 // (grPixel,numPixel) is stored twice : the first one for the icon
00444 // the second one for the image ...
00445 // pb : sometimes , (0x0088,0x0200) exists, but doesn't contain *anything*
00446 // see gdcmData/MxTwinLossLess.dcm ...
00447
00448 //std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
00449
00450 IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);
00451 TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
00452 gdcmHeaderEntry* PixelElement;
00453 if (countGrPixel == 1)
00454 PixelElement = (it.first)->second;
00455 else {
00456 PixelElement = (++it.first)->second; // hope there are no more than 2 !
00457 }
00458 if (PixelElement) {
00459 return PixelElement->GetOffset();
00460 } else {
00461 /* std::cout << "Big trouble : Pixel Element ("
00462 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
00463 << std::endl; */
00464 return 0;
00465 }
00466 }
|
|
|
Returns the size (in bytes) of a single pixel of data.
Reimplemented from gdcmHeader. Definition at line 55 of file gdcmHeaderHelper.cxx. References dbg, gdcmHeader::GetEntryByNumber(), GetPixelType(), and gdcmDebug::Verbose().
00055 {
00056
00057 // 0028 0100 US IMG Bits Allocated
00058 // (in order no to be messed up by old RGB images)
00059 if (gdcmHeader::GetEntryByNumber(0x0028,0x0100) == "24")
00060 return 3;
00061
00062 std::string PixelType = GetPixelType();
00063 if (PixelType == "8U" || PixelType == "8S")
00064 return 1;
00065 if (PixelType == "16U" || PixelType == "16S")
00066 return 2;
00067 if (PixelType == "32U" || PixelType == "32S")
00068 return 4;
00069 if (PixelType == "FD") // to help unfortunate users to manage DOUBLE
00070 return 8;
00071 dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type");
00072 return 0;
00073 }
|
|
|
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 Double,.
Reimplemented from gdcmHeader. Definition at line 93 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose(). Referenced by GetPixelSize().
00093 {
00094 std::string BitsAlloc;
00095 BitsAlloc = GetEntryByNumber(0x0028, 0x0100);
00096 if (BitsAlloc == GDCM_UNFOUND) { // Bits Allocated
00097 dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated");
00098 BitsAlloc = std::string("16");
00099 }
00100 if (BitsAlloc == "12") // It will be unpacked
00101 BitsAlloc = std::string("16");
00102 else if (BitsAlloc == "24") // (in order no to be messed up
00103 BitsAlloc = std::string("8"); // by old RGB images)
00104
00105 std::string Signed;
00106 Signed = GetEntryByNumber(0x0028, 0x0103);
00107 if (Signed == GDCM_UNFOUND) { // "Pixel Representation"
00108 dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Pixel Representation");
00109 BitsAlloc = std::string("0");
00110 }
00111 if (BitsAlloc == "64") // to help users that want to deal with DOUBLE
00112 return("FD");
00113
00114 if (Signed == "0")
00115 Signed = std::string("U");
00116 else
00117 Signed = std::string("S");
00118
00119 return( BitsAlloc + Signed);
00120 }
|
|
|
Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane).
Definition at line 365 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by gdcmFile::GetImageDataIntoVectorRaw().
00365 {
00366 std::string StrSize = GetEntryByNumber(0x0028,0x0006);
00367 if (StrSize == GDCM_UNFOUND)
00368 return 0;
00369 return atoi(StrSize.c_str());
00370 }
|
|
|
Get the public dictionary used.
Definition at line 185 of file gdcmParser.cxx. References gdcmParser::RefPubDict. Referenced by gdcmDicomDir::SetElement().
00185 {
00186 return(RefPubDict);
00187 }
|
|
|
gets the info from 0028,1052 : Rescale Intercept
Definition at line 211 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00211 {
00212 float resInter = 0.;
00213 std::string StrRescInter = GetEntryByNumber(0x0028,0x1052); //0028 1052 DS IMG Rescale Intercept
00214 if (StrRescInter != GDCM_UNFOUND) {
00215 if( sscanf( StrRescInter.c_str(), "%f", &resInter) != 1) {
00216 dbg.Verbose(0, "gdcmHeader::GetRescaleIntercept: Rescale Slope is empty");
00217 // bug in the element 0x0028,0x1052
00218 }
00219 }
00220 return resInter;
00221 }
|
|
|
gets the info from 0028,1053 : Rescale Slope
Definition at line 228 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00228 {
00229 float resSlope = 1.;
00230 std::string StrRescSlope = GetEntryByNumber(0x0028,0x1053); //0028 1053 DS IMG Rescale Slope
00231 if (StrRescSlope != GDCM_UNFOUND) {
00232 if( sscanf( StrRescSlope.c_str(), "%f", &resSlope) != 1) {
00233 dbg.Verbose(0, "gdcmHeader::GetRescaleSlope: Rescale Slope is empty");
00234 // bug in the element 0x0028,0x1053
00235 }
00236 }
00237 return resSlope;
00238 }
|
|
|
Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB -1 or 3 Planes-).
Definition at line 351 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by GetNumberOfScalarComponents(), GetNumberOfScalarComponentsRaw(), gdcmFile::ParsePixelData(), gdcmFile::ReadPixelData(), and gdcmFile::SetPixelDataSizeFromHeader().
00351 {
00352 std::string StrSize = GetEntryByNumber(0x0028,0x0002);
00353 if (StrSize == GDCM_UNFOUND)
00354 return 1; // Well, it's supposed to be mandatory ...
00355 // but sometimes it's missing : *we* assume Gray pixels
00356 return atoi(StrSize.c_str());
00357 }
|
|
|
gets the info from 0020,000e : Series Instance UID
Definition at line 315 of file gdcmHeaderHelper.cxx. References gdcmHeader::GetEntryByNumber().
00315 {
00316 return GetEntryByNumber(0x0020,0x000e); //0020 000e UI REL Series Instance UID
00317 }
|
|
|
Get the shadow dictionary used.
Definition at line 193 of file gdcmParser.cxx. References gdcmParser::RefShaDict.
00193 {
00194 return(RefShaDict);
00195 }
|
|
|
gets the info from 0020,000d : Study Instance UID
Definition at line 305 of file gdcmHeaderHelper.cxx. References gdcmHeader::GetEntryByNumber().
00305 {
00306 return GetEntryByNumber(0x0020,0x000d); //0020 000d UI REL Study Instance UID
00307 }
|
|
|
Definition at line 101 of file gdcmParser.h. Referenced by gdcmFile::gdcm_read_RLE_file(), gdcmFile::GetImageDataIntoVectorRaw(), gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00101 { return sw; }
|
|
|
gets the info from 0002,0010 : Transfert Syntax and gdcmTS else 1.
Definition at line 695 of file gdcmHeader.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), gdcmGlobal::GetTS(), gdcmTS::GetValue(), and gdcmDebug::Verbose().
00695 {
00696 // use the gdcmTS (TS : Transfert Syntax)
00697 std::string TransfertSyntax = GetEntryByNumber(0x0002,0x0010);
00698 if (TransfertSyntax == GDCM_UNFOUND) {
00699 dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName: unfound Transfert Syntax (0002,0010)");
00700 return "Uncompressed ACR-NEMA";
00701 }
00702 // we do it only when we need it
00703 gdcmTS * ts = gdcmGlobal::GetTS();
00704 std::string tsName=ts->GetValue(TransfertSyntax);
00705 //delete ts; // Seg Fault when deleted ?!
00706 return tsName;
00707 }
|
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0. change GetXImagePosition -> GetXOrigin in order not to confuse reader
Definition at line 362 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00362 {
00363 float xImPos, yImPos, zImPos;
00364 std::string StrImPos = GetEntryByNumber(0x0020,0x0032);
00365
00366 if (StrImPos == GDCM_UNFOUND) {
00367 dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position Patient (0020,0032)");
00368 StrImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images
00369 if (StrImPos == GDCM_UNFOUND) {
00370 dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image Position (RET) (0020,0030)");
00371 // How to tell the caller nothing was found ?
00372 return 0.;
00373 }
00374 }
00375 if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3)
00376 return 0.;
00377 return xImPos;
00378 }
|
|
|
Retrieve the number of columns of image.
Definition at line 264 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by gdcmFile::gdcm_read_RLE_file(), gdcmFile::GetImageDataIntoVectorRaw(), gdcmFile::ParsePixelData(), gdcmFile::ReadPixelData(), and gdcmFile::SetPixelDataSizeFromHeader().
00264 {
00265 std::string StrSize;
00266 StrSize = GetEntryByNumber(0x0028,0x0011);
00267 if (StrSize == GDCM_UNFOUND)
00268 return 0;
00269 return atoi(StrSize.c_str());
00270 }
|
|
|
gets the info from 0028,0030 : Pixel Spacing else 1.
Definition at line 128 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00128 {
00129 float xspacing, yspacing;
00130 std::string StrSpacing = GetEntryByNumber(0x0028,0x0030);
00131
00132 if (StrSpacing == GDCM_UNFOUND) {
00133 dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)");
00134 return 1.;
00135 }
00136 if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
00137 return 0.;
00138 if (xspacing == 0.) {
00139 dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
00140 // seems to be a bug in the header ...
00141 sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
00142 }
00143 return xspacing;
00144 }
|
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0.
Definition at line 387 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00387 {
00388 float xImPos, yImPos, zImPos;
00389 std::string StrImPos = GetEntryByNumber(0x0020,0x0032);
00390
00391 if (StrImPos == GDCM_UNFOUND) {
00392 dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position Patient (0020,0032)");
00393 StrImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images
00394 if (StrImPos == GDCM_UNFOUND) {
00395 dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image Position (RET) (0020,0030)");
00396 // How to tell the caller nothing was found ?
00397 return 0.;
00398 }
00399 }
00400 if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3)
00401 return 0.;
00402 return yImPos;
00403 }
|
|
|
Retrieve the number of lines of image.
Definition at line 279 of file gdcmHeader.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmHeader::IsDicomV3(). Referenced by gdcmFile::gdcm_read_RLE_file(), gdcmFile::GetImageDataIntoVectorRaw(), gdcmFile::ParsePixelData(), gdcmFile::ReadPixelData(), and gdcmFile::SetPixelDataSizeFromHeader().
00279 {
00280 std::string StrSize = GetEntryByNumber(0x0028,0x0010);
00281 if (StrSize != GDCM_UNFOUND)
00282 return atoi(StrSize.c_str());
00283 if ( IsDicomV3() )
00284 return 0;
00285 else
00286 // The Rows (0028,0010) entry was optional for ACR/NEMA. It might
00287 // hence be a signal (1d image). So we default to 1:
00288 return 1;
00289 }
|
|
|
gets the info from 0028,0030 : Pixel Spacing else 1.
Definition at line 152 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00152 {
00153 float xspacing, yspacing;
00154 std::string StrSpacing = GetEntryByNumber(0x0028,0x0030);
00155
00156 if (StrSpacing == GDCM_UNFOUND) {
00157 dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)");
00158 return 1.;
00159 }
00160 if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
00161 return 0.;
00162 if (xspacing == 0.) {
00163 dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
00164 // seems to be a bug in the header ...
00165 sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
00166 }
00167 return yspacing;
00168 }
|
|
|
gets the info from 0020,0032 : Image Position Patient \ else from 0020,0030 : Image Position (RET) \ else from 0020,1041 : Slice Location \ else from 0020,0050 : Location \ else 0.
Definition at line 414 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00414 {
00415 float xImPos, yImPos, zImPos;
00416 std::string StrImPos = GetEntryByNumber(0x0020,0x0032);
00417 if (StrImPos != GDCM_UNFOUND) {
00418 if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) {
00419 dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position Patient (0020,0032)");
00420 return 0.; // bug in the element 0x0020,0x0032
00421 } else {
00422 return zImPos;
00423 }
00424 }
00425 StrImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images
00426 if (StrImPos != GDCM_UNFOUND) {
00427 if( sscanf( StrImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) {
00428 dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position (RET) (0020,0030)");
00429 return 0.; // bug in the element 0x0020,0x0032
00430 } else {
00431 return zImPos;
00432 }
00433 }
00434 std::string StrSliceLocation = GetEntryByNumber(0x0020,0x1041);// for *very* old ACR-NEMA images
00435 if (StrSliceLocation != GDCM_UNFOUND) {
00436 if( sscanf( StrSliceLocation.c_str(), "%f", &zImPos) !=1) {
00437 dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Slice Location (0020,1041)");
00438 return 0.; // bug in the element 0x0020,0x1041
00439 } else {
00440 return zImPos;
00441 }
00442 }
00443 dbg.Verbose(0, "gdcmHeader::GetZImagePosition: unfound Slice Location (0020,1041)");
00444 std::string StrLocation = GetEntryByNumber(0x0020,0x0050);
00445 if (StrLocation != GDCM_UNFOUND) {
00446 if( sscanf( StrLocation.c_str(), "%f", &zImPos) !=1) {
00447 dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Location (0020,0050)");
00448 return 0.; // bug in the element 0x0020,0x0050
00449 } else {
00450 return zImPos;
00451 }
00452 }
00453 dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Location (0020,0050)");
00454 return 0.; // Hopeless
00455 }
|
|
|
Retrieve the number of planes of volume or the number of frames of a multiframe.
Definition at line 300 of file gdcmHeader.cxx. References GDCM_UNFOUND, and gdcmHeader::GetEntryByNumber(). Referenced by gdcmFile::gdcm_read_RLE_file(), gdcmFile::GetImageDataIntoVectorRaw(), and gdcmFile::SetPixelDataSizeFromHeader().
00300 {
00301 // Both DicomV3 and ACR/Nema consider the "Number of Frames"
00302 // as the third dimension.
00303 std::string StrSize = GetEntryByNumber(0x0028,0x0008);
00304 if (StrSize != GDCM_UNFOUND)
00305 return atoi(StrSize.c_str());
00306
00307 // We then consider the "Planes" entry as the third dimension
00308 StrSize = GetEntryByNumber(0x0028,0x0012);
00309 if (StrSize != GDCM_UNFOUND)
00310 return atoi(StrSize.c_str());
00311 return 1;
00312 }
|
|
|
gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1.
Definition at line 177 of file gdcmHeaderHelper.cxx. References dbg, GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), and gdcmDebug::Verbose().
00177 {
00178 // Spacing Between Slices : distance entre le milieu de chaque coupe
00179 // Les coupes peuvent etre :
00180 // jointives (Spacing between Slices = Slice Thickness)
00181 // chevauchantes (Spacing between Slices < Slice Thickness)
00182 // disjointes (Spacing between Slices > Slice Thickness)
00183 // Slice Thickness : epaisseur de tissus sur laquelle est acquis le signal
00184 // ca interesse le physicien de l'IRM, pas le visualisateur de volumes ...
00185 // Si le Spacing Between Slices est absent,
00186 // on suppose que les coupes sont jointives
00187
00188 std::string StrSpacingBSlices = GetEntryByNumber(0x0018,0x0088);
00189
00190 if (StrSpacingBSlices == GDCM_UNFOUND) {
00191 dbg.Verbose(0, "gdcmHeader::GetZSpacing: unfound StrSpacingBSlices");
00192 std::string StrSliceThickness = GetEntryByNumber(0x0018,0x0050);
00193 if (StrSliceThickness == GDCM_UNFOUND)
00194 return 1.;
00195 else
00196 // if no 'Spacing Between Slices' is found,
00197 // we assume slices join together
00198 // (no overlapping, no interslice gap)
00199 // if they don't, we're fucked up
00200 return atof(StrSliceThickness.c_str());
00201 } else {
00202 return atof(StrSpacingBSlices.c_str());
00203 }
00204 }
|
|
|
tells us if LUT are used
Definition at line 506 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(). Referenced by gdcmFile::GetImageDataIntoVector(), gdcmFile::GetImageDataRaw(), GetNumberOfScalarComponents(), and gdcmFile::SetPixelDataSizeFromHeader().
00506 {
00507
00508 // Check the presence of the LUT Descriptors, and LUT Tables
00509 // LutDescriptorRed
00510 if ( !GetHeaderEntryByNumber(0x0028,0x1101) )
00511 return false;
00512 // LutDescriptorGreen
00513 if ( !GetHeaderEntryByNumber(0x0028,0x1102) )
00514 return false;
00515 // LutDescriptorBlue
00516 if ( !GetHeaderEntryByNumber(0x0028,0x1103) )
00517 return false;
00518 // Red Palette Color Lookup Table Data
00519 if ( !GetHeaderEntryByNumber(0x0028,0x1201) )
00520 return false;
00521 // Green Palette Color Lookup Table Data
00522 if ( !GetHeaderEntryByNumber(0x0028,0x1202) )
00523 return false;
00524 // Blue Palette Color Lookup Table Data
00525 if ( !GetHeaderEntryByNumber(0x0028,0x1203) )
00526 return false;
00527 return true;
00528 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a DeflatedExplicitVRLittleEndian one.
Definition at line 279 of file gdcmParser.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), gdcmParser::LoadHeaderEntrySafe(), and UI1_2_840_10008_1_2_1_99. Referenced by gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00279 {
00280 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00281 if ( !Element )
00282 return false;
00283 LoadHeaderEntrySafe(Element);
00284
00285 std::string Transfer = Element->GetValue();
00286 if ( Transfer == UI1_2_840_10008_1_2_1_99 )
00287 return true;
00288 return false;
00289 }
|
|
|
Predicate for dicom version 3 file.
Definition at line 250 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(). Referenced by gdcmHeader::GetYSize(), gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00250 {
00251 // Checking if Transfert Syntax exists is enough
00252 // Anyway, it's to late check if the 'Preamble' was found ...
00253 // And ... would it be a rich idea to check ?
00254 // (some 'no Preamble' DICOM images exist !)
00255 return (GetHeaderEntryByNumber(0x0002, 0x0010) != NULL);
00256 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a Explicit VR Big Endian one.
Definition at line 297 of file gdcmParser.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), gdcmParser::LoadHeaderEntrySafe(), and UI1_2_840_10008_1_2_2. Referenced by gdcmParser::FindHeaderEntryLength(), gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00297 {
00298 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00299 if ( !Element )
00300 return false;
00301 LoadHeaderEntrySafe(Element);
00302
00303 std::string Transfer = Element->GetValue();
00304 if ( Transfer == UI1_2_840_10008_1_2_2 ) //1.2.2 ??? A verifier !
00305 return true;
00306 return false;
00307 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a ExplicitVRLittleEndian one.
Definition at line 261 of file gdcmParser.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), gdcmParser::LoadHeaderEntrySafe(), and UI1_2_840_10008_1_2_1. Referenced by gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00261 {
00262 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00263 if ( !Element )
00264 return false;
00265 LoadHeaderEntrySafe(Element);
00266
00267 std::string Transfer = Element->GetValue();
00268 if ( Transfer == UI1_2_840_10008_1_2_1 )
00269 return true;
00270 return false;
00271 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a ImplicitVRLittleEndian one.
Definition at line 243 of file gdcmParser.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), gdcmParser::LoadHeaderEntrySafe(), and UI1_2_840_10008_1_2. Referenced by gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00243 {
00244 gdcmHeaderEntry *Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00245 if ( !Element )
00246 return false;
00247 LoadHeaderEntrySafe(Element);
00248
00249 std::string Transfer = Element->GetValue();
00250 if ( Transfer == UI1_2_840_10008_1_2 )
00251 return true;
00252 return false;
00253 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEG2000 one.
Definition at line 232 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe(). Referenced by gdcmFile::ReadPixelData().
00232 {
00233 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00234 if ( !Element )
00235 return false;
00236 LoadHeaderEntrySafe(Element);
00237
00238 std::string Transfer = Element->GetValue();
00239 if ( (Transfer == "1.2.840.10008.1.2.4.90")
00240 || (Transfer == "1.2.840.10008.1.2.4.91") )
00241 return true;
00242 return false;
00243 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGBaseLineProcess1 one.
Definition at line 120 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe().
00120 {
00121 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00122 if ( !Element )
00123 return false;
00124 LoadHeaderEntrySafe(Element);
00125
00126 std::string Transfer = Element->GetValue();
00127 if ( Transfer == "1.2.840.10008.1.2.4.50" )
00128 return true;
00129 return false;
00130 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGExtendedProcess2-4 one.
Definition at line 138 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe().
00138 {
00139 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00140 if ( !Element )
00141 return false;
00142 LoadHeaderEntrySafe(Element);
00143 return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" );
00144 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGExtendeProcess3-5 one.
Definition at line 152 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe().
00152 {
00153 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00154 if ( !Element )
00155 return false;
00156 LoadHeaderEntrySafe(Element);
00157
00158 std::string Transfer = Element->GetValue();
00159 if ( Transfer == "1.2.840.10008.1.2.4.52" )
00160 return true;
00161 return false;
00162 }
|
|
|
Determines if Transfer Syntax was already encountered and if it corresponds to a JPEG Lossless one.
Definition at line 210 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe(). Referenced by gdcmFile::ReadPixelData().
00210 {
00211 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00212 // faire qq chose d'intelligent a la place de ça
00213 if ( !Element )
00214 return false;
00215 LoadHeaderEntrySafe(Element);
00216
00217 const char * Transfert = Element->GetValue().c_str();
00218 if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true;
00219 if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true;
00220 if (Element->GetValue() == "1.2.840.10008.1.2.4.57") return true;
00221
00222 return false;
00223 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a JPEGSpectralSelectionProcess6-8 one.
Definition at line 171 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe().
00171 {
00172 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00173 if ( !Element )
00174 return false;
00175 LoadHeaderEntrySafe(Element);
00176
00177 std::string Transfer = Element->GetValue();
00178 if ( Transfer == "1.2.840.10008.1.2.4.53" )
00179 return true;
00180 return false;
00181 }
|
|
|
This predicate, based on hopefully reasonable heuristics, decides whether or not the current gdcmParser was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File.
Reimplemented from gdcmParser. Definition at line 96 of file gdcmHeader.cxx. References GDCM_UNFOUND, gdcmHeader::GetEntryByNumber(), gdcmParser::GetHeaderEntryByNumber(), and gdcmParser::IsReadable(). Referenced by gdcmFile::gdcmFile(), and gdcmDicomDir::NewDicomDir().
00096 {
00097 if(!gdcmParser::IsReadable()) {
00098 return(false);
00099 }
00100 std::string res = GetEntryByNumber(0x0028, 0x0005);
00101 if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
00102 return false; // Image Dimensions
00103 if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
00104 return false; // "Bits Allocated"
00105 if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
00106 return false; // "Bits Stored"
00107 if ( !GetHeaderEntryByNumber(0x0028, 0x0102) )
00108 return false; // "High Bit"
00109 if ( !GetHeaderEntryByNumber(0x0028, 0x0103) )
00110 return false; // "Pixel Representation" i.e. 'Sign'
00111 return true;
00112 }
|
|
|
Determines if the Transfer Syntax was already encountered and if it corresponds to a RLE Lossless one.
Definition at line 190 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetValue(), and gdcmParser::LoadHeaderEntrySafe(). Referenced by gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00190 {
00191 gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
00192 if ( !Element )
00193 return false;
00194 LoadHeaderEntrySafe(Element);
00195
00196 std::string Transfer = Element->GetValue();
00197 if ( Transfer == "1.2.840.10008.1.2.5" ) {
00198 return true;
00199 }
00200 return false;
00201 }
|
|
||||||||||||
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 734 of file gdcmParser.cxx. References gdcmParser::fp, gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetLength(), gdcmHeaderEntry::GetOffset(), and gdcmParser::SetEntryVoidAreaByNumber(). Referenced by gdcmParser::LoadHeaderEntries().
00735 {
00736 gdcmHeaderEntry * Element= GetHeaderEntryByNumber(Group, Elem);
00737 if ( !Element )
00738 return NULL;
00739 size_t o =(size_t)Element->GetOffset();
00740 fseek(fp, o, SEEK_SET);
00741 int l=Element->GetLength();
00742 void * a = malloc(l);
00743 if(!a)
00744 return NULL;
00745
00746 SetEntryVoidAreaByNumber(a, Group, Elem);
00747 // TODO check the result
00748 size_t l2 = fread(a, 1, l ,fp);
00749 if(l != l2)
00750 {
00751 free(a);
00752 return NULL;
00753 }
00754
00755 return a;
00756 }
|
|
|
Loads the element while preserving the current underlying file position indicator as opposed to to LoadHeaderEntry that modifies it.
Definition at line 877 of file gdcmParser.cxx. References gdcmParser::fp, and gdcmParser::LoadHeaderEntry(). Referenced by gdcmParser::IsDeflatedExplicitVRLittleEndianTransferSyntax(), gdcmParser::IsExplicitVRBigEndianTransferSyntax(), gdcmParser::IsExplicitVRLittleEndianTransferSyntax(), gdcmParser::IsImplicitVRLittleEndianTransferSyntax(), gdcmHeader::IsJPEG2000(), gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(), gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(), gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(), gdcmHeader::IsJPEGLossless(), gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(), and gdcmHeader::IsRLELossLessTransferSyntax().
00877 {
00878 long PositionOnEntry = ftell(fp);
00879 LoadHeaderEntry(entry);
00880 fseek(fp, PositionOnEntry, SEEK_SET);
00881 }
|
|
|
opens the file
Definition at line 325 of file gdcmParser.cxx. References dbg, and gdcmDebug::Verbose(). Referenced by gdcmParser::gdcmParser(), gdcmFile::ParsePixelData(), and gdcmFile::ReadPixelData().
00327 {
00328 fp=fopen(filename.c_str(),"rb");
00329 if(exception_on_error)
00330 {
00331 if(!fp)
00332 throw gdcmFileError("gdcmParser::gdcmParser(const char *, bool)");
00333 }
00334
00335 if ( fp )
00336 {
00337 guint16 zero;
00338 fread(&zero, (size_t)2, (size_t)1, fp);
00339
00340 //ACR -- or DICOM with no Preamble --
00341 if( zero == 0x0008 || zero == 0x0800 || zero == 0x0002 || zero == 0x0200)
00342 return(fp);
00343
00344 //DICOM
00345 fseek(fp, 126L, SEEK_CUR);
00346 char dicm[4];
00347 fread(dicm, (size_t)4, (size_t)1, fp);
00348 if( memcmp(dicm, "DICM", 4) == 0 )
00349 return(fp);
00350
00351 fclose(fp);
00352 dbg.Verbose(0, "gdcmParser::OpenFile not DICOM/ACR", filename.c_str());
00353 }
00354 else {
00355 dbg.Verbose(0, "gdcmParser::OpenFile cannot open file", filename.c_str());
00356 }
00357 return(NULL);
00358 }
|
|
|
compares 2 Headers, according to DICOMDIR rules --> not-for-rats function
Definition at line 743 of file gdcmHeader.cxx. References gdcmHeader::GetEntryByNumber().
00743 {
00744 std::string s1,s2;
00745
00746 // Patient Name
00747 s1=this->GetEntryByNumber(0x0010,0x0010);
00748 s2=header.GetEntryByNumber(0x0010,0x0010);
00749 if(s1 < s2)
00750 return(true);
00751 else if(s1 > s2)
00752 return(false);
00753 else
00754 {
00755 // Patient ID
00756 s1=this->GetEntryByNumber(0x0010,0x0020);
00757 s2=header.GetEntryByNumber(0x0010,0x0020);
00758 if (s1 < s2)
00759 return(true);
00760 else if (s1 > s2)
00761 return(1);
00762 else
00763 {
00764 // Study Instance UID
00765 s1=this->GetEntryByNumber(0x0020,0x000d);
00766 s2=header.GetEntryByNumber(0x0020,0x000d);
00767 if (s1 < s2)
00768 return(true);
00769 else if(s1 > s2)
00770 return(false);
00771 else
00772 {
00773 // Serie Instance UID
00774 s1=this->GetEntryByNumber(0x0020,0x000e);
00775 s2=header.GetEntryByNumber(0x0020,0x000e);
00776 if (s1 < s2)
00777 return(true);
00778 else if(s1 > s2)
00779 return(false);
00780 }
00781 }
00782 }
00783 return(false);
00784 }
|
|
|
Reimplemented in gdcmDicomDir. Definition at line 52 of file gdcmParser.h.
00052 {PrintEntry(os);};
|
|
|
Prints the Header Entries (Dicom Elements) both from the H Table and the chained list.
Definition at line 148 of file gdcmParser.cxx. References gdcmParser::listEntries.
00148 {
00149 std::ostringstream s;
00150
00151 for (ListTag::iterator i = listEntries.begin();
00152 i != listEntries.end();
00153 ++i)
00154 {
00155 (*i)->SetPrintLevel(printLevel);
00156 (*i)->Print(os);
00157 }
00158 os<<s.str();
00159 }
|
|
|
Prints The Dict Entries of THE public Dicom Dictionnry.
Definition at line 166 of file gdcmParser.cxx. References gdcmDict::Print(), and gdcmParser::RefPubDict.
00166 {
00167 RefPubDict->Print(os);
00168 }
|
|
|
Prints The Dict Entries of THE shadow Dicom Dictionnry.
Definition at line 175 of file gdcmParser.cxx. References gdcmDict::Print(), and gdcmParser::RefShaDict.
00175 {
00176 RefShaDict->Print(os);
00177 }
|
|
||||||||||||||||
|
Set a new value if the invoked element exists Seems to be useless !!!
Definition at line 491 of file gdcmParser.cxx. References gdcmParser::SetEntryByNumber(). Referenced by gdcmHeader::anonymizeHeader().
00492 {
00493 std::string v = Value;
00494 SetEntryByNumber(v, Group, Elem);
00495 return true;
00496 }
|
|
||||||||||||||||
|
Modifies the value of a given Header Entry (Dicom Element) if it exists; Creates it with the given value if it doesn't.
Definition at line 469 of file gdcmParser.cxx. References gdcmParser::AddHeaderEntry(), gdcmParser::NewHeaderEntryByNumber(), and gdcmParser::SetEntryByNumber().
00469 {
00470 gdcmHeaderEntry* nvHeaderEntry=NewHeaderEntryByNumber(Group, Elem);
00471
00472 if(!nvHeaderEntry)
00473 return(false);
00474
00475 AddHeaderEntry(nvHeaderEntry);
00476
00477 std::string v = Value;
00478 SetEntryByNumber(v, Group, Elem);
00479 return(true);
00480 }
|
|
||||||||||||||||
|
Modifies the value of a given Header Entry (Dicom Element) if it exists; Creates it with the given value if it doesn't.
Definition at line 446 of file gdcmParser.cxx. References gdcmParser::AddHeaderEntry(), gdcmParser::CheckIfEntryExistByNumber(), gdcmParser::NewHeaderEntryByNumber(), and gdcmParser::SetEntryByNumber(). Referenced by gdcmHeader::anonymizeHeader(), and gdcmParser::Write().
00448 {
00449 if (CheckIfEntryExistByNumber(Group, Elem) == 0) {
00450 gdcmHeaderEntry *a =NewHeaderEntryByNumber(Group, Elem);
00451 if (a == NULL)
00452 return false;
00453 AddHeaderEntry(a);
00454 }
00455 SetEntryByNumber(Value, Group, Elem);
00456 return(true);
00457 }
|
|
||||||||||||
|
Sets the value (string) of the Header Entry (Dicom Element).
Reimplemented from gdcmParser. Definition at line 97 of file gdcmHeader.h. References gdcmParser::SetEntryByName().
00098 { return(gdcmParser::SetEntryByName(content,tagName)); }
|
|
||||||||||||||||
|
Accesses an existing gdcmHeaderEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Reimplemented from gdcmParser. Definition at line 95 of file gdcmHeader.h. References gdcmParser::SetEntryByNumber(). Referenced by gdcmFile::GetImageDataIntoVector(), gdcmFile::GetImageDataIntoVectorRaw(), gdcmHeader::SetImageDataSize(), and gdcmFile::WriteBase().
00096 { return(gdcmParser::SetEntryByNumber(content,group,element)); }
|
|
||||||||||||||||
|
Accesses an existing gdcmHeaderEntry (i.e. a Dicom Element) in the PubHeaderEntrySet of this instance through it's (group, element) and modifies it's length with the given value.
Reimplemented from gdcmParser. Definition at line 100 of file gdcmHeader.h. References gdcmParser::SetEntryLengthByNumber().
00101 { return(gdcmParser::SetEntryLengthByNumber(l,group,element)); }
|
|
||||||||||||||||
|
Sets a 'non string' value to a given Dicom Element.
Definition at line 766 of file gdcmParser.cxx. References gdcmParser::tagHT, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmParser::LoadEntryVoidArea().
00769 {
00770 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
00771 if ( ! tagHT.count(key))
00772 return false;
00773 ( ((tagHT.equal_range(key)).first)->second )->SetVoidArea(area);
00774 return true;
00775 }
|
|
|
Sets the Pixel Area size in the Header --> not-for-rats function.
Definition at line 716 of file gdcmHeader.cxx. References gdcmParser::GetHeaderEntryByNumber(), gdcmHeader::SetEntryByNumber(), and gdcmHeaderEntry::SetLength(). Referenced by gdcmFile::SetImageData().
00716 {
00717 std::string content1;
00718 char car[20];
00719
00720 // Assumes HeaderEntry (GrPixel, NumPixel) is unique ...
00721 // TODO deal with multiplicity (see gdcmData/icone.dcm)
00722 sprintf(car,"%d",ImageDataSize);
00723
00724 gdcmHeaderEntry *a = GetHeaderEntryByNumber(GrPixel, NumPixel);
00725 a->SetLength(ImageDataSize);
00726
00727 ImageDataSize+=8;
00728 sprintf(car,"%d",ImageDataSize);
00729 content1=car;
00730 SetEntryByNumber(content1, GrPixel, NumPixel);
00731 }
|
|
|
Sets the print level for the Dicom Header.
Reimplemented in gdcmDicomDir. Definition at line 51 of file gdcmParser.h.
00051 { printLevel = level; };
|
|
|
Set the shadow dictionary used.
Definition at line 212 of file gdcmParser.cxx. References DictKey, gdcmDictSet::GetDict(), gdcmGlobal::GetDicts(), and gdcmParser::RefShaDict.
00212 {
00213 RefShaDict=gdcmGlobal::GetDicts()->GetDict(dictName);
00214 return(!RefShaDict);
00215 }
|
|
|
Set the shadow dictionary used.
Definition at line 202 of file gdcmParser.cxx. References gdcmParser::RefShaDict.
00202 {
00203 RefShaDict=dict;
00204 return(!RefShaDict);
00205 }
|
|
|
Swaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 1156 of file gdcmParser.cxx. References dbg, gdcmDebug::Error(), and gdcmParser::sw. Referenced by gdcmFile::gdcm_read_RLE_file(), gdcmParser::GetHeaderEntryValue(), gdcmFile::ParsePixelData(), gdcmParser::ReadInt32(), gdcmFile::ReadPixelData(), and gdcmParser::UnswapLong().
01156 {
01157 switch (sw) {
01158 case 0 :
01159 break;
01160 case 4321 :
01161 a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) |
01162 ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) );
01163 break;
01164
01165 case 3412 :
01166 a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) );
01167 break;
01168
01169 case 2143 :
01170 a=( ((a<<8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) );
01171 break;
01172 default :
01173 dbg.Error(" gdcmParser::SwapLong : unset swap code");
01174 a=0;
01175 }
01176 return(a);
01177 }
|
|
|
Swaps the bytes so they agree with the processor order.
Definition at line 1194 of file gdcmParser.cxx. References gdcmParser::sw. Referenced by gdcmParser::FindHeaderEntryLength(), gdcmFile::gdcm_read_RLE_file(), gdcmParser::GetHeaderEntryValue(), gdcmFile::ParsePixelData(), gdcmParser::ReadInt16(), gdcmFile::ReadPixelData(), and gdcmParser::UnswapShort().
01194 {
01195 if ( (sw==4321) || (sw==2143) )
01196 a =(((a<<8) & 0x0ff00) | ((a>>8)&0x00ff));
01197 return (a);
01198 }
|
|
|
Unswaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 1185 of file gdcmParser.cxx. References gdcmParser::SwapLong().
01185 {
01186 return (SwapLong(a));
01187 }
|
|
|
Unswaps the bytes so they agree with the processor order.
Definition at line 1205 of file gdcmParser.cxx. References gdcmParser::SwapShort().
01205 {
01206 return (SwapShort(a));
01207 }
|
|
||||||||||||
|
Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader.
Definition at line 892 of file gdcmParser.cxx. References gdcmParser::AddHeaderEntry(), ExplicitVR, gdcmHeaderEntry::GetElement(), gdcmHeaderEntry::GetGroup(), gdcmParser::GetHeaderEntryByNumber(), gdcmHeaderEntry::GetLength(), gdcmHeaderEntry::GetVR(), GroupHT, GroupKey, gdcmHeaderEntry::SetLength(), gdcmHeaderEntry::SetValue(), gdcmParser::tagHT, and TagKey.
00892 {
00893 guint16 gr, el;
00894 std::string vr;
00895
00896 gdcmHeaderEntry *elem;
00897 char trash[10];
00898 std::string str_trash;
00899
00900 GroupKey key;
00901 GroupHT groupHt; // to hold the length of each group
00902 TagKey tk;
00903 // remember :
00904 // typedef std::map<GroupKey, int> GroupHT;
00905
00906 gdcmHeaderEntry *elemZ;
00907
00908 // for each Tag in the DCM Header
00909
00910 for (TagHeaderEntryHT::iterator tag2 = tagHT.begin();
00911 tag2 != tagHT.end();
00912 ++tag2)
00913 {
00914 elem = tag2->second;
00915 gr = elem->GetGroup();
00916 el = elem->GetElement();
00917 vr = elem->GetVR();
00918
00919 sprintf(trash, "%04x", gr);
00920 key = trash; // generate 'group tag'
00921
00922 // if the caller decided not to take SEQUENCEs into account
00923 // e.g : he wants to write an ACR-NEMA File
00924
00925 if (SkipSequence && vr == "SQ")
00926 continue;
00927
00928 // Still unsolved problem :
00929 // we cannot find the 'Sequence Delimitation Item'
00930 // since it's at the end of the Hash Table
00931 // (fffe,e0dd)
00932
00933 // pas SEQUENCE en ACR-NEMA
00934 // WARNING :
00935 // --> la descente a l'interieur' des SQ
00936 // devrait etre faite avec une liste chainee, pas avec une HTable...
00937
00938 if ( groupHt.count(key) == 0) // we just read the first elem of a given group
00939 {
00940 if (el == 0x0000) // the first elem is 0x0000
00941 {
00942 groupHt[key] = 0; // initialize group length
00943 }
00944 else
00945 {
00946 groupHt[key] = 2 + 2 + 4 + elem->GetLength(); // non 0x0000 first group elem
00947 }
00948 }
00949 else // any elem but the first
00950 {
00951 if (type == ExplicitVR)
00952 {
00953 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") )
00954 {
00955 groupHt[key] += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
00956 }
00957 }
00958 groupHt[key] += 2 + 2 + 4 + elem->GetLength();
00959 }
00960 }
00961
00962 unsigned short int gr_bid;
00963
00964 for (GroupHT::iterator g = groupHt.begin(); // for each group we found
00965 g != groupHt.end();
00966 ++g)
00967 {
00968 // FIXME: g++ -Wall -Wstrict-prototypes reports on following line:
00969 // warning: unsigned int format, different type arg
00970 sscanf(g->first.c_str(),"%x",&gr_bid);
00971 tk = g->first + "|0000"; // generate the element full tag
00972
00973 if ( tagHT.count(tk) == 0) // if element 0x0000 not found
00974 {
00975 gdcmDictEntry * tagZ = new gdcmDictEntry(gr_bid, 0x0000, "UL");
00976 elemZ = new gdcmHeaderEntry(tagZ);
00977 elemZ->SetLength(4);
00978 AddHeaderEntry(elemZ); // create it
00979 }
00980 else
00981 {
00982 elemZ=GetHeaderEntryByNumber(gr_bid, 0x0000);
00983 }
00984 sprintf(trash ,"%d",g->second);
00985 str_trash=trash;
00986 elemZ->SetValue(str_trash);
00987 }
00988 }
|
|
|
Update the entries with the shadow dictionary. Only non even entries are analyzed.
Reimplemented from gdcmParser. Definition at line 103 of file gdcmHeader.h. References gdcmParser::UpdateShaEntries().
00104 { gdcmParser::UpdateShaEntries(); }
|
|
||||||||||||
|
Definition at line 381 of file gdcmParser.cxx. References ExplicitVR, gdcmParser::ReplaceOrCreateByNumber(), gdcmParser::SetEntryLengthByNumber(), UI1_2_840_10008_1_2, UI1_2_840_10008_1_2_1, and gdcmParser::WriteEntries(). Referenced by gdcmFile::WriteBase().
00381 {
00382 // ==============
00383 // TODO The stuff was rewritten using the chained list instead
00384 // of the H table
00385 // so we could remove the GroupHT from the gdcmParser
00386 // To be checked
00387 // =============
00388
00389 // TODO : move the following lines (and a lot of others, to be written)
00390 // to a future function CheckAndCorrectHeader
00391
00392 // Question :
00393 // Comment pourrait-on savoir si le DcmHeader vient d'un fichier DicomV3 ou non
00394 // (FileType est un champ de gdcmParser ...)
00395 // WARNING : Si on veut ecrire du DICOM V3 a partir d'un DcmHeader ACR-NEMA
00396 // no way
00397 // a moins de se livrer a un tres complique ajout des champs manquants.
00398 // faire un CheckAndCorrectHeader (?)
00399
00400
00401 if (type == ImplicitVR)
00402 {
00403 std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2;
00404 ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010);
00405
00406 //FIXME Refer to standards on page 21, chapter 6.2 "Value representation":
00407 // values with a VR of UI shall be padded with a single trailing null
00408 // Dans le cas suivant on doit pader manuellement avec un 0
00409
00410 SetEntryLengthByNumber(18, 0x0002, 0x0010);
00411 }
00412
00413 if (type == ExplicitVR)
00414 {
00415 std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1;
00416 ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010);
00417
00418 //FIXME Refer to standards on page 21, chapter 6.2 "Value representation":
00419 // values with a VR of UI shall be padded with a single trailing null
00420 // Dans le cas suivant on doit pader manuellement avec un 0
00421
00422 SetEntryLengthByNumber(20, 0x0002, 0x0010);
00423 }
00424
00425 /* TODO : rewrite later
00426
00427 if ( (type == ImplicitVR) || (type == ExplicitVR) )
00428 UpdateGroupLength(false,type);
00429 if ( type == ACR)
00430 UpdateGroupLength(true,ACR);
00431 */
00432
00433 WriteEntries(fp,type);
00434 return(true);
00435 }
|
|
|
|
|
||||||||||||
|
writes on disc according to the requested format (ACR-NEMA, ExplicitVR, ImplicitVR) the image
Definition at line 1003 of file gdcmParser.cxx. References ACR, gdcmParser::countGrPixel, DICOMDIR, ExplicitVR, gdcmParser::GrPixel, gdcmParser::listEntries, gdcmParser::NumPixel, and Tokenize(). Referenced by gdcmParser::Write(), and gdcmDicomDir::Write().
01004 {
01005 guint16 gr, el;
01006 guint32 lgr;
01007 std::string value;
01008 const char * val;
01009 std::string vr;
01010 guint32 val_uint32;
01011 guint16 val_uint16;
01012 guint16 valZero =0;
01013 void *voidArea;
01014 std::vector<std::string> tokens;
01015
01016 // TODO : function CheckHeaderCoherence to be written
01017
01018 // uses now listEntries to iterate, not TagHt!
01019 //
01020 // pb : gdcmParser.Add does NOT update listEntries
01021 // TODO : find a trick (in STL?) to do it, at low cost !
01022
01023 void *ptr;
01024
01025 // TODO (?) tester les echecs en ecriture (apres chaque fwrite)
01026 int compte =0;
01027
01028 for (ListTag::iterator tag2=listEntries.begin();
01029 tag2 != listEntries.end();
01030 ++tag2)
01031 {
01032 // === Deal with the length
01033 // --------------------
01034 if(((*tag2)->GetLength())%2==1)
01035 {
01036 (*tag2)->SetValue((*tag2)->GetValue()+"\0");
01037 (*tag2)->SetLength((*tag2)->GetLength()+1);
01038 }
01039
01040 gr = (*tag2)->GetGroup();
01041 el = (*tag2)->GetElement();
01042 lgr = (*tag2)->GetReadLength();
01043 val = (*tag2)->GetValue().c_str();
01044 vr = (*tag2)->GetVR();
01045 voidArea = (*tag2)->GetVoidArea();
01046
01047 if ( type == ACR )
01048 {
01049 if (gr < 0x0008) continue; // ignore pure DICOM V3 groups
01050 if (gr %2) continue; // ignore shadow groups
01051 if (vr == "SQ" ) continue; // ignore Sequences
01052 // TODO : find a trick to *skip* the SeQuences !
01053 // Not only ignore the SQ element
01054 if (gr == 0xfffe ) continue; // ignore delimiters
01055 }
01056
01057 fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp); //group
01058 fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
01059
01060 // if ( (type == ExplicitVR) && (gr <= 0x0002) ) // ?!? < 2
01061 if ( (type == ExplicitVR) || (type == DICOMDIR) )
01062 {
01063 // EXPLICIT VR
01064 guint16 z=0, shortLgr;
01065 if (vr == "unkn")
01066 { // Unknown was 'written'
01067 shortLgr=lgr;
01068 fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
01069 fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
01070 }
01071 else
01072 {
01073 if (gr != 0xfffe)
01074 { // NO value for 'delimiters'
01075 if (vr == "unkn") // Unknown was 'written'
01076 fwrite(&z,(size_t)2 ,(size_t)1 ,_fp);
01077 else
01078 fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
01079 }
01080
01081 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || gr == 0xfffe)
01082 {
01083 if (gr != 0xfffe)
01084 fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
01085 fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
01086 }
01087 else
01088 {
01089 shortLgr=lgr;
01090 fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
01091 }
01092 }
01093 }
01094 else // IMPLICIT VR
01095 {
01096 fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
01097 }
01098
01099 // === Deal with the value
01100 // -------------------
01101 if (vr == "SQ") continue; // no "value" to write for the SEQuences
01102 if (gr == 0xfffe)continue;
01103
01104 if (voidArea != NULL)
01105 { // there is a 'non string' LUT, overlay, etc
01106 fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
01107 continue;
01108 }
01109
01110 if (vr == "US" || vr == "SS")
01111 {
01112 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
01113 Tokenize ((*tag2)->GetValue(), tokens, "\\");
01114 for (unsigned int i=0; i<tokens.size();i++)
01115 {
01116 val_uint16 = atoi(tokens[i].c_str());
01117 ptr = &val_uint16;
01118 fwrite ( ptr,(size_t)2 ,(size_t)1 ,_fp);
01119 }
01120 tokens.clear();
01121 continue;
01122 }
01123 if (vr == "UL" || vr == "SL")
01124 {
01125 tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
01126 Tokenize ((*tag2)->GetValue(), tokens, "\\");
01127 for (unsigned int i=0; i<tokens.size();i++)
01128 {
01129 val_uint32 = atoi(tokens[i].c_str());
01130 ptr = &val_uint32;
01131 fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
01132 }
01133 tokens.clear();
01134 continue;
01135 }
01136
01137 // Pixels are never loaded in the element !
01138 // we stop writting when Pixel are processed
01139 // FIX : we loose trailing elements (RAB, right now)
01140
01141 if ((gr == GrPixel) && (el == NumPixel) ) {
01142 compte++;
01143 if (compte == countGrPixel) // we passed *all* the GrPixel,NumPixel
01144 break;
01145 }
01146 fwrite ( val,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
01147 }
01148 }
|
|
|
Definition at line 160 of file gdcmParser.h. Referenced by gdcmParser::WriteEntries(). |
|
|
Definition at line 152 of file gdcmParser.h. Referenced by gdcmParser::FixHeaderEntryFoundLength(), and gdcmParser::gdcmParser(). |
|
|
Definition at line 142 of file gdcmParser.h. Referenced by gdcmParser::CheckSwap(), gdcmParser::FindHeaderEntryLength(), gdcmParser::FindHeaderEntryVR(), gdcmParser::GetFileType(), gdcmParser::IsReadable(), and gdcmParser::LoadHeaderEntries(). |
|
|
Definition at line 141 of file gdcmParser.h. Referenced by gdcmParser::CheckSwap(), gdcmParser::CloseFile(), gdcmParser::FindHeaderEntryLength(), gdcmParser::FindHeaderEntryLengthOB(), gdcmParser::FindHeaderEntryVR(), gdcmParser::IsHeaderEntryAnInteger(), gdcmParser::LoadEntryVoidArea(), gdcmParser::LoadHeaderEntries(), gdcmParser::LoadHeaderEntry(), gdcmParser::LoadHeaderEntrySafe(), gdcmParser::ReadInt16(), gdcmParser::ReadInt32(), gdcmParser::ReadNextHeaderEntry(), and gdcmParser::SkipBytes(). |
|
|
Definition at line 156 of file gdcmParser.h. Referenced by gdcmParser::FindHeaderEntryLength(), and gdcmParser::WriteEntries(). |
|
|
Definition at line 69 of file gdcmParser.cxx. Referenced by gdcmParser::CheckSwap(). |
|
|
Definition at line 150 of file gdcmParser.h. Referenced by gdcmParser::AddHeaderEntry(), gdcmParser::IsReadable(), gdcmParser::PrintEntry(), gdcmParser::UpdateShaEntries(), and gdcmParser::WriteEntries(). |
|
|
Definition at line 72 of file gdcmParser.cxx. Referenced by gdcmParser::gdcmParser(). |
|
|
Definition at line 76 of file gdcmParser.cxx. |
|
|
Definition at line 157 of file gdcmParser.h. Referenced by gdcmParser::FindHeaderEntryLength(), and gdcmParser::WriteEntries(). |
|
|
Definition at line 153 of file gdcmParser.h. |
|
|
Definition at line 149 of file gdcmParser.h. Referenced by gdcmParser::AddHeaderEntry(), gdcmParser::CheckIfEntryExistByNumber(), gdcmParser::GenerateFreeTagKeyInGroup(), gdcmParser::GetEntryByNumber(), gdcmParser::GetHeaderEntryByNumber(), gdcmParser::GetHeaderEntrySameNumber(), gdcmParser::SetEntryByNumber(), gdcmParser::SetEntryLengthByNumber(), gdcmParser::SetEntryVoidAreaByNumber(), and gdcmParser::UpdateGroupLength(). |
1.3.6