diff --git a/README.md b/README.md index 31f0177..34e4fa1 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ The supported file options are: - `--remove_undefined_lengths`: forces the output file(s) to have no data elements with udnefined lengths - `--anonymize` or `--anonymize=my_new_patient_id`: anonymizes the input file(s) +## Documentation + +Please visit [github pages](https://project-eutopia.github.io/vega/). + ## Reading/writing files 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. diff --git a/examples/edit.cpp b/examples/edit.cpp new file mode 100644 index 0000000..cbd99c1 --- /dev/null +++ b/examples/edit.cpp @@ -0,0 +1,32 @@ +//compile with clang++ --std=c++11 -lvega -lz edit.cpp -o edit +#include +#include +#include + +#include "vega/dictionary/dictionary.h" +#include "vega/dicom/file.h" + +int main(int argc, char *argv[]) { + if (argc < 3) { + std::cout << "Usage: edit input_file output_file" << std::endl; + return 1; + } + // Optional you can set the dictionary file + // vega::dictionary::Dictionary::set_dictionary("/path/to/dictionary/dictionary.txt"); + vega::dicom::File file(argv[1]); + + auto element = file.data_set->element(); + if (element) { + // If there are patient names, set them all to "Smith^Alice" + for (auto& name : element->manipulator()) { + name = "Smith^Alice"; + } + } else { + std::cout << "Coudn't find patient name, creating it" << std::endl; + // If there are no patient names, add one with value "Smith^Alice" + element = file.data_set()->new_element(); + element->manipulator()->push_back("Smith^Alice"); + } + file.write(argv[2]); + return 0; +}