[ismrmrd] 159/281: Changes to schema and python bindings to fix xml header and readArray.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:09 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 118018ba1f3c59175b1acaaef37b33b1d3e5dff0
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Mon Jul 29 16:25:40 2013 -0400

    Changes to schema and python bindings to fix xml header and readArray.
---
 bindings/python/ismrmrd_python.i |  52 ++++++++++++++++----
 schema/ismrmrd.xsd               | 103 +++++++++++++++++++--------------------
 2 files changed, 92 insertions(+), 63 deletions(-)

diff --git a/bindings/python/ismrmrd_python.i b/bindings/python/ismrmrd_python.i
index b1fb679..544db80 100644
--- a/bindings/python/ismrmrd_python.i
+++ b/bindings/python/ismrmrd_python.i
@@ -377,8 +377,13 @@ import_array();
 {
     PyObject* getData()
     {
-        npy_intp dims[] = { $self->elements() };
-        PyObject *array = PyArray_SimpleNew(1, dims, NPY_USHORT);
+        int ndim = $self->dimensions_.size();
+	npy_intp* dims = new npy_intp[ndim];
+	for (int d=0; d<ndim; d++){
+            dims[d] = $self->dimensions_[d];
+        }
+	PyObject *array = PyArray_New(&PyArray_Type, ndim, dims, NPY_USHORT, NULL, NULL, 0, NPY_ARRAY_FARRAY, NULL);
+	delete[] dims;
 
         char *raw = PyArray_BYTES(array);
         int data_size = PyArray_ITEMSIZE(array);
@@ -423,8 +428,13 @@ import_array();
 {
     PyObject* getData()
     {
-        npy_intp dims[] = { $self->elements() };
-        PyObject *array = PyArray_SimpleNew(1, dims, NPY_FLOAT);
+        int ndim = $self->dimensions_.size();
+	npy_intp* dims = new npy_intp[ndim];
+	for (int d=0; d<ndim; d++){
+            dims[d] = $self->dimensions_[d];
+        }
+	PyObject *array = PyArray_New(&PyArray_Type, ndim, dims, NPY_FLOAT, NULL, NULL, 0, NPY_ARRAY_FARRAY, NULL);
+	delete[] dims;
 
         char *raw = PyArray_BYTES(array);
         int data_size = PyArray_ITEMSIZE(array);
@@ -469,8 +479,13 @@ import_array();
 {
     PyObject* getData()
     {
-        npy_intp dims[] = { $self->elements() };
-        PyObject *array = PyArray_SimpleNew(1, dims, NPY_DOUBLE);
+        int ndim = $self->dimensions_.size();
+	npy_intp* dims = new npy_intp[ndim];
+	for (int d=0; d<ndim; d++){
+            dims[d] = $self->dimensions_[d];
+        }
+	PyObject *array = PyArray_New(&PyArray_Type, ndim, dims, NPY_DOUBLE, NULL, NULL, 0, NPY_ARRAY_FARRAY, NULL);
+	delete[] dims;
 
         char *raw = PyArray_BYTES(array);
         int data_size = PyArray_ITEMSIZE(array);
@@ -515,8 +530,13 @@ import_array();
 {
     PyObject* getData()
     {
-        npy_intp dims[] = { $self->elements() };
-        PyObject *array = PyArray_SimpleNew(1, dims, NPY_CFLOAT);
+        int ndim = $self->dimensions_.size();
+        npy_intp* dims = new npy_intp[ndim];
+        for (int d=0; d<ndim; d++){
+            dims[d] = $self->dimensions_[d];
+        }
+	PyObject *array = PyArray_New(&PyArray_Type, ndim, dims, NPY_CFLOAT, NULL, NULL, 0, NPY_ARRAY_FARRAY, NULL);
+        delete[] dims;
 
         char *raw = PyArray_BYTES(array);
         int data_size = PyArray_ITEMSIZE(array);
@@ -539,6 +559,13 @@ import_array();
             return;
         } 
 
+        //if (PyArray_ISFORTRAN((PyArrayObject*)array)) {
+        //    std::cout << "Fortran" << std::endl;
+        //}
+        //else {
+        //    std::cout << "C" << std::endl;
+        //}
+	
         int ndim = PyArray_NDIM(array);
         npy_intp *dims = PyArray_DIMS(array);
         char *raw = PyArray_BYTES(array);
@@ -562,8 +589,13 @@ import_array();
 {
     PyObject* getData()
     {
-        npy_intp dims[] = { $self->elements() };
-        PyObject *array = PyArray_SimpleNew(1, dims, NPY_CDOUBLE);
+        int ndim = $self->dimensions_.size();
+	npy_intp* dims = new npy_intp[ndim];
+	for (int d=0; d<ndim; d++){
+            dims[d] = $self->dimensions_[d];
+        }
+	PyObject *array = PyArray_New(&PyArray_Type, ndim, dims, NPY_CDOUBLE, NULL, NULL, 0, NPY_ARRAY_FARRAY, NULL);
+	delete[] dims;
 
         char *raw = PyArray_BYTES(array);
         int data_size = PyArray_ITEMSIZE(array);
diff --git a/schema/ismrmrd.xsd b/schema/ismrmrd.xsd
index 96d44f2..4be1512 100644
--- a/schema/ismrmrd.xsd
+++ b/schema/ismrmrd.xsd
@@ -99,27 +99,27 @@
 
   <xs:complexType name="encodingSpaceType">
     <xs:all>
-      <xs:element name="matrixSize">
-	<xs:complexType>
-	  <xs:sequence>
-	    <xs:element default="1" maxOccurs="1" minOccurs="1" name="x" type="xs:unsignedShort"/>
-	    <xs:element default="1" maxOccurs="1" minOccurs="1" name="y" type="xs:unsignedShort"/>
-	    <xs:element default="1" maxOccurs="1" minOccurs="1" name="z" type="xs:unsignedShort"/>
-	  </xs:sequence>
-	</xs:complexType>
-      </xs:element>
-      <xs:element name="fieldOfView_mm">
-	<xs:complexType>
-	  <xs:sequence>
-	    <xs:element maxOccurs="1" minOccurs="1" name="x" type="xs:float"/>
-	    <xs:element maxOccurs="1" minOccurs="1" name="y" type="xs:float"/>
-	    <xs:element maxOccurs="1" minOccurs="1" name="z" type="xs:float"/>
-	  </xs:sequence>
-	</xs:complexType>
-      </xs:element>
+      <xs:element maxOccurs="1" minOccurs="1" name="matrixSize" type="matrixSize"/>
+      <xs:element maxOccurs="1" minOccurs="1" name="fieldOfView_mm" type="fieldOfView_mm"/>
     </xs:all>
   </xs:complexType>
 
+  <xs:complexType name="matrixSize">
+    <xs:sequence>
+      <xs:element default="1" maxOccurs="1" minOccurs="1" name="x" type="xs:unsignedShort"/>
+      <xs:element default="1" maxOccurs="1" minOccurs="1" name="y" type="xs:unsignedShort"/>
+      <xs:element default="1" maxOccurs="1" minOccurs="1" name="z" type="xs:unsignedShort"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="fieldOfView_mm">
+    <xs:sequence>
+      <xs:element maxOccurs="1" minOccurs="1" name="x" type="xs:float"/>
+      <xs:element maxOccurs="1" minOccurs="1" name="y" type="xs:float"/>
+      <xs:element maxOccurs="1" minOccurs="1" name="z" type="xs:float"/>
+    </xs:sequence>
+  </xs:complexType>
+
   <xs:complexType name="limitType">
     <xs:all>
       <xs:element default="0" name="minimum" type="xs:unsignedShort"/>
@@ -164,11 +164,11 @@
   </xs:complexType>
 
   <xs:complexType name="sequenceParametersType">
-  	<xs:sequence>
-  		<xs:element minOccurs="1" maxOccurs="unbounded" type="xs:float" name="TR"/>
-  		<xs:element minOccurs="1" maxOccurs="unbounded" type="xs:float" name="TE"/>
-  		<xs:element minOccurs="0" maxOccurs="unbounded" type="xs:float" name="TI"/>
-  	</xs:sequence>
+    <xs:sequence>
+      <xs:element minOccurs="1" maxOccurs="unbounded" type="xs:float" name="TR"/>
+      <xs:element minOccurs="1" maxOccurs="unbounded" type="xs:float" name="TE"/>
+      <xs:element minOccurs="0" maxOccurs="unbounded" type="xs:float" name="TI"/>
+    </xs:sequence>
   </xs:complexType>
 
   <xs:complexType name="userParameterLongType">
@@ -197,38 +197,35 @@
       <xs:element minOccurs="1" name="studyInstanceUID" type="xs:string"/>
       <xs:element minOccurs="0" name="seriesInstanceUIDRoot" type="xs:string"/>
       <xs:element minOccurs="0" name="frameOfReferenceUID" type="xs:string"/>
+      <xs:element minOccurs="0" name="referencedImageSequence" type="referencedImageSequence"/>
+      <xs:element minOccurs="0" name="MRImageModule" type="MRImageModule"/>
+    </xs:all>
+  </xs:complexType>
 
-      <xs:element minOccurs="0" name="referencedImageSequence">
-        <xs:complexType>
-          <xs:sequence>
-            <xs:element minOccurs="0" maxOccurs="unbounded" name="referencedSOPInstanceUID" type="xs:string"/>
-          </xs:sequence>
-        </xs:complexType>
-      </xs:element>
-
-      <xs:element minOccurs="0" name="MRImageModule">
-        <xs:complexType>
-          <xs:all>
-            <xs:element minOccurs="0" name="imageType" type="xs:string"/>
-            <xs:element minOccurs="0" name="scanningSequence" type="xs:string"/>
-            <xs:element minOccurs="0" name="sequenceVariant" type="xs:string"/>
-            <xs:element minOccurs="0" name="scanOptions" type="xs:string"/>
-            <xs:element minOccurs="0" name="mrAcquisitionType" type="xs:string"/>
-            <xs:element minOccurs="0" name="echoTrainLength" type="xs:long"/>
-            <xs:element minOccurs="0" name="triggerTime" type="xs:float"/>
-            <xs:element minOccurs="0" name="flipAngle_deg" type="xs:long"/>
-            <xs:element minOccurs="0" name="freqEncodingDirection">
-              <xs:simpleType>
-                <xs:restriction base="xs:string">
-                  <xs:enumeration value="ROW"/>
-                  <xs:enumeration value="COL"/>
-                </xs:restriction>
-              </xs:simpleType>
-            </xs:element>
-          </xs:all>
-        </xs:complexType>
+  <xs:complexType name="referencedImageSequence">
+    <xs:sequence>
+      <xs:element minOccurs="0" maxOccurs="unbounded" name="referencedSOPInstanceUID" type="xs:string"/>
+    </xs:sequence>
+  </xs:complexType>
+      
+  <xs:complexType name="MRImageModule">
+    <xs:all>
+      <xs:element minOccurs="0" name="imageType" type="xs:string"/>
+      <xs:element minOccurs="0" name="scanningSequence" type="xs:string"/>
+      <xs:element minOccurs="0" name="sequenceVariant" type="xs:string"/>
+      <xs:element minOccurs="0" name="scanOptions" type="xs:string"/>
+      <xs:element minOccurs="0" name="mrAcquisitionType" type="xs:string"/>
+      <xs:element minOccurs="0" name="echoTrainLength" type="xs:long"/>
+      <xs:element minOccurs="0" name="triggerTime" type="xs:float"/>
+      <xs:element minOccurs="0" name="flipAngle_deg" type="xs:long"/>
+      <xs:element minOccurs="0" name="freqEncodingDirection">
+        <xs:simpleType>
+          <xs:restriction base="xs:string">
+            <xs:enumeration value="ROW"/>
+            <xs:enumeration value="COL"/>
+          </xs:restriction>
+        </xs:simpleType>
       </xs:element>
-
     </xs:all>
   </xs:complexType>
 

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