#include <gdcmFile.h>
Inheritance diagram for gdcm::File:

Public Types | |
| typedef std::list< Element > | ListElements |
Public Member Functions | |
| File () | |
| Constructor used when we want to generate dicom files from scratch. | |
| File (std::string const &filename) | |
| Constructor. | |
| ~File () | |
| Canonical destructor. | |
| bool | IsReadable () |
| This predicate, based on hopefully reasonable heuristics, decides whether or not the current File was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File. | |
| int | GetImageNumber () |
| gets the info from 0020,0013 : Image Number else 0. | |
| ModalityType | GetModality () |
| gets the info from 0008,0060 : Modality | |
| int | GetXSize () |
| Retrieve the number of columns of image. | |
| int | GetYSize () |
| Retrieve the number of lines of image. | |
| int | GetZSize () |
| Retrieve the number of planes of volume or the number of frames of a multiframe. | |
| float | GetXSpacing () |
| gets the info from 0028,0030 : Pixel Spacing else 1.0 | |
| float | GetYSpacing () |
| gets the info from 0028,0030 : Pixel Spacing else 1.0 | |
| float | GetZSpacing () |
| gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1.0 | |
| 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. | |
| void | GetImageOrientationPatient (float iop[6]) |
| gets the info from 0020,0037 : Image Orientation Patient (needed to organize DICOM files based on their x,y,z position) | |
| int | GetBitsStored () |
| Retrieve the number of Bits Stored (actually used) (as opposed to number of Bits Allocated). | |
| int | GetBitsAllocated () |
| Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files, 16, ...). | |
| int | GetHighBitPosition () |
| Retrieve the high bit position. | |
| int | GetSamplesPerPixel () |
| Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB -1 or 3 Planes-). | |
| int | GetPlanarConfiguration () |
| Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane). | |
| int | GetPixelSize () |
| Return 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 floating double 64 bits (Not kosher DICOM, but so usefull!). | |
| bool | IsSignedPixelData () |
| Check whether the pixels are signed or UNsigned data. | |
| bool | IsMonochrome () |
| Check whether this a monochrome picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). | |
| bool | IsPaletteColor () |
| Check whether this a "PALETTE COLOR" picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). | |
| bool | IsYBRFull () |
| Check whether this a "YBR_FULL" color picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). | |
| bool | HasLUT () |
| tells us if LUT are used | |
| int | GetLUTNbits () |
| gets the info from 0028,1101 : Lookup Table Desc-Red else 0 | |
| 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 to get RGB pixels image when it's stored as a PALETTE COLOR image -the (vtk) user is supposed to know how deal with LUTs -. | |
| uint16_t | GetGrPixel () |
| Accessor to File::GrPixel. | |
| uint16_t | GetNumPixel () |
| Accessor to File::NumPixel. | |
| size_t | GetPixelOffset () |
| Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !). | |
| size_t | GetPixelAreaLength () |
| Recover the pixel area length (in Bytes). | |
| RLEFramesInfo * | GetRLEInfo () |
| returns the RLE info | |
| JPEGFragmentsInfo * | GetJPEGInfo () |
| Returns the JPEG Fragments info. | |
| void | AddAnonymizeElement (uint16_t group, uint16_t elem, std::string const &value) |
| Adds the characteristics of a new element we want to anonymize. | |
| void | ClearAnonymizeList () |
| Clears the list of elements to be anonymized. | |
| void | AnonymizeNoLoad () |
| Overwrites in the file the values of the DicomElements held in the list. | |
| bool | AnonymizeFile () |
| anonymize a File (removes Patient's personal info passed with AddAnonymizeElement() | |
| bool | Write (std::string fileName, FileType filetype) |
| Performs some consistency checking on various 'File related' (as opposed to 'DicomDir related') entries then writes in a file all the (Dicom Elements) included the Pixels. | |
| Dict * | GetPubDict () |
| Get the public dictionary used. | |
| Dict * | GetShaDict () |
| Get the shadow dictionary used. | |
| bool | SetShaDict (Dict *dict) |
| Set the shadow dictionary used. | |
| bool | SetShaDict (DictKey const &dictName) |
| Set the shadow dictionary used. | |
| bool | IsDicomV3 () |
| Predicate for dicom version 3 file. | |
| bool | IsPapyrus () |
| Predicate for Papyrus file Dedicated to whomsoever it may concern. | |
| FileType | GetFileType () |
| returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) | |
| std::string | GetTransferSyntax () |
| Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured). | |
| std::string | GetTransferSyntaxName () |
| Accesses the info from 0002,0010 : Transfer Syntax and TS. | |
| int | GetSwapCode () |
| 'Swap code' accessor (see SwapCode ) | |
| uint16_t | SwapShort (uint16_t) |
| Swaps the bytes so they agree with the processor order. | |
| uint32_t | SwapLong (uint32_t) |
| Swaps back the bytes of 4-byte long integer accordingly to processor order. | |
| uint16_t | UnswapShort (uint16_t a) |
| Unswaps back the bytes of 2-bytes long integer so they agree with the processor order. | |
| uint32_t | UnswapLong (uint32_t a) |
| Unswaps back the bytes of 4-byte long integer so they agree with the processor order. | |
| const std::string & | GetFileName () const |
| Accessor to Filename. | |
| void | SetFileName (std::string const &fileName) |
| Accessor to Filename. | |
| std::ifstream * | OpenFile () |
| Tries to open the file Document::Filename and checks the preamble when existing. | |
| bool | CloseFile () |
| closes the file | |
| void | WriteContent (std::ofstream *fp, FileType type) |
| Writes in a file all the Header Entries (Dicom Elements). | |
| virtual void | LoadEntryBinArea (uint16_t group, uint16_t elem) |
| Loads (from disk) the element content when a string is not suitable. | |
| virtual void | LoadEntryBinArea (BinEntry *entry) |
| Loads (from disk) the element content when a string is not suitable. | |
| void | LoadDocEntrySafe (DocEntry *entry) |
| Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it. | |
| bool | operator< (Document &document) |
| Compares two documents, according to DicomDir rules. | |
| virtual void | Print (std::ostream &os=std::cout, std::string const &indent="") |
| Prints the Header Entries (Dicom Elements) from the H Table. | |
| bool | AddEntry (DocEntry *Entry) |
| add a new Dicom Element pointer to the H Table | |
| bool | RemoveEntry (DocEntry *EntryToRemove) |
| Clear the hash table from given entry AND delete the entry. | |
| bool | RemoveEntryNoDestroy (DocEntry *EntryToRemove) |
| Clear the hash table from given entry BUT keep the entry. | |
| void | ClearEntry () |
| delete all entries in the ElementSet | |
| DocEntry * | GetFirstEntry () |
| Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
| DocEntry * | GetNextEntry () |
| Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence). | |
| DocEntry * | GetDocEntry (uint16_t group, uint16_t elem) |
| retrieves a Dicom Element using (group, element) | |
| bool | IsEmpty () |
| Tells us if the ElementSet contains no entry. | |
| virtual std::string | GetEntryValue (uint16_t group, uint16_t elem) |
| Get the "std::string representable" value of the Dicom entry. | |
| virtual void * | GetEntryBinArea (uint16_t group, uint16_t elem) |
| Gets (from Header) a 'non string' element value. | |
| virtual int | GetEntryLength (uint16_t group, uint16_t elem) |
| Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag.. | |
| virtual std::string | GetEntryVR (uint16_t group, uint16_t elem) |
| 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. | |
| ValEntry * | GetValEntry (uint16_t group, uint16_t elem) |
| Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry. | |
| BinEntry * | GetBinEntry (uint16_t group, uint16_t elem) |
| Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry. | |
| SeqEntry * | GetSeqEntry (uint16_t group, uint16_t elem) |
| Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry. | |
| bool | SetValEntry (std::string const &content, uint16_t group, uint16_t elem) |
| Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
| bool | SetValEntry (std::string const &content, ValEntry *entry) |
| Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
| bool | SetBinEntry (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
| Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
| bool | SetBinEntry (uint8_t *content, int lgth, BinEntry *entry) |
| Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value. | |
| ValEntry * | InsertValEntry (std::string const &value, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
| Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant. | |
| BinEntry * | InsertBinEntry (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
| Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document. | |
| SeqEntry * | InsertSeqEntry (uint16_t group, uint16_t elem) |
| Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant. | |
| virtual bool | CheckIfEntryExist (uint16_t group, uint16_t elem) |
| Checks if a given Dicom Element exists within the H table. | |
| ValEntry * | NewValEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
| Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
| BinEntry * | NewBinEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN) |
| Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
| SeqEntry * | NewSeqEntry (uint16_t group, uint16_t elem) |
| Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent. | |
| DictEntry * | NewVirtualDictEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN, TagName const &vm=GDCM_UNKNOWN, TagName const &name=GDCM_UNKNOWN) |
| Request a new virtual dict entry to the dict set. | |
| void | SetPrintLevel (int level) |
| Sets the print level for the Dicom Header Elements. | |
| int | GetPrintLevel () |
| Gets the print level for the Dicom Entries. | |
Protected Member Functions | |
| void | InitializeDefaultFile () |
| Initialize a default DICOM File that should contain all the field require by other reader. DICOM standard does not explicitely defines those fields, heuristic has been choosen. This is not perfect as we are writting a CT image... | |
| uint16_t | ReadInt16 () throw ( FormatError ) |
| Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness). | |
| uint32_t | ReadInt32 () throw ( FormatError ) |
| Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness). | |
| void | SkipBytes (uint32_t) |
| skips bytes inside the source file | |
| int | ComputeGroup0002Length (FileType filetype) |
| Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader. | |
| DictEntry * | GetDictEntry (uint16_t group, uint16_t elem) |
| Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one. | |
| DictEntry * | GetDictEntry (uint16_t group, uint16_t elem, TagName const &vr) |
| Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary. | |
Protected Attributes | |
| RLEFramesInfo * | RLEInfo |
| Store the RLE frames info obtained during parsing of pixels. | |
| JPEGFragmentsInfo * | JPEGInfo |
| Store the JPEG fragments info obtained during parsing of pixels. | |
| uint16_t | NumPixel |
| In some cases (e.g. for some ACR-NEMA images) the Entry Element Number of the 'Pixel Element' is *not* found at 0x0010. In order to make things easier the parser shall store the proper value in NumPixel to provide a unique access facility. | |
| uint16_t | GrPixel |
| In some cases (e.g. for some ACR-NEMA images) the header entry for the group of pixels is *not* found at 0x7fe0. In order to make things easier the parser shall store the proper value in GrPixel to provide a unique access facility. | |
| std::string | Filename |
| Refering underlying filename. | |
| int | SwapCode |
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
| |
| bool | Group0002Parsed |
| whether we already parsed group 0002 (Meta Elements) | |
| bool | HasDCMPreamble |
| whether file has a DCM Preamble | |
| std::ifstream * | Fp |
| File Pointer, opened during Document parsing. | |
| FileType | Filetype |
| ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown. | |
| ListElements | AnonymizeList |
| List of element to Anonymize. | |
| int | PrintLevel |
| Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Static Protected Attributes | |
| const unsigned int | HEADER_LENGTH_TO_READ |
| After opening the file, we read HEADER_LENGTH_TO_READ bytes. | |
| const unsigned int | MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff |
| Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded. | |
| const unsigned int | MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff |
| Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE are NOT printed. | |
Private Member Functions | |
| void | ComputeRLEInfo () |
| Parse pixel data from disk of [multi-]fragment RLE encoding. Compute the RLE extra information and store it in RLEInfo for later pixel retrieval usage. | |
| void | ComputeJPEGFragmentInfo () |
| Parse pixel data from disk of [multi-]fragment Jpeg encoding. Compute the jpeg extra information (fragment[s] offset[s] and length) and store it[them] in JPEGInfo for later pixel retrieval usage. | |
| bool | ReadTag (uint16_t, uint16_t) |
| Assuming the internal file pointer Document::Fp is placed at the beginning of a tag check whether this tag is (TestGroup, TestElement). | |
| uint32_t | ReadTagLength (uint16_t, uint16_t) |
| Assuming the internal file pointer Document::Fp is placed at the beginning of a tag (TestGroup, TestElement), read the length associated to the Tag. | |
| void | ReadAndSkipEncapsulatedBasicOffsetTable () |
| When parsing the Pixel Data of an encapsulated file, read the basic offset table (when present, and BTW dump it). | |
The typical usage of instances of class File is to classify a set of dicom files according to header information e.g. to create a file hierarchy reflecting the Patient/Study/Serie informations, or extracting a given SerieId. Accessing the content (image[s] or volume[s]) is beyond the functionality of this class and belongs to gdmcFile.
The File::Set*Tag* family members cannot be defined as protected due to Swig limitations for as Has_a dependency between File and FileHelper.
Definition at line 95 of file gdcmFile.h.
|
|
Definition at line 47 of file gdcmDocument.h. |
|
|
Constructor used when we want to generate dicom files from scratch.
Definition at line 152 of file gdcmFile.cxx. References InitializeDefaultFile(), JPEGInfo, and RLEInfo.
00152 : 00153 Document() 00154 { 00155 RLEInfo = new RLEFramesInfo; 00156 JPEGInfo = new JPEGFragmentsInfo; 00157 InitializeDefaultFile(); 00158 } |
|
|
Constructor.
Definition at line 53 of file gdcmFile.cxx. References gdcm::ElementSet::AddEntry(), gdcm::Document::CloseFile(), ComputeJPEGFragmentInfo(), ComputeRLEInfo(), gdcm::ContentEntry::Copy(), gdcm::GDCM_UNFOUND, gdcm::BinEntry::GetBinArea(), GetBitsAllocated(), gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryValue(), gdcm::DocEntry::GetOffset(), gdcm::Document::GetTransferSyntax(), gdcm::DocEntry::GetVR(), GrPixel, gdcm::BinEntry::IsSelfArea(), JPEGInfo, gdcm::DocEntrySet::NewVirtualDictEntry(), NumPixel, gdcm::Document::OpenFile(), gdcm::ElementSet::RemoveEntry(), RLEInfo, gdcm::BinEntry::SetBinArea(), and gdcm::BinEntry::SetSelfArea().
00054 :Document( filename ) 00055 { 00056 RLEInfo = new RLEFramesInfo; 00057 JPEGInfo = new JPEGFragmentsInfo; 00058 00059 // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 00060 // We may encounter the 'RETired' (0x0028, 0x0200) tag 00061 // (Image Location") . This entry contains the number of 00062 // the group that contains the pixel data (hence the "Pixel Data" 00063 // is found by indirection through the "Image Location"). 00064 // Inside the group pointed by "Image Location" the searched element 00065 // is conventionally the element 0x0010 (when the norm is respected). 00066 // When the "Image Location" is missing we default to group 0x7fe0. 00067 // Note: this IS the right place for the code 00068 00069 // Image Location 00070 const std::string &imgLocation = GetEntryValue(0x0028, 0x0200); 00071 if ( imgLocation == GDCM_UNFOUND ) 00072 { 00073 // default value 00074 GrPixel = 0x7fe0; 00075 } 00076 else 00077 { 00078 GrPixel = (uint16_t) atoi( imgLocation.c_str() ); 00079 } 00080 00081 // sometimes Image Location value doesn't follow 00082 // the supposed processor endianness. 00083 // see gdcmData/cr172241.dcm 00084 if ( GrPixel == 0xe07f ) 00085 { 00086 GrPixel = 0x7fe0; 00087 } 00088 00089 if ( GrPixel != 0x7fe0 ) 00090 { 00091 // This is a kludge for old dirty Philips imager. 00092 NumPixel = 0x1010; 00093 } 00094 else 00095 { 00096 NumPixel = 0x0010; 00097 } 00098 00099 // Now, we know GrPixel and NumPixel. 00100 // Let's create a VirtualDictEntry to allow a further VR modification 00101 // and force VR to match with BitsAllocated. 00102 DocEntry *entry = GetDocEntry(GrPixel, NumPixel); 00103 if ( entry != 0 ) 00104 { 00105 // Compute the RLE or JPEG info 00106 OpenFile(); 00107 std::string ts = GetTransferSyntax(); 00108 Fp->seekg( entry->GetOffset(), std::ios::beg ); 00109 if ( Global::GetTS()->IsRLELossless(ts) ) 00110 ComputeRLEInfo(); 00111 else if ( Global::GetTS()->IsJPEG(ts) ) 00112 ComputeJPEGFragmentInfo(); 00113 CloseFile(); 00114 00115 // Create a new BinEntry to change the the DictEntry 00116 // The changed DictEntry will have 00117 // - a correct PixelVR OB or OW) 00118 // - a VM to "PXL" 00119 // - the name to "Pixel Data" 00120 BinEntry *oldEntry = dynamic_cast<BinEntry *>(entry); 00121 if(oldEntry) 00122 { 00123 std::string PixelVR; 00124 // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB) 00125 // more than 8 (i.e 12, 16) is a 'O Words' 00126 if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) 00127 PixelVR = "OB"; 00128 else 00129 PixelVR = "OW"; 00130 00131 // Change only made if usefull 00132 if( PixelVR != oldEntry->GetVR() ) 00133 { 00134 DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel, 00135 PixelVR,"1","Pixel Data"); 00136 00137 BinEntry *newEntry = new BinEntry(newDict); 00138 newEntry->Copy(entry); 00139 newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea()); 00140 oldEntry->SetSelfArea(false); 00141 00142 RemoveEntry(oldEntry); 00143 AddEntry(newEntry); 00144 } 00145 } 00146 } 00147 } |
|
|
Canonical destructor.
Definition at line 163 of file gdcmFile.cxx. References JPEGInfo, and RLEInfo.
|
|
||||||||||||||||
|
Adds the characteristics of a new element we want to anonymize.
Definition at line 1144 of file gdcmFile.cxx. References gdcm::Element::Elem, gdcm::Element::Group, and gdcm::Element::Value.
01147 {
01148 Element el;
01149 el.Group = group;
01150 el.Elem = elem;
01151 el.Value = value;
01152 AnonymizeList.push_back(el);
01153 }
|
|
|
add a new Dicom Element pointer to the H Table
Implements gdcm::DocEntrySet. Definition at line 69 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by File(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().
00070 {
00071 const TagKey &key = newEntry->GetKey();
00072
00073 if( TagHT.count(key) == 1 )
00074 {
00075 gdcmWarningMacro( "Key already present: " << key.c_str());
00076 return false;
00077 }
00078 else
00079 {
00080 TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
00081 return true;
00082 }
00083 }
|
|
|
anonymize a File (removes Patient's personal info passed with AddAnonymizeElement()
Definition at line 1206 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryValue(), and gdcm::DocEntrySet::SetValEntry().
01207 {
01208 // If Anonymisation list is empty, let's perform some basic anonymization
01209 if ( AnonymizeList.begin() == AnonymizeList.end() )
01210 {
01211 // If exist, replace by spaces
01212 SetValEntry (" ",0x0010, 0x2154); // Telephone
01213 SetValEntry (" ",0x0010, 0x1040); // Adress
01214 SetValEntry (" ",0x0010, 0x0020); // Patient ID
01215
01216 DocEntry* patientNameHE = GetDocEntry (0x0010, 0x0010);
01217
01218 if ( patientNameHE ) // we replace it by Study Instance UID (why not ?)
01219 {
01220 std::string studyInstanceUID = GetEntryValue (0x0020, 0x000d);
01221 if ( studyInstanceUID != GDCM_UNFOUND )
01222 {
01223 SetValEntry(studyInstanceUID, 0x0010, 0x0010);
01224 }
01225 else
01226 {
01227 SetValEntry("anonymised", 0x0010, 0x0010);
01228 }
01229 }
01230 }
01231 else
01232 {
01233 gdcm::DocEntry *d;
01234 for (ListElements::iterator it = AnonymizeList.begin();
01235 it != AnonymizeList.end();
01236 ++it)
01237 {
01238 d = GetDocEntry( (*it).Group, (*it).Elem);
01239
01240 if ( d == NULL)
01241 continue;
01242
01243 if ( dynamic_cast<BinEntry *>(d)
01244 || dynamic_cast<SeqEntry *>(d) )
01245 continue;
01246
01247 SetValEntry ((*it).Value, (*it).Group, (*it).Elem);
01248 }
01249 }
01250
01251 // In order to make definitively impossible any further identification
01252 // remove or replace all the stuff that contains a Date
01253
01254 //0008 0012 DA ID Instance Creation Date
01255 //0008 0020 DA ID Study Date
01256 //0008 0021 DA ID Series Date
01257 //0008 0022 DA ID Acquisition Date
01258 //0008 0023 DA ID Content Date
01259 //0008 0024 DA ID Overlay Date
01260 //0008 0025 DA ID Curve Date
01261 //0008 002a DT ID Acquisition Datetime
01262 //0018 9074 DT ACQ Frame Acquisition Datetime
01263 //0018 9151 DT ACQ Frame Reference Datetime
01264 //0018 a002 DT ACQ Contribution Date Time
01265 //0020 3403 SH REL Modified Image Date (RET)
01266 //0032 0032 DA SDY Study Verified Date
01267 //0032 0034 DA SDY Study Read Date
01268 //0032 1000 DA SDY Scheduled Study Start Date
01269 //0032 1010 DA SDY Scheduled Study Stop Date
01270 //0032 1040 DA SDY Study Arrival Date
01271 //0032 1050 DA SDY Study Completion Date
01272 //0038 001a DA VIS Scheduled Admission Date
01273 //0038 001c DA VIS Scheduled Discharge Date
01274 //0038 0020 DA VIS Admitting Date
01275 //0038 0030 DA VIS Discharge Date
01276 //0040 0002 DA PRC Scheduled Procedure Step Start Date
01277 //0040 0004 DA PRC Scheduled Procedure Step End Date
01278 //0040 0244 DA PRC Performed Procedure Step Start Date
01279 //0040 0250 DA PRC Performed Procedure Step End Date
01280 //0040 2004 DA PRC Issue Date of Imaging Service Request
01281 //0040 4005 DT PRC Scheduled Procedure Step Start Date and Time
01282 //0040 4011 DT PRC Expected Completion Date and Time
01283 //0040 a030 DT PRC Verification Date Time
01284 //0040 a032 DT PRC Observation Date Time
01285 //0040 a120 DT PRC DateTime
01286 //0040 a121 DA PRC Date
01287 //0040 a13a DT PRC Referenced Datetime
01288 //0070 0082 DA ??? Presentation Creation Date
01289 //0100 0420 DT ??? SOP Autorization Date and Time
01290 //0400 0105 DT ??? Digital Signature DateTime
01291 //2100 0040 DA PJ Creation Date
01292 //3006 0008 DA SSET Structure Set Date
01293 //3008 0024 DA ??? Treatment Control Point Date
01294 //3008 0054 DA ??? First Treatment Date
01295 //3008 0056 DA ??? Most Recent Treatment Date
01296 //3008 0162 DA ??? Safe Position Exit Date
01297 //3008 0166 DA ??? Safe Position Return Date
01298 //3008 0250 DA ??? Treatment Date
01299 //300a 0006 DA RT RT Plan Date
01300 //300a 022c DA RT Air Kerma Rate Reference Date
01301 //300e 0004 DA RT Review Date
01302
01303 return true;
01304 }
|
|
|
Overwrites in the file the values of the DicomElements held in the list.
Definition at line 1159 of file gdcmFile.cxx. References gdcm::ElementSet::GetDocEntry(), gdcm::DocEntry::GetLength(), and gdcm::DocEntry::GetOffset().
01160 {
01161 std::fstream *fp = new std::fstream(Filename.c_str(),
01162 std::ios::in | std::ios::out | std::ios::binary);
01163
01164 // TODO : FIXME
01165 // how to white out disk space if longer than 50 ?
01166
01167
01168 gdcm::DocEntry *d;
01169 uint32_t offset;
01170 uint32_t lgth;
01171 uint32_t valLgth;
01172 std::string *spaces;
01173 for (ListElements::iterator it = AnonymizeList.begin();
01174 it != AnonymizeList.end();
01175 ++it)
01176 {
01177 d = GetDocEntry( (*it).Group, (*it).Elem);
01178
01179 if ( d == NULL)
01180 continue;
01181
01182 if ( dynamic_cast<BinEntry *>(d)
01183 || dynamic_cast<SeqEntry *>(d) )
01184 continue;
01185
01186 offset = d->GetOffset();
01187 lgth = d->GetLength();
01188 if (valLgth < lgth)
01189 {
01190 spaces = new std::string( lgth-valLgth, ' ');
01191 (*it).Value = (*it).Value + *spaces;
01192 delete spaces;
01193 }
01194 fp->seekp( offset, std::ios::beg );
01195 fp->write( (*it).Value.c_str(), lgth );
01196
01197 }
01198 fp->close();
01199 delete fp;
01200 }
|
|
||||||||||||
|
Checks if a given Dicom Element exists within the H table.
Definition at line 434 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry().
00435 {
00436 return GetDocEntry(group,elem)!=NULL;
00437 }
|
|
|
Clears the list of elements to be anonymized.
Definition at line 162 of file gdcmFile.h.
00162 { AnonymizeList.clear(); }
|
|
|
delete all entries in the ElementSet
Implements gdcm::DocEntrySet. Definition at line 125 of file gdcmElementSet.cxx. References gdcm::ElementSet::TagHT. Referenced by gdcm::DicomDir::CreateDicomDir(), gdcm::DicomDir::SetElements(), and gdcm::ElementSet::~ElementSet().
00126 {
00127 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
00128 {
00129 if ( cc->second )
00130 {
00131 delete cc->second;
00132 }
00133 }
00134 TagHT.clear();
00135 }
|
|
|
closes the file
Definition at line 464 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by gdcm::Document::Document(), File(), gdcm::FileHelper::GetRaw(), gdcm::Document::LoadEntryBinArea(), and gdcm::Document::OpenFile().
|
|
|
Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader.
Definition at line 717 of file gdcmDocument.cxx. References gdcm::ExplicitVR, gdcm::DocEntry::GetElement(), gdcm::ElementSet::GetFirstEntry(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ElementSet::GetNextEntry(), and gdcm::DocEntry::GetVR(). Referenced by Write().
00718 {
00719 uint16_t gr;
00720 std::string vr;
00721
00722 int groupLength = 0;
00723 bool found0002 = false;
00724
00725 // for each zero-level Tag in the DCM Header
00726 DocEntry *entry = GetFirstEntry();
00727 while( entry )
00728 {
00729 gr = entry->GetGroup();
00730
00731 if( gr == 0x0002 )
00732 {
00733 found0002 = true;
00734
00735 if( entry->GetElement() != 0x0000 )
00736 {
00737 vr = entry->GetVR();
00738
00739 if( filetype == ExplicitVR )
00740 {
00741 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") )
00742 {
00743 // explicit VR AND OB, OW, SQ : 4 more bytes
00744 groupLength += 4;
00745 }
00746 }
00747 groupLength += 2 + 2 + 4 + entry->GetLength();
00748 }
00749 }
00750 else if (found0002 )
00751 break;
00752
00753 entry = GetNextEntry();
00754 }
00755 return groupLength;
00756 }
|
|
|
Parse pixel data from disk of [multi-]fragment Jpeg encoding. Compute the jpeg extra information (fragment[s] offset[s] and length) and store it[them] in JPEGInfo for later pixel retrieval usage.
Definition at line 1588 of file gdcmFile.cxx. References gdcm::JPEGFragmentsInfo::AddFragment(), gdcmWarningMacro, gdcm::Document::GetTransferSyntax(), JPEGInfo, ReadAndSkipEncapsulatedBasicOffsetTable(), ReadTag(), ReadTagLength(), gdcm::JPEGFragment::SetLength(), gdcm::JPEGFragment::SetOffset(), and gdcm::Document::SkipBytes(). Referenced by File().
01589 {
01590 // If you need to, look for comments of ComputeRLEInfo().
01591 std::string ts = GetTransferSyntax();
01592 if ( ! Global::GetTS()->IsJPEG(ts) )
01593 {
01594 return;
01595 }
01596
01597 ReadAndSkipEncapsulatedBasicOffsetTable();
01598
01599 // Loop on the fragments[s] and store the parsed information in a
01600 // JPEGInfo.
01601 long fragmentLength;
01602 while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) )
01603 {
01604 long fragmentOffset = Fp->tellg();
01605
01606 // Store the collected info
01607 JPEGFragment *newFragment = new JPEGFragment;
01608 newFragment->SetOffset(fragmentOffset);
01609 newFragment->SetLength(fragmentLength);
01610 JPEGInfo->AddFragment(newFragment);
01611
01612 SkipBytes(fragmentLength);
01613 }
01614
01615 // Make sure that at the end of the item we encounter a 'Sequence
01616 // Delimiter Item':
01617 if ( !ReadTag(0xfffe, 0xe0dd) )
01618 {
01619 gdcmWarningMacro( "No sequence delimiter item at end of JPEG item sequence");
01620 }
01621 }
|
|
|
Parse pixel data from disk of [multi-]fragment RLE encoding. Compute the RLE extra information and store it in RLEInfo for later pixel retrieval usage.
Definition at line 1492 of file gdcmFile.cxx. References gdcm::RLEFramesInfo::AddFrame(), gdcmWarningMacro, gdcm::Document::GetTransferSyntax(), ReadAndSkipEncapsulatedBasicOffsetTable(), gdcm::Document::ReadInt32(), ReadTag(), ReadTagLength(), RLEInfo, gdcm::RLEFrame::SetLength(), gdcm::RLEFrame::SetNumberOfFragments(), gdcm::RLEFrame::SetOffset(), and gdcm::Document::SkipBytes(). Referenced by File().
01493 {
01494 std::string ts = GetTransferSyntax();
01495 if ( !Global::GetTS()->IsRLELossless(ts) )
01496 {
01497 return;
01498 }
01499
01500 // Encoded pixel data: for the time being we are only concerned with
01501 // Jpeg or RLE Pixel data encodings.
01502 // As stated in PS 3.5-2003, section 8.2 p44:
01503 // "If sent in Encapsulated Format (i.e. other than the Native Format) the
01504 // value representation OB is used".
01505 // Hence we expect an OB value representation. Concerning OB VR,
01506 // the section PS 3.5-2003, section A.4.c p 58-59, states:
01507 // "For the Value Representations OB and OW, the encoding shall meet the
01508 // following specifications depending on the Data element tag:"
01509 // [...snip...]
01510 // - the first item in the sequence of items before the encoded pixel
01511 // data stream shall be basic offset table item. The basic offset table
01512 // item value, however, is not required to be present"
01513 ReadAndSkipEncapsulatedBasicOffsetTable();
01514
01515 // Encapsulated RLE Compressed Images (see PS 3.5-2003, Annex G)
01516 // Loop on the individual frame[s] and store the information
01517 // on the RLE fragments in a RLEFramesInfo.
01518 // Note: - when only a single frame is present, this is a
01519 // classical image.
01520 // - when more than one frame are present, then we are in
01521 // the case of a multi-frame image.
01522 long frameLength;
01523 while ( (frameLength = ReadTagLength(0xfffe, 0xe000)) )
01524 {
01525 // Parse the RLE Header and store the corresponding RLE Segment
01526 // Offset Table information on fragments of this current Frame.
01527 // Note that the fragment pixels themselves are not loaded
01528 // (but just skipped).
01529 long frameOffset = Fp->tellg();
01530
01531 uint32_t nbRleSegments = ReadInt32();
01532 if ( nbRleSegments > 16 )
01533 {
01534 // There should be at most 15 segments (refer to RLEFrame class)
01535 gdcmWarningMacro( "Too many segments.");
01536 }
01537
01538 uint32_t rleSegmentOffsetTable[16];
01539 for( int k = 1; k <= 15; k++ )
01540 {
01541 rleSegmentOffsetTable[k] = ReadInt32();
01542 }
01543
01544 // Deduce from both the RLE Header and the frameLength the
01545 // fragment length, and again store this info in a
01546 // RLEFramesInfo.
01547 long rleSegmentLength[15];
01548 // skipping (not reading) RLE Segments
01549 if ( nbRleSegments > 1)
01550 {
01551 for(unsigned int k = 1; k <= nbRleSegments-1; k++)
01552 {
01553 rleSegmentLength[k] = rleSegmentOffsetTable[k+1]
01554 - rleSegmentOffsetTable[k];
01555 SkipBytes(rleSegmentLength[k]);
01556 }
01557 }
01558
01559 rleSegmentLength[nbRleSegments] = frameLength
01560 - rleSegmentOffsetTable[nbRleSegments];
01561 SkipBytes(rleSegmentLength[nbRleSegments]);
01562
01563 // Store the collected info
01564 RLEFrame *newFrame = new RLEFrame;
01565 newFrame->SetNumberOfFragments(nbRleSegments);
01566 for( unsigned int uk = 1; uk <= nbRleSegments; uk++ )
01567 {
01568 newFrame->SetOffset(uk,frameOffset + rleSegmentOffsetTable[uk]);
01569 newFrame->SetLength(uk,rleSegmentLength[uk]);
01570 }
01571 RLEInfo->AddFrame(newFrame);
01572 }
01573
01574 // Make sure that at the end of the item we encounter a 'Sequence
01575 // Delimiter Item':
01576 if ( !ReadTag(0xfffe, 0xe0dd) )
01577 {
01578 gdcmWarningMacro( "No sequence delimiter item at end of RLE item sequence");
01579 }
01580 }
|
|
||||||||||||
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry.
Definition at line 127 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry(). Referenced by gdcm::DocEntrySet::GetEntryBinArea(), and gdcm::DocEntrySet::SetBinEntry().
00128 {
00129 DocEntry *currentEntry = GetDocEntry(group, elem);
00130 if ( !currentEntry )
00131 {
00132 gdcmWarningMacro( "No corresponding BinEntry " << std::hex << group <<
00133 "," << elem);
00134 return NULL;
00135 }
00136
00137 return dynamic_cast<BinEntry*>(currentEntry);
00138 }
|
|
|
Retrieve the number of Bits Allocated (8, 12 -compacted ACR-NEMA files, 16, ...).
Definition at line 675 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), File(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().
00676 {
00677 std::string strSize = GetEntryValue(0x0028,0x0100);
00678 if ( strSize == GDCM_UNFOUND )
00679 {
00680 gdcmWarningMacro( "(0028,0100) is supposed to be mandatory");
00681 return 0; // It's supposed to be mandatory
00682 // the caller will have to check
00683 }
00684 return atoi( strSize.c_str() );
00685 }
|
|
|
Retrieve the number of Bits Stored (actually used) (as opposed to number of Bits Allocated).
Definition at line 657 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00658 {
00659 std::string strSize = GetEntryValue( 0x0028, 0x0101 );
00660 if ( strSize == GDCM_UNFOUND )
00661 {
00662 gdcmWarningMacro("(0028,0101) is supposed to be mandatory");
00663 return 0; // It's supposed to be mandatory
00664 // the caller will have to check
00665 }
00666 return atoi( strSize.c_str() );
00667 }
|
|
||||||||||||||||
|
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.
Definition at line 558 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNKNOWN, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetName(), gdcm::DictEntry::GetVR(), gdcm::DocEntrySet::NewVirtualDictEntry(), and gdcm::TagName.
00560 {
00561 DictEntry *dictEntry = GetDictEntry(group,elem);
00562 DictEntry *goodEntry = dictEntry;
00563 std::string goodVR = vr;
00564
00565 if (elem == 0x0000) goodVR="UL";
00566
00567 if ( goodEntry )
00568 {
00569 if ( goodVR != goodEntry->GetVR()
00570 && goodVR != GDCM_UNKNOWN )
00571 {
00572 goodEntry = NULL;
00573 }
00574 }
00575
00576 // Create a new virtual DictEntry if necessary
00577 if (!goodEntry)
00578 {
00579 if (dictEntry)
00580 {
00581 goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME",
00582 dictEntry->GetName() );
00583 }
00584 else
00585 {
00586 goodEntry = NewVirtualDictEntry(group, elem, goodVR);
00587 }
00588 }
00589 return goodEntry;
00590 }
|
|
||||||||||||
|
Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one.
Definition at line 534 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::Dict::GetEntry(). Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::DocEntrySet::NewValEntry(), and gdcm::Document::ReadNextDocEntry().
00535 {
00536 DictEntry *found = 0;
00537 Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
00538 if (!pubDict)
00539 {
00540 gdcmWarningMacro( "We SHOULD have a default dictionary");
00541 }
00542 else
00543 {
00544 found = pubDict->GetEntry(group, elem);
00545 }
00546 return found;
00547 }
|
|
||||||||||||
|
||||||||||||
|
Gets (from Header) a 'non string' element value.
Definition at line 57 of file gdcmDocEntrySet.cxx. References gdcm::BinEntry::GetBinArea(), and gdcm::DocEntrySet::GetBinEntry(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00058 {
00059 BinEntry *entry = GetBinEntry(group, elem);
00060 if( entry )
00061 return entry->GetBinArea();
00062 return 0;
00063 }
|
|
||||||||||||
|
Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..
Definition at line 73 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength(). Referenced by gdcm::DicomDir::SetElement(), and Write().
00074 {
00075 DocEntry *entry = GetDocEntry(group, elem);
00076 if( entry )
00077 return entry->GetLength();
00078 return -1;
00079 }
|
|
||||||||||||
|
Get the "std::string representable" value of the Dicom entry.
Definition at line 43 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::ContentEntry::GetValue(). Referenced by gdcm::SerieHelper::AddFileName(), AnonymizeFile(), gdcm::Document::Document(), File(), GetBitsAllocated(), GetBitsStored(), GetHighBitPosition(), GetImageNumber(), GetImageOrientationPatient(), GetLUTNbits(), GetModality(), GetNumberOfScalarComponents(), GetPixelType(), GetPlanarConfiguration(), GetRescaleIntercept(), GetRescaleSlope(), GetSamplesPerPixel(), gdcm::Document::GetTransferSyntaxName(), GetXOrigin(), GetXSize(), GetXSpacing(), GetYOrigin(), GetYSize(), GetYSpacing(), GetZOrigin(), GetZSize(), GetZSpacing(), gdcm::PixelReadConvert::GrabInformationsFromFile(), IsMonochrome(), IsPaletteColor(), IsReadable(), IsSignedPixelData(), IsYBRFull(), gdcm::Document::operator<(), gdcm::DicomDir::SetElement(), and Write().
00044 {
00045 ContentEntry *entry = dynamic_cast<ContentEntry *>(GetDocEntry(group,elem));
00046 if( entry )
00047 return entry->GetValue();
00048 return GDCM_UNFOUND;
00049 }
|
|
||||||||||||
|
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.
Definition at line 94 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetVR().
00095 {
00096 DocEntry *entry = GetDocEntry(group, elem);
00097 if( entry )
00098 return entry->GetVR();
00099 return GDCM_UNFOUND;
00100 }
|
|
|
Accessor to Filename.
Definition at line 79 of file gdcmDocument.h. Referenced by gdcm::SerieHelper::FileNameLessThan(), gdcm::DicomDir::ParseDirectory(), and gdcm::DicomDir::SetElement().
00079 { return Filename; }
|
|
|
returns the File Type (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
Definition at line 276 of file gdcmDocument.cxx. References gdcm::Document::Filetype, and gdcm::FileType.
00277 {
00278 return Filetype;
00279 }
|
|
|
Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 142 of file gdcmElementSet.cxx. References gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDir::DicomDir(), and gdcm::DicomDir::NewMeta().
00143 {
00144 ItTagHT = TagHT.begin();
00145 if (ItTagHT != TagHT.end())
00146 return ItTagHT->second;
00147 return NULL;
00148 }
|
|
|
Accessor to File::GrPixel.
Definition at line 146 of file gdcmFile.h.
00146 { return GrPixel; }
|
|
|
Retrieve the high bit position.
Definition at line 693 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00694 {
00695 std::string strSize = GetEntryValue( 0x0028, 0x0102 );
00696 if ( strSize == GDCM_UNFOUND )
00697 {
00698 gdcmWarningMacro( "(0028,0102) is supposed to be mandatory");
00699 return 0;
00700 }
00701 return atoi( strSize.c_str() );
00702 }
|
|
|
gets the info from 0020,0013 : Image Number else 0.
Definition at line 217 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::SerieHelper::ImageNumberLessThan().
00218 {
00219 // The function i atoi() takes the address of an area of memory as
00220 // parameter and converts the string stored at that location to an integer
00221 // using the external decimal to internal binary conversion rules. This may
00222 // be preferable to sscanf() since atoi() is a much smaller, simpler and
00223 // faster function. sscanf() can do all possible conversions whereas
00224 // atoi() can only do single decimal integer conversions.
00225 //0020 0013 IS REL Image Number
00226 std::string strImNumber = GetEntryValue(0x0020,0x0013);
00227 if ( strImNumber != GDCM_UNFOUND )
00228 {
00229 return atoi( strImNumber.c_str() );
00230 }
00231 return 0; //Hopeless
00232 }
|
|
|
gets the info from 0020,0037 : Image Orientation Patient (needed to organize DICOM files based on their x,y,z position)
Definition at line 624 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
00625 {
00626 std::string strImOriPat;
00627 //iop is supposed to be float[6]
00628 iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.;
00629
00630 // 0020 0037 DS REL Image Orientation (Patient)
00631 if ( (strImOriPat = GetEntryValue(0x0020,0x0037)) != GDCM_UNFOUND )
00632 {
00633 if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
00634 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
00635 {
00636 gdcmWarningMacro( "Wrong Image Orientation Patient (0020,0037). Less than 6 values were found." );
00637 }
00638 }
00639 //For ACR-NEMA
00640 // 0020 0035 DS REL Image Orientation (RET)
00641 else if ( (strImOriPat = GetEntryValue(0x0020,0x0035)) != GDCM_UNFOUND )
00642 {
00643 if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
00644 &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
00645 {
00646 gdcmWarningMacro( "wrong Image Orientation Patient (0020,0035). Less than 6 values were found." );
00647 }
00648 }
00649 }
|
|
|
Returns the JPEG Fragments info.
Definition at line 156 of file gdcmFile.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00156 { return JPEGInfo; }
|
|
|
gets the info from 0028,1101 : Lookup Table Desc-Red else 0
Definition at line 961 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, and gdcm::DocEntrySet::GetEntryValue().
00962 {
00963 std::vector<std::string> tokens;
00964 int lutNbits;
00965
00966 //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red
00967 // = Lookup Table Desc-Blue
00968 // Consistency already checked in GetLUTLength
00969 std::string lutDescription = GetEntryValue(0x0028,0x1101);
00970 if ( lutDescription == GDCM_UNFOUND )
00971 {
00972 return 0;
00973 }
00974
00975 tokens.clear(); // clean any previous value
00976 Util::Tokenize ( lutDescription, tokens, "\\" );
00977 //LutLength=atoi(tokens[0].c_str());
00978 //LutDepth=atoi(tokens[1].c_str());
00979
00980 lutNbits = atoi( tokens[2].c_str() );
00981 tokens.clear();
00982
00983 return lutNbits;
00984 }
|
|
|
gets the info from 0008,0060 : Modality
Definition at line 238 of file gdcmFile.cxx. References gdcm::AS, gdcm::AU, gdcm::BI, gdcm::CF, gdcm::CP, gdcm::CR, gdcm::CS, gdcm::CT, gdcm::DD, gdcm::DF, gdcm::DG, gdcm::DM, gdcm::DS, gdcm::DX, gdcm::ECG, gdcm::EPS, gdcm::FA, gdcm::FS, gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryValue(), gdcm::HC, gdcm::HD, gdcm::LP, gdcm::LS, gdcm::MA, gdcm::ModalityType, gdcm::MR, gdcm::NM, gdcm::OT, gdcm::PT, gdcm::RF, gdcm::RG, gdcm::RTDOSE, gdcm::RTIMAGE, gdcm::RTPLAN, gdcm::RTSTRUCT, gdcm::SM, gdcm::ST, gdcm::TG, gdcm::Unknow, gdcm::US, gdcm::VF, gdcm::XA, and gdcm::XC.
00239 {
00240 // 0008 0060 CS ID Modality
00241 std::string strModality = GetEntryValue(0x0008,0x0060);
00242 if ( strModality != GDCM_UNFOUND )
00243 {
00244 if ( strModality.find("AU") < strModality.length()) return AU;
00245 else if ( strModality.find("AS") < strModality.length()) return AS;
00246 else if ( strModality.find("BI") < strModality.length()) return BI;
00247 else if ( strModality.find("CF") < strModality.length()) return CF;
00248 else if ( strModality.find("CP") < strModality.length()) return CP;
00249 else if ( strModality.find("CR") < strModality.length()) return CR;
00250 else if ( strModality.find("CT") < strModality.length()) return CT;
00251 else if ( strModality.find("CS") < strModality.length()) return CS;
00252 else if ( strModality.find("DD") < strModality.length()) return DD;
00253 else if ( strModality.find("DF") < strModality.length()) return DF;
00254 else if ( strModality.find("DG") < strModality.length()) return DG;
00255 else if ( strModality.find("DM") < strModality.length()) return DM;
00256 else if ( strModality.find("DS") < strModality.length()) return DS;
00257 else if ( strModality.find("DX") < strModality.length()) return DX;
00258 else if ( strModality.find("ECG") < strModality.length()) return ECG;
00259 else if ( strModality.find("EPS") < strModality.length()) return EPS;
00260 else if ( strModality.find("FA") < strModality.length()) return FA;
00261 else if ( strModality.find("FS") < strModality.length()) return FS;
00262 else if ( strModality.find("HC") < strModality.length()) return HC;
00263 else if ( strModality.find("HD") < strModality.length()) return HD;
00264 else if ( strModality.find("LP") < strModality.length()) return LP;
00265 else if ( strModality.find("LS") < strModality.length()) return LS;
00266 else if ( strModality.find("MA") < strModality.length()) return MA;
00267 else if ( strModality.find("MR") < strModality.length()) return MR;
00268 else if ( strModality.find("NM") < strModality.length()) return NM;
00269 else if ( strModality.find("OT") < strModality.length()) return OT;
00270 else if ( strModality.find("PT") < strModality.length()) return PT;
00271 else if ( strModality.find("RF") < strModality.length()) return RF;
00272 else if ( strModality.find("RG") < strModality.length()) return RG;
00273 else if ( strModality.find("RTDOSE") < strModality.length()) return RTDOSE;
00274 else if ( strModality.find("RTIMAGE") < strModality.length()) return RTIMAGE;
00275 else if ( strModality.find("RTPLAN") < strModality.length()) return RTPLAN;
00276 else if ( strModality.find("RTSTRUCT") < strModality.length()) return RTSTRUCT;
00277 else if ( strModality.find("SM") < strModality.length()) return SM;
00278 else if ( strModality.find("ST") < strModality.length()) return ST;
00279 else if ( strModality.find("TG") < strModality.length()) return TG;
00280 else if ( strModality.find("US") < strModality.length()) return US;
00281 else if ( strModality.find("VF") < strModality.length()) return VF;
00282 else if ( strModality.find("XA") < strModality.length()) return XA;
00283 else if ( strModality.find("XC") < strModality.length()) return XC;
00284
00285 else
00286 {
00289 return Unknow;
00290 }
00291 }
00292
00293 return Unknow;
00294 }
|
|
|
Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
Implements gdcm::DocEntrySet. Definition at line 156 of file gdcmElementSet.cxx. References gdcmAssertMacro, gdcm::ElementSet::ItTagHT, and gdcm::ElementSet::TagHT. Referenced by gdcm::Document::ComputeGroup0002Length().
00157 {
00158 gdcmAssertMacro (ItTagHT != TagHT.end());
00159
00160 ++ItTagHT;
00161 if (ItTagHT != TagHT.end())
00162 return ItTagHT->second;
00163 return NULL;
00164 }
|
|
|
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 1035 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryValue(), GetSamplesPerPixel(), and HasLUT(). Referenced by vtkGdcmReader::CheckFileCoherence(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().
01036 {
01037 if ( GetSamplesPerPixel() == 3 )
01038 {
01039 return 3;
01040 }
01041
01042 // 0028 0100 US IMG Bits Allocated
01043 // (in order no to be messed up by old RGB images)
01044 if ( GetEntryValue(0x0028,0x0100) == "24" )
01045 {
01046 return 3;
01047 }
01048
01049 std::string strPhotometricInterpretation = GetEntryValue(0x0028,0x0004);
01050
01051 if ( ( strPhotometricInterpretation == "PALETTE COLOR ") )
01052 {
01053 if ( HasLUT() )// PALETTE COLOR is NOT enough
01054 {
01055 return 3;
01056 }
01057 else
01058 {
01059 return 1;
01060 }
01061 }
01062
01063 // beware of trailing space at end of string
01064 // DICOM tags are never of odd length
01065 if ( strPhotometricInterpretation == GDCM_UNFOUND ||
01066 Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME1") ||
01067 Util::DicomStringEqual(strPhotometricInterpretation, "MONOCHROME2") )
01068 {
01069 return 1;
01070 }
01071 else
01072 {
01073 // we assume that *all* kinds of YBR are dealt with
01074 return 3;
01075 }
01076 }
|
|
|
This function is intended to user that DOESN'T want to 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 1085 of file gdcmFile.cxx. References GetSamplesPerPixel(). Referenced by vtkGdcmReader::CheckFileCoherence().
01086 {
01087 // 0028 0100 US IMG Bits Allocated
01088 // (in order no to be messed up by old RGB images)
01089 if ( File::GetEntryValue(0x0028,0x0100) == "24" )
01090 {
01091 return 3;
01092 }
01093
01094 // we assume that *all* kinds of YBR are dealt with
01095 return GetSamplesPerPixel();
01096 }
|
|
|
Accessor to File::NumPixel.
Definition at line 148 of file gdcmFile.h.
00148 { return NumPixel; }
|
|
|
Recover the pixel area length (in Bytes).
Definition at line 1125 of file gdcmFile.cxx. References gdcmDebugMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntry::GetLength(), GrPixel, and NumPixel. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
01126 {
01127 DocEntry *pxlElement = GetDocEntry(GrPixel, NumPixel);
01128 if ( pxlElement )
01129 {
01130 return pxlElement->GetLength();
01131 }
01132 else
01133 {
01134 gdcmDebugMacro( "Big trouble : Pixel Element ("
01135 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found" );
01136 return 0;
01137 }
01138 }
|
|
|
Recover the offset (from the beginning of the file) of *image* pixels (not *icone image* pixels, if any !).
Definition at line 1103 of file gdcmFile.cxx. References gdcmDebugMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntry::GetOffset(), GrPixel, and NumPixel. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
01104 {
01105 DocEntry *pxlElement = GetDocEntry(GrPixel, NumPixel);
01106 if ( pxlElement )
01107 {
01108 return pxlElement->GetOffset();
01109 }
01110 else
01111 {
01112 gdcmDebugMacro( "Big trouble : Pixel Element ("
01113 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found" );
01114 return 0;
01115 }
01116 }
|
|
|
Return the size (in bytes) of a single pixel of data.
Definition at line 743 of file gdcmFile.cxx. References gdcmWarningMacro, and GetPixelType(). Referenced by vtkGdcmReader::CheckFileCoherence(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00744 {
00745 // 0028 0100 US IMG Bits Allocated
00746 // (in order no to be messed up by old RGB images)
00747 // if (File::GetEntryValue(0x0028,0x0100) == "24")
00748 // return 3;
00749
00750 std::string pixelType = GetPixelType();
00751 if ( pixelType == "8U" || pixelType == "8S" )
00752 {
00753 return 1;
00754 }
00755 if ( pixelType == "16U" || pixelType == "16S")
00756 {
00757 return 2;
00758 }
00759 if ( pixelType == "32U" || pixelType == "32S")
00760 {
00761 return 4;
00762 }
00763 if ( pixelType == "FD" )
00764 {
00765 return 8;
00766 }
00767 gdcmWarningMacro( "Unknown pixel type");
00768 return 0;
00769 }
|
|
|
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!).
Definition at line 785 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence(), and GetPixelSize().
00786 {
00787 std::string bitsAlloc = GetEntryValue(0x0028, 0x0100); // Bits Allocated
00788 if ( bitsAlloc == GDCM_UNFOUND )
00789 {
00790 gdcmWarningMacro( "Missing Bits Allocated (0028,0100)");
00791 bitsAlloc = "16"; // default and arbitrary value, not to polute the output
00792 }
00793
00794 if ( bitsAlloc == "64" )
00795 {
00796 return "FD";
00797 }
00798 else if ( bitsAlloc == "12" )
00799 {
00800 // It will be unpacked
00801 bitsAlloc = "16";
00802 }
00803 else if ( bitsAlloc == "24" )
00804 {
00805 // (in order no to be messed up
00806 bitsAlloc = "8"; // by old RGB images)
00807 }
00808
00809 std::string sign = GetEntryValue(0x0028, 0x0103);//"Pixel Representation"
00810
00811 if (sign == GDCM_UNFOUND )
00812 {
00813 gdcmWarningMacro( "Missing Pixel Representation (0028,0103)");
00814 sign = "U"; // default and arbitrary value, not to polute the output
00815 }
00816 else if ( sign == "0" )
00817 {
00818 sign = "U";
00819 }
00820 else
00821 {
00822 sign = "S";
00823 }
00824 return bitsAlloc + sign;
00825 }
|
|
|
Retrieve the Planar Configuration for RGB images (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane).
Definition at line 727 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00728 {
00729 std::string strSize = GetEntryValue(0x0028,0x0006);
00730 if ( strSize == GDCM_UNFOUND )
00731 {
00732 gdcmWarningMacro( "Not found : Planar Configuration (0028,0006)");
00733 return 0;
00734 }
00735 return atoi( strSize.c_str() );
00736 }
|
|
|
Gets the print level for the Dicom Entries.
Definition at line 48 of file gdcmBase.h.
00048 { return PrintLevel; };
|
|
|
Get the public dictionary used.
Definition at line 183 of file gdcmDocument.cxx. References gdcm::Document::RefPubDict. Referenced by gdcm::DicomDir::SetElement().
00184 {
00185 return RefPubDict;
00186 }
|
|
|
gets the info from 0028,1052 : Rescale Intercept
0028 1052 DS IMG Rescale Intercept Definition at line 990 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
00991 {
00992 float resInter = 0.;
00994 const std::string &strRescInter = GetEntryValue(0x0028,0x1052);
00995 if ( strRescInter != GDCM_UNFOUND )
00996 {
00997 if( sscanf( strRescInter.c_str(), "%f", &resInter) != 1 )
00998 {
00999 // bug in the element 0x0028,0x1052
01000 gdcmWarningMacro( "Rescale Intercept (0028,1052) is empty." );
01001 }
01002 }
01003
01004 return resInter;
01005 }
|
|
|
gets the info from 0028,1053 : Rescale Slope
Definition at line 1011 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
01012 {
01013 float resSlope = 1.;
01014 //0028 1053 DS IMG Rescale Slope
01015 std::string strRescSlope = GetEntryValue(0x0028,0x1053);
01016 if ( strRescSlope != GDCM_UNFOUND )
01017 {
01018 if( sscanf( strRescSlope.c_str(), "%f", &resSlope) != 1)
01019 {
01020 // bug in the element 0x0028,0x1053
01021 gdcmWarningMacro( "Rescale Slope (0028,1053) is empty.");
01022 }
01023 }
01024
01025 return resSlope;
01026 }
|
|
|
returns the RLE info
Definition at line 154 of file gdcmFile.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00154 { return RLEInfo; }
|
|
|
Retrieve the number of Samples Per Pixel (1 : gray level, 3 : RGB -1 or 3 Planes-).
Definition at line 710 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::FileHelper::CheckWriteIntegrity(), GetNumberOfScalarComponents(), GetNumberOfScalarComponentsRaw(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00711 {
00712 const std::string &strSize = GetEntryValue(0x0028,0x0002);
00713 if ( strSize == GDCM_UNFOUND )
00714 {
00715 gdcmWarningMacro( "(0028,0002) is supposed to be mandatory");
00716 return 1; // Well, it's supposed to be mandatory ...
00717 // but sometimes it's missing : *we* assume Gray pixels
00718 }
00719 return atoi( strSize.c_str() );
00720 }
|
|
||||||||||||
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.
Definition at line 148 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry().
00149 {
00150 DocEntry *currentEntry = GetDocEntry(group, elem);
00151 if ( !currentEntry )
00152 {
00153 gdcmWarningMacro( "No corresponding SeqEntry " << std::hex << group <<
00154 "," << elem);
00155 return NULL;
00156 }
00157
00158 return dynamic_cast<SeqEntry*>(currentEntry);
00159 }
|
|
|
Get the shadow dictionary used.
Definition at line 191 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict.
00192 {
00193 return RefShaDict;
00194 }
|
|
|
'Swap code' accessor (see SwapCode )
Definition at line 66 of file gdcmDocument.h. Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00066 { return SwapCode; }
|
|
|
Accessor to the Transfer Syntax (when present) of the current document (it internally handles reading the value from disk when only parsing occured).
Definition at line 287 of file gdcmDocument.cxx. References gdcm::GDCM_UNKNOWN, gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), and gdcm::Document::LoadDocEntrySafe(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), File(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::HandleOutOfGroup0002().
00288 {
00289 DocEntry *entry = GetDocEntry(0x0002, 0x0010);
00290 if ( !entry )
00291 {
00292 return GDCM_UNKNOWN;
00293 }
00294
00295 // The entry might be present but not loaded (parsing and loading
00296 // happen at different stages): try loading and proceed with check...
00297 LoadDocEntrySafe(entry);
00298 if (ValEntry *valEntry = dynamic_cast< ValEntry* >(entry) )
00299 {
00300 std::string transfer = valEntry->GetValue();
00301 // The actual transfer (as read from disk) might be padded. We
00302 // first need to remove the potential padding. We can make the
00303 // weak assumption that padding was not executed with digits...
00304 if ( transfer.length() == 0 )
00305 {
00306 // for brain damaged headers
00307 return GDCM_UNKNOWN;
00308 }
00309 while ( !isdigit((unsigned char)transfer[transfer.length()-1]) )
00310 {
00311 transfer.erase(transfer.length()-1, 1);
00312 }
00313 return transfer;
00314 }
00315 return GDCM_UNKNOWN;
00316 }
|
|
|
Accesses the info from 0002,0010 : Transfer Syntax and TS.
Definition at line 322 of file gdcmDocument.cxx. References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcmErrorMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetEntryValue(), and gdcm::TSKey. Referenced by gdcm::Document::HandleOutOfGroup0002().
00323 {
00324 // use the TS (TS : Transfer Syntax)
00325 std::string transferSyntax = GetEntryValue(0x0002,0x0010);
00326
00327 if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) )
00328 {
00329 gdcmErrorMacro( "Transfer Syntax not loaded. " << std::endl
00330 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" );
00331 return "Uncompressed ACR-NEMA";
00332 }
00333 if ( transferSyntax == GDCM_UNFOUND )
00334 {
00335 gdcmWarningMacro( "Unfound Transfer Syntax (0002,0010)");
00336 return "Uncompressed ACR-NEMA";
00337 }
00338
00339 // we do it only when we need it
00340 const TSKey &tsName = Global::GetTS()->GetValue( transferSyntax );
00341
00342 // Global::GetTS() is a global static you shall never try to delete it!
00343 return tsName;
00344 }
|
|
||||||||||||
|
Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry.
Definition at line 110 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::GetDocEntry(). Referenced by gdcm::DocEntrySet::SetValEntry(), and Write().
00111 {
00112 DocEntry *currentEntry = GetDocEntry(group, elem);
00113 if ( !currentEntry )
00114 return NULL;
00115
00116 return dynamic_cast<ValEntry*>(currentEntry);
00117 }
|
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0.
Definition at line 490 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
00491 {
00492 float xImPos, yImPos, zImPos;
00493 std::string strImPos = GetEntryValue(0x0020,0x0032);
00494
00495 if ( strImPos == GDCM_UNFOUND )
00496 {
00497 gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
00498 strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
00499 if ( strImPos == GDCM_UNFOUND )
00500 {
00501 gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
00502 return 0.;
00503 }
00504 }
00505
00506 if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
00507 {
00508 return 0.;
00509 }
00510
00511 return xImPos;
00512 }
|
|
|
Retrieve the number of columns of image.
Definition at line 301 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence(), gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00302 {
00303 const std::string &strSize = GetEntryValue(0x0028,0x0011);
00304 if ( strSize == GDCM_UNFOUND )
00305 {
00306 return 0;
00307 }
00308
00309 return atoi( strSize.c_str() );
00310 }
|
|
|
gets the info from 0028,0030 : Pixel Spacing else 1.0
Definition at line 368 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmAssertMacro, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence().
00369 {
00370 float xspacing = 1.0;
00371 float yspacing = 1.0;
00372 const std::string &strSpacing = GetEntryValue(0x0028,0x0030);
00373
00374 if( strSpacing == GDCM_UNFOUND )
00375 {
00376 gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
00377 return 1.;
00378 }
00379
00380 int nbValues;
00381 if( ( nbValues = sscanf( strSpacing.c_str(),
00382 "%f\\%f", &yspacing, &xspacing)) != 2 )
00383 {
00384 // if no values, xspacing is set to 1.0
00385 if( nbValues == 0 )
00386 xspacing = 1.0;
00387 // if single value is found, xspacing is defaulted to yspacing
00388 if( nbValues == 1 )
00389 xspacing = yspacing;
00390
00391 if ( xspacing == 0.0 )
00392 xspacing = 1.0;
00393
00394 return xspacing;
00395
00396 }
00397
00398 // to avoid troubles with David Clunie's-like images
00399 if ( xspacing == 0. && yspacing == 0.)
00400 return 1.;
00401
00402 if ( xspacing == 0.)
00403 {
00404 gdcmWarningMacro("gdcmData/CT-MONO2-8-abdo.dcm problem");
00405 // seems to be a bug in the header ...
00406 nbValues = sscanf( strSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
00407 gdcmAssertMacro( nbValues == 2 );
00408 }
00409
00410 return xspacing;
00411 }
|
|
|
gets the info from 0020,0032 : Image Position Patient else from 0020,0030 : Image Position (RET) else 0.
Definition at line 520 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
00521 {
00522 float xImPos, yImPos, zImPos;
00523 std::string strImPos = GetEntryValue(0x0020,0x0032);
00524
00525 if ( strImPos == GDCM_UNFOUND)
00526 {
00527 gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
00528 strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
00529 if ( strImPos == GDCM_UNFOUND )
00530 {
00531 gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
00532 return 0.;
00533 }
00534 }
00535
00536 if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
00537 {
00538 return 0.;
00539 }
00540
00541 return yImPos;
00542 }
|
|
|
Retrieve the number of lines of image.
Definition at line 318 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetEntryValue(), and gdcm::Document::IsDicomV3(). Referenced by vtkGdcmReader::CheckFileCoherence(), gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00319 {
00320 const std::string &strSize = GetEntryValue(0x0028,0x0010);
00321 if ( strSize != GDCM_UNFOUND )
00322 {
00323 return atoi( strSize.c_str() );
00324 }
00325 if ( IsDicomV3() )
00326 {
00327 return 0;
00328 }
00329
00330 // The Rows (0028,0010) entry was optional for ACR/NEMA. It might
00331 // hence be a signal (1D image). So we default to 1:
00332 return 1;
00333 }
|
|
|
gets the info from 0028,0030 : Pixel Spacing else 1.0
Definition at line 418 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence().
00419 {
00420 float yspacing = 1.;
00421 std::string strSpacing = GetEntryValue(0x0028,0x0030);
00422
00423 if ( strSpacing == GDCM_UNFOUND )
00424 {
00425 gdcmWarningMacro("Unfound Pixel Spacing (0028,0030)");
00426 return 1.;
00427 }
00428
00429 // if sscanf cannot read any float value, it won't affect yspacing
00430 int nbValues = sscanf( strSpacing.c_str(), "%f", &yspacing);
00431
00432 // if no values, xspacing is set to 1.0
00433 if( nbValues == 0 )
00434 yspacing = 1.0;
00435
00436 if ( yspacing == 0.0 )
00437 yspacing = 1.0;
00438
00439 return yspacing;
00440 }
|
|
|
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 552 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue().
00553 {
00554 float xImPos, yImPos, zImPos;
00555 std::string strImPos = GetEntryValue(0x0020,0x0032);
00556
00557 if ( strImPos != GDCM_UNFOUND )
00558 {
00559 if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3)
00560 {
00561 gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
00562 return 0.; // bug in the element 0x0020,0x0032
00563 }
00564 else
00565 {
00566 return zImPos;
00567 }
00568 }
00569
00570 strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
00571 if ( strImPos != GDCM_UNFOUND )
00572 {
00573 if( sscanf( strImPos.c_str(),
00574 "%f\\%f\\%f", &xImPos, &yImPos, &zImPos ) != 3 )
00575 {
00576 gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
00577 return 0.; // bug in the element 0x0020,0x0032
00578 }
00579 else
00580 {
00581 return zImPos;
00582 }
00583 }
00584
00585 std::string strSliceLocation = GetEntryValue(0x0020,0x1041); // for *very* old ACR-NEMA images
00586 if ( strSliceLocation != GDCM_UNFOUND )
00587 {
00588 if( sscanf( strSliceLocation.c_str(), "%f", &zImPos) != 1)
00589 {
00590 gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
00591 return 0.; // bug in the element 0x0020,0x1041
00592 }
00593 else
00594 {
00595 return zImPos;
00596 }
00597 }
00598 gdcmWarningMacro( "Unfound Slice Location (0020,1041)");
00599
00600 std::string strLocation = GetEntryValue(0x0020,0x0050);
00601 if ( strLocation != GDCM_UNFOUND )
00602 {
00603 if( sscanf( strLocation.c_str(), "%f", &zImPos) != 1)
00604 {
00605 gdcmWarningMacro( "Wrong Location (0020,0050)");
00606 return 0.; // bug in the element 0x0020,0x0050
00607 }
00608 else
00609 {
00610 return zImPos;
00611 }
00612 }
00613 gdcmWarningMacro( "Unfound Location (0020,0050)");
00614
00615 return 0.; // Hopeless
00616 }
|
|
|
Retrieve the number of planes of volume or the number of frames of a multiframe.
Definition at line 343 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence(), gdcm::FileHelper::CheckWriteIntegrity(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00344 {
00345 // Both DicomV3 and ACR/Nema consider the "Number of Frames"
00346 // as the third dimension.
00347 const std::string &strSize = GetEntryValue(0x0028,0x0008);
00348 if ( strSize != GDCM_UNFOUND )
00349 {
00350 return atoi( strSize.c_str() );
00351 }
00352
00353 // We then consider the "Planes" entry as the third dimension
00354 const std::string &strSize2 = GetEntryValue(0x0028,0x0012);
00355 if ( strSize2 != GDCM_UNFOUND )
00356 {
00357 return atoi( strSize2.c_str() );
00358 }
00359
00360 return 1;
00361 }
|
|
|
gets the info from 0018,0088 : Space Between Slices else from 0018,0050 : Slice Thickness else 1.0
Definition at line 448 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by vtkGdcmReader::CheckFileCoherence().
00449 {
00450 // Spacing Between Slices : distance entre le milieu de chaque coupe
00451 // Les coupes peuvent etre :
00452 // jointives (Spacing between Slices = Slice Thickness)
00453 // chevauchantes (Spacing between Slices < Slice Thickness)
00454 // disjointes (Spacing between Slices > Slice Thickness)
00455 // Slice Thickness : epaisseur de tissus sur laquelle est acquis le signal
00456 // ca interesse le physicien de l'IRM, pas le visualisateur de volumes ...
00457 // Si le Spacing Between Slices est Missing,
00458 // on suppose que les coupes sont jointives
00459
00460 const std::string &strSpacingBSlices = GetEntryValue(0x0018,0x0088);
00461
00462 if ( strSpacingBSlices == GDCM_UNFOUND )
00463 {
00464 gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
00465 const std::string &strSliceThickness = GetEntryValue(0x0018,0x0050);
00466 if ( strSliceThickness == GDCM_UNFOUND )
00467 {
00468 gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
00469 return 1.;
00470 }
00471 else
00472 {
00473 // if no 'Spacing Between Slices' is found,
00474 // we assume slices join together
00475 // (no overlapping, no interslice gap)
00476 // if they don't, we're fucked up
00477 return (float)atof( strSliceThickness.c_str() );
00478 }
00479 }
00480 //else
00481 return (float)atof( strSpacingBSlices.c_str() );
00482 }
|
|
|
tells us if LUT are used
Definition at line 915 of file gdcmFile.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by vtkGdcmReader::CheckFileCoherence(), gdcm::FileHelper::CheckWriteIntegrity(), gdcm::FileHelper::GetImageData(), gdcm::FileHelper::GetImageDataIntoVector(), GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::FileHelper::SetWriteToRaw().
00916 {
00917 // Check the presence of the LUT Descriptors, and LUT Tables
00918 // LutDescriptorRed
00919 if ( !GetDocEntry(0x0028,0x1101) )
00920 {
00921 return false;
00922 }
00923 // LutDescriptorGreen
00924 if ( !GetDocEntry(0x0028,0x1102) )
00925 {
00926 return false;
00927 }
00928 // LutDescriptorBlue
00929 if ( !GetDocEntry(0x0028,0x1103) )
00930 {
00931 return false;
00932 }
00933 // Red Palette Color Lookup Table Data
00934 if ( !GetDocEntry(0x0028,0x1201) )
00935 {
00936 return false;
00937 }
00938 // Green Palette Color Lookup Table Data
00939 if ( !GetDocEntry(0x0028,0x1202) )
00940 {
00941 return false;
00942 }
00943 // Blue Palette Color Lookup Table Data
00944 if ( !GetDocEntry(0x0028,0x1203) )
00945 {
00946 return false;
00947 }
00948
00949 // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent)
00950 // NOT taken into account, but we don't know how to use it ...
00951 return true;
00952 }
|
|
|
Initialize a default DICOM File that should contain all the field require by other reader. DICOM standard does not explicitely defines those fields, heuristic has been choosen. This is not perfect as we are writting a CT image...
Definition at line 1406 of file gdcmFile.cxx. References GrPixel, gdcm::DocEntrySet::InsertBinEntry(), gdcm::DocEntrySet::InsertValEntry(), and NumPixel. Referenced by File().
01407 {
01408 std::string date = Util::GetCurrentDate();
01409 std::string time = Util::GetCurrentTime();
01410 std::string uid = Util::CreateUniqueUID();
01411 std::string uidMedia = uid;
01412 std::string uidInst = uid;
01413 std::string uidClass = Util::CreateUniqueUID();
01414 std::string uidStudy = Util::CreateUniqueUID();
01415 std::string uidSerie = Util::CreateUniqueUID();
01416
01417 // Meta Element Group Length
01418 InsertValEntry("146 ", 0x0002, 0x0000);
01419 // Media Storage SOP Class UID (CT Image Storage)
01420 InsertValEntry("1.2.840.10008.5.1.4.1.1.2", 0x0002, 0x0002);
01421 // Media Storage SOP Instance UID
01422 InsertValEntry(uidMedia.c_str(), 0x0002, 0x0003);
01423 // Transfer Syntax UID (Explicit VR Little Endian)
01424 InsertValEntry("1.2.840.10008.1.2.1 ", 0x0002, 0x0010);
01425 // META Implementation Class UID
01426 InsertValEntry(uidClass.c_str(), 0x0002, 0x0012);
01427 // Source Application Entity Title
01428 InsertValEntry("GDCM", 0x0002, 0x0016);
01429
01430 // Instance Creation Date
01431 InsertValEntry(date.c_str(), 0x0008, 0x0012);
01432 // Instance Creation Time
01433 InsertValEntry(time.c_str(), 0x0008, 0x0013);
01434 // SOP Class UID
01435 InsertValEntry("1.2.840.10008.5.1.4.1.1.2", 0x0008, 0x0016);
01436 // SOP Instance UID
01437 InsertValEntry(uidInst.c_str(), 0x0008, 0x0018);
01438 // Modality
01439 InsertValEntry("CT", 0x0008, 0x0060);
01440 // Manufacturer
01441 InsertValEntry("GDCM", 0x0008, 0x0070);
01442 // Institution Name
01443 InsertValEntry("GDCM", 0x0008, 0x0080);
01444 // Institution Address
01445 InsertValEntry("http://www-creatis.insa-lyon.fr/Public/Gdcm", 0x0008, 0x0081);
01446
01447 // Patient's Name
01448 InsertValEntry("GDCM", 0x0010, 0x0010);
01449 // Patient ID
01450 InsertValEntry("GDCMID", 0x0010, 0x0020);
01451
01452 // Study Instance UID
01453 InsertValEntry(uidStudy.c_str(), 0x0020, 0x000d);
01454 // Series Instance UID
01455 InsertValEntry(uidSerie.c_str(), 0x0020, 0x000e);
01456 // StudyID
01457 InsertValEntry("1", 0x0020, 0x0010);
01458 // SeriesNumber
01459 InsertValEntry("1", 0x0020, 0x0011);
01460
01461 // Samples per pixel 1 or 3
01462 InsertValEntry("1", 0x0028, 0x0002);
01463 // photochromatic interpretation
01464 InsertValEntry("MONOCHROME1", 0x0028, 0x0004);
01465 // nbRows
01466 InsertValEntry("0", 0x0028, 0x0010);
01467 // nbCols
01468 InsertValEntry("0", 0x0028, 0x0011);
01469 // BitsAllocated 8 or 12 or 16
01470 InsertValEntry("8", 0x0028, 0x0100);
01471 // BitsStored <= BitsAllocated
01472 InsertValEntry("8", 0x0028, 0x0101);
01473 // HighBit <= BitsAllocated - 1
01474 InsertValEntry("7", 0x0028, 0x0102);
01475 // Pixel Representation 0(unsigned) or 1(signed)
01476 InsertValEntry("0", 0x0028, 0x0103);
01477
01478 // default value
01479 // Special case this is the image (not a string)
01480 GrPixel = 0x7fe0;
01481 NumPixel = 0x0010;
01482 InsertBinEntry(0, 0, GrPixel, NumPixel);
01483 }
|
|
||||||||||||||||||||||||
|
Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.
Definition at line 309 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetBinEntry(), and gdcm::TagName. Referenced by InitializeDefaultFile(), and gdcm::FileHelper::InsertBinEntry().
00312 {
00313 BinEntry *binEntry = 0;
00314 DocEntry *currentEntry = GetDocEntry( group, elem );
00315
00316 // Verify the currentEntry
00317 if (currentEntry)
00318 {
00319 binEntry = dynamic_cast<BinEntry *>(currentEntry);
00320
00321 // Verify the VR
00322 if( binEntry )
00323 if( binEntry->GetVR()!=vr )
00324 binEntry = NULL;
00325
00326 // if currentEntry doesn't correspond to the requested valEntry
00327 if( !binEntry)
00328 {
00329 if( !RemoveEntry(currentEntry) )
00330 {
00331 gdcmWarningMacro( "Removal of previous DocEntry failed.");
00332
00333 return NULL;
00334 }
00335 }
00336 }
00337
00338 // Create a new binEntry if necessary
00339 if( !binEntry)
00340 {
00341 binEntry = NewBinEntry(group, elem, vr);
00342
00343 if ( !AddEntry(binEntry) )
00344 {
00345 gdcmWarningMacro( "AddEntry failed allthough this is a creation.");
00346
00347 delete binEntry;
00348 return NULL;
00349 }
00350 }
00351
00352 // Set the binEntry value
00353 uint8_t *tmpArea;
00354 if( lgth>0 && binArea )
00355 {
00356 tmpArea = new uint8_t[lgth];
00357 memcpy(tmpArea,binArea,lgth);
00358 }
00359 else
00360 {
00361 tmpArea = 0;
00362 }
00363 if( !SetBinEntry(tmpArea,lgth,binEntry) )
00364 {
00365 if( tmpArea )
00366 {
00367 delete[] tmpArea;
00368 }
00369 }
00370
00371 return binEntry;
00372 }
|
|
||||||||||||
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.
Definition at line 382 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry(). Referenced by gdcm::FileHelper::InsertSeqEntry().
00383 {
00384 SeqEntry *seqEntry = 0;
00385 DocEntry *currentEntry = GetDocEntry( group, elem );
00386
00387 // Verify the currentEntry
00388 if( currentEntry )
00389 {
00390 seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
00391
00392 // Verify the VR
00393 if( seqEntry )
00394 seqEntry = NULL;
00395
00396 // if currentEntry doesn't correspond to the requested seqEntry
00397 if( !seqEntry )
00398 {
00399 if (!RemoveEntry(currentEntry))
00400 {
00401 gdcmWarningMacro( "Removal of previous DocEntry failed.");
00402
00403 return NULL;
00404 }
00405 }
00406 }
00407 // Create a new seqEntry if necessary
00408 if( !seqEntry )
00409 {
00410 seqEntry = NewSeqEntry(group, elem);
00411
00412 if( !AddEntry(seqEntry) )
00413 {
00414 gdcmWarningMacro( "AddEntry failed allthough this is a creation.");
00415
00416 delete seqEntry;
00417 return NULL;
00418 }
00419 }
00420
00421 // TODO : Find a trick to insert a SequenceDelimitationItem
00422 // in the SeqEntry, at the end.
00423 return seqEntry;
00424 }
|
|
||||||||||||||||||||
|
Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
Definition at line 250 of file gdcmDocEntrySet.cxx. References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewValEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetValEntry(), and gdcm::TagName. Referenced by InitializeDefaultFile(), gdcm::FileHelper::InsertValEntry(), and Write().
00253 {
00254 ValEntry *valEntry = 0;
00255 DocEntry *currentEntry = GetDocEntry( group, elem );
00256
00257 if (currentEntry)
00258 {
00259 valEntry = dynamic_cast<ValEntry *>(currentEntry);
00260
00261 // Verify the VR
00262 if( valEntry )
00263 if( valEntry->GetVR()!=vr )
00264 valEntry = NULL;
00265
00266 // if currentEntry doesn't correspond to the requested valEntry
00267 if( !valEntry)
00268 {
00269 if( !RemoveEntry(currentEntry) )
00270 {
00271 gdcmWarningMacro( "Removal of previous DocEntry failed.");
00272
00273 return NULL;
00274 }
00275 }
00276 }
00277
00278 // Create a new valEntry if necessary
00279 if( !valEntry )
00280 {
00281 valEntry = NewValEntry( group, elem, vr );
00282
00283 if ( !AddEntry(valEntry) )
00284 {
00285 gdcmWarningMacro("AddEntry failed although this is a creation.");
00286
00287 delete valEntry;
00288 return NULL;
00289 }
00290 }
00291
00292 // Set the binEntry value
00293 SetValEntry(value, valEntry); // The std::string value
00294 return valEntry;
00295 }
|
|
|
Predicate for dicom version 3 file.
Definition at line 245 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by GetYSize(), and gdcm::PixelReadConvert::GrabInformationsFromFile().
00246 {
00247 // Checking if Transfer Syntax exists is enough
00248 // Anyway, it's to late check if the 'Preamble' was found ...
00249 // And ... would it be a rich idea to check ?
00250 // (some 'no Preamble' DICOM images exist !)
00251 return GetDocEntry(0x0002, 0x0010) != NULL;
00252 }
|
|
|
Tells us if the ElementSet contains no entry.
Implements gdcm::DocEntrySet. Definition at line 63 of file gdcmElementSet.h. Referenced by gdcm::Document::IsReadable().
00063 { return TagHT.empty(); };
|
|
|
Check whether this a monochrome picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
Definition at line 854 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00855 {
00856 const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
00857 if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1")
00858 || Util::DicomStringEqual(PhotometricInterp, "MONOCHROME2") )
00859 {
00860 return true;
00861 }
00862 if ( PhotometricInterp == GDCM_UNFOUND )
00863 {
00864 gdcmWarningMacro( "Not found : Photometric Interpretation (0028,0004)");
00865 }
00866 return false;
00867 }
|
|
|
Check whether this a "PALETTE COLOR" picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
Definition at line 874 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00875 {
00876 std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
00877 if ( PhotometricInterp == "PALETTE COLOR " )
00878 {
00879 return true;
00880 }
00881 if ( PhotometricInterp == GDCM_UNFOUND )
00882 {
00883 gdcmWarningMacro( "Not found : Palette color (0028,0004)");
00884 }
00885 return false;
00886 }
|
|
|
Predicate for Papyrus file Dedicated to whomsoever it may concern.
Definition at line 259 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry().
00260 {
00261 // check for Papyrus private Sequence
00262 DocEntry *e = GetDocEntry(0x0041, 0x1050);
00263 if ( !e )
00264 return false;
00265 // check if it's actually a Sequence
00266 if ( !dynamic_cast<SeqEntry*>(e) )
00267 return false;
00268 return true;
00269 }
|
|
|
This predicate, based on hopefully reasonable heuristics, decides whether or not the current File was properly parsed and contains the mandatory information for being considered as a well formed and usable Dicom/Acr File.
Reimplemented from gdcm::Document. Definition at line 181 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcm::ElementSet::GetDocEntry(), and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::SerieHelper::AddFileName(), vtkGdcmReader::CheckFileCoherence(), gdcm::DicomDir::CreateDicomDirChainedList(), and gdcm::FileHelper::Initialize().
00182 {
00183 if( !Document::IsReadable() )
00184 {
00185 return false;
00186 }
00187
00188 const std::string &res = GetEntryValue(0x0028, 0x0005);
00189 if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
00190 {
00191 return false; // Image Dimensions
00192 }
00193 if ( !GetDocEntry(0x0028, 0x0100) )
00194 {
00195 return false; // "Bits Allocated"
00196 }
00197 if ( !GetDocEntry(0x0028, 0x0101) )
00198 {
00199 return false; // "Bits Stored"
00200 }
00201 if ( !GetDocEntry(0x0028, 0x0102) )
00202 {
00203 return false; // "High Bit"
00204 }
00205 if ( !GetDocEntry(0x0028, 0x0103) )
00206 {
00207 return false; // "Pixel Representation" i.e. 'Sign'
00208 }
00209
00210 return true;
00211 }
|
|
|
Check whether the pixels are signed or UNsigned data.
Definition at line 833 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00834 {
00835 std::string strSize = GetEntryValue( 0x0028, 0x0103 );
00836 if ( strSize == GDCM_UNFOUND )
00837 {
00838 gdcmWarningMacro( "(0028,0103) is supposed to be mandatory");
00839 return false;
00840 }
00841 int sign = atoi( strSize.c_str() );
00842 if ( sign == 0 )
00843 {
00844 return false;
00845 }
00846 return true;
00847 }
|
|
|
Check whether this a "YBR_FULL" color picture or not by accessing the "Photometric Interpretation" tag ( 0x0028, 0x0004 ).
Definition at line 893 of file gdcmFile.cxx. References gdcm::GDCM_UNFOUND, gdcmWarningMacro, and gdcm::DocEntrySet::GetEntryValue(). Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().
00894 {
00895 std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
00896 if ( PhotometricInterp == "YBR_FULL" )
00897 {
00898 return true;
00899 }
00900 if ( PhotometricInterp == GDCM_UNFOUND )
00901 {
00902 gdcmWarningMacro( "Not found : YBR Full (0028,0004)");
00903 }
00904 return false;
00905 }
|
|
|
Loads the element while preserving the current underlying file position indicator as opposed to LoadDocEntry that modifies it.
Definition at line 581 of file gdcmDocument.cxx. References gdcm::Document::Fp, and gdcm::Document::LoadDocEntry(). Referenced by gdcm::Document::GetTransferSyntax().
00582 {
00583 if(Fp)
00584 {
00585 long PositionOnEntry = Fp->tellg();
00586 LoadDocEntry(entry);
00587 Fp->seekg(PositionOnEntry, std::ios::beg);
00588 }
00589 }
|
|
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 541 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmWarningMacro, gdcm::BinEntry::GetBinArea(), gdcm::DocEntry::GetLength(), gdcm::DocEntry::GetOffset(), gdcm::Document::OpenFile(), and gdcm::BinEntry::SetBinArea().
00542 {
00543 if(elem->GetBinArea())
00544 return;
00545
00546 bool openFile = !Fp;
00547 if(openFile)
00548 OpenFile();
00549
00550 size_t o =(size_t)elem->GetOffset();
00551 Fp->seekg(o, std::ios::beg);
00552
00553 size_t l = elem->GetLength();
00554 uint8_t *a = new uint8_t[l];
00555 if( !a )
00556 {
00557 gdcmWarningMacro( "Cannot allocate BinEntry content");
00558 return;
00559 }
00560
00562 Fp->read((char*)a, l);
00563 if( Fp->fail() || Fp->eof())
00564 {
00565 delete[] a;
00566 return;
00567 }
00568
00569 elem->SetBinArea(a);
00570
00571 if(openFile)
00572 CloseFile();
00573 }
|
|
||||||||||||
|
Loads (from disk) the element content when a string is not suitable.
Definition at line 522 of file gdcmDocument.cxx. References gdcm::ElementSet::GetDocEntry(). Referenced by gdcm::Document::Document(), gdcm::PixelReadConvert::GrabInformationsFromFile(), and gdcm::Document::LoadDocEntry().
00523 {
00524 // Search the corresponding DocEntry
00525 DocEntry *docElement = GetDocEntry(group, elem);
00526 if ( !docElement )
00527 return;
00528
00529 BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
00530 if( !binElement )
00531 return;
00532
00533 LoadEntryBinArea(binElement);
00534 }
|
|
||||||||||||||||
|
Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 471 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName. Referenced by gdcm::FileHelper::CopyBinEntry(), gdcm::DocEntrySet::InsertBinEntry(), and gdcm::Document::ReadNextDocEntry().
00473 {
00474 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00475 gdcmAssertMacro(dictEntry);
00476
00477 BinEntry *newEntry = new BinEntry(dictEntry);
00478 if (!newEntry)
00479 {
00480 gdcmWarningMacro( "Failed to allocate BinEntry");
00481 return 0;
00482 }
00483 return newEntry;
00484 }
|
|
||||||||||||
|
Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 493 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, and gdcm::DocEntrySet::GetDictEntry(). Referenced by gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry().
00494 {
00495 DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
00496 gdcmAssertMacro(dictEntry);
00497
00498 SeqEntry *newEntry = new SeqEntry( dictEntry );
00499 if (!newEntry)
00500 {
00501 gdcmWarningMacro( "Failed to allocate SeqEntry");
00502 return 0;
00503 }
00504 return newEntry;
00505 }
|
|
||||||||||||||||
|
Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
Definition at line 447 of file gdcmDocEntrySet.cxx. References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName. Referenced by gdcm::FileHelper::CopyValEntry(), gdcm::DocEntrySet::InsertValEntry(), and gdcm::Document::ReadNextDocEntry().
00449 {
00450 DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00451 gdcmAssertMacro(dictEntry);
00452
00453 ValEntry *newEntry = new ValEntry(dictEntry);
00454 if (!newEntry)
00455 {
00456 gdcmWarningMacro( "Failed to allocate ValEntry");
00457 return 0;
00458 }
00459 return newEntry;
00460 }
|
|
||||||||||||||||||||||||
|
Request a new virtual dict entry to the dict set.
Definition at line 515 of file gdcmDocEntrySet.cxx. References gdcm::TagName. Referenced by File(), and gdcm::DocEntrySet::GetDictEntry().
00519 {
00520 return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
00521 }
|
|
|
Tries to open the file Document::Filename and checks the preamble when existing.
Definition at line 395 of file gdcmDocument.cxx. References gdcm::Document::CloseFile(), gdcm::Document::Fp, gdcmDebugMacro, gdcmWarningMacro, and gdcm::Document::HasDCMPreamble. Referenced by gdcm::Document::Document(), File(), gdcm::FileHelper::GetRaw(), and gdcm::Document::LoadEntryBinArea().
00396 {
00397 HasDCMPreamble = false;
00398 if (Filename.length() == 0)
00399 {
00400 return 0;
00401 }
00402
00403 if(Fp)
00404 {
00405 gdcmWarningMacro( "File already open: " << Filename.c_str());
00406 CloseFile();
00407 }
00408
00409 Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary);
00410 if( ! *Fp )
00411 {
00412 gdcmDebugMacro( "Cannot open file: " << Filename.c_str());
00413 delete Fp;
00414 Fp = 0;
00415 return 0;
00416 }
00417
00418 uint16_t zero = 0;
00419 Fp->read((char*)&zero, (size_t)2);
00420 if( Fp->eof() )
00421 {
00422 CloseFile();
00423 return 0;
00424 }
00425
00426 //ACR -- or DICOM with no Preamble; may start with a Shadow Group --
00427 if(
00428 zero == 0x0001 || zero == 0x0100 || zero == 0x0002 || zero == 0x0200 ||
00429 zero == 0x0003 || zero == 0x0300 || zero == 0x0004 || zero == 0x0400 ||
00430 zero == 0x0005 || zero == 0x0500 || zero == 0x0006 || zero == 0x0600 ||
00431 zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 )
00432 {
00433 std::string msg
00434 = Util::Format("ACR/DICOM with no preamble: (%04x)\n", zero);
00435 gdcmWarningMacro( msg.c_str() );
00436 return Fp;
00437 }
00438
00439 //DICOM
00440 Fp->seekg(126L, std::ios::cur);
00441 char dicm[4] = {' ',' ',' ',' '};
00442 Fp->read(dicm, (size_t)4);
00443 if( Fp->eof() )
00444 {
00445 CloseFile();
00446 return 0;
00447 }
00448 if( memcmp(dicm, "DICM", 4) == 0 )
00449 {
00450 HasDCMPreamble = true;
00451 return Fp;
00452 }
00453
00454 CloseFile();
00455 gdcmWarningMacro( "Not DICOM/ACR (missing preamble)" << Filename.c_str());
00456
00457 return 0;
00458 }
|
|
|
Compares two documents, according to DicomDir rules.
Definition at line 598 of file gdcmDocument.cxx. References gdcm::DocEntrySet::GetEntryValue().
00599 {
00600 // Patient Name
00601 std::string s1 = GetEntryValue(0x0010,0x0010);
00602 std::string s2 = document.GetEntryValue(0x0010,0x0010);
00603 if(s1 < s2)
00604 {
00605 return true;
00606 }
00607 else if( s1 > s2 )
00608 {
00609 return false;
00610 }
00611 else
00612 {
00613 // Patient ID
00614 s1 = GetEntryValue(0x0010,0x0020);
00615 s2 = document.GetEntryValue(0x0010,0x0020);
00616 if ( s1 < s2 )
00617 {
00618 return true;
00619 }
00620 else if ( s1 > s2 )
00621 {
00622 return false;
00623 }
00624 else
00625 {
00626 // Study Instance UID
00627 s1 = GetEntryValue(0x0020,0x000d);
00628 s2 = document.GetEntryValue(0x0020,0x000d);
00629 if ( s1 < s2 )
00630 {
00631 return true;
00632 }
00633 else if( s1 > s2 )
00634 {
00635 return false;
00636 }
00637 else
00638 {
00639 // Serie Instance UID
00640 s1 = GetEntryValue(0x0020,0x000e);
00641 s2 = document.GetEntryValue(0x0020,0x000e);
00642 if ( s1 < s2 )
00643 {
00644 return true;
00645 }
00646 else if( s1 > s2 )
00647 {
00648 return false;
00649 }
00650 }
00651 }
00652 }
00653 return false;
00654 }
|
|
||||||||||||
|
Prints the Header Entries (Dicom Elements) from the H Table.
Reimplemented from gdcm::Base. Reimplemented in gdcm::DicomDir. Definition at line 195 of file gdcmElementSet.cxx. References gdcm::DocEntry::Print(), gdcm::Base::SetPrintLevel(), and gdcm::ElementSet::TagHT. Referenced by gdcm::FileHelper::Print().
00196 {
00197 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
00198 {
00199 DocEntry *entry = i->second;
00200
00201 entry->SetPrintLevel(PrintLevel);
00202 entry->Print(os);
00203
00204 if ( dynamic_cast<SeqEntry*>(entry) )
00205 {
00206 // Avoid the newline for a sequence:
00207 continue;
00208 }
00209 os << std::endl;
00210 }
00211 }
|
|
|
When parsing the Pixel Data of an encapsulated file, read the basic offset table (when present, and BTW dump it).
Definition at line 1708 of file gdcmFile.cxx. References gdcmWarningMacro, ReadTagLength(), and str2num. Referenced by ComputeJPEGFragmentInfo(), and ComputeRLEInfo().
01709 {
01711 uint32_t itemLength = ReadTagLength(0xfffe, 0xe000);
01712
01713 // When present, read the basic offset table itself.
01714 // Notes: - since the presence of this basic offset table is optional
01715 // we can't rely on it for the implementation, and we will simply
01716 // trash it's content (when present).
01717 // - still, when present, we could add some further checks on the
01718 // lengths, but we won't bother with such fuses for the time being.
01719 if ( itemLength != 0 )
01720 {
01721 char *basicOffsetTableItemValue = new char[itemLength + 1];
01722 Fp->read(basicOffsetTableItemValue, itemLength);
01723
01724 #ifdef GDCM_DEBUG
01725 for (unsigned int i=0; i < itemLength; i += 4 )
01726 {
01727 uint32_t individualLength = str2num( &basicOffsetTableItemValue[i],
01728 uint32_t);
01729 gdcmWarningMacro( "Read one length: " <<
01730 std::hex << individualLength );
01731 }
01732 #endif //GDCM_DEBUG
01733
01734 delete[] basicOffsetTableItemValue;
01735 }
01736 }
|
|
|
Reads a supposed to be 16 Bits integer (swaps it depending on processor endianness).
Definition at line 663 of file gdcmDocument.cxx. Referenced by gdcm::Document::LoadDocEntry(), gdcm::Document::ReadNextDocEntry(), and ReadTag().
00665 {
00666 uint16_t g;
00667 Fp->read ((char*)&g, (size_t)2);
00668 if ( Fp->fail() )
00669 {
00670 throw FormatError( "Document::ReadInt16()", " file error." );
00671 }
00672 if( Fp->eof() )
00673 {
00674 throw FormatError( "Document::ReadInt16()", "EOF." );
00675 }
00676 g = SwapShort(g);
00677 return g;
00678 }
|
|
|
Reads a supposed to be 32 Bits integer (swaps it depending on processor endianness).
Definition at line 685 of file gdcmDocument.cxx. Referenced by ComputeRLEInfo(), gdcm::Document::LoadDocEntry(), and ReadTagLength().
00687 {
00688 uint32_t g;
00689 Fp->read ((char*)&g, (size_t)4);
00690 if ( Fp->fail() )
00691 {
00692 throw FormatError( "Document::ReadInt32()", " file error." );
00693 }
00694 if( Fp->eof() )
00695 {
00696 throw FormatError( "Document::ReadInt32()", "EOF." );
00697 }
00698 g = SwapLong(g);
00699 return g;
00700 }
|
|
||||||||||||
|
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag check whether this tag is (TestGroup, TestElement).
Definition at line 1636 of file gdcmFile.cxx. References gdcmWarningMacro, and gdcm::Document::ReadInt16(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), and ReadTagLength().
01637 {
01638 long positionOnEntry = Fp->tellg();
01639 long currentPosition = Fp->tellg(); // On debugging purposes
01640
01641 // Read the Item Tag group and element, and make
01642 // sure they are what we expected:
01643 uint16_t itemTagGroup;
01644 uint16_t itemTagElement;
01645 try
01646 {
01647 itemTagGroup = ReadInt16();
01648 itemTagElement = ReadInt16();
01649 }
01650 catch ( FormatError e )
01651 {
01652 //std::cerr << e << std::endl;
01653 return false;
01654 }
01655 if ( itemTagGroup != testGroup || itemTagElement != testElement )
01656 {
01657 gdcmWarningMacro( "Wrong Item Tag found:"
01658 << " We should have found tag ("
01659 << std::hex << testGroup << "," << testElement << ")" << std::endl
01660 << " but instead we encountered tag ("
01661 << std::hex << itemTagGroup << "," << itemTagElement << ")"
01662 << " at address: " << " 0x(" << (unsigned int)currentPosition << ")"
01663 ) ;
01664 Fp->seekg(positionOnEntry, std::ios::beg);
01665
01666 return false;
01667 }
01668 return true;
01669 }
|
|
||||||||||||
|
Assuming the internal file pointer Document::Fp is placed at the beginning of a tag (TestGroup, TestElement), read the length associated to the Tag.
Definition at line 1685 of file gdcmFile.cxx. References gdcmWarningMacro, gdcm::Document::ReadInt32(), and ReadTag(). Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), and ReadAndSkipEncapsulatedBasicOffsetTable().
01686 {
01687
01688 if ( !ReadTag(testGroup, testElement) )
01689 {
01690 return 0;
01691 }
01692
01694 long currentPosition = Fp->tellg();
01695 uint32_t itemLength = ReadInt32();
01696 {
01697 gdcmWarningMacro( "Basic Item Length is: "
01698 << itemLength << std::endl
01699 << " at address: " << std::hex << (unsigned int)currentPosition);
01700 }
01701 return itemLength;
01702 }
|
|
|
Clear the hash table from given entry AND delete the entry.
Implements gdcm::DocEntrySet. Definition at line 89 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by File(), and gdcm::DocEntryArchive::Restore().
00090 {
00091 const TagKey &key = entryToRemove->GetKey();
00092 if( TagHT.count(key) == 1 )
00093 {
00094 TagHT.erase(key);
00095 //gdcmWarningMacro( "One element erased.");
00096 delete entryToRemove;
00097 return true;
00098 }
00099
00100 gdcmWarningMacro( "Key not present");
00101 return false ;
00102 }
|
|
|
Clear the hash table from given entry BUT keep the entry.
Implements gdcm::DocEntrySet. Definition at line 108 of file gdcmElementSet.cxx. References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::ElementSet::TagHT, and gdcm::TagKey. Referenced by gdcm::DicomDir::NewMeta(), gdcm::DocEntryArchive::Push(), and Write().
00109 {
00110 const TagKey &key = entryToRemove->GetKey();
00111 if( TagHT.count(key) == 1 )
00112 {
00113 TagHT.erase(key);
00114 //gdcmWarningMacro( "One element erased.");
00115 return true;
00116 }
00117
00118 gdcmWarningMacro( "Key not present");
00119 return false ;
00120 }
|
|
||||||||||||||||
|
Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 228 of file gdcmDocEntrySet.cxx. References gdcm::GDCM_BINLOADED, gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), and gdcm::ContentEntry::SetValue().
00229 {
00230 if(entry)
00231 {
00232 entry->SetBinArea(content);
00233 entry->SetLength(lgth);
00234 entry->SetValue(GDCM_BINLOADED);
00235 return true;
00236 }
00237 return false;
00238 }
|
|
||||||||||||||||||||
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 191 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetBinEntry(). Referenced by gdcm::DocEntrySet::InsertBinEntry(), and gdcm::FileHelper::SetBinEntry().
00193 {
00194 BinEntry *entry = GetBinEntry(group, elem);
00195 if (!entry )
00196 {
00197 gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
00198 "," << elem << " element (try promotion first).");
00199 return false;
00200 }
00201
00202 return SetBinEntry(content,lgth,entry);
00203 }
|
|
|
Accessor to Filename.
Definition at line 81 of file gdcmDocument.h. Referenced by gdcm::DicomDir::DicomDir().
00081 { Filename = fileName; }
|
|
|
Sets the print level for the Dicom Header Elements.
Definition at line 45 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print().
00045 { PrintLevel = level; };
|
|
|
Set the shadow dictionary used.
Definition at line 210 of file gdcmDocument.cxx. References gdcm::DictKey, and gdcm::Document::RefShaDict.
00211 {
00212 RefShaDict = Global::GetDicts()->GetDict(dictName);
00213 return !RefShaDict;
00214 }
|
|
|
Set the shadow dictionary used.
Definition at line 200 of file gdcmDocument.cxx. References gdcm::Document::RefShaDict.
00201 {
00202 RefShaDict = dict;
00203 return !RefShaDict;
00204 }
|
|
||||||||||||
|
Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
Definition at line 211 of file gdcmDocEntrySet.cxx. References gdcm::ValEntry::SetValue().
00212 {
00213 if(entry)
00214 {
00215 entry->SetValue(content);
00216 return true;
00217 }
00218 return false;
00219 }
|
|
||||||||||||||||
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 169 of file gdcmDocEntrySet.cxx. References gdcmWarningMacro, and gdcm::DocEntrySet::GetValEntry(). Referenced by AnonymizeFile(), gdcm::Document::Document(), gdcm::DocEntrySet::InsertValEntry(), gdcm::FileHelper::SetValEntry(), and Write().
00171 {
00172 ValEntry *entry = GetValEntry(group, elem);
00173 if (!entry )
00174 {
00175 gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
00176 "," << elem << " element (try promotion first).");
00177 return false;
00178 }
00179 return SetValEntry(content,entry);
00180 }
|
|
|
skips bytes inside the source file
Definition at line 707 of file gdcmDocument.cxx. References gdcm::Document::Fp. Referenced by ComputeJPEGFragmentInfo(), ComputeRLEInfo(), and gdcm::Document::SkipDocEntry().
00708 {
00709 //FIXME don't dump the returned value
00710 Fp->seekg((long)nBytes, std::ios::cur);
00711 }
|
|
|
Swaps back the bytes of 4-byte long integer accordingly to processor order.
Definition at line 365 of file gdcmDocument.cxx. References gdcmErrorMacro, and gdcm::Document::SwapCode. Referenced by gdcm::Document::GetDocEntryValue().
00366 {
00367 switch (SwapCode)
00368 {
00369 case 1234 :
00370 break;
00371 case 4321 :
00372 a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) |
00373 ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) );
00374 break;
00375 case 3412 :
00376 a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) );
00377 break;
00378 case 2143 :
00379 a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) );
00380 break;
00381 default :
00382 gdcmErrorMacro( "Unset swap code:" << SwapCode );
00383 a = 0;
00384 }
00385 return a;
00386 }
|
|
|
Swaps the bytes so they agree with the processor order.
Definition at line 351 of file gdcmDocument.cxx. References gdcm::Document::SwapCode. Referenced by gdcm::Document::GetDocEntryValue(), and gdcm::Document::HandleOutOfGroup0002().
|
|
|
Unswaps back the bytes of 4-byte long integer so they agree with the processor order.
Definition at line 75 of file gdcmDocument.h.
00075 { return SwapLong(a);}
|
|
|
Unswaps back the bytes of 2-bytes long integer so they agree with the processor order.
Definition at line 72 of file gdcmDocument.h.
00072 { return SwapShort(a);}
|
|
||||||||||||
|
Performs some consistency checking on various 'File related' (as opposed to 'DicomDir related') entries then writes in a file all the (Dicom Elements) included the Pixels.
Definition at line 1314 of file gdcmFile.cxx. References gdcm::Document::ComputeGroup0002Length(), gdcmWarningMacro, gdcm::ElementSet::GetDocEntry(), gdcm::DocEntrySet::GetEntryLength(), gdcm::DocEntrySet::GetEntryValue(), gdcm::DocEntrySet::GetValEntry(), GrPixel, gdcm::DocEntrySet::InsertValEntry(), NumPixel, gdcm::ElementSet::RemoveEntryNoDestroy(), gdcm::DocEntrySet::SetValEntry(), and gdcm::ValEntry::SetValue(). Referenced by gdcm::FileHelper::Write().
01315 {
01316 std::ofstream *fp = new std::ofstream(fileName.c_str(),
01317 std::ios::out | std::ios::binary);
01318 if (*fp == NULL)
01319 {
01320 gdcmWarningMacro("Failed to open (write) File: " << fileName.c_str());
01321 return false;
01322 }
01323
01324 // Entry : 0002|0000 = group length -> recalculated
01325 ValEntry *e0002 = GetValEntry(0x0002,0x0000);
01326 if( e0002 )
01327 {
01328 std::ostringstream sLen;
01329 sLen << ComputeGroup0002Length(filetype);
01330 e0002->SetValue(sLen.str());
01331 }
01332
01333 // Bits Allocated
01334 if ( GetEntryValue(0x0028,0x0100) == "12")
01335 {
01336 SetValEntry("16", 0x0028,0x0100);
01337 }
01338
01339 int i_lgPix = GetEntryLength(GrPixel, NumPixel);
01340 if (i_lgPix != -2)
01341 {
01342 // no (GrPixel, NumPixel) element
01343 std::string s_lgPix = Util::Format("%d", i_lgPix+12);
01344 s_lgPix = Util::DicomString( s_lgPix.c_str() );
01345 InsertValEntry(s_lgPix,GrPixel, 0x0000);
01346 }
01347
01348 // FIXME : should be nice if we could move it to File
01349 // (or in future gdcmPixelData class)
01350
01351 // Drop Palette Color, if necessary
01352 if ( GetEntryValue(0x0028,0x0002).c_str()[0] == '3' )
01353 {
01354 // if SamplesPerPixel = 3, sure we don't need any LUT !
01355 // Drop 0028|1101, 0028|1102, 0028|1103
01356 // Drop 0028|1201, 0028|1202, 0028|1203
01357
01358 DocEntry *e = GetDocEntry(0x0028,0x01101);
01359 if (e)
01360 {
01361 RemoveEntryNoDestroy(e);
01362 }
01363 e = GetDocEntry(0x0028,0x1102);
01364 if (e)
01365 {
01366 RemoveEntryNoDestroy(e);
01367 }
01368 e = GetDocEntry(0x0028,0x1103);
01369 if (e)
01370 {
01371 RemoveEntryNoDestroy(e);
01372 }
01373 e = GetDocEntry(0x0028,0x01201);
01374 if (e)
01375 {
01376 RemoveEntryNoDestroy(e);
01377 }
01378 e = GetDocEntry(0x0028,0x1202);
01379 if (e)
01380 {
01381 RemoveEntryNoDestroy(e);
01382 }
01383 e = GetDocEntry(0x0028,0x1203);
01384 if (e)
01385 {
01386 RemoveEntryNoDestroy(e);
01387 }
01388 }
01389
01390 Document::WriteContent(fp, filetype);
01391
01392 fp->close();
01393 delete fp;
01394
01395 return true;
01396 }
|
|
||||||||||||
|
Writes in a file all the Header Entries (Dicom Elements).
Reimplemented from gdcm::ElementSet. Definition at line 482 of file gdcmDocument.cxx. References gdcm::ExplicitVR, and gdcm::ImplicitVR.
00483 {
00484 // \TODO move the following lines (and a lot of others, to be written)
00485 // to a future function CheckAndCorrectHeader
00486
00487 // (necessary if user wants to write a DICOM V3 file
00488 // starting from an ACR-NEMA (V2) Header
00489
00490 if ( filetype == ImplicitVR || filetype == ExplicitVR )
00491 {
00492 // writing Dicom File Preamble
00493 char filePreamble[128];
00494 memset(filePreamble, 0, 128);
00495 fp->write(filePreamble, 128);
00496 fp->write("DICM", 4);
00497 }
00498
00499 /*
00500 * \todo rewrite later, if really usefull
00501 * - 'Group Length' element is optional in DICOM
00502 * - but un-updated odd groups lengthes can causes pb
00503 * (xmedcon breaker)
00504 *
00505 * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) )
00506 * UpdateGroupLength(false,filetype);
00507 * if ( filetype == ACR)
00508 * UpdateGroupLength(true,ACR);
00509 */
00510
00511 ElementSet::WriteContent(fp, filetype); // This one is recursive
00512 }
|
|
|
List of element to Anonymize.
Definition at line 150 of file gdcmDocument.h. |
|
|
Refering underlying filename.
Definition at line 112 of file gdcmDocument.h. |
|
|
ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown.
Definition at line 138 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::FindDocEntryVR(), gdcm::Document::GetFileType(), gdcm::Document::HandleOutOfGroup0002(), gdcm::Document::Initialize(), gdcm::Document::IsReadable(), gdcm::Document::ParseDES(), and gdcm::Document::ReadNextDocEntry(). |
|
|
File Pointer, opened during Document parsing.
Definition at line 135 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::CloseFile(), gdcm::Document::Document(), gdcm::Document::FindDocEntryVR(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadDocEntrySafe(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::OpenFile(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::Document::ReadNextDocEntry(), gdcm::Document::SkipBytes(), and gdcm::Document::SkipToNextDocEntry(). |
|
|
whether we already parsed group 0002 (Meta Elements)
Definition at line 129 of file gdcmDocument.h. Referenced by gdcm::Document::Document(), and gdcm::Document::HandleOutOfGroup0002(). |
|
|
In some cases (e.g. for some ACR-NEMA images) the header entry for the group of pixels is *not* found at 0x7fe0. In order to make things easier the parser shall store the proper value in GrPixel to provide a unique access facility.
Definition at line 187 of file gdcmFile.h. Referenced by File(), GetPixelAreaLength(), GetPixelOffset(), InitializeDefaultFile(), and Write(). |
|
|
whether file has a DCM Preamble
Definition at line 132 of file gdcmDocument.h. Referenced by gdcm::Document::OpenFile(), and gdcm::Document::ReadNextDocEntry(). |
|
|
After opening the file, we read HEADER_LENGTH_TO_READ bytes.
Definition at line 141 of file gdcmDocument.h. |
|
|
Store the JPEG fragments info obtained during parsing of pixels.
Definition at line 176 of file gdcmFile.h. Referenced by ComputeJPEGFragmentInfo(), File(), and ~File(). |
|
|
Elements whose value is longer than MAX_SIZE_LOAD_ELEMENT_VALUE are NOT loaded.
Definition at line 51 of file gdcmDocument.cxx. Referenced by gdcm::Document::Document(). |
|
|
Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE are NOT printed.
Definition at line 52 of file gdcmDocument.cxx. |
|
|
In some cases (e.g. for some ACR-NEMA images) the Entry Element Number of the 'Pixel Element' is *not* found at 0x0010. In order to make things easier the parser shall store the proper value in NumPixel to provide a unique access facility.
Definition at line 182 of file gdcmFile.h. Referenced by File(), GetPixelAreaLength(), GetPixelOffset(), InitializeDefaultFile(), and Write(). |
|
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 53 of file gdcmBase.h. Referenced by gdcm::Base::Base(). |
|
|
Store the RLE frames info obtained during parsing of pixels.
Definition at line 174 of file gdcmFile.h. Referenced by ComputeRLEInfo(), File(), and ~File(). |
|
|
Swap code gives an information on the byte order of a supposed to be an int32, as it's read on disc (depending on the image Transfer Syntax *and* on the processor endianess) as opposed as it should in memory to be dealt as an int32. For instance :
Definition at line 126 of file gdcmDocument.h. Referenced by gdcm::Document::CheckSwap(), gdcm::Document::Document(), gdcm::Document::SwapLong(), gdcm::Document::SwapShort(), and gdcm::Document::SwitchByteSwapCode(). |
1.3.6