[ismrmrd] 08/16: Added coil label section to acquisitionSystemInformation, updated C++ XML library to match, fixed some warnings in example C programs

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


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

ghisvail-guest pushed a commit to annotated tag v1.2.0
in repository ismrmrd.

commit 9702a74913482d3d87b93df2595da560dfd9b351
Author: Michael S. Hansen <michael.hansen at nih.gov>
Date:   Mon Dec 15 20:30:46 2014 -0500

    Added coil label section to acquisitionSystemInformation, updated C++ XML library to match, fixed some warnings in example C programs
---
 CMakeLists.txt                      |   4 +-
 examples/c/main.c                   |   6 +-
 include/ismrmrd/xml.h               |   6 ++
 libsrc/xml.cpp                      |  16 ++++-
 schema/ismrmrd.xsd                  |  28 +++++---
 schema/ismrmrd_example_extended.xml | 128 ++++++++++++++++++++++++++++++++++++
 utilities/CMakeLists.txt            |  11 +++-
 utilities/ismrmrd_test_xml.cpp      |  55 ++++++++++++++++
 8 files changed, 237 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 384f4ae..898a031 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,10 +50,10 @@ endif (WIN32)
 #the flexible header. The micro number changes when there are small changes
 #in the utility libraries, that don't affect the data format itself.
 set(ISMRMRD_VERSION_MAJOR 1)
-set(ISMRMRD_VERSION_MINOR 1)
+set(ISMRMRD_VERSION_MINOR 2)
 set(ISMRMRD_VERSION_PATCH 0) 
 
-set(ISMRMRD_XML_SCHEMA_SHA1 "5aa55db3d67187febb1b8bb8da54e67fc745ebd0")
+set(ISMRMRD_XML_SCHEMA_SHA1 "99a63f4e8cf08ffc268f5ee8b8c8b2a1edf69412")
 
 #Remove line breaks and white space that does not change the meaning of the schema
 file(STRINGS ${CMAKE_SOURCE_DIR}/schema/ismrmrd.xsd SCHEMA_STRINGS) #Read all strings from file 
diff --git a/examples/c/main.c b/examples/c/main.c
index bd01a8e..cdb95d4 100644
--- a/examples/c/main.c
+++ b/examples/c/main.c
@@ -108,9 +108,9 @@ int main(void)
     printf("Acquisition index: %u\n", index);
     ismrmrd_read_acquisition(&dataset2, index, &acq2);
     printf("Number of samples: %u\n", acq2.head.number_of_samples);
-    printf("Flags: %llu\n", acq2.head.flags);
-    printf("Channel Mask[0]: %llu\n", acq2.head.channel_mask[0]);
-    printf("Channel Mask[1]: %llu\n", acq2.head.channel_mask[1]);
+    printf("Flags: %lu\n", acq2.head.flags);
+    printf("Channel Mask[0]: %lu\n", acq2.head.channel_mask[0]);
+    printf("Channel Mask[1]: %lu\n", acq2.head.channel_mask[1]);
     printf("Channel 3 is %d\n", ismrmrd_is_channel_on(acq2.head.channel_mask, 3));
     printf("Channel 5 is %d\n", ismrmrd_is_channel_on(acq2.head.channel_mask, 5));
     
diff --git a/include/ismrmrd/xml.h b/include/ismrmrd/xml.h
index 8f8c18f..5695532 100644
--- a/include/ismrmrd/xml.h
+++ b/include/ismrmrd/xml.h
@@ -134,6 +134,11 @@ namespace ISMRMRD
     std::vector<ReferencedImageSequence> referencedImageSequence;
   };
 
+  struct CoilLabel
+  {
+    unsigned short coilNumber;
+    std::string coilName;
+  };
   
   struct AcquisitionSystemInformation
   {
@@ -142,6 +147,7 @@ namespace ISMRMRD
     Optional<float> systemFieldStrength_T;
     Optional<float> relativeReceiverNoiseBandwidth;
     Optional<unsigned short> receiverChannels;
+    std::vector<CoilLabel> coilLabel;
     Optional<std::string> institutionName;
     Optional<std::string> stationName;
   };
diff --git a/libsrc/xml.cpp b/libsrc/xml.cpp
index c782c11..0bab44e 100644
--- a/libsrc/xml.cpp
+++ b/libsrc/xml.cpp
@@ -366,7 +366,7 @@ namespace ISMRMRD
 	    ReferencedImageSequence r;
 	    r.referencedSOPInstanceUID = ric.child_value();
 	    info.referencedImageSequence.push_back(r);
-	    ric = ric.next_sibling("referenceSOPInstanceIUID");
+	    ric = ric.next_sibling("referencedSOPInstanceUID");
 	  }
 	}
 
@@ -380,6 +380,14 @@ namespace ISMRMRD
 	info.systemFieldStrength_T = parse_optional_float(acquisitionSystemInformation, "systemFieldStrength_T");
 	info.relativeReceiverNoiseBandwidth = parse_optional_float(acquisitionSystemInformation, "relativeReceiverNoiseBandwidth");
 	info.receiverChannels = parse_optional_ushort(acquisitionSystemInformation, "receiverChannels");
+	pugi::xml_node coilLabel = acquisitionSystemInformation.child("coilLabel");
+	while (coilLabel) {
+	  CoilLabel l;
+	  l.coilNumber = std::atoi(coilLabel.child_value("coilNumber"));
+	  l.coilName = parse_string(coilLabel, "coilName");
+	  info.coilLabel.push_back(l);
+	  coilLabel = coilLabel.next_sibling("coilLabel");
+	}
 	info.institutionName = parse_optional_string(acquisitionSystemInformation, "institutionName");
 	info.stationName = parse_optional_string(acquisitionSystemInformation, "stationName");
 
@@ -589,6 +597,12 @@ namespace ISMRMRD
       append_optional_node(n1,"systemFieldStrength_T",h.acquisitionSystemInformation->systemFieldStrength_T);
       append_optional_node(n1,"relativeReceiverNoiseBandwidth",h.acquisitionSystemInformation->relativeReceiverNoiseBandwidth);
       append_optional_node(n1,"receiverChannels",h.acquisitionSystemInformation->receiverChannels);
+      for (size_t i = 0; i < h.acquisitionSystemInformation->coilLabel.size(); i++) {
+	n2 = n1.append_child();
+	n2.set_name("coilLabel");
+	append_node(n2,"coilNumber",h.acquisitionSystemInformation->coilLabel[i].coilNumber);
+	append_node(n2,"coilName",h.acquisitionSystemInformation->coilLabel[i].coilName);
+      }
       append_optional_node(n1,"institutionName",h.acquisitionSystemInformation->institutionName);
       append_optional_node(n1,"stationName",h.acquisitionSystemInformation->stationName);
     }
diff --git a/schema/ismrmrd.xsd b/schema/ismrmrd.xsd
index 08eb359..9553980 100644
--- a/schema/ismrmrd.xsd
+++ b/schema/ismrmrd.xsd
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<xs:schema xmlns="http://www.ismrm.org/ISMRMRD" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.ismrm.org/ISMRMRD" version="1">
+<xs:schema xmlns="http://www.ismrm.org/ISMRMRD" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.ismrm.org/ISMRMRD" version="2">
 
     <xs:element name="ismrmrdHeader" type="ismrmrdHeader"/>
 
@@ -81,16 +81,24 @@
     </xs:sequence>
   </xs:complexType>
 
+  <xs:complexType name="coilLabelType">
+    <xs:sequence>
+      <xs:element maxOccurs="1" minOccurs="1" name="coilNumber" type="xs:unsignedShort" />
+      <xs:element maxOccurs="1" minOccurs="1" name="coilName" type="xs:string" />
+    </xs:sequence>
+  </xs:complexType>
+
   <xs:complexType name="acquisitionSystemInformationType">
-    <xs:all>
-      <xs:element minOccurs="0" name="systemVendor" type="xs:string"/>
-      <xs:element minOccurs="0" name="systemModel" type="xs:string"/>
-      <xs:element minOccurs="0" name="systemFieldStrength_T" type="xs:float"/>
-      <xs:element minOccurs="0" name="relativeReceiverNoiseBandwidth" type="xs:float"/>
-      <xs:element minOccurs="0" name="receiverChannels" type="xs:unsignedShort"/>
-      <xs:element minOccurs="0" name="institutionName" type="xs:string"/>
-      <xs:element minOccurs="0" name="stationName" type="xs:string"/>
-    </xs:all>
+    <xs:sequence>
+      <xs:element minOccurs="0" maxOccurs="1" name="systemVendor" type="xs:string"/>
+      <xs:element minOccurs="0" maxOccurs="1" name="systemModel" type="xs:string"/>
+      <xs:element minOccurs="0" maxOccurs="1" name="systemFieldStrength_T" type="xs:float"/>
+      <xs:element minOccurs="0" maxOccurs="1" name="relativeReceiverNoiseBandwidth" type="xs:float"/>
+      <xs:element minOccurs="0" maxOccurs="1" name="receiverChannels" type="xs:unsignedShort"/>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="coilLabel" type="coilLabelType" />  
+      <xs:element minOccurs="0" maxOccurs="1" name="institutionName" type="xs:string"/>
+      <xs:element minOccurs="0" maxOccurs="1" name="stationName" type="xs:string"/>
+    </xs:sequence>
   </xs:complexType>
 
   <xs:complexType name="experimentalConditionsType">
diff --git a/schema/ismrmrd_example_extended.xml b/schema/ismrmrd_example_extended.xml
index 50dcaaa..deb8dbe 100644
--- a/schema/ismrmrd_example_extended.xml
+++ b/schema/ismrmrd_example_extended.xml
@@ -47,6 +47,134 @@
     <systemFieldStrength_T>1.494</systemFieldStrength_T>
     <relativeReceiverNoiseBandwidth>0.79</relativeReceiverNoiseBandwidth>
     <receiverChannels>32</receiverChannels>
+    <coilLabel>
+      <coilNumber>0</coilNumber>
+      <coilName>COIL_0</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>1</coilNumber>
+      <coilName>COIL_1</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>2</coilNumber>
+      <coilName>COIL_2</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>3</coilNumber>
+      <coilName>COIL_3</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>4</coilNumber>
+      <coilName>COIL_4</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>5</coilNumber>
+      <coilName>COIL_5</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>6</coilNumber>
+      <coilName>COIL_6</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>7</coilNumber>
+      <coilName>COIL_7</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>8</coilNumber>
+      <coilName>COIL_8</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>9</coilNumber>
+      <coilName>COIL_9</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>10</coilNumber>
+      <coilName>COIL_10</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>11</coilNumber>
+      <coilName>COIL_11</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>12</coilNumber>
+      <coilName>COIL_12</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>13</coilNumber>
+      <coilName>COIL_13</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>14</coilNumber>
+      <coilName>COIL_14</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>15</coilNumber>
+      <coilName>COIL_15</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>16</coilNumber>
+      <coilName>COIL_16</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>17</coilNumber>
+      <coilName>COIL_17</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>18</coilNumber>
+      <coilName>COIL_18</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>19</coilNumber>
+      <coilName>COIL_19</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>20</coilNumber>
+      <coilName>COIL_20</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>21</coilNumber>
+      <coilName>COIL_21</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>22</coilNumber>
+      <coilName>COIL_22</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>23</coilNumber>
+      <coilName>COIL_23</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>24</coilNumber>
+      <coilName>COIL_24</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>25</coilNumber>
+      <coilName>COIL_25</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>26</coilNumber>
+      <coilName>COIL_26</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>27</coilNumber>
+      <coilName>COIL_27</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>28</coilNumber>
+      <coilName>COIL_28</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>29</coilNumber>
+      <coilName>COIL_29</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>30</coilNumber>
+      <coilName>COIL_30</coilName>
+    </coilLabel>
+    <coilLabel>
+      <coilNumber>31</coilNumber>
+      <coilName>COIL_31</coilName>
+    </coilLabel>
     <institutionName>Some University</institutionName>
     <stationName>MRI Scanner 1</stationName>
   </acquisitionSystemInformation>
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index 363c8c8..f385a37 100644
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -1,7 +1,8 @@
 # Build the info application
 message("Building info application")
 include_directories(${CMAKE_BINARY_DIR}/include
-                    ${CMAKE_SOURCE_DIR}/include)
+                    ${CMAKE_SOURCE_DIR}/include
+		    ${CMAKE_SOURCE_DIR}/libsrc)
 
 add_executable(ismrmrd_info ismrmrd_info.cpp)
 target_link_libraries(ismrmrd_info ismrmrd)
@@ -11,6 +12,14 @@ add_executable(ismrmrd_read_timing_test read_timing_test.cpp)
 target_link_libraries(ismrmrd_read_timing_test ismrmrd)
 install(TARGETS ismrmrd_read_timing_test DESTINATION bin)
 
+if (NOT WIN32)
+  add_executable(ismrmrd_test_xml 
+    ismrmrd_test_xml.cpp 
+    ${CMAKE_SOURCE_DIR}/libsrc/pugixml.cpp )
+  target_link_libraries(ismrmrd_test_xml ismrmrd)
+  install(TARGETS ismrmrd_test_xml DESTINATION bin)
+endif(NOT WIN32)
+
 find_package(Boost COMPONENTS program_options)
 find_package(FFTW3 COMPONENTS single)
 
diff --git a/utilities/ismrmrd_test_xml.cpp b/utilities/ismrmrd_test_xml.cpp
new file mode 100644
index 0000000..a074f29
--- /dev/null
+++ b/utilities/ismrmrd_test_xml.cpp
@@ -0,0 +1,55 @@
+#include <iostream>
+#include <fstream>
+#include <streambuf>
+#include "ismrmrd/xml.h"
+#include "pugixml.hpp"
+
+int main(int argc, char** argv)
+{
+
+  if (argc < 2) {
+    std::cout << "Usage:\n\ttest_ismrmrd_xml <ismrmrd_xml_header.xml>\n" << std::endl;
+    return -1;
+  }
+
+  std::string filename(argv[1]);
+
+  std::cout << "ISMRMRD Header: " << filename << std::endl;
+
+  std::ifstream t(filename.c_str());
+  std::string xml((std::istreambuf_iterator<char>(t)),
+		  std::istreambuf_iterator<char>());
+
+  ISMRMRD::IsmrmrdHeader h;
+  deserialize(xml.c_str(),h);
+
+  pugi::xml_document doc;
+  pugi::xml_parse_result result = doc.load(xml.c_str());
+  if (!result) {
+    std::cout << "Unable to load XML document using pugixml parser" << std::endl;
+  }
+
+  std::ofstream raw("raw.xml");
+  std::ofstream proc("processed.xml");
+  
+
+  doc.save(raw);
+  serialize(h,proc);
+
+  /*
+  deserialize(xml->c_str(),h);
+
+  std::cout << "Resonance frequency: " << h.experimentalConditions.H1resonanceFrequency_Hz << std::endl;
+  std::cout << "TR: " << h.sequenceParameters.get().TR[0] << std::endl;
+  if (h.userParameters) {
+    std::cout << "User parameters found" << std::endl;
+    for (size_t i = 0; i < h.userParameters->userParameterLong.size(); i++) {
+      std::cout << "UserLong: " << h.userParameters->userParameterLong[i].name.c_str() << ", " 
+		<< h.userParameters->userParameterLong[i].value << std::endl;
+    }
+  }
+
+  serialize(h,std::cout);
+  */
+  return 0;
+}

-- 
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