| 1 |
# C++ Support Library |
| 2 |
To enable easy prototyping of C++ software using the ISMRMRD data format, a simple C++ wrapper class is provided (defined in [dataset.h](../include/ismrmrd/dataset.h)). |
| 3 |
|
| 4 |
Using this wrapper, C++ applications can be programmed as: |
| 5 |
```C++ |
| 6 |
// Open dataset |
| 7 |
ISMRMRD::Dataset d(datafile.c_str(), "dataset", false); |
| 8 |
|
| 9 |
std::string xml; |
| 10 |
d.readHeader(xml); |
| 11 |
ISMRMRD::IsmrmrdHeader hdr; |
| 12 |
ISMRMRD::deserialize(xml.c_str(),hdr); |
| 13 |
|
| 14 |
// Do something with the header |
| 15 |
|
| 16 |
unsigned int number_of_acquisitions = d.getNumberOfAcquisitions(); |
| 17 |
ISMRMRD::Acquisition acq; |
| 18 |
for (unsigned int i = 0; i < number_of_acquisitions; i++) { |
| 19 |
// Read one acquisition at a time |
| 20 |
d.readAcquisition(i, acq); |
| 21 |
|
| 22 |
// Do something with the data |
| 23 |
} |
| 24 |
``` |
| 25 |
|
| 26 |
Since the XML header is defined in the [schema/ismrmrd.xsd](../schema/ismrmrd.xsd) file, it can be parsed with numerous xml parsing libraries. The ISMRMRD library includes an API that allows for programmatically deserializing, manipulating, and serializing the XML header. See the code in the [utilities](https://github.com/ismrmrd/ismrmrd/blob/master/utilities) directory for examples of how to use the XML API. |
| 27 |
|
| 28 |
# C++ Example Applications |
| 29 |
The distribution includes two example applications, one that creates a simple 2D single-channel dataset from scratch and one that reconstructs this dataset (you need FFTW installed to compile these test applications). The data generation application can be found in [utilities/generate_cartesian_shepp_logan.cpp](../utilities/generate_cartesian_shepp_logan.cpp): |
| 30 |
|
| 31 |
To reconstruct this synthetic dataset, you can use the test reconstruction application [utilities/recon_cartesian_2d.cpp](../utilities/recon_cartesian_2d.cpp). |
| 32 |
|
| 33 |
|
| 34 |
# External use of ISMRMRD C++ library in other projects |
| 35 |
To use ISMRMRD for your externally developed projects, add the following to your CMakeLists.txt file: |
| 36 |
``` |
| 37 |
find_package( ISMRMRD REQUIRED ) |
| 38 |
include_directories( ${ISMRMRD_INCLUDE_DIR} ) |
| 39 |
target_link_libraries( mytarget ISMRMRD::ISMRMRD ) |
| 40 |
``` |
| 41 |
then when configuring your package use set the following cmake variables (command line variant shown): |
| 42 |
``` |
| 43 |
cmake <path to my source tree> |
| 44 |
``` |