[ismrmrd] 176/281: Install a copy of the jar file inside the matlab class. Matlab api fix so that an error isreturned if the data does not exist yet.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:11 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 1454f25f6681ad25a1d0d1916be89466122b32b6
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Thu Aug 29 10:59:03 2013 -0400

    Install a copy of the jar file inside the matlab class.  Matlab api fix so that an error isreturned if the data does not exist yet.
---
 bindings/java/CMakeLists.txt     |  3 +++
 matlab/+ismrmrd/IsmrmrdDataset.m | 43 ++++++++++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/bindings/java/CMakeLists.txt b/bindings/java/CMakeLists.txt
index 90edc7e..fa3c159 100644
--- a/bindings/java/CMakeLists.txt
+++ b/bindings/java/CMakeLists.txt
@@ -27,8 +27,11 @@ add_custom_command(
     COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/XMLString.java
                ${CMAKE_CURRENT_BINARY_DIR}/org/ismrm/ismrmrd/xmlhdr/
     COMMAND sh make_jar.sh
+    #TODO: split into two jars, one for the headers and one for the xml, or just make two.
+    COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/ismrmrd.jar ${CMAKE_CURRENT_BINARY_DIR}/ismrmrdxmlhdr.jar
     VERBATIM
 )
 
 install(TARGETS jismrmrd DESTINATION java)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ismrmrd.jar DESTINATION java)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ismrmrdxmlhdr.jar DESTINATION matlab/+ismrmrd)
diff --git a/matlab/+ismrmrd/IsmrmrdDataset.m b/matlab/+ismrmrd/IsmrmrdDataset.m
index 68fa01e..c4eae9b 100644
--- a/matlab/+ismrmrd/IsmrmrdDataset.m
+++ b/matlab/+ismrmrd/IsmrmrdDataset.m
@@ -16,6 +16,15 @@ classdef IsmrmrdDataset
             % Set the hdf types
             obj.htypes = ismrmrd.hdf5_datatypes;
             
+            % Set the javaclasspath to be able to load the xml header bits
+            % Check to see if the jar is already on our path
+            [loc,~,~] = fileparts(which(sprintf('ismrmrd.%s',mfilename)));
+            jarpath = fullfile(loc,'ismrmrdxmlhdr.jar');
+            jpath = javaclasspath('-all');
+            if ~any(strcmp(jarpath,jpath))
+                javaaddpath(jarpath);
+            end
+            
             % If the file exists, open it for read/write
             % otherwise, create it
             if exist(filename,'file')
@@ -42,16 +51,15 @@ classdef IsmrmrdDataset
             % Check if the group exists
             lapl_id=H5P.create('H5P_LINK_ACCESS');
             if (H5L.exists(obj.fid,grouppath,lapl_id) == 0)
-                % group does not exist, create it and set a default header
+                % group does not exist, create it
                 group_id = H5G.create(obj.fid, grouppath, 0);
                 H5G.close(group_id);
-                % create a default xml header object
-                %obj.xmlhdr = ismrmrd.XMLHeader();
+                % initialize the xmlhdr object
                 obj.xmlhdr = org.ismrm.ismrmrd.xmlhdr.IsmrmrdHeader();
+                obj.writexml(obj.xmlstring());
             else
                 % group exists, read the xml header
                 % and create a new convert it to an xml header object
-                %obj.xmlhdr = ismrmrd.XMLHeader().stringToHeader(obj.readxml());
                 obj.xmlhdr = org.ismrm.ismrmrd.xmlhdr.XMLString.StringToIsmrmrdHeader(obj.readxml());
             end
             H5P.close(lapl_id);
@@ -60,15 +68,17 @@ classdef IsmrmrdDataset
 
         function obj = close(obj)
             % synchronize the xml header
-            %xmlstring = ismrmrd.XMLHeader.headerToString(obj.xmlhdr);
-            xmlstring = org.ismrm.ismrmrd.xmlhdr.XMLString.IsmrmrdHeaderToString(obj.xmlhdr);
-            obj.writexml(xmlstring);
+            obj.writexml(obj.xmlstring());
             % close the file
             H5F.close(obj.fid);
         end
 
+        function xmlstring = xmlstring(obj)
+            % convert xmlhdr to a string
+            xmlstring = org.ismrm.ismrmrd.xmlhdr.XMLString.IsmrmrdHeaderToString(obj.xmlhdr);
+        end
+        
         function xmlstring = readxml(obj)
-
             % Check if the XML header exists
             % TODO: set it's value to the default
             lapl_id=H5P.create('H5P_LINK_ACCESS');
@@ -100,8 +110,9 @@ classdef IsmrmrdDataset
 
         function writexml(obj,xmlstring)
             % No validation is performed.  You're on your own.
-
-            xmlstring = char(xmlstring)
+            % make sure it's a char
+            xmlstring = char(xmlstring);
+            
             % TODO: add error checking on the write and return a status
             % TODO: if the matlab variable length string bug is resolved
             % then we should change this logic to just modify the length
@@ -135,11 +146,15 @@ classdef IsmrmrdDataset
 
             % Close the XML
             H5D.close(xml_id);
-
         end
 
         function nacq = getNumberOfAcquisitions(obj)
 
+            % Check if the Data exists
+            lapl_id=H5P.create('H5P_LINK_ACCESS');
+            if (H5L.exists(obj.fid, obj.datapath, lapl_id) == 0)
+                error([obj.datapath ' does not exist in the HDF5 dataset.']);
+            end
             dset = H5D.open(obj.fid, obj.datapath);
             space = H5D.get_space(dset);
             H5S.get_simple_extent_dims(space);
@@ -152,6 +167,12 @@ classdef IsmrmrdDataset
 
         function acq = readAcquisition(obj, nacq)
 
+            % Check if the Data exists
+            lapl_id=H5P.create('H5P_LINK_ACCESS');
+            if (H5L.exists(obj.fid, obj.datapath, lapl_id) == 0)
+                error([obj.datapath ' does not exist in the HDF5 dataset.']);
+            end
+
             % Open the data
             dset_id = H5D.open(obj.fid, obj.datapath);
 

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