Skip to content

Commit

Permalink
Implemented workaround enabling new Gadgetron to read old ISMRMRD acq…
Browse files Browse the repository at this point in the history
…uisition data (#1021)

* implemented workaround enabling new Gadgetron to read old ISMRMRD acquisition data

* added error and warning messages in cases of xml headers versions mismatch

* more verbose error and warning messages in MRAcquisitionData::read

* Fix MR Geometry (#980)

* Added test in python for iamge geometry

* Modified tests to write the nii files correctly

* Added test for reorientation of mr images

* Calculates MR geometry less wrong for stacks of 2D slices

This is not correct yet since it is not well-defined what happens if there are larger gaps between different slices

* Changed GeometricalInfo::operator==() to allow flaot comparison

* Changed reorient and set_up_geom_info
Now the first voxel center is shifted in the 2D case to -FOV/2 which is one slice spacing
every next slice is then displaced by the slice spacing between neighboring slices.

for the 3D case this does not have any effect

* Added 3D reorientation test with bad test data path

* Revert "Added 3D reorientation test with bad test data path"

This reverts commit 21809e4.

* Forgot to save before commit merge

* Edited some comments

* Added random parameters for reorientation test

* Changed input files for python reorientation test

* Updated comment

* Reordered setup steps for 2D mr image

* Modified output data path

* Updated test to store data incorrect location

* Fixed position computation of 2D MR images
This contains two changes.
* The images are now sorted wrt to their projection onto the slice direction.
* The image position of a 2D image now contains the correct offset for each slice

Comments detail the individual changes and their reason

* Cleaned mr cpp tests [ci skip]

* Modified MR dicom python test

* Scales output image before writing dicom in test

* Deleted obsolete test

* Updated comment

* Added check for float tolerance instead of == comparison

* Updated comment

* Updated changes.md

* implemented workaround enabling new Gadgetron to read old ISMRMRD acquisition data

* minor edits (trailing blanks etc) [ci skip]

* reworded XML version error message [ci skip]

Co-authored-by: Johannes Mayer <[email protected]>
  • Loading branch information
evgueni-ovtchinnikov and Johannes Mayer authored Dec 2, 2021
1 parent bf9ea8b commit 02b25e2
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/xGadgetron/cGadgetron/gadgetron_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ limitations under the License.
\author Johannes Mayer
\author SyneRBI
*/
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>

#include <ismrmrd/xml.h>
#include <ismrmrd/ismrmrd.h>


#include <ismrmrd/version.h>
#include <ismrmrd/xml.h>

#include "sirf/common/iequals.h"
Expand Down Expand Up @@ -107,6 +106,30 @@ MRAcquisitionData::read( const std::string& filename_ismrmrd_with_ext )
uint32_t num_acquis = d.getNumberOfAcquisitions();
mtx.unlock();

std::stringstream str;
std::string xml = this->acqs_info_.c_str();
size_t i = xml.find("<version>");
if (i != std::string::npos) {
size_t j = xml.find("</version>");
int va = std::stoi(xml.substr(i + 9, j - i - 9));
int v = ISMRMRD_XMLHDR_VERSION;
if (va > v) {
str << "Input acquisition file was written in with "
<< "ISMRMRD XML version "<< va
<< ", but the version of ISMRMRD used presently by SIRF "
<< "supports XML version " << v
<< " or less only, terminating...";
THROW(str.str());
}
else if (va < v) {
std::cout << "WARNING: ";
std::cout << "acquisitions header version (" << va;
std::cout << ") is older than ISMRMRD header version (" << v;
std::cout << "), ignoring...\n";
this->acqs_info_ = xml.substr(0, i) + xml.substr(j + 10);
}
}

for( uint32_t i_acqu=0; i_acqu<num_acquis; i_acqu++)
{
if( verbose )
Expand Down

0 comments on commit 02b25e2

Please sign in to comment.