Class DicomDictionary
- java.lang.Object
-
- gov.nih.mipav.model.file.DicomDictionary
-
public class DicomDictionary extends java.lang.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:- VERS (DICOM version)
- VR (Value Representation)
- VM (Value Multiplicity)
- KEYWORD (the NAME, without white-space)
- 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:
parseFile(int)
,FileInfoDicom
,FileDicom
,FileDicomInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_DICTIONARY
DOCUMENT ME!static java.lang.String
DEFAULT_DICTIONARY_FILENAME
default dictionary file name, "dicom_dictionary.txt".private static java.util.Hashtable<FileDicomKey,FileDicomTagInfo>
masterHashtable
Hashtable filled with known DICOM tags with empty value attributes.private static long
serialVersionUID
Use serialVersionUID for interoperability.protected static int
SUBSET_DICTIONARY
DOCUMENT ME!static java.lang.String
SUBSET_DICTIONARY_FILENAME
subset dictionary file name, "dicomsave.dictionary".private static java.util.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.
-
Constructor Summary
Constructors Constructor Description DicomDictionary()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsTag(FileDicomKey key)
Returns whether the dicom dictionary contains a tag with the given key identifier.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.static boolean
doesSubsetDicomTagTableExist()
Quietly checks to see if the subset dicom dictionary exists on disk.protected static boolean
doParseFile()
static java.util.Hashtable<FileDicomKey,FileDicomTagInfo>
getDicomTagTable()
Returns a reference to the DICOM Hashtable.static java.util.Hashtable<FileDicomKey,FileDicomTagInfo>
getDicomTagTable(boolean forceReload)
Returns a reference to the DICOM Hashtable.protected static java.io.BufferedReader
getFileReader(java.lang.String filename)
Gets a buffered reader for a given file name.static FileDicomTagInfo
getInfo(FileDicomKey key)
Return information about a key in the dicom dictionary.static java.lang.String
getKeyFromTagName(java.lang.String searchTagName)
Find the key of the corresponding tag name in the hashtable.static java.lang.String
getKeyword(FileDicomKey key)
Find the keyword of the tag given by the key in the hashtable.static java.lang.String
getName(FileDicomKey key)
Find the realworld name of the tag given by the key in the hashtable.static java.util.Hashtable<FileDicomKey,FileDicomTagInfo>
getSubsetDicomTagTable()
Returns a reference to the subset dicom tag table.static java.util.Hashtable<FileDicomKey,FileDicomTagInfo>
getSubsetDicomTagTable(boolean forceReload)
Returns a reference to the subset dicom tag table.static FileDicomTagInfo.VR
getType(FileDicomKey key)
Accessor that returns the type of the tag (different from, but related to the vr).static int
getVM(FileDicomKey key)
Accessor that returns the value multiplicity of the tag.static FileDicomTagInfo.VR
getVR(FileDicomKey key)
Accessor that returns the value representation of the tag.protected static void
parseFile(int dictionary_type)
Method called once when the user opens MIPAV.static FileDicomKey[]
sortTagKeys(java.util.Hashtable<FileDicomKey,FileDicomTagInfo> dicomTagsList)
Sorts the list of tags and returns it as an array in order of FileDicomKeys.static void
writeFile(java.io.File dictFile, java.util.Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash)
Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.static void
writeFile(java.io.File dictFile, java.util.Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash, java.lang.String altComment)
Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Use serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
DEFAULT_DICTIONARY_FILENAME
public static final java.lang.String DEFAULT_DICTIONARY_FILENAME
default dictionary file name, "dicom_dictionary.txt".- See Also:
- Constant Field Values
-
SUBSET_DICTIONARY_FILENAME
public static final java.lang.String SUBSET_DICTIONARY_FILENAME
subset dictionary file name, "dicomsave.dictionary".- See Also:
- Constant Field Values
-
DEFAULT_DICTIONARY
protected static final int DEFAULT_DICTIONARY
DOCUMENT ME!- See Also:
- Constant Field Values
-
SUBSET_DICTIONARY
protected static final int SUBSET_DICTIONARY
DOCUMENT ME!- See Also:
- Constant Field Values
-
masterHashtable
private static java.util.Hashtable<FileDicomKey,FileDicomTagInfo> masterHashtable
Hashtable filled with known DICOM tags with empty value attributes.
-
subsetHashtable
private static java.util.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.
-
-
Method Detail
-
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 java.util.Hashtable<FileDicomKey,FileDicomTagInfo> getDicomTagTable()
Returns a reference to the DICOM Hashtable.- Returns:
- a reference to the dicom tag table
-
getDicomTagTable
public static java.util.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 java.lang.String getKeyFromTagName(java.lang.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 java.lang.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 java.lang.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 java.util.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 java.util.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(java.util.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(java.io.File dictFile, java.util.Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash) throws java.io.IOException
Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.- Parameters:
dictFile
- the dicom dictionary file to write outdicomHash
- the dicom tag mapping to write out- Throws:
java.io.IOException
- when the file cannot be written to.
-
writeFile
public static void writeFile(java.io.File dictFile, java.util.Hashtable<FileDicomKey,FileDicomTagInfo> dicomHash, java.lang.String altComment) throws java.io.IOException
Writes the DICOMHashtable given to the file that the CreateDicomFiles points to.- Parameters:
dictFile
- the dicom dictionary file to write outdicomHash
- the dicom tag mapping to write outaltComment
- an additional comment to write out to the file- Throws:
java.io.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 java.io.BufferedReader getFileReader(java.lang.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:
FileDicomTagInfo
-
doParseFile
protected static boolean doParseFile()
-
-