Class DicomDictionary

java.lang.Object
gov.nih.mipav.model.file.DicomDictionary

public class DicomDictionary extends Object
This class reads a text file that lists all the tags that the DICOM file reader will need to know about. It stores these in a static Hashtable. We assume the dictionary file is found in the working directory of mipav or in the root of the jar file MIPAV is being run from (see the ClassLoader.getResource() method, with the default name "dicom_dictionary.txt".

The dictionary defines each tag on its own line, begining with the tag's ID in parenthesis, for example: (01AC,1101), where the initial 4 digits are the group number, and the second for digits are the element number. Following the group and element, each attribute of the tag definition is specified by attribute type, followed by an "=", then the attribute value in quotations. The attributes are separated by tabs, and are held in order:

  1. VERS (DICOM version)
  2. VR (Value Representation)
  3. VM (Value Multiplicity)
  4. KEYWORD (the NAME, without white-space)
  5. NAME (A real-world description of the meaning of this tag)

Once the dictionary is parsed, the tag values are blank, so that when FileDicom reads the new file, it sets the Hashtable in FileInfoDicom to this Hashtable and then sets the value attributes as it reads them in. This way all standard tags are accounted for and if their value attribute is null, the FileInfoDicom table will not display that tag.

Furthermore, the utility of this class is enhanced to provide two additional functions:

  • It parses a dictionary file
  • It has a static method to write out a dicom dictionary out to a file.
Version:
1.0 Aug 1, 1999
Author:
Neva Cherniavsky
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • DEFAULT_DICTIONARY_FILENAME

      public static final String DEFAULT_DICTIONARY_FILENAME
      default dictionary file name, "dicom_dictionary.txt".
      See Also:
    • SUBSET_DICTIONARY_FILENAME

      public static final String SUBSET_DICTIONARY_FILENAME
      subset dictionary file name, "dicomsave.dictionary".
      See Also:
    • DEFAULT_DICTIONARY

      protected static final int DEFAULT_DICTIONARY
      DOCUMENT ME!
      See Also:
    • SUBSET_DICTIONARY

      protected static final int SUBSET_DICTIONARY
      DOCUMENT ME!
      See Also:
    • masterHashtable

      private static Hashtable<FileDicomKey,FileDicomTagInfo> masterHashtable
      Hashtable filled with known DICOM tags with empty value attributes.
    • subsetHashtable

      private static Hashtable<FileDicomKey,FileDicomTagInfo> subsetHashtable
      Hashtable filled with DICOM tags which are a subset (not necessarily a proper subset) of dicom tags in the master table. This subset is then used to export dicom tags to the XML image format.
  • Constructor Details

    • DicomDictionary

      public DicomDictionary()
  • Method Details

    • containsTag

      public static boolean containsTag(FileDicomKey key)
      Returns whether the dicom dictionary contains a tag with the given key identifier.
      Parameters:
      key - the key for this tag
      Returns:
      whether a tag matching the given key is contained in the dicom dictionary.
    • getDicomTagTable

      public static Hashtable<FileDicomKey,FileDicomTagInfo> getDicomTagTable()
      Returns a reference to the DICOM Hashtable.
      Returns:
      a reference to the dicom tag table
    • getDicomTagTable

      public static Hashtable<FileDicomKey,FileDicomTagInfo> getDicomTagTable(boolean forceReload)
      Returns a reference to the DICOM Hashtable.
      Parameters:
      forceReload - If true, forces the master tag table to be re-read from the dicom dictionary file
      Returns:
      a reference to the dicom tag table
    • getInfo

      public static FileDicomTagInfo getInfo(FileDicomKey key)
      Return information about a key in the dicom dictionary.
      Parameters:
      key - the key to retreive information about
      Returns:
      information about the requested key
    • getKeyFromTagName

      public static String getKeyFromTagName(String searchTagName)
      Find the key of the corresponding tag name in the hashtable. Returns null if it no key is found.
      Parameters:
      searchTagName - The name of the tag for which you want the key.
      Returns:
      The key as a String, for example "0010,0028" If the tag name is not in the hashtable, null is returned.
    • getKeyword

      public static String getKeyword(FileDicomKey key)
      Find the keyword of the tag given by the key in the hashtable.
      Parameters:
      key - the key of the desired name.
      Returns:
      the keyword (the 2nd-to-last entry in "dicom_dictionary.txt"). if the tag is not in the hashtable, null is returned.
    • getName

      public static String getName(FileDicomKey key)
      Find the realworld name of the tag given by the key in the hashtable.
      Parameters:
      key - the key of the desired name.
      Returns:
      the realworld name (the last enry in "dicom_dictionary.txt"). if the tag is not in the hashtable, null is returned.
    • doesSubsetDicomTagTableExist

      public static boolean doesSubsetDicomTagTableExist()
      Quietly checks to see if the subset dicom dictionary exists on disk. Can be used to avoid a call to getSubsetDicomTagTable() that might cause a warning dialog to appear.
      Returns:
      True if SUBSET_DICTIONARY_FILENAME exists.
    • getSubsetDicomTagTable

      public static Hashtable<FileDicomKey,FileDicomTagInfo> getSubsetDicomTagTable()
      Returns a reference to the subset dicom tag table.
      Returns:
      A reference to the subset dicom tag table
    • getSubsetDicomTagTable

      public static Hashtable<FileDicomKey,FileDicomTagInfo> getSubsetDicomTagTable(boolean forceReload)
      Returns a reference to the subset dicom tag table.
      Parameters:
      forceReload - If true, forces the subset tag table to be re-read from the dicom save dictionary file
      Returns:
      A reference to the subset dicom tag table
    • getType

      public static FileDicomTagInfo.VR getType(FileDicomKey key)
      Accessor that returns the type of the tag (different from, but related to the vr).
      Parameters:
      key - the key of the desired name.
      Returns:
      the type if the tag is not in the hashtable, null is returned.
    • getVM

      public static int getVM(FileDicomKey key)
      Accessor that returns the value multiplicity of the tag. The value multiplicity is how many instances of this value representation (VR) there can be in one tag.
      Parameters:
      key - the key of the desired name.
      Returns:
      the value multiplicity if the tag is not in the hashtable, 0 is returned.
    • getVR

      public static FileDicomTagInfo.VR getVR(FileDicomKey key)
      Accessor that returns the value representation of the tag. The value representation allows the reader the read and interpret the tag properly. Because private tags are not unique, the VR is null and they may be read and/or displayed improperly.
      Parameters:
      key - the key of the desired name.
      Returns:
      the value representation if the tag is not in the hashtable, null is returned.
    • sortTagKeys

      public static FileDicomKey[] sortTagKeys(Hashtable<FileDicomKey,FileDicomTagInfo> dicomTagsList)
      Sorts the list of tags and returns it as an array in order of FileDicomKeys.
      Parameters:
      dicomTagsList - The hashtable of DICOM tags (the keys are FileDicomKey and the object referred to by that key is the FileDicomTagInfo).
      Returns:
      a sorted array of DICOM Keys.
    • writeFile

      public static void writeFile(File dictFile, Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash) throws IOException
      Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.
      Parameters:
      dictFile - the dicom dictionary file to write out
      dicomHash - the dicom tag mapping to write out
      Throws:
      IOException - when the file cannot be written to.
    • writeFile

      public static void writeFile(File dictFile, Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash, String altComment) throws IOException
      Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.
      Parameters:
      dictFile - the dicom dictionary file to write out
      dicomHash - the dicom tag mapping to write out
      altComment - an additional comment to write out to the file
      Throws:
      IOException - when the file cannot be written to.
    • convertToWildKey

      protected static FileDicomKey convertToWildKey(FileDicomKey key)
      Converts group numbers of 60xx or 50xx dicom key elements so that the dicom dictionary will be able to find them.
    • getFileReader

      protected static BufferedReader getFileReader(String filename)
      Gets a buffered reader for a given file name.
      Parameters:
      filename - The file we will be reading.
      Returns:
      A reader for the given file name.
    • parseFile

      protected static void parseFile(int dictionary_type)
      Method called once when the user opens MIPAV. It parses the dictionary file, normally called "dicom_dictionary.txt". The dictionary file is where all the tags are listed and stores these in the DICOMHashtable, with empty value attributes.
      See Also:
    • doParseFile

      protected static boolean doParseFile()