Class DicomDirectory
- java.lang.Object
-
- com.pixelmed.dicom.DicomDirectory
-
- All Implemented Interfaces:
javax.swing.tree.TreeModel
public class DicomDirectory extends java.lang.Object implements javax.swing.tree.TreeModel
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap
mapOfDirectoryRecordsToSequenceItems
-
Constructor Summary
Constructors Constructor Description DicomDirectory()
Create an empty DicomDirectoryDicomDirectory(AttributeList list)
Create a DicomDirectory from a DICOMDIR instance already read as an AttributeListDicomDirectory(AttributeList list, boolean doConcatenations)
Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList, optionally creating synthetic concatenation recordsDicomDirectory(java.io.File rootDirectory, java.lang.String[] fileNames)
Create a new DicomDirectory from a list of existing DICOM files contained within a specified root directory.DicomDirectory(java.lang.String[] fileNames)
Create a new DicomDirectory from a list of existing DICOM files contained within the current working directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeListFromDicomFileToDirectory(AttributeList list, java.lang.String fileName)
Add an instance described by a list of attributes to this directory.void
addTreeModelListener(javax.swing.event.TreeModelListener tml)
static java.util.Vector<java.lang.String>
findAllContainedReferencedFileNames(DicomDirectoryRecord record, java.lang.String parentFilePath)
Get all the referenced file names at or below the specified directory record.java.util.Vector<java.lang.String>
findAllContainedReferencedFileNames(java.lang.String parentFilePath)
Get all the referenced file names in the entire directory.static java.util.HashMap<java.lang.String,DicomDirectoryRecord>
findAllContainedReferencedFileNamesAndTheirRecords(DicomDirectoryRecord record, java.lang.String parentFilePath)
Get all the referenced file names at or below the specified directory record, and a map to the directory records that reference them.java.util.HashMap<java.lang.String,DicomDirectoryRecord>
findAllContainedReferencedFileNamesAndTheirRecords(java.lang.String parentFilePath)
Get all the referenced file names in the entire directory, and a map to the directory records that reference them.java.util.Vector<AttributeList>
findAllImagesForFrameOfReference(java.lang.String frameOfReferenceUID)
Get the attribute lists from all the IMAGE level directory records which have a particular FrameOfReferenceUID.java.lang.Object
getChild(java.lang.Object node, int index)
int
getChildCount(java.lang.Object parent)
int
getIndexOfChild(java.lang.Object parent, java.lang.Object child)
java.util.Map<java.lang.String,java.lang.String>
getMapOfSOPInstanceUIDToReferencedFileName(java.lang.String parentFilePath)
Build a map of file names indexed by SOP Instance UID.java.lang.String
getReferencedFileNameForSOPInstanceUID(java.lang.String sopInstanceUID)
Get the file name for the specified SOP Instance UID.java.lang.Object
getRoot()
boolean
isLeaf(java.lang.Object node)
static void
main(java.lang.String[] arg)
Read DICOM files and create a DICOMDIR.void
readDicomFileAndAddToDirectory(java.io.File rootDirectory, java.lang.String fileName)
Read DICOM file and add it to this directory.void
readDicomFileAndAddToDirectory(java.lang.String fileName)
Read DICOM file and add it to this directory.void
removeTreeModelListener(javax.swing.event.TreeModelListener tml)
java.lang.String
toString()
void
valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
void
write(java.lang.String name)
Write the directory to the named file.
-
-
-
Constructor Detail
-
DicomDirectory
public DicomDirectory(java.lang.String[] fileNames)
Create a new DicomDirectory from a list of existing DICOM files contained within the current working directory.
The filenames must be relative to the current working directory, and not absolute paths, since the full name will be used in the DICOMDIR records.
Filenames are NOT checked for compliance with restrictions on length and character set.
- Parameters:
fileNames
- the names of the DICOM files (relative to the current working directory)
-
DicomDirectory
public DicomDirectory(java.io.File rootDirectory, java.lang.String[] fileNames)
Create a new DicomDirectory from a list of existing DICOM files contained within a specified root directory.
The specified root directory will NOT be included in the referenced file name in the DICOMDIR records.
Filenames are NOT checked for compliance with restrictions on length and character set.
- Parameters:
rootDirectory
- the name of the directory to use as the root, which contains the DICOM filefileNames
- the names of the DICOM files (relative to rootDirectory)
-
DicomDirectory
public DicomDirectory()
Create an empty DicomDirectory
-
DicomDirectory
public DicomDirectory(AttributeList list) throws DicomException
Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList- Parameters:
list
- a list of attributes describing a DICOMDIR instance- Throws:
DicomException
- if error in DICOM encoding
-
DicomDirectory
public DicomDirectory(AttributeList list, boolean doConcatenations) throws DicomException
Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList, optionally creating synthetic concatenation records- Parameters:
list
- a list of attributes describing a DICOMDIR instancedoConcatenations
- true if synthetic concatenation records are to be created- Throws:
DicomException
- if error in DICOM encoding
-
-
Method Detail
-
getChild
public java.lang.Object getChild(java.lang.Object node, int index)
- Specified by:
getChild
in interfacejavax.swing.tree.TreeModel
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
- Specified by:
getIndexOfChild
in interfacejavax.swing.tree.TreeModel
-
getRoot
public java.lang.Object getRoot()
- Specified by:
getRoot
in interfacejavax.swing.tree.TreeModel
-
getChildCount
public int getChildCount(java.lang.Object parent)
- Specified by:
getChildCount
in interfacejavax.swing.tree.TreeModel
-
isLeaf
public boolean isLeaf(java.lang.Object node)
- Specified by:
isLeaf
in interfacejavax.swing.tree.TreeModel
-
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
- Specified by:
valueForPathChanged
in interfacejavax.swing.tree.TreeModel
-
addTreeModelListener
public void addTreeModelListener(javax.swing.event.TreeModelListener tml)
- Specified by:
addTreeModelListener
in interfacejavax.swing.tree.TreeModel
-
removeTreeModelListener
public void removeTreeModelListener(javax.swing.event.TreeModelListener tml)
- Specified by:
removeTreeModelListener
in interfacejavax.swing.tree.TreeModel
-
readDicomFileAndAddToDirectory
public void readDicomFileAndAddToDirectory(java.io.File rootDirectory, java.lang.String fileName) throws DicomException, java.io.IOException
Read DICOM file and add it to this directory.- Parameters:
rootDirectory
- the name of the directory to use as the root, which contains the DICOM filefileName
- the name of the DICOM file (relative to rootDirectory)- Throws:
java.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
readDicomFileAndAddToDirectory
public void readDicomFileAndAddToDirectory(java.lang.String fileName) throws DicomException, java.io.IOException
Read DICOM file and add it to this directory.- Parameters:
fileName
- the name of the DICOM file (relative to the current working directory)- Throws:
java.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
addAttributeListFromDicomFileToDirectory
public void addAttributeListFromDicomFileToDirectory(AttributeList list, java.lang.String fileName) throws DicomException, java.io.IOException
Add an instance described by a list of attributes to this directory. Builds the necessary patient, study, series and instance level directory records, with the instance level record being the appropriate type for the SOP Class.- Parameters:
list
- the list of attributes containing the attributes to add to this directoryfileName
- the name of the DICOM file- Throws:
java.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encoding, or the SOP Class is not recognized, or the instance already exists in the directory
-
write
public void write(java.lang.String name) throws java.io.IOException, DicomException
Write the directory to the named file.
- Parameters:
name
- the file name to write to- Throws:
java.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getMapOfSOPInstanceUIDToReferencedFileName
public java.util.Map<java.lang.String,java.lang.String> getMapOfSOPInstanceUIDToReferencedFileName(java.lang.String parentFilePath)
Build a map of file names indexed by SOP Instance UID.
- Parameters:
parentFilePath
- the path to the root of the file names encoded in this directory- Returns:
- a map of SOP Instance UID keys to file names including the supplied parentFilePath
-
getReferencedFileNameForSOPInstanceUID
public java.lang.String getReferencedFileNameForSOPInstanceUID(java.lang.String sopInstanceUID) throws DicomException
Get the file name for the specified SOP Instance UID.
- Parameters:
sopInstanceUID
- the SOP Instance UID wanted- Returns:
- the referenced file name, or null if not found
- Throws:
DicomException
- if map has not been initialized
-
findAllContainedReferencedFileNamesAndTheirRecords
public static java.util.HashMap<java.lang.String,DicomDirectoryRecord> findAllContainedReferencedFileNamesAndTheirRecords(DicomDirectoryRecord record, java.lang.String parentFilePath)
Get all the referenced file names at or below the specified directory record, and a map to the directory records that reference them.
- Parameters:
record
- directory record to start atparentFilePath
- the folder in which the DICOMDIR lives (i.e., the base for contained references)- Returns:
- a
HashMap
whose keys areString
file names fully qualified by the specified parent, mapped to DicomDirectoryRecords
-
findAllContainedReferencedFileNamesAndTheirRecords
public java.util.HashMap<java.lang.String,DicomDirectoryRecord> findAllContainedReferencedFileNamesAndTheirRecords(java.lang.String parentFilePath)
Get all the referenced file names in the entire directory, and a map to the directory records that reference them.
- Parameters:
parentFilePath
- the folder in which the DICOMDIR lives (i.e., the base for contained references)- Returns:
- a
HashMap
whose keys areString
file names fully qualified by the specified parent, mapped to DicomDirectoryRecords
-
findAllContainedReferencedFileNames
public static java.util.Vector<java.lang.String> findAllContainedReferencedFileNames(DicomDirectoryRecord record, java.lang.String parentFilePath)
Get all the referenced file names at or below the specified directory record.
- Parameters:
record
- directory record to start atparentFilePath
- the folder in which the DICOMDIR lives (i.e., the base for contained references)- Returns:
- a
Vector
ofString
file names fully qualified by the specified parent
-
findAllContainedReferencedFileNames
public java.util.Vector<java.lang.String> findAllContainedReferencedFileNames(java.lang.String parentFilePath)
Get all the referenced file names in the entire directory.
- Parameters:
parentFilePath
- the folder in which the DICOMDIR lives (i.e., the base for contained references)- Returns:
- a
Vector
ofString
file names fully qualified by the specified parent
-
findAllImagesForFrameOfReference
public java.util.Vector<AttributeList> findAllImagesForFrameOfReference(java.lang.String frameOfReferenceUID)
Get the attribute lists from all the IMAGE level directory records which have a particular FrameOfReferenceUID.
Useful for finding potential localizers and orthogonal images.
Note that even though FrameOfReference is a series level entity, in the CT/MR profiles it is specified at the IMAGE directory record level.
- Parameters:
frameOfReferenceUID
- the frame of reference UID to search for- Returns:
- a
Vector
ofAttributeList
-
main
public static void main(java.lang.String[] arg)
Read DICOM files and create a DICOMDIR.
- Parameters:
arg
- optionally the folder in which the files and DICOMDIR are rooted, the filename of the DICOMDIR to be created, then optionally a list of all the filenames of the DICOM files to include (otherwise the folder will be searched)
-
-