vega
|
C++ library for reading/writing/editing DICOM files. Detailed documentation can be found here.
To get started, clone the repository:
To compile and install the shared library to your system, take the following steps:
To compile code that uses this library, you should link the library, the zlib library, and have to use at least C++11 standard:
Here is a simple example of using the library to read a file in and print a string representation of the content to standard out.
To write a DICOM file, you call the vega::dicom::File::write
method, either passing in a string that represents the file name, or a std::shared_ptr<std::ostream>
pointer to an output stream.
To create a new DICOM file, use the File
constructor with either const SOPClass&
reference, or a const SOPClass&
reference and const UID&
reference to a SOP instance UID.
The rough structure of a DICOM file is that at the root of a DICOM file is a single data set, where each data set contains a set of data elements. A data element is identified by a unique tag, which is a pair of 2 byte unsigned integers, often represented in hexadecimal, for instance (300A,00C2) is the tag corresponding to "Beam Name". A data set contains at most one data element for each tag, so it is effectively a map from tags to data elements. Each data element contains some data whose interpretation is determined by the tag, for instance (0010,0010) which corresponds to the patient's name. The storage format of the data is determined by the value representation (or VR).
Each File
object has a data_set()
method which returns a shared_ptr
to the root vega::dicom::DataSet
object. DataSet
has iterators for going through each DataElement
, and also offers many useful methods for selecting a specific DataElement
. You can search for a DataElement
using a dictionary element string name, e.g. "PatientName"
or a tag like Tag{0x0010,0x0010}
.
The data stored inside each DataElement
is accessed through what is called a manipulator. Each manipulator, for instance vega::manipulators::DateManipulator
is used for data elements with VR DA (corresponding to "date"). This manipulator acts very much like a std::vector
of vega::Date
objects which makes reading, adding, and modifying data very easy. The translation to the behind-the-scenes DICOM formats is hidden from the user.
In addition to DataElement
, there is also an easier to use class vega::dicom::Element<T>
, where T
is a dictionary element type (e.g. vega::dictionary::PatientName
, see include/vega/dictionary_data.h
for all possibilities). The benefit of using this class is that you do not need to make explicit the manipulator class, as it is implied by the type (e.g. vega::dictionary::PatientName::manipulator_type
is the expected PersonNameManipulator
). As an example of adding patient name to a new data set: