Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions examples/edit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//compile with clang++ --std=c++11 -lvega -lz edit.cpp -o edit
#include <iostream>
#include <cstdlib>
#include <string>

#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<vega::dictionary::PatientName>();
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<vega::dictionary::PatientName>();
element->manipulator()->push_back("Smith^Alice");
}
file.write(argv[2]);
return 0;
}