[ismrmrd] 246/281: Just working through the XML stuff

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit a2978a46c7564188a57324315f6c2d9511a6d939
Author: Michael S. Hansen <michael.hansen at nih.gov>
Date:   Fri Aug 8 16:32:55 2014 -0400

    Just working through the XML stuff
---
 xml/ismrmrd_xml.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 xml/ismrmrd_xml.h   |  2 +-
 2 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/xml/ismrmrd_xml.cpp b/xml/ismrmrd_xml.cpp
index 0f2c0f0..30511a3 100644
--- a/xml/ismrmrd_xml.cpp
+++ b/xml/ismrmrd_xml.cpp
@@ -30,6 +30,49 @@ namespace ISMRMRD
     return *this;
   }
   
+  //Utility Functions for deserializing Header
+  EncodingSpace parse_encoding_space(pugi::xml_node& n, const char* child) 
+  {
+    EncodingSpace e;
+    pugi::xml_node encodingSpace = n.child(child);
+    pugi::xml_node matrixSize = encodingSpace.child("matrixSize");
+    pugi::xml_node fieldOfView_mm = encodingSpace.child("fieldOfView_mm");
+    
+    if (!matrixSize) {
+      throw std::runtime_error("matrixSize not found in encodingSpace");
+    } else {
+      e.matrixSize.x = std::atoi(matrixSize.child_value("x"));
+      e.matrixSize.y = std::atoi(matrixSize.child_value("y"));
+      e.matrixSize.z = std::atoi(matrixSize.child_value("z"));
+    }
+
+    if (!fieldOfView_mm) {
+      throw std::runtime_error("fieldOfView_mm not found in encodingSpace");
+    } else {
+      e.fieldOfView_mm.x = std::atoi(fieldOfView_mm.child_value("x"));
+      e.fieldOfView_mm.y = std::atoi(fieldOfView_mm.child_value("y"));
+      e.fieldOfView_mm.z = std::atoi(fieldOfView_mm.child_value("z"));
+    }
+
+    return e;
+  }
+  
+  Optional<Limit> parse_encoding_limit(pugi::xml_node& n, const char* child) 
+  {
+    Optional<Limit> o;
+    pugi::xml_node nc = n.child(child);
+    
+    if (nc) {
+      Limit l;
+      l.minimum = std::atoi(nc.child_value("minimum"));
+      l.maximum = std::atoi(nc.child_value("maximum"));
+      l.center = std::atoi(nc.child_value("center"));
+      o = l;
+    }
+
+    return o;
+  }
+
   void IsmrmrdHeaderProxy::deserialize(const char* xml) 
   {
     pugi::xml_document doc;
@@ -64,7 +107,46 @@ namespace ISMRMRD
 	throw std::runtime_error("encoding section not found in ismrmrdHeader");
       } else {
 	while (encoding) {
+	  Encoding e;
 	  
+	  try {
+	    e.encodedSpace = parse_encoding_space(encoding,"encodedSpace");
+	    e.reconSpace = parse_encoding_space(encoding,"reconSpace");
+	  } catch (std::runtime_error& e) {
+	    std::cout << "Unable to parse encoding section: " << e.what() << std::endl;
+	    throw;
+	  }
+
+	  pugi::xml_node encodingLimits = encoding.child("encodingLimits");
+	  
+	  if (!encodingLimits) {
+	    throw std::runtime_error("encodingLimits not found in encoding section");
+	  } else {
+	    e.encodingLimits.kspace_encoding_step_0 = parse_encoding_limit(encodingLimits,"kspace_encoding_step_0");
+	    e.encodingLimits.kspace_encoding_step_1 = parse_encoding_limit(encodingLimits,"kspace_encoding_step_1");
+	    e.encodingLimits.kspace_encoding_step_2 = parse_encoding_limit(encodingLimits,"kspace_encoding_step_2");
+	    e.encodingLimits.average                = parse_encoding_limit(encodingLimits,"average");
+	    e.encodingLimits.slice                  = parse_encoding_limit(encodingLimits,"slice");
+	    e.encodingLimits.contrast               = parse_encoding_limit(encodingLimits,"contrast");
+	    e.encodingLimits.phase                  = parse_encoding_limit(encodingLimits,"phase");
+	    e.encodingLimits.repetition             = parse_encoding_limit(encodingLimits,"repetition");
+	    e.encodingLimits.set                    = parse_encoding_limit(encodingLimits,"set");
+	    e.encodingLimits.segment                = parse_encoding_limit(encodingLimits,"segment");
+	  }
+	  
+	  pugi::xml_node trajectory = encoding.child("trajectory");
+	  if (!trajectory) {
+	    throw std::runtime_error("trajectory not found in encoding section");
+	  } else {
+	    e.trajectory = String(trajectory.value());
+	  }
+
+	  pugi::xml_node trajectoryDescription = encoding.child("trajectoryDescription");
+	  
+	  if (trajectoryDescription) {
+	    
+	  }
+
 	  encoding = encoding.next_sibling("encoding");
 	}
 
diff --git a/xml/ismrmrd_xml.h b/xml/ismrmrd_xml.h
index 8b60b9c..febc072 100644
--- a/xml/ismrmrd_xml.h
+++ b/xml/ismrmrd_xml.h
@@ -486,7 +486,7 @@ namespace ISMRMRD
     }
 
   protected:
-    IsmrmrdHeader h_;    
+    IsmrmrdHeader h_;
   };
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list