[ismrmrd] 132/281: Created a VERY simple example java program.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:06 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 52adfafeab03f71fb286ae8f2fa76d93399aa40d
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Fri Apr 5 13:42:19 2013 -0400

    Created a VERY simple example java program.
---
 bindings/java/runme.java        | 16 --------------
 examples/java/ismrmrd_test.java | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/bindings/java/runme.java b/bindings/java/runme.java
deleted file mode 100644
index 30b849b..0000000
--- a/bindings/java/runme.java
+++ /dev/null
@@ -1,16 +0,0 @@
-public class runme {
-    public static void main(String argv[]) {
-        System.loadLibrary("jismrmrd");
-
-        //System.out.format("ISMRMRD_USER_INTS: %d%n", ismrmrd.ISMRMRD_USER_INTS);
-        IsmrmrdDataset f = new IsmrmrdDataset("testdata.h5", "/dataset");
-        String xml = f.readHeader();
-        System.out.println(xml);
-
-        Acquisition a = f.readAcquisition(10);
-        float[] data = a.getData();
-        for (int i=0; i < a.getNumberOfSamples() * a.getActiveChannels(); i++) {
-            System.out.format("%f ", data[i]);
-        }
-    }
-}
diff --git a/examples/java/ismrmrd_test.java b/examples/java/ismrmrd_test.java
new file mode 100644
index 0000000..07177ac
--- /dev/null
+++ b/examples/java/ismrmrd_test.java
@@ -0,0 +1,46 @@
+import org.ismrm.ismrmrd.*;
+import org.ismrm.ismrmrd.xmlhdr.*;
+
+public class ismrmrd_test {
+
+    public static void main(String argv[]) {
+        // Load the ISMRMRD JNI library
+	try {
+	    JNILibLoader.load();
+	}
+	catch (java.net.URISyntaxException e) {
+	    System.err.println("JNI Library failed to load: " + e.getMessage());
+            System.exit(1);
+	}
+	
+	String filename = "";
+	if (argv.length == 1) {
+	    filename = argv[0];
+	}
+	else {
+	    System.err.println("Give me a filename.");
+            System.exit(1);
+	}
+     
+        IsmrmrdDataset f = new IsmrmrdDataset(filename, "/dataset");
+        String xmlstring = f.readHeader();
+        System.out.println("The XML Header");
+        System.out.println(xmlstring);
+
+	IsmrmrdHeader hdr = new IsmrmrdHeader();;
+	try {
+	    hdr = XMLString.StringToIsmrmrdHeader(xmlstring);
+	}
+	catch (javax.xml.bind.JAXBException e){
+	    System.err.println("XML Header could not be parsed." + e.getMessage());
+            System.exit(1);
+	}
+        long freq = hdr.getExperimentalConditions().getH1ResonanceFrequencyHz();
+        System.out.format("%n%n The resonance frequency is %d.%n", freq);
+
+        long nacq = f.getNumberOfAcquisitions();
+        System.out.format("%n%n The number of Acquisitions is %d.%n", nacq);
+
+    }
+
+}

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