[ismrmrd] 01/01: Imported Upstream version 0.5.2
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Fri May 9 23:01:36 UTC 2014
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch upstream
in repository ismrmrd.
commit 33064202ddcb28c2b8776ede6a846b5c9dad7ff5
Author: Ghislain Vaillant <ghisvail at gmail.com>
Date: Fri May 9 21:17:52 2014 +0100
Imported Upstream version 0.5.2
---
CMakeLists.txt | 16 +-
bindings/CMakeLists.txt | 13 +-
bindings/java/CMakeLists.txt | 5 +-
bindings/python/ismrmrd_python.i | 6 +
examples/matlab/test_create_dataset.m | 8 +-
examples/matlab/test_recon_dataset.m | 32 ++-
matlab/+ismrmrd/+util/hdf5_datatypes.m | 384 ++++++++-------------------------
matlab/+ismrmrd/Acquisition.m | 16 +-
matlab/+ismrmrd/AcquisitionHeader.m | 283 +++++++++++++++++++-----
matlab/+ismrmrd/ImageHeader.m | 249 +++++++++++++++------
matlab/+ismrmrd/IsmrmrdDataset.m | 6 +-
11 files changed, 570 insertions(+), 448 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d0de14..49d1ba1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,7 @@ SET(XSDS schema/ismrmrd.xsd)
SET(XSD_ARGS cxx-tree --generate-serialization)
#SET(XSD_ARGS cxx-tree --generate-serialization --export-symbol EXPORTISMRMRDXSD --hxx-prologue-file ${CMAKE_SOURCE_DIR}/ismrmrd_xsd_export.h)
WRAP_XSD(XSDS_SOURCES XSD_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/schema ${XSDS} OPTIONS ${XSD_ARGS})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src/xsd ${XSD_INCLUDE_DIR} ${XERCESC_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${HDF5_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}/cpp)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src/xsd ${XSD_INCLUDE_DIR} ${XERCESC_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${HDF5_CXX_INCLUDE_DIR} ${HDF5_C_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
# This dummy is required to trigger autogeneration of ${XSDS_SOURCES}
@@ -38,18 +38,12 @@ add_library(ismrmrd SHARED ismrmrd_hdf5.cpp)
#The findHDF5.cmake does not work very well on Windows, let's help it out
IF(WIN32)
- SET(HDF5_LIB_DIR ${HDF5_INCLUDE_DIR}/../lib)
- target_link_libraries(ismrmrd optimized ${HDF5_LIB_DIR}/hdf5dll.lib)
- target_link_libraries(ismrmrd optimized ${HDF5_LIB_DIR}/hdf5_cppdll.lib)
- target_link_libraries(ismrmrd optimized ${HDF5_LIB_DIR}/hdf5_hldll.lib)
+ target_link_libraries(ismrmrd optimized ${HDF5_hdf5_LIBRARY_RELEASE} ${HDF5_hdf5_cpp_LIBRARY_RELEASE})
+ target_link_libraries(ismrmrd debug ${HDF5_hdf5_LIBRARY_DEBUG} ${HDF5_hdf5_cpp_LIBRARY_DEBUG})
- target_link_libraries(ismrmrd debug ${HDF5_LIB_DIR}/hdf5ddll.lib)
- target_link_libraries(ismrmrd debug ${HDF5_LIB_DIR}/hdf5_cppddll.lib)
- target_link_libraries(ismrmrd debug ${HDF5_LIB_DIR}/hdf5_hlddll.lib)
-
- target_link_libraries(ismrmrd ${Boost_LIBRARIES})
+ target_link_libraries(ismrmrd ${Boost_LIBRARIES})
ELSE (WIN32)
- target_link_libraries(ismrmrd ${HDF5_LIBRARIES} ${Boost_LIBRARIES})
+ target_link_libraries(ismrmrd ${HDF5_LIBRARIES} ${Boost_LIBRARIES})
ENDIF(WIN32)
INSTALL(FILES ismrmrd.h ismrmrd_hdf5.h ismrmrd_hdf5_datatypes.h ismrmrd_export.h DESTINATION include)
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 4be6529..3b31948 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -8,11 +8,7 @@ if(SWIG_FOUND)
if(PYTHONLIBS_FOUND)
find_package(NumPy)
if(NUMPY_FOUND)
- if (NUMPY_VERSION VERSION_LESS "1.7")
- message("NumPy version < 1.7. Not building Python bindings")
- else (${NUMPY_VERSION} VERSION_LESS "1.7")
- add_subdirectory(python)
- endif (NUMPY_VERSION VERSION_LESS "1.7")
+ add_subdirectory(python)
else(NUMPY_FOUND)
message("NumPy not found. Not building Python bindings")
endif(NUMPY_FOUND)
@@ -22,10 +18,9 @@ if(SWIG_FOUND)
find_package(JNI)
if(JNI_FOUND)
- message(STATUS "JAVA Include Path: ${JAVA_INCLUDE_PATH}")
add_subdirectory(java)
- else()
- message("JNI not found. Not building Java bindings")
- endif()
+ else(JNI_FOUND)
+ message("Java Native Interface not found. Not building Java bindings")
+ endif(JNI_FOUND)
endif(SWIG_FOUND)
diff --git a/bindings/java/CMakeLists.txt b/bindings/java/CMakeLists.txt
index 5eb54b9..1355612 100644
--- a/bindings/java/CMakeLists.txt
+++ b/bindings/java/CMakeLists.txt
@@ -1,9 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${HDF5_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}/cpp ${Boost_INCLUDE_DIR})
-include_directories(${JAVA_INCLUDE_PATH})
-if (UNIX)
- include_directories(${JAVA_INCLUDE_PATH}/linux)
-endif (UNIX)
+include_directories(${JNI_INCLUDE_DIRS})
set(CMAKE_SWIG_FLAGS -package org.ismrm.ismrmrd)
set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/org/ismrm/ismrmrd)
diff --git a/bindings/python/ismrmrd_python.i b/bindings/python/ismrmrd_python.i
index e577e81..c564a1f 100644
--- a/bindings/python/ismrmrd_python.i
+++ b/bindings/python/ismrmrd_python.i
@@ -7,6 +7,12 @@
#include "ismrmrd_hdf5.h"
#include "numpy/arrayobject.h"
+// for compatibility with Numpy version <= 1.6
+#define NUMPY17_API 0x00000007
+#if NPY_FEATURE_VERSION < NUMPY17_API
+#define NPY_ARRAY_FARRAY NPY_FARRAY
+#endif
+
#define SWIG_FILE_WITH_INIT
/* exception helpers */
diff --git a/examples/matlab/test_create_dataset.m b/examples/matlab/test_create_dataset.m
index a9c17f8..ceeff32 100644
--- a/examples/matlab/test_create_dataset.m
+++ b/examples/matlab/test_create_dataset.m
@@ -50,13 +50,13 @@ end
acqblock = ismrmrd.Acquisition(nY);
% Set the header elements that don't change
-acqblock.head.version(:) = 1.0;
+acqblock.head.version(:) = 1;
acqblock.head.number_of_samples(:) = nX;
acqblock.head.center_sample(:) = floor(nX/2);
acqblock.head.active_channels(:) = nCoils;
-acqblock.head.read_dir = repmat(single([1 0 0]'),[1 nY]);
-acqblock.head.phase_dir = repmat(single([0 1 0]'),[1 nY]);
-acqblock.head.slice_dir = repmat(single([0 0 1]'),[1 nY]);
+acqblock.head.read_dir = repmat([1 0 0]',[1 nY]);
+acqblock.head.phase_dir = repmat([0 1 0]',[1 nY]);
+acqblock.head.slice_dir = repmat([0 0 1]',[1 nY]);
% Loop over the acquisitions, set the header, set the data and append
for rep = 1:nReps
diff --git a/examples/matlab/test_recon_dataset.m b/examples/matlab/test_recon_dataset.m
index 3cb0a16..00cd4e5 100644
--- a/examples/matlab/test_recon_dataset.m
+++ b/examples/matlab/test_recon_dataset.m
@@ -28,7 +28,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Loading an existing file %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-filename = 'shepp-logan.h5';
+filename = 'testdata.h5';
if exist(filename, 'file')
dset = ismrmrd.IsmrmrdDataset(filename, 'dataset');
else
@@ -62,23 +62,33 @@ rec_FOVz = dset.xmlhdr.getEncoding.get(0).getReconSpace.getFieldOfViewMm.getZ;
if isempty(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getSlice)
nSlices = 1;
else
- nSlices = dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getSlice.getMaximum;
+ nSlices = dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getSlice.getMaximum;
+ if nSlices == 0;
+ nSlices = 1;
+ end
end
-% Number of coils, in the system information
-nCoils = double(dset.xmlhdr.getAcquisitionSystemInformation.getReceiverChannels);
+% Number of coils, repetitions, contrasts etc.
+% We have to wrap this in a try/catch because a valid xml header may
+% not have an entry for the the parameter in question
+% Encoding limit values in the XML header are zero based
+% Java return values needed to be converte to matlab types for math.
+try
+ nCoils = double(dset.xmlhdr.getAcquisitionSystemInformation.getReceiverChannels);
+catch
+ nCoils = 1;
+end
-% Repetitions, contrasts etc.
-if isempty(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getRepetition)
+try
+ nReps = double(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getRepetition.getMaximum) + 1;
+catch
nReps = 1;
-else
- nReps = double(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getRepetition.getMaximum);
end
-if isempty(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getContrast)
+try
+ nContrasts = double(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getContrast.getMaximum) + 1;
+catch
nContrasts = 1;
-else
- nContrasts = double(dset.xmlhdr.getEncoding.get(0).getEncodingLimits.getContrast.getMaximum);
end
% TODO add the other possibilites
diff --git a/matlab/+ismrmrd/+util/hdf5_datatypes.m b/matlab/+ismrmrd/+util/hdf5_datatypes.m
index 14788d7..2562d08 100644
--- a/matlab/+ismrmrd/+util/hdf5_datatypes.m
+++ b/matlab/+ismrmrd/+util/hdf5_datatypes.m
@@ -1,6 +1,11 @@
classdef hdf5_datatypes
% This convenience class defines the HDF5 types used in the
% ISMRMRD HDF5 file
+
+% The names, types, layout and offsets consistent with that generated
+% by the C++ API. See the note at the bottom of the file for how to
+% do this.
+
properties
T_float;
T_double;
@@ -63,144 +68,46 @@ classdef hdf5_datatypes
function b = getType_EncodingCounters()
- typesize = 17*H5T.get_size('H5T_NATIVE_UINT16');
- b = H5T.create ('H5T_COMPOUND', typesize);
-
- offset = 0;
- H5T.insert(b, 'kspace_encode_step_1', offset, 'H5T_NATIVE_UINT16');
-
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
- H5T.insert(b, 'kspace_encode_step_2', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'average', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'slice', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'contrast', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'phase', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'repetition', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'set', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'segment', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'user', offset, H5T.array_create('H5T_NATIVE_UINT16',[8]));
+ b = H5T.create ('H5T_COMPOUND', 34);
+ H5T.insert(b, 'kspace_encode_step_1', 0, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'kspace_encode_step_2', 2, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'average', 4, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'slice', 6, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'contrast', 8, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'phase', 10, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'repetition', 12, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'set', 14, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'segment', 16, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'user', 18, H5T.array_create('H5T_NATIVE_UINT16',[8]));
end
function b = getType_AcquisitionHeader()
-
- typesize = 0;
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % version
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT64'); % flag
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT32'); % measurement_uid
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT32'); % scan_counter
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT32'); % acquisition_time_stamp
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_UINT32'); % physio_time_stamps
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % number_of_samples
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % available_channels
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % active_channels
- typesize = typesize + 16*H5T.get_size('H5T_NATIVE_UINT64'); % channel_mask
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % discard_pre
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % discard_post
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % center_sample
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % encoding_space_ref
- typesize = typesize + H5T.get_size('H5T_NATIVE_UINT16'); % trajectory_dimension
- typesize = typesize + H5T.get_size('H5T_NATIVE_FLOAT'); % sample_time_us
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_FLOAT'); % position
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_FLOAT'); % read_dir
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_FLOAT'); % phase_dir
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_FLOAT'); % slice_dir
- typesize = typesize + 3*H5T.get_size('H5T_NATIVE_FLOAT'); % patient_table_position
- typesize = typesize + H5T.get_size(ismrmrd.util.hdf5_datatypes.getType_EncodingCounters()); % idx
- typesize = typesize + 8*H5T.get_size('H5T_NATIVE_INT32'); % user_int
- typesize = typesize + 8*H5T.get_size('H5T_NATIVE_FLOAT'); % user_float
-
- b = H5T.create ('H5T_COMPOUND', typesize);
-
- offset = 0;
- H5T.insert(b, 'version', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'flags', offset, 'H5T_NATIVE_UINT64');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT64');
-
- H5T.insert(b, 'measurement_uid', offset, 'H5T_NATIVE_UINT32');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT32');
-
- H5T.insert(b, 'scan_counter', offset, 'H5T_NATIVE_UINT32');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT32');
-
- H5T.insert(b, 'acquisition_time_stamp', offset, 'H5T_NATIVE_UINT32');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT32');
-
- H5T.insert(b, 'physiology_time_stamp', offset, H5T.array_create('H5T_NATIVE_UINT32',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_UINT32');
-
- H5T.insert(b, 'number_of_samples', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'available_channels', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'active_channels', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'channel_mask', offset, H5T.array_create('H5T_NATIVE_UINT64',[16]));
- offset = offset + 16*H5T.get_size('H5T_NATIVE_UINT64');
-
- H5T.insert(b, 'discard_pre', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'discard_post', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'center_sample', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'encoding_space_ref', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'trajectory_dimensions', offset, 'H5T_NATIVE_UINT16');
- offset = offset + H5T.get_size('H5T_NATIVE_UINT16');
-
- H5T.insert(b, 'sample_time_us', offset, 'H5T_NATIVE_FLOAT');
- offset = offset + H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'position', offset, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'read_dir', offset, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'phase_dir', offset, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'slice_dir', offset, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'patient_table_position', offset, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
- offset = offset + 3*H5T.get_size('H5T_NATIVE_FLOAT');
-
- H5T.insert(b, 'idx', offset, ismrmrd.util.hdf5_datatypes.getType_EncodingCounters);
- offset = offset + H5T.get_size(ismrmrd.util.hdf5_datatypes.getType_EncodingCounters);
-
- H5T.insert(b, 'user_int', offset, H5T.array_create('H5T_NATIVE_INT32',[8]));
- offset = offset + 8*H5T.get_size('H5T_NATIVE_INT32');
-
- H5T.insert(b, 'user_float', offset, H5T.array_create('H5T_NATIVE_FLOAT',[8]));
- %offset = offset + 8*H5T.get_size('H5T_NATIVE_FLOAT');
-
+ b = H5T.create ('H5T_COMPOUND', 360);
+ H5T.insert(b, 'version', 0, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'flags', 2, 'H5T_NATIVE_UINT64');
+ H5T.insert(b, 'measurement_uid', 10, 'H5T_NATIVE_UINT32');
+ H5T.insert(b, 'scan_counter', 14, 'H5T_NATIVE_UINT32');
+ H5T.insert(b, 'acquisition_time_stamp', 18, 'H5T_NATIVE_UINT32');
+ H5T.insert(b, 'physiology_time_stamp', 22, H5T.array_create('H5T_NATIVE_UINT32',[3]));
+ H5T.insert(b, 'number_of_samples', 54, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'available_channels', 56, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'active_channels', 58, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'channel_mask', 60, H5T.array_create('H5T_NATIVE_UINT64',[16]));
+ H5T.insert(b, 'discard_pre', 188, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'discard_post', 190, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'center_sample', 192, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'encoding_space_ref', 194, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'trajectory_dimensions', 196, 'H5T_NATIVE_UINT16');
+ H5T.insert(b, 'sample_time_us', 198, 'H5T_NATIVE_FLOAT');
+ H5T.insert(b, 'position', 202, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
+ H5T.insert(b, 'read_dir', 214, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
+ H5T.insert(b, 'phase_dir', 226, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
+ H5T.insert(b, 'slice_dir', 238, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
+ H5T.insert(b, 'patient_table_position', 250, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
+ H5T.insert(b, 'idx', 262, ismrmrd.util.hdf5_datatypes.getType_EncodingCounters);
+ H5T.insert(b, 'user_int', 296, H5T.array_create('H5T_NATIVE_INT32',[8]));
+ H5T.insert(b, 'user_float', 328, H5T.array_create('H5T_NATIVE_FLOAT',[8]));
end
function b = getType_Acquisition()
@@ -209,171 +116,56 @@ classdef hdf5_datatypes
traj = H5T.vlen_create(ismrmrd.util.hdf5_datatypes.getType_float());
data = H5T.vlen_create(ismrmrd.util.hdf5_datatypes.getType_float());
- typesize = H5T.get_size(head) + H5T.get_size(traj) + H5T.get_size(data);
-
- b = H5T.create ('H5T_COMPOUND', typesize);
-
- offset = 0;
- H5T.insert(b, 'head', offset, head);
- offset = offset + H5T.get_size(head);
- H5T.insert(b, 'traj', offset, traj);
- offset = offset + H5T.get_size(traj);
- H5T.insert(b, 'data', offset, data);
+ b = H5T.create ('H5T_COMPOUND', 392);
+ H5T.insert(b, 'head', 0, head);
+ H5T.insert(b, 'traj', 360, traj);
+ H5T.insert(b, 'data', 376, data);
end
end % Methods (Static)
end
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(AcquisitionHeader_with_data)));
-%
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<AcquisitionHeader>();
-% boost::shared_ptr<DataType> cxvdatatype = getIsmrmrdHDF5Type<complex_t>();
-% cxvdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (cxvdatatype->getId())));
-% boost::shared_ptr<DataType> realvdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (PredType::NATIVE_FLOAT.getId())));
-%
-% ret->insertMember( "head", HOFFSET(AcquisitionHeader_with_data,head), *head_type);
-% ret->insertMember( "traj", HOFFSET(AcquisitionHeader_with_data,traj), *realvdatatype);
-% ret->insertMember( "data", HOFFSET(AcquisitionHeader_with_data,data), *cxvdatatype);
-
-
-
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader>()
-% {
-%
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader)));
-%
-% ret->insertMember( "version", HOFFSET(ImageHeader, version), PredType::NATIVE_UINT16);
-% ret->insertMember( "flags", HOFFSET(ImageHeader, flags), PredType::NATIVE_UINT64);
-% ret->insertMember( "measurement_uid", HOFFSET(ImageHeader, measurement_uid), PredType::NATIVE_UINT32);
-%
-% std::vector<hsize_t> dims(1,0);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> mat_size_array_type(new ArrayType(PredType::NATIVE_UINT16, 1, &dims[0]));
-% ret->insertMember( "matrix_size", HOFFSET(ImageHeader, matrix_size), *mat_size_array_type);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> fov_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "field_of_view", HOFFSET(ImageHeader, field_of_view), *fov_array_type);
-%
-% ret->insertMember( "channels", HOFFSET(ImageHeader, channels), PredType::NATIVE_UINT16);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> position_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "position", HOFFSET(ImageHeader, position), *position_array_type);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> phase_dir_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "phase_dir", HOFFSET(ImageHeader, phase_dir), *phase_dir_array_type);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> slice_dir_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "slice_dir", HOFFSET(ImageHeader, slice_dir), *slice_dir_array_type);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> table_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "patient_table_position", HOFFSET(ImageHeader, patient_table_position), *table_array_type);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> table_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "patient_table_position", HOFFSET(ImageHeader, patient_table_position), *table_array_type);
-%
-%
-% ret->insertMember( "average", HOFFSET(ImageHeader, average), PredType::NATIVE_UINT16);
-% ret->insertMember( "slice", HOFFSET(ImageHeader, slice), PredType::NATIVE_UINT16);
-% ret->insertMember( "contrast", HOFFSET(ImageHeader, contrast), PredType::NATIVE_UINT16);
-% ret->insertMember( "phase", HOFFSET(ImageHeader, phase), PredType::NATIVE_UINT16);
-% ret->insertMember( "repetition", HOFFSET(ImageHeader, repetition), PredType::NATIVE_UINT16);
-% ret->insertMember( "set", HOFFSET(ImageHeader, set), PredType::NATIVE_UINT16);
-% ret->insertMember( "acquisition_time_stamp", HOFFSET(ImageHeader, acquisition_time_stamp), PredType::NATIVE_UINT32);
-%
-% dims[0] = 3;
-% boost::shared_ptr<DataType> array_type(new ArrayType(PredType::NATIVE_UINT32, 1, &dims[0]));
-% ret->insertMember( "physiology_time_stamp", HOFFSET(ImageHeader, physiology_time_stamp), *array_type);
-%
-% ret->insertMember( "image_data_type", HOFFSET(ImageHeader, image_data_type), PredType::NATIVE_UINT16);
-% ret->insertMember( "image_type", HOFFSET(ImageHeader, image_type), PredType::NATIVE_UINT16);
-% ret->insertMember( "image_index", HOFFSET(ImageHeader, image_index), PredType::NATIVE_UINT16);
-% ret->insertMember( "image_series_index", HOFFSET(ImageHeader, image_series_index), PredType::NATIVE_UINT16);
-%
-% dims[0] = 8;
-% boost::shared_ptr<DataType> user_int_array_type(new ArrayType(PredType::NATIVE_INT32, 1, &dims[0]));
-% ret->insertMember( "user_int", HOFFSET(ImageHeader, user_int), *user_int_array_type);
-%
-% dims[0] = 8;
-% boost::shared_ptr<DataType> user_float_array_type(new ArrayType(PredType::NATIVE_FLOAT, 1, &dims[0]));
-% ret->insertMember( "user_float", HOFFSET(ImageHeader, user_float), *user_float_array_type);
-%
-% return ret;
-% }
-%
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data<float> >()
-% {
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader_with_data<float>)));
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<ImageHeader>();
-% boost::shared_ptr<DataType> vdatatype = getIsmrmrdHDF5Type<float>();
-% vdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (vdatatype->getId())));
-% ret->insertMember( "head", HOFFSET(ImageHeader_with_data<float>,head), *head_type);
-% ret->insertMember( "data", HOFFSET(ImageHeader_with_data<float>,data), *vdatatype);
-% return ret;
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data<double> >()
-% {
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader_with_data<double>)));
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<ImageHeader>();
-% boost::shared_ptr<DataType> vdatatype = getIsmrmrdHDF5Type<double>();
-% vdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (vdatatype->getId())));
-% ret->insertMember( "head", HOFFSET(ImageHeader_with_data<double>,head), *head_type);
-% ret->insertMember( "data", HOFFSET(ImageHeader_with_data<double>,data), *vdatatype);
-% return ret;
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data<unsigned short> >()
-% {
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader_with_data<unsigned short>)));
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<ImageHeader>();
-% boost::shared_ptr<DataType> vdatatype = getIsmrmrdHDF5Type<unsigned short>();
-% vdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (vdatatype->getId())));
-% ret->insertMember( "head", HOFFSET(ImageHeader_with_data<unsigned short>,head), *head_type);
-% ret->insertMember( "data", HOFFSET(ImageHeader_with_data<unsigned short>,data), *vdatatype);
-% return ret;
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data<complex_t> >()
-% {
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader_with_data<complex_t>)));
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<ImageHeader>();
-% boost::shared_ptr<DataType> vdatatype = getIsmrmrdHDF5Type<complex_t>();
-% vdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (vdatatype->getId())));
-% ret->insertMember( "head", HOFFSET(ImageHeader_with_data<complex_t>,head), *head_type);
-% ret->insertMember( "data", HOFFSET(ImageHeader_with_data<complex_t>,data), *vdatatype);
-% return ret;
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data<double_complex_t> >()
-% {
-% boost::shared_ptr<CompType> ret = boost::shared_ptr<CompType>(new CompType(sizeof(ImageHeader_with_data<double_complex_t>)));
-% boost::shared_ptr<DataType> head_type = getIsmrmrdHDF5Type<ImageHeader>();
-% boost::shared_ptr<DataType> vdatatype = getIsmrmrdHDF5Type<double_complex_t>();
-% vdatatype = boost::shared_ptr<DataType>(new DataType(H5Tvlen_create (vdatatype->getId())));
-% ret->insertMember( "head", HOFFSET(ImageHeader_with_data<double_complex_t>,head), *head_type);
-% ret->insertMember( "data", HOFFSET(ImageHeader_with_data<double_complex_t>,data), *vdatatype);
-% return ret;
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data< std::complex<float> > >()
-% {
-% return getIsmrmrdHDF5Type<ImageHeader_with_data<complex_t> >();
-% }
-%
-% template <> boost::shared_ptr<DataType> getIsmrmrdHDF5Type<ImageHeader_with_data< std::complex<double> > >()
-% {
-% return getIsmrmrdHDF5Type<ImageHeader_with_data<double_complex_t> >();
-% }
-%
-% }
-%
+% Generate a dataset using the C++ utilities and run
+% h5ls -a -v testdata/dataset/data
+% This produces something the following output
+%"head" +0 struct {
+% "version" +0 native unsigned short
+% "flags" +2 native unsigned long
+% "measurement_uid" +10 native unsigned int
+% "scan_counter" +14 native unsigned int
+% "acquisition_time_stamp" +18 native unsigned int
+% "physiology_time_stamp" +22 [3] native unsigned int
+% "number_of_samples" +54 native unsigned short
+% "available_channels" +56 native unsigned short
+% "active_channels" +58 native unsigned short
+% "channel_mask" +60 [16] native unsigned long
+% "discard_pre" +188 native unsigned short
+% "discard_post" +190 native unsigned short
+% "center_sample" +192 native unsigned short
+% "encoding_space_ref" +194 native unsigned short
+% "trajectory_dimensions" +196 native unsigned short
+% "sample_time_us" +198 native float
+% "position" +202 [3] native float
+% "read_dir" +214 [3] native float
+% "phase_dir" +226 [3] native float
+% "slice_dir" +238 [3] native float
+% "patient_table_position" +250 [3] native float
+% "idx" +262 struct {
+% "kspace_encode_step_1" +0 native unsigned short
+% "kspace_encode_step_2" +2 native unsigned short
+% "average" +4 native unsigned short
+% "slice" +6 native unsigned short
+% "contrast" +8 native unsigned short
+% "phase" +10 native unsigned short
+% "repetition" +12 native unsigned short
+% "set" +14 native unsigned short
+% "segment" +16 native unsigned short
+% "user" +18 [8] native unsigned short
+% } 34 bytes
+% "user_int" +296 [8] native int
+% "user_float" +328 [8] native float
+%} 360 bytes
+%"traj" +360 variable length of native float
+%"data" +376 variable length of native float
+%} 392 bytes
diff --git a/matlab/+ismrmrd/Acquisition.m b/matlab/+ismrmrd/Acquisition.m
index 9dd441d..cdb8dcf 100644
--- a/matlab/+ismrmrd/Acquisition.m
+++ b/matlab/+ismrmrd/Acquisition.m
@@ -87,8 +87,13 @@ classdef Acquisition < handle
function extend(obj,N)
% Extend with blank head and empty traj and data.
- M = N+obj.getNumber();
- obj.head.extend(N);
+ if isempty(obj.head)
+ M = N;
+ obj.head = ismrmrd.AcquisitionHeader(N);
+ else
+ M = N+obj.getNumber();
+ obj.head.extend(N);
+ end
obj.traj{M} = [];
obj.data{M} = [];
end
@@ -117,6 +122,13 @@ classdef Acquisition < handle
end
end
+ function v = trajToFloat(obj)
+ v = cell(1,length(obj.traj));
+ for p = 1:length(obj.traj)
+ v{p} = single(obj.traj{p});
+ end
+ end
+
end
end
\ No newline at end of file
diff --git a/matlab/+ismrmrd/AcquisitionHeader.m b/matlab/+ismrmrd/AcquisitionHeader.m
index cd4e3db..db8ccb9 100644
--- a/matlab/+ismrmrd/AcquisitionHeader.m
+++ b/matlab/+ismrmrd/AcquisitionHeader.m
@@ -77,6 +77,8 @@ classdef AcquisitionHeader < handle
methods
function obj = AcquisitionHeader(arg)
+ % Constructor
+
switch nargin
case 0
% No argument constructor
@@ -91,7 +93,7 @@ classdef AcquisitionHeader < handle
elseif (length(arg)==1 && ismrmrd.util.isInt(arg)) == 1
% number
extend(obj,arg);
- elseif isa(arg,'int8')
+ elseif isa(arg,'uint8')
% Byte array
fromBytes(obj,arg);
else
@@ -106,7 +108,10 @@ classdef AcquisitionHeader < handle
end
function nacq = getNumber(obj)
+ % Return the number of headers
+
nacq = length(obj.version);
+
end
function hdr = select(obj, range)
@@ -155,6 +160,7 @@ classdef AcquisitionHeader < handle
function extend(obj,N)
% Extend with blank header
+
range = obj.getNumber + (1:N);
obj.version(1,range) = zeros(1,N,'uint16');
obj.flags(1,range) = zeros(1,N,'uint64');
@@ -192,6 +198,8 @@ classdef AcquisitionHeader < handle
end
function append(obj, head)
+ % Append a header
+
Nstart = obj.getNumber + 1;
Nend = obj.getNumber + length(head.version);
Nrange = Nstart:Nend;
@@ -231,6 +239,8 @@ classdef AcquisitionHeader < handle
end
function fromStruct(obj, hdr)
+ % Convert a struct to the object
+
%warning! no error checking
obj.version = hdr.version;
obj.flags = hdr.flags;
@@ -268,6 +278,8 @@ classdef AcquisitionHeader < handle
end
function hdr = toStruct(obj)
+ % Convert the object to a plain struct
+
%warning! no error checking
hdr = struct();
hdr.version = obj.version;
@@ -306,9 +318,9 @@ classdef AcquisitionHeader < handle
end
function fromBytes(obj, bytearray)
+ % Convert from a byte array to an ISMRMRD AcquisitionHeader
+ % This conforms to the memory layout of the C-struct
- % TODO: physiology_time_stamp should be 3. So size will change
- % from 360 to 340;
if size(bytearray,1) ~= 360
error('Wrong number of bytes for AcquisitionHeader.')
end
@@ -319,8 +331,8 @@ classdef AcquisitionHeader < handle
obj.measurement_uid(p) = typecast(bytearray( 11: 14,p), 'uint32'); ... % Unique ID for the measurement %
obj.scan_counter(p) = typecast(bytearray( 15: 18,p), 'uint32'); ... % Current acquisition number in the measurement %
obj.acquisition_time_stamp(p) = typecast(bytearray( 19: 22,p), 'uint32'); ... % Acquisition clock %
- obj.physiology_time_stamp(:,p) = typecast(bytearray( 23: 30,p), 'uint32'); ... % Physiology time stamps, e.g. ecg, breating, etc. %
- ... % TODO: the C header has a bug. 3 is correct
+ obj.physiology_time_stamp(:,p) = typecast(bytearray( 23: 34,p), 'uint32'); ... % Physiology time stamps, e.g. ecg, breating, etc. %
+ ... % C-Struct padding
obj.number_of_samples(p) = typecast(bytearray( 55: 56,p), 'uint16'); ... % Number of samples acquired %
obj.available_channels(p) = typecast(bytearray( 57: 58,p), 'uint16'); ... % Available coils %
obj.active_channels(p) = typecast(bytearray( 59: 60,p), 'uint16'); ... % Active coils on current acquisiton %
@@ -352,57 +364,225 @@ classdef AcquisitionHeader < handle
end
function bytes = toBytes(obj)
- % Convert to an ISMRMRD AcquisitionHeader struct to a byte array.
+ % Convert to an ISMRMRD AcquisitionHeader to a byte array
+ % This conforms to the memory layout of the C-struct
N = obj.getNumber;
-
- % TODO: physiology_time_stamp should be 3.
- %bytes = zeros(340,N,'int8');
- bytes = zeros(360,N,'int8');
+ bytes = zeros(360,N,'uint8');
for p = 1:N
off = 1;
- bytes(off:off+1,p) = typecast(obj.version(p) ,'int8'); off=off+2;
- bytes(off:off+7,p) = typecast(obj.flags(p) ,'int8'); off=off+8;
- bytes(off:off+3,p) = typecast(obj.measurement_uid(p) ,'int8'); off=off+4;
- bytes(off:off+3,p) = typecast(obj.scan_counter(p) ,'int8'); off=off+4;
- bytes(off:off+3,p) = typecast(obj.acquisition_time_stamp(p),'int8'); off=off+4;
-
- % TODO: physiology_time_stamp should be 3.
- % but the C struct has a bug, so convert to padding.
- bytes(off:off+11,p) = typecast(obj.physiology_time_stamp(:,p) ,'int8'); off=off+12;
+ bytes(off:off+1,p) = typecast(obj.version(p) ,'uint8'); off=off+2;
+ bytes(off:off+7,p) = typecast(obj.flags(p) ,'uint8'); off=off+8;
+ bytes(off:off+3,p) = typecast(obj.measurement_uid(p) ,'uint8'); off=off+4;
+ bytes(off:off+3,p) = typecast(obj.scan_counter(p) ,'uint8'); off=off+4;
+ bytes(off:off+3,p) = typecast(obj.acquisition_time_stamp(p),'uint8'); off=off+4;
+ % The C struct has padding because of the 5 unused physio time stamps
+ bytes(off:off+11,p) = typecast(obj.physiology_time_stamp(:,p) ,'uint8'); off=off+12;
off = off+20; % Discard 5*uint32;
-
- bytes(off:off+1,p) = typecast(obj.number_of_samples(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.available_channels(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.active_channels(p) ,'int8'); off=off+2;
- bytes(off:off+127,p) = typecast(obj.channel_mask(:,p) ,'int8'); off=off+128;
- bytes(off:off+1,p) = typecast(obj.discard_pre(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.discard_post(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.center_sample(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.encoding_space_ref(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.trajectory_dimensions(p) ,'int8'); off=off+2;
- bytes(off:off+3,p) = typecast(obj.sample_time_us(p) ,'int8'); off=off+4;
- bytes(off:off+11,p) = typecast(obj.position(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.read_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.phase_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.slice_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.patient_table_position(:,p),'int8'); off=off+12;
- bytes(off:off+1,p) = typecast(obj.idx.kspace_encode_step_1(p),'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.kspace_encode_step_2(p),'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.average(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.slice(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.contrast(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.phase(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.repetition(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.set(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.idx.segment(p) ,'int8'); off=off+2;
- bytes(off:off+15,p) = typecast(obj.idx.user(:,p) ,'int8'); off=off+16;
- bytes(off:off+31,p) = typecast(obj.user_int(:,p) ,'int8'); off=off+32;
- bytes(off:off+31,p) = typecast(obj.user_float(:,p) ,'int8');
+ bytes(off:off+1,p) = typecast(obj.number_of_samples(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.available_channels(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.active_channels(p) ,'uint8'); off=off+2;
+ bytes(off:off+127,p) = typecast(obj.channel_mask(:,p) ,'uint8'); off=off+128;
+ bytes(off:off+1,p) = typecast(obj.discard_pre(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.discard_post(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.center_sample(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.encoding_space_ref(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.trajectory_dimensions(p) ,'uint8'); off=off+2;
+ bytes(off:off+3,p) = typecast(obj.sample_time_us(p) ,'uint8'); off=off+4;
+ bytes(off:off+11,p) = typecast(obj.position(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.read_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.phase_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.slice_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.patient_table_position(:,p),'uint8'); off=off+12;
+ bytes(off:off+1,p) = typecast(obj.idx.kspace_encode_step_1(p),'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.kspace_encode_step_2(p),'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.average(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.slice(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.contrast(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.phase(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.repetition(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.set(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.idx.segment(p) ,'uint8'); off=off+2;
+ bytes(off:off+15,p) = typecast(obj.idx.user(:,p) ,'uint8'); off=off+16;
+ bytes(off:off+31,p) = typecast(obj.user_int(:,p) ,'uint8'); off=off+32;
+ bytes(off:off+31,p) = typecast(obj.user_float(:,p) ,'uint8');
end
end
+ function obj = check(obj)
+ % Check and fix the obj types
+
+ % Check the number of elements for each entry
+ N = obj.getNumber();
+ if (size(obj.flags) ~= N)
+ error('Size of flags is not correct.');
+ end
+ if ((size(obj.measurement_uid,1) ~= 1) || ...
+ (size(obj.measurement_uid,2) ~= N))
+ error('Size of measurement_uid is not correct.');
+ end
+ if ((size(obj.scan_counter,1) ~= 1) || ...
+ (size(obj.scan_counter,2) ~= N))
+ error('Size of scan_counter is not correct.');
+ end
+ if ((size(obj.acquisition_time_stamp,1) ~= 1) || ...
+ (size(obj.acquisition_time_stamp,2) ~= N))
+ error('Size of acquisition_time_stamp is not correct.');
+ end
+ if ((size(obj.physiology_time_stamp,1) ~= 3) || ...
+ (size(obj.physiology_time_stamp,2) ~= N))
+ error('Size of physiology_time_stamp is not correct.');
+ end
+ if ((size(obj.number_of_samples,1) ~= 1) || ...
+ (size(obj.number_of_samples,2) ~= N))
+ error('Size of number_of_samples is not correct.');
+ end
+
+ if ((size(obj.available_channels,1) ~= 1) || ...
+ (size(obj.available_channels,2) ~= N))
+ error('Size of available_channels is not correct.');
+ end
+ if ((size(obj.active_channels,1) ~= 1) || ...
+ (size(obj.active_channels,2) ~= N))
+ error('Size of active_channels is not correct.');
+ end
+ if ((size(obj.channel_mask,1) ~= 16) || ...
+ (size(obj.channel_mask,2) ~= N))
+ error('Size of channel_mask is not correct.');
+ end
+ if ((size(obj.discard_pre,1) ~= 1) || ...
+ (size(obj.discard_pre,2) ~= N))
+ error('Size of discard_pre is not correct.');
+ end
+ if ((size(obj.discard_post,1) ~= 1) || ...
+ (size(obj.discard_post,2) ~= N))
+ error('Size of discard_post is not correct.');
+ end
+ if ((size(obj.center_sample,1) ~= 1) || ...
+ (size(obj.center_sample,2) ~= N))
+ error('Size of center_sample is not correct.');
+ end
+ if ((size(obj.encoding_space_ref,1) ~= 1) || ...
+ (size(obj.encoding_space_ref,2) ~= N))
+ error('Size of encoding_space_ref is not correct.');
+ end
+ if ((size(obj.trajectory_dimensions,1) ~= 1) || ...
+ (size(obj.trajectory_dimensions,2) ~= N))
+ error('Size of trajectory_dimensions is not correct.');
+ end
+ if ((size(obj.sample_time_us,1) ~= 1) || ...
+ (size(obj.sample_time_us,2) ~= N))
+ error('Size of sample_time_us is not correct.');
+ end
+ if ((size(obj.position,1) ~= 3) || ...
+ (size(obj.position,2) ~= N))
+ error('Size of position is not correct.');
+ end
+ if ((size(obj.read_dir,1) ~= 3) || ...
+ (size(obj.read_dir,2) ~= N))
+ error('Size of read_dir is not correct.');
+ end
+ if ((size(obj.phase_dir,1) ~= 3) || ...
+ (size(obj.phase_dir,2) ~= N))
+ error('Size of phase_dir is not correct.');
+ end
+ if ((size(obj.slice_dir,1) ~= 3) || ...
+ (size(obj.slice_dir,2) ~= N))
+ error('Size of slice_dir is not correct.');
+ end
+ if ((size(obj.patient_table_position,1) ~= 3) || ...
+ (size(obj.patient_table_position,2) ~= N))
+ error('Size of patient_table_position is not correct.');
+ end
+ if ((size(obj.idx.kspace_encode_step_1,1) ~= 1) || ...
+ (size(obj.idx.kspace_encode_step_1,2) ~= N))
+ error('Size of kspace_encode_step_1 is not correct.');
+ end
+ if ((size(obj.idx.kspace_encode_step_2,1) ~= 1) || ...
+ (size(obj.idx.kspace_encode_step_2,2) ~= N))
+ error('Size of kspace_encode_step_2 is not correct.');
+ end
+ if ((size(obj.idx.average,1) ~= 1) || ...
+ (size(obj.idx.average,2) ~= N))
+ error('Size of idx.average is not correct.');
+ end
+ if ((size(obj.idx.slice,1) ~= 1) || ...
+ (size(obj.idx.slice,2) ~= N))
+ error('Size of idx.slice is not correct.');
+ end
+ if ((size(obj.idx.contrast,1) ~= 1) || ...
+ (size(obj.idx.contrast,2) ~= N))
+ error('Size of idx.contrast is not correct.');
+ end
+ if ((size(obj.idx.phase,1) ~= 1) || ...
+ (size(obj.idx.phase,2) ~= N))
+ error('Size of idx.phase is not correct.');
+ end
+ if ((size(obj.idx.repetition,1) ~= 1) || ...
+ (size(obj.idx.repetition,2) ~= N))
+ error('Size of idx.repetition is not correct.');
+ end
+ if ((size(obj.idx.set,1) ~= 1) || ...
+ (size(obj.idx.set,2) ~= N))
+ error('Size of idx.set is not correct.');
+ end
+ if ((size(obj.idx.segment,1) ~= 1) || ...
+ (size(obj.idx.segment,2) ~= N))
+ error('Size of idx.segment is not correct.');
+ end
+ if ((size(obj.idx.user,1) ~= 8) || ...
+ (size(obj.idx.user,2) ~= N))
+ error('Size of idx.user is not correct.');
+ end
+ if ((size(obj.user_int,1) ~= 8) || ...
+ (size(obj.user_int,2) ~= N))
+ error('Size of user_int is not correct.');
+ end
+ if ((size(obj.user_float,1) ~= 8) || ...
+ (size(obj.user_float,2) ~= N))
+ error('Size of user_float is not correct.');
+ end
+
+ % Fix the type of all the elements
+ obj.version = uint16(obj.version);
+ obj.flags = uint64(obj.flags);
+ obj.measurement_uid = uint32(obj.measurement_uid);
+ obj.scan_counter = uint32(obj.scan_counter);
+ obj.acquisition_time_stamp = uint32(obj.acquisition_time_stamp);
+ obj.physiology_time_stamp = uint32(obj.physiology_time_stamp);
+ obj.number_of_samples = uint16(obj.number_of_samples);
+ obj.available_channels = uint16(obj.available_channels);
+ obj.active_channels = uint16(obj.active_channels);
+ obj.channel_mask = uint64(obj.channel_mask);
+ obj.discard_pre = uint16(obj.discard_pre);
+ obj.discard_post = uint16(obj.discard_post);
+ obj.center_sample = uint16(obj.center_sample);
+ obj.encoding_space_ref = uint16(obj.encoding_space_ref);
+ obj.trajectory_dimensions = uint16(obj.trajectory_dimensions);
+ obj.sample_time_us = single(obj.sample_time_us);
+ obj.position = single(obj.position);
+ obj.read_dir = single(obj.read_dir);
+ obj.phase_dir = single(obj.phase_dir);
+ obj.slice_dir = single(obj.slice_dir);
+ obj.patient_table_position = single(obj.patient_table_position);
+ obj.idx.kspace_encode_step_1 = uint16(obj.idx.kspace_encode_step_1);
+ obj.idx.kspace_encode_step_2 = uint16(obj.idx.kspace_encode_step_2);
+ obj.idx.average = uint16(obj.idx.average);
+ obj.idx.slice = uint16(obj.idx.slice);
+ obj.idx.contrast = uint16(obj.idx.contrast);
+ obj.idx.phase = uint16(obj.idx.phase);
+ obj.idx.repetition = uint16(obj.idx.repetition);
+ obj.idx.set = uint16(obj.idx.set);
+ obj.idx.segment = uint16(obj.idx.segment);
+ obj.idx.user = uint16(obj.idx.user);
+ obj.user_int = int32(obj.user_int);
+ obj.user_float = single(obj.user_float);
+
+ end
+
function ret = flagIsSet(obj, flag, range)
+ % bool = obj.flagIsSet(flag, range)
+
if nargin < 3
range = 1:obj.getNumber;
end
@@ -461,8 +641,13 @@ classdef AcquisitionHeader < handle
obj.flags(range(p)) = obj.flags(range(p)) - bitmask;
end
end
-
-
+ end
+
+ function flagClearAll(obj, range)
+ if nargin < 2
+ range = 1:obj.getNumber;
+ end
+ obj.flags(range) = zeros(1,length(range),'uint64');
end
end
diff --git a/matlab/+ismrmrd/ImageHeader.m b/matlab/+ismrmrd/ImageHeader.m
index 9c0940b..f5555f4 100644
--- a/matlab/+ismrmrd/ImageHeader.m
+++ b/matlab/+ismrmrd/ImageHeader.m
@@ -75,7 +75,7 @@ classdef ImageHeader < handle
elseif (length(arg)==1 && ismrmrd.util.isInt(arg)) == 1
% number
extend(obj,arg);
- elseif isa(arg,'int8')
+ elseif isa(arg,'uint8')
% Byte array
fromBytes(obj,arg);
else
@@ -252,82 +252,209 @@ classdef ImageHeader < handle
end
function fromBytes(obj, bytearray)
+ % Convert from a byte array to an ISMRMRD ImageHeader
+ % This conforms to the memory layout of the C-struct
- % TODO: physiology_time_stamp should be 3. So size will change
- % from 214 to 194;
if size(bytearray,1) ~= 214
error('Wrong number of bytes for AcquisitionHeader.')
end
N = size(bytearray,2);
for p = 1:N
- obj.version(p) = typecast(bytes(1:2,p), 'uint16');
- obj.flags(p) = typecast(bytes(3:10,p), 'uint64');
- obj.measurement_uid(p) = typecast(bytes(11:14,p), 'uint32');
- obj.matrix_size(:,p) = typecast(bytes(15:20,p), 'uint16');
- obj.field_of_view(:,p) = typecast(bytes(21:32,p), 'single');
- obj.channels(p) = typecast(bytes(33:34,p), 'uint16');
- obj.position(:,p) = typecast(bytes(35:46,p), 'single');
- obj.read_dir(:,p) = typecast(bytes(47:58,p), 'single');
- obj.phase_dir(:,p) = typecast(bytes(59:70,p), 'single');
- obj.slice_dir(:,p) = typecast(bytes(71:82,p), 'single');
- obj.patient_table_position(:,p) = typecast(bytes(83:94,p), 'single');
- obj.average(p) = typecast(bytes(95:96,p), 'uint16');
- obj.slice(p) = typecast(bytes(97:98,p), 'uint16');
- obj.contrast(p) = typecast(bytes(99:100,p), 'uint16');
- obj.phase(p) = typecast(bytes(101:102,p), 'uint16');
- obj.repetition(p) = typecast(bytes(103:104,p), 'uint16');
- obj.set(p) = typecast(bytes(105:106,p), 'uint16');
- obj.acquisition_time_stamp(p) = typecast(bytes(107:110,p), 'uint32');
- obj.physiology_time_stamp(:,p) = typecast(bytes(111:122,p), 'uint32');
- ... % TODO: the C header has a bug. 3 is correct
- obj.image_data_type(p) = typecast(bytes(143:144,p), 'uint16');
- obj.image_type(p) = typecast(bytes(145:146,p), 'uint16');
- obj.image_index(p) = typecast(bytes(147:148,p), 'uint16');
- obj.image_series_index(p) = typecast(bytes(149:150,p), 'uint16');
- obj.user_int(:,p) = typecast(bytes(151:182,p), 'uint32');
- obj.user_float(:,p) = typecast(bytes(183:214,p), 'single');
+ obj.version(p) = typecast(bytearray(1:2,p), 'uint16');
+ obj.flags(p) = typecast(bytearray(3:10,p), 'uint64');
+ obj.measurement_uid(p) = typecast(bytearray(11:14,p), 'uint32');
+ obj.matrix_size(:,p) = typecast(bytearray(15:20,p), 'uint16');
+ obj.field_of_view(:,p) = typecast(bytearray(21:32,p), 'single');
+ obj.channels(p) = typecast(bytearray(33:34,p), 'uint16');
+ obj.position(:,p) = typecast(bytearray(35:46,p), 'single');
+ obj.read_dir(:,p) = typecast(bytearray(47:58,p), 'single');
+ obj.phase_dir(:,p) = typecast(bytearray(59:70,p), 'single');
+ obj.slice_dir(:,p) = typecast(bytearray(71:82,p), 'single');
+ obj.patient_table_position(:,p) = typecast(bytearray(83:94,p), 'single');
+ obj.average(p) = typecast(bytearray(95:96,p), 'uint16');
+ obj.slice(p) = typecast(bytearray(97:98,p), 'uint16');
+ obj.contrast(p) = typecast(bytearray(99:100,p), 'uint16');
+ obj.phase(p) = typecast(bytearray(101:102,p), 'uint16');
+ obj.repetition(p) = typecast(bytearray(103:104,p), 'uint16');
+ obj.set(p) = typecast(bytearray(105:106,p), 'uint16');
+ obj.acquisition_time_stamp(p) = typecast(bytearray(107:110,p), 'uint32');
+ obj.physiology_time_stamp(:,p) = typecast(bytearray(111:122,p), 'uint32');
+ ... % C-struct has padding
+ obj.image_data_type(p) = typecast(bytearray(143:144,p), 'uint16');
+ obj.image_type(p) = typecast(bytearray(145:146,p), 'uint16');
+ obj.image_index(p) = typecast(bytearray(147:148,p), 'uint16');
+ obj.image_series_index(p) = typecast(bytearray(149:150,p), 'uint16');
+ obj.user_int(:,p) = typecast(bytearray(151:182,p), 'uint32');
+ obj.user_float(:,p) = typecast(bytearray(183:214,p), 'single');
end
end
function bytes = toBytes(obj)
- % Convert to an ISMRMRD AcquisitionHeader struct to a byte array.
+ % Convert an ISMRMRD AcquisitionHeader to a byte array
+ % This conforms to the memory layout of the C-struct
N = obj.getNumber;
-
- % TODO: physiology_time_stamp should be 3.
- %bytes = zeros(194,N,'int8');
- bytes = zeros(214,N,'int8');
+ bytes = zeros(214,N,'uint8');
for p = 1:N
off = 1;
- bytes(off:off+1,p) = typecast(obj.version(p) ,'int8'); off=off+2;
- bytes(off:off+7,p) = typecast(obj.flags(p) ,'int8'); off=off+8;
- bytes(off:off+3,p) = typecast(obj.measurement_uid(p) ,'int8'); off=off+4;
- bytes(off:off+5,p) = typecast(obj.matrix_size(:,p) ,'int8'); off=off+6;
- bytes(off:off+11,p) = typecast(obj.field_of_view(:,p) ,'int8'); off=off+12;
- bytes(off:off+1,p) = typecast(obj.channels(p) ,'int8'); off=off+2;
- bytes(off:off+11,p) = typecast(obj.position(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.read_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.phase_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.slice_dir(:,p) ,'int8'); off=off+12;
- bytes(off:off+11,p) = typecast(obj.patient_table_position(:,p),'int8'); off=off+12;
- bytes(off:off+1,p) = typecast(obj.average(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.slice(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.contrast(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.phase(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.repetition(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.set(p) ,'int8'); off=off+2;
- bytes(off:off+3,p) = typecast(obj.acquisition_time_stamp(p) ,'int8'); off=off+4;
- % TODO: physiology_time_stamp should be 3.
- % but the C struct has a bug, so convert to padding.
- bytes(off:off+11,p) = typecast(obj.physiology_time_stamp(:,p) ,'int8'); off=off+12;
+ bytes(off:off+1,p) = typecast(obj.version(p) ,'uint8'); off=off+2;
+ bytes(off:off+7,p) = typecast(obj.flags(p) ,'uint8'); off=off+8;
+ bytes(off:off+3,p) = typecast(obj.measurement_uid(p) ,'uint8'); off=off+4;
+ bytes(off:off+5,p) = typecast(obj.matrix_size(:,p) ,'uint8'); off=off+6;
+ bytes(off:off+11,p) = typecast(obj.field_of_view(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+1,p) = typecast(obj.channels(p) ,'uint8'); off=off+2;
+ bytes(off:off+11,p) = typecast(obj.position(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.read_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.phase_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.slice_dir(:,p) ,'uint8'); off=off+12;
+ bytes(off:off+11,p) = typecast(obj.patient_table_position(:,p),'uint8'); off=off+12;
+ bytes(off:off+1,p) = typecast(obj.average(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.slice(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.contrast(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.phase(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.repetition(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.set(p) ,'uint8'); off=off+2;
+ bytes(off:off+3,p) = typecast(obj.acquisition_time_stamp(p) ,'uint8'); off=off+4;
+ % The C struct has padding.
+ bytes(off:off+11,p) = typecast(obj.physiology_time_stamp(:,p) ,'uint8'); off=off+12;
off = off+20; % Discard 5*uint32;
- bytes(off:off+1,p) = typecast(obj.image_data_type(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.image_type(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.image_index(p) ,'int8'); off=off+2;
- bytes(off:off+1,p) = typecast(obj.image_series_index(p) ,'int8'); off=off+2;
- bytes(off:off+31,p) = typecast(obj.user_int(:,p) ,'int8'); off=off+32;
- bytes(off:off+31,p) = typecast(obj.user_float(:,p) ,'int8');
+ bytes(off:off+1,p) = typecast(obj.image_data_type(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.image_type(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.image_index(p) ,'uint8'); off=off+2;
+ bytes(off:off+1,p) = typecast(obj.image_series_index(p) ,'uint8'); off=off+2;
+ bytes(off:off+31,p) = typecast(obj.user_int(:,p) ,'uint8'); off=off+32;
+ bytes(off:off+31,p) = typecast(obj.user_float(:,p) ,'uint8');
+ end
+ end
+
+ function obj = check(obj)
+ % Check and fix the obj types
+
+ % Check the number of elements for each entry
+ N = obj.getNumber();
+ if (size(obj.flags) ~= N)
+ error('Size of flags is not correct.');
+ end
+ if ((size(obj.measurement_uid,1) ~= 1) || ...
+ (size(obj.measurement_uid,2) ~= N))
+ error('Size of measurement_uid is not correct.');
+ end
+ if ((size(obj.matrix_size,1) ~= 3) || ...
+ (size(obj.matrix_size,2) ~= N))
+ error('Size of matrix_size is not correct.');
+ end
+ if ((size(obj.field_of_view,1) ~= 3) || ...
+ (size(obj.field_of_view,2) ~= N))
+ error('Size of field_of_view is not correct.');
+ end
+ if ((size(obj.channels,1) ~= 1) || ...
+ (size(obj.channels,2) ~= N))
+ error('Size of field_of_view is not correct.');
+ end
+ if ((size(obj.position,1) ~= 3) || ...
+ (size(obj.position,2) ~= N))
+ error('Size of position is not correct.');
+ end
+ if ((size(obj.read_dir,1) ~= 3) || ...
+ (size(obj.read_dir,2) ~= N))
+ error('Size of read_dir is not correct.');
+ end
+ if ((size(obj.phase_dir,1) ~= 3) || ...
+ (size(obj.phase_dir,2) ~= N))
+ error('Size of phase_dir is not correct.');
+ end
+ if ((size(obj.slice_dir,1) ~= 3) || ...
+ (size(obj.slice_dir,2) ~= N))
+ error('Size of slice_dir is not correct.');
+ end
+ if ((size(obj.patient_table_position,1) ~= 3) || ...
+ (size(obj.patient_table_position,2) ~= N))
+ error('Size of patient_table_position is not correct.');
end
+ if ((size(obj.average,1) ~= 1) || ...
+ (size(obj.average,2) ~= N))
+ error('Size of average is not correct.');
+ end
+ if ((size(obj.slice,1) ~= 1) || ...
+ (size(obj.slice,2) ~= N))
+ error('Size of slice is not correct.');
+ end
+ if ((size(obj.contrast,1) ~= 1) || ...
+ (size(obj.contrast,2) ~= N))
+ error('Size of contrast is not correct.');
+ end
+ if ((size(obj.phase,1) ~= 1) || ...
+ (size(obj.phase,2) ~= N))
+ error('Size of phase is not correct.');
+ end
+ if ((size(obj.repetition,1) ~= 1) || ...
+ (size(obj.repetition,2) ~= N))
+ error('Size of repetition is not correct.');
+ end
+ if ((size(obj.set,1) ~= 1) || ...
+ (size(obj.set,2) ~= N))
+ error('Size of set is not correct.');
+ end
+ if ((size(obj.acquisition_time_stamp,1) ~= 1) || ...
+ (size(obj.acquisition_time_stamp,2) ~= N))
+ error('Size of acquisition_time_stamp is not correct.');
+ end
+ if ((size(obj.physiology_time_stamp,1) ~= 3) || ...
+ (size(obj.physiology_time_stamp,2) ~= N))
+ error('Size of physiology_time_stamp is not correct.');
+ end
+ if ((size(obj.image_data_type,1) ~= 1) || ...
+ (size(obj.image_data_type,2) ~= N))
+ error('Size of image_data_type is not correct.');
+ end
+ if ((size(obj.image_type,1) ~= 1) || ...
+ (size(obj.image_type,2) ~= N))
+ error('Size of image_type is not correct.');
+ end
+ if ((size(obj.image_index,1) ~= 1) || ...
+ (size(obj.image_index,2) ~= N))
+ error('Size of image_index is not correct.');
+ end
+ if ((size(obj.image_series_index,1) ~= 1) || ...
+ (size(obj.image_series_index,2) ~= N))
+ error('Size of image_series_index is not correct.');
+ end
+ if ((size(obj.user_int,1) ~= 8) || ...
+ (size(obj.user_int,2) ~= N))
+ error('Size of user_int is not correct.');
+ end
+ if ((size(obj.user_float,1) ~= 8) || ...
+ (size(obj.user_float,2) ~= N))
+ error('Size of user_float is not correct.');
+ end
+
+ % Fix the type of all the elements
+ obj.version = uint16(obj.version);
+ obj.flags = uint64(obj.flags);
+ obj.measurement_uid = uint32(obj.measurement_uid);
+ obj.matrix_size = uint16(obj.matrix_size);
+ obj.field_of_view = single(obj.field_of_view);
+ obj.channels = uint16(obj.channels);
+ obj.position = single(obj.position);
+ obj.read_dir = single(obj.read_dir);
+ obj.phase_dir = single(obj.phase_dir);
+ obj.slice_dir = single(obj.slice_dir);
+ obj.patient_table_position = single(obj.patient_table_position);
+ obj.average = uint16(obj.average);
+ obj.slice = uint16(obj.slice);
+ obj.contrast = uint16(obj.contrast);
+ obj.phase = uint16(obj.phase);
+ obj.repetition = uint16(obj.repetition);
+ obj.set = uint16(obj.set);
+ obj.acquisition_time_stamp = uint32(obj.acquisition_time_stamp);
+ obj.physiology_time_stamp = uint32(obj.physiology_time_stamp);
+ obj.image_data_type = uint16(obj.image_data_type);
+ obj.image_type = uint16(obj.image_type);
+ obj.image_index = uint16(obj.image_index);
+ obj.image_series_index = uint16(obj.image_series_index);
+ obj.user_int = int32(obj.user_int);
+ obj.user_float = single(obj.user_float);
+
end
function ret = flagIsSet(obj, flag, range)
diff --git a/matlab/+ismrmrd/IsmrmrdDataset.m b/matlab/+ismrmrd/IsmrmrdDataset.m
index d38fbae..6ca12e8 100644
--- a/matlab/+ismrmrd/IsmrmrdDataset.m
+++ b/matlab/+ismrmrd/IsmrmrdDataset.m
@@ -267,10 +267,14 @@ classdef IsmrmrdDataset
% Mem space
mem_space_id = H5S.create_simple(2,[N 1],[]);
+ % Check and fix the acquisition header types
+ acq.head.check();
+ % TODO: Error checking on the sizes of the data and trajectories.
+
% Pack the acquisition into the correct struct for writing
d = struct();
d.head = acq.head.toStruct();
- d.traj = acq.traj;
+ d.traj = acq.trajToFloat();
d.data = acq.dataToFloat();
% Write
--
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