[ismrmrd] 183/281: New matlab class style interface working for acquisitions.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:12 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 f49e7e4a83122574e6e5fd298e4e2729531af0d0
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Fri Sep 6 13:43:11 2013 -0400

    New matlab class style interface working for acquisitions.
---
 examples/matlab/simple_cartesian_recon.m |   8 +-
 matlab/+ismrmrd/+util/hdf5_datatypes.m   |  30 +-
 matlab/+ismrmrd/Acquisition.m            | 175 ++----------
 matlab/+ismrmrd/AcquisitionFlags.m       |  39 ---
 matlab/+ismrmrd/AcquisitionHeader.m      | 471 ++++++++++++++++++++++++++++---
 matlab/+ismrmrd/FlagBit.m                |  32 ---
 matlab/+ismrmrd/Flags.m                  |  65 -----
 matlab/+ismrmrd/IsmrmrdDataset.m         |   7 +-
 8 files changed, 466 insertions(+), 361 deletions(-)

diff --git a/examples/matlab/simple_cartesian_recon.m b/examples/matlab/simple_cartesian_recon.m
index 3502953..08913f7 100644
--- a/examples/matlab/simple_cartesian_recon.m
+++ b/examples/matlab/simple_cartesian_recon.m
@@ -60,8 +60,6 @@ else
     center_partition = 0;
 end
 
-acqFlags = ismrmrd.AcquisitionFlags;
-
 % Allocate a buffer for storing 1 repetition's worth of data
 buffer = zeros([matrix_size(1),matrix_size(2),matrix_size(3),slices,channels],'single');
 
@@ -73,10 +71,10 @@ acq = f.readAcquisition();
 
 % Loop over all the acquisitions
 counter = 0;
-for p = 1:f.getNumberOfAcquisitions
+for p = 1:acq.getNumber()
     
     % ignore the noise scans
-    if acqFlags.isSet(acq.head.flags(p),'ACQ_IS_NOISE_MEASUREMENT')
+    if acq.head.flagIsSet(acq.head.FLAGS.ACQ_IS_NOISE_MEASUREMENT,p)
         continue
     end
 
@@ -91,7 +89,7 @@ for p = 1:f.getNumberOfAcquisitions
     buffer(:,line_number,partition_number,slice_number,:) = acq.data{p};
     
     % Is this the last in slice? We should make an image
-    if (acqFlags.isSet(acq.head.flags(p),'ACQ_LAST_IN_SLICE'))
+    if acq.head.flagIsSet(acq.head.FLAGS.ACQ_LAST_IN_SLICE,p)
         counter = counter + 1;
         fprintf('Reconstructing image %d\n', counter); 
         fprintf('   slice: %d\n', slice_number); 
diff --git a/matlab/+ismrmrd/+util/hdf5_datatypes.m b/matlab/+ismrmrd/+util/hdf5_datatypes.m
index ccd9a8a..14788d7 100644
--- a/matlab/+ismrmrd/+util/hdf5_datatypes.m
+++ b/matlab/+ismrmrd/+util/hdf5_datatypes.m
@@ -16,15 +16,15 @@ classdef hdf5_datatypes
     methods
         
         function obj = hdf5_datatypes()
-            obj.T_float = obj.getType_float();
-            obj.T_double = obj.getType_double();
-            obj.T_char = obj.getType_char();
-            obj.T_complexfloat = obj.getType_complexfloat();
-            obj.T_complexdouble = obj.getType_complexdouble();
-            obj.T_ushort = obj.getType_ushort();
-            obj.T_EncodingCounters = obj.getType_EncodingCounters();
-            obj.T_AcquisitionHeader = obj.getType_AcquisitionHeader();
-            obj.T_Acquisition = obj.getType_Acquisition();
+            obj.T_float = ismrmrd.util.hdf5_datatypes.getType_float();
+            obj.T_double = ismrmrd.util.hdf5_datatypes.getType_double();
+            obj.T_char = ismrmrd.util.hdf5_datatypes.getType_char();
+            obj.T_complexfloat = ismrmrd.util.hdf5_datatypes.getType_complexfloat();
+            obj.T_complexdouble = ismrmrd.util.hdf5_datatypes.getType_complexdouble();
+            obj.T_ushort = ismrmrd.util.hdf5_datatypes.getType_ushort();
+            obj.T_EncodingCounters = ismrmrd.util.hdf5_datatypes.getType_EncodingCounters();
+            obj.T_AcquisitionHeader = ismrmrd.util.hdf5_datatypes.getType_AcquisitionHeader();
+            obj.T_Acquisition = ismrmrd.util.hdf5_datatypes.getType_Acquisition();
         end
         
     end
@@ -122,7 +122,7 @@ classdef hdf5_datatypes
             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.hdf5_datatypes.getType_EncodingCounters()); % idx
+            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
 
@@ -192,8 +192,8 @@ classdef hdf5_datatypes
             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.hdf5_datatypes.getType_EncodingCounters);
-            offset = offset + H5T.get_size(ismrmrd.hdf5_datatypes.getType_EncodingCounters);
+            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');
@@ -205,9 +205,9 @@ classdef hdf5_datatypes
 
         function b = getType_Acquisition()
 
-            head = H5T.copy(ismrmrd.hdf5_datatypes.getType_AcquisitionHeader);
-            traj = H5T.vlen_create(ismrmrd.hdf5_datatypes.getType_float());
-            data = H5T.vlen_create(ismrmrd.hdf5_datatypes.getType_float());
+            head = H5T.copy(ismrmrd.util.hdf5_datatypes.getType_AcquisitionHeader());
+            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);
 
diff --git a/matlab/+ismrmrd/Acquisition.m b/matlab/+ismrmrd/Acquisition.m
index 8b20d56..9dd441d 100644
--- a/matlab/+ismrmrd/Acquisition.m
+++ b/matlab/+ismrmrd/Acquisition.m
@@ -17,21 +17,21 @@ classdef Acquisition < handle
                     
                 case 1
                     % One argument constructor
-                    if isfield(arg1, 'version')
-                        % First argument is a header
-                        M = length(arg1.version);
-                        obj.head = arg1;
-                        obj.traj{M} = [];
-                        obj.data{M} = [];
-                    else
+                    if ismrmrd.util.isInt(arg1)
                         % First argument is a number
                         M = arg1;
                         extend(obj,M);
+                    else                        
+                        % First argument is a header (hopefully)
+                        M = length(arg1.version);
+                        obj.head = ismrmrd.AcquisitionHeader(arg1);
+                        obj.traj{M} = [];
+                        obj.data{M} = [];
                     end
                     
                 case 3
                     % Three argument constructor
-                    obj.head = arg1;
+                    obj.head = ismrmrd.AcquisitionHeader(arg1);
                     M = length(arg1.version);
                     if isempty(traj)
                         obj.traj{M} = [];
@@ -53,99 +53,29 @@ classdef Acquisition < handle
             end
         end
         
-        function nacq = getNumberOfAcquisitions(obj)
-            if isfield(obj.head,'version')
-                nacq = length(obj.head.version);
-            else
-                nacq = 0;
-            end
+        function nacq = getNumber(obj)
+            nacq = obj.head.getNumber();
         end
         
         function acq = select(obj, range)
             % Return a copy of a range of acquisitions
             
             % create an empty acquisition
-            M = length(range);
-            acq = ismrmrd.Acquisition(M);
+            acq = ismrmrd.Acquisition();
             % Fill the header
-            acq.head.version = obj.head.version(range);
-            acq.head.flags = obj.head.flags(range);
-            acq.head.measurement_uid = obj.head.measurement_uid(range);
-            acq.head.scan_counter = obj.head.scan_counter(range);
-            acq.head.acquisition_time_stamp = obj.head.acquisition_time_stamp(range);
-            acq.head.physiology_time_stamp = obj.head.physiology_time_stamp(:,range);
-            acq.head.number_of_samples = obj.head.number_of_samples(range);
-            acq.head.available_channels = obj.head.available_channels(range);
-            acq.head.active_channels = obj.head.active_channels(range);
-            acq.head.channel_mask = obj.head.channel_mask(:,range);
-            acq.head.discard_pre = obj.head.discard_pre(range);
-            acq.head.discard_post = obj.head.discard_post(range);
-            acq.head.center_sample = obj.head.center_sample(range);
-            acq.head.encoding_space_ref = obj.head.encoding_space_ref(range);
-            acq.head.trajectory_dimensions = obj.head.trajectory_dimensions(range);
-            acq.head.sample_time_us = obj.head.sample_time_us(range);
-            acq.head.position = obj.head.position(:,range);
-            acq.head.read_dir = obj.head.read_dir(:,range);
-            acq.head.phase_dir = obj.head.phase_dir(:,range);
-            acq.head.slice_dir = obj.head.slice_dir(:,range);
-            acq.head.patient_table_position = obj.head.patient_table_position(:,range);
-            acq.head.idx.kspace_encode_step_1 = obj.head.idx.kspace_encode_step_1(range);
-            acq.head.idx.kspace_encode_step_2 = obj.head.idx.kspace_encode_step_2(range);
-            acq.head.idx.average = obj.head.idx.average(range);
-            acq.head.idx.slice = obj.head.idx.slice(range);
-            acq.head.idx.contrast = obj.head.idx.contrast(range);
-            acq.head.idx.phase = obj.head.idx.phase(range);
-            acq.head.idx.repetition = obj.head.idx.repetition(range);
-            acq.head.idx.set = obj.head.idx.set(range);
-            acq.head.idx.segment = obj.head.idx.segment(range);
-            acq.head.idx.user = obj.head.idx.user(:,range);
-            acq.head.user_int = obj.head.user_int(:,range);
-            acq.head.user_float = obj.head.user_float(:,range);
-            
+            acq.head = obj.head.select(range);
             % Fill the trajectory and the data
-            for p = 1:M
+            for p = 1:length(range)
                 acq.traj{p} = obj.traj{range(p)};
                 acq.data{p} = obj.data{range(p)};
             end    
         end
         
         function append(obj, head, traj, data)
-            Nstart = obj.getNumberOfAcquisitions + 1;
-            Nend   = obj.getNumberOfAcquisitions + length(head.version);
+            Nstart = obj.getNumber + 1;
+            Nend   = obj.getNumber + length(head.version);
             Nrange = Nstart:Nend;
-            obj.head.version(Nrange) = hdr.version;
-            obj.head.flags(Nrange) = hdr.flags;
-            obj.head.measurement_uid(Nrange) = hdr.measurement_uid;
-            obj.head.scan_counter(Nrange) = hdr.scan_counter;
-            obj.head.acquisition_time_stamp(Nrange) = hdr.acquisition_time_stamp;
-            obj.head.physiology_time_stamp(:,Nrange) = hdr.physiology_time_stamp;
-            obj.head.number_of_samples(Nrange) = hdr.number_of_samples;
-            obj.head.available_channels(Nrange) = hdr.available_channels;
-            obj.head.active_channels(Nrange) = hdr.active_channels;
-            obj.head.channel_mask(:,Nrange) = hdr.channel_mask;
-            obj.head.discard_pre(Nrange) = hdr.discard_pre;
-            obj.head.discard_post(Nrange) = hdr.discard_post;
-            obj.head.center_sample(Nrange) = hdr.center_sample;
-            obj.head.encoding_space_ref(Nrange) = hdr.encoding_space_ref;
-            obj.head.trajectory_dimensions(Nrange) = hdr.trajectory_dimensions;
-            obj.head.sample_time_us(Nrange) = hdr.sample_time_us;
-            obj.head.position(:,Nrange) = hdr.position;
-            obj.head.read_dir(:,Nrange) = hdr.read_dir;
-            obj.head.phase_dir(:,Nrange) = hdr.phase_dir;
-            obj.head.slice_dir(:,Nrange) = hdr.slice_dir;
-            obj.head.patient_table_position(:,Nrange) = hdr.patient_table_position;
-            obj.head.idx.kspace_encode_step_1(Nrange) = hdr.idx.kspace_encode_step_1;
-            obj.head.idx.kspace_encode_step_2(Nrange) = hdr.idx.kspace_encode_step_2;
-            obj.head.idx.average(Nrange) = hdr.idx.average;
-            obj.head.idx.slice(Nrange) = hdr.idx.slice;
-            obj.head.idx.contrast(Nrange) = hdr.idx.contrast;
-            obj.head.idx.phase(Nrange) = hdr.idx.phase;
-            obj.head.idx.repetition(Nrange) = hdr.idx.repetition;
-            obj.head.idx.set(Nrange) = hdr.idx.set;
-            obj.head.idx.segment(Nrange) = hdr.idx.segment;
-            obj.head.idx.user(:,Nrange) = hdr.idx.user;
-            obj.head.user_int(:,Nrange) = hdr.user_int;
-            obj.head.user_float(:,Nrange) = hdr.user_float;
+            obj.head.append(head);
             if isempty(traj) > 0
                 obj.traj{Nrange} = traj;
             end
@@ -157,81 +87,12 @@ classdef Acquisition < handle
         
         function extend(obj,N)
             % Extend with blank head and empty traj and data.
-            M = N+obj.getNumberOfAcquisitions();
-            hdr = ismrmrd.AcquisitionHeader();
-            obj.head.version(M) = hdr.version;
-            obj.head.flags(M) = hdr.flags;
-            obj.head.measurement_uid(M) = hdr.measurement_uid;
-            obj.head.scan_counter(M) = hdr.scan_counter;
-            obj.head.acquisition_time_stamp(M) = hdr.acquisition_time_stamp;
-            obj.head.physiology_time_stamp(:,M) = hdr.physiology_time_stamp;
-            obj.head.number_of_samples(M) = hdr.number_of_samples;
-            obj.head.available_channels(M) = hdr.available_channels;
-            obj.head.active_channels(M) = hdr.active_channels;
-            obj.head.channel_mask(:,M) = hdr.channel_mask;
-            obj.head.discard_pre(M) = hdr.discard_pre;
-            obj.head.discard_post(M) = hdr.discard_post;
-            obj.head.center_sample(M) = hdr.center_sample;
-            obj.head.encoding_space_ref(M) = hdr.encoding_space_ref;
-            obj.head.trajectory_dimensions(M) = hdr.trajectory_dimensions;
-            obj.head.sample_time_us(M) = hdr.sample_time_us;
-            obj.head.position(:,M) = hdr.position;
-            obj.head.read_dir(:,M) = hdr.read_dir;
-            obj.head.phase_dir(:,M) = hdr.phase_dir;
-            obj.head.slice_dir(:,M) = hdr.slice_dir;
-            obj.head.patient_table_position(:,M) = hdr.patient_table_position;
-            obj.head.idx.kspace_encode_step_1(M) = hdr.idx.kspace_encode_step_1;
-            obj.head.idx.kspace_encode_step_2(M) = hdr.idx.kspace_encode_step_2;
-            obj.head.idx.average(M) = hdr.idx.average;
-            obj.head.idx.slice(M) = hdr.idx.slice;
-            obj.head.idx.contrast(M) = hdr.idx.contrast;
-            obj.head.idx.phase(M) = hdr.idx.phase;
-            obj.head.idx.repetition(M) = hdr.idx.repetition;
-            obj.head.idx.set(M) = hdr.idx.set;
-            obj.head.idx.segment(M) = hdr.idx.segment;
-            obj.head.idx.user(:,M) = hdr.idx.user;
-            obj.head.user_int(:,M) = hdr.user_int;
-            obj.head.user_float(:,M) = hdr.user_float;
+            M = N+obj.getNumber();
+            obj.head.extend(N);
             obj.traj{M} = [];
             obj.data{M} = []; 
         end
         
-        function obj = setHead(obj,p,hdr)
-            obj.head.version(p) = hdr.version;
-            obj.head.flags(p) = hdr.flags;
-            obj.head.measurement_uid(p) = hdr.measurement_uid;
-            obj.head.scan_counter(p) = hdr.scan_counter;
-            obj.head.acquisition_time_stamp(p) = hdr.acquisition_time_stamp; 
-            obj.head.physiology_time_stamp(:,p) = hdr.physiology_time_stamp;
-            obj.head.number_of_samples(p) = hdr.number_of_samples;
-            obj.head.available_channels(p) = hdr.available_channels;
-            obj.head.active_channels(p) = hdr.active_channels;
-            obj.head.channel_mask(:,p) = hdr.channel_mask;
-            obj.head.discard_pre(p) = hdr.discard_pre;
-            obj.head.discard_post(p) = hdr.discard_post;
-            obj.head.center_sample(p) = hdr.center_sample;
-            obj.head.encoding_space_ref(p) = hdr.encoding_space_ref;
-            obj.head.trajectory_dimensions(p) = hdr.trajectory_dimensions;
-            obj.head.sample_time_us(p) = hdr.sample_time_us;
-            obj.head.position(:,p) = hdr.position;
-            obj.head.read_dir(:,p) = hdr.read_dir;
-            obj.head.phase_dir(:,p) = hdr.phase_dir;
-            obj.head.slice_dir(:,p) = hdr.slice_dir;
-            obj.head.patient_table_position(:,p) = hdr.patient_table_position;
-            obj.head.idx.kspace_encode_step_1(p) = hdr.idx.kspace_encode_step_1;
-            obj.head.idx.kspace_encode_step_2(p) = hdr.idx.kspace_encode_step_2;
-            obj.head.idx.average(p) = hdr.idx.average;
-            obj.head.idx.slice(p) = hdr.idx.slice;
-            obj.head.idx.contrast(p) = hdr.idx.contrast;
-            obj.head.idx.phase(p) = hdr.idx.phase;
-            obj.head.idx.repetition(p) = hdr.idx.repetition;
-            obj.head.idx.set(p) = hdr.idx.set;
-            obj.head.idx.segment(p) = hdr.idx.segment;
-            obj.head.idx.user(:,p) = hdr.idx.user;
-            obj.head.user_int(:,p) = hdr.user_int;
-            obj.head.user_float(:,p) = hdr.user_float;
-        end
-        
         function dataFromFloat(obj,v)
             if (isempty(obj.head) || (length(v) ~= length(obj.head.version)))
                 error('Mismatch between size of head and data.  Please set head first.');
diff --git a/matlab/+ismrmrd/AcquisitionFlags.m b/matlab/+ismrmrd/AcquisitionFlags.m
deleted file mode 100644
index 01e2aab..0000000
--- a/matlab/+ismrmrd/AcquisitionFlags.m
+++ /dev/null
@@ -1,39 +0,0 @@
-classdef AcquisitionFlags < ismrmrd.Flags
-    properties(Constant)
-        % Looping indicators %
-        ACQ_FIRST_IN_ENCODE_STEP1                	= 1,
-        ACQ_LAST_IN_ENCODE_STEP1    				= 2,
-        ACQ_FIRST_IN_ENCODE_STEP2   				= 3,
-        ACQ_LAST_IN_ENCODE_STEP2    				= 4,
-        ACQ_FIRST_IN_AVERAGE        				= 5,
-        ACQ_LAST_IN_AVERAGE         				= 6,
-        ACQ_FIRST_IN_SLICE          				= 7,
-        ACQ_LAST_IN_SLICE           				= 8,
-        ACQ_FIRST_IN_CONTRAST       				= 9,
-        ACQ_LAST_IN_CONTRAST        				= 10,
-        ACQ_FIRST_IN_PHASE          				= 11,
-        ACQ_LAST_IN_PHASE           				= 12,
-        ACQ_FIRST_IN_REPETITION     				= 13,
-        ACQ_LAST_IN_REPETITION      				= 14,
-        ACQ_FIRST_IN_SET            				= 15,
-        ACQ_LAST_IN_SET             				= 16,
-        ACQ_FIRST_IN_SEGMENT        				= 17,
-        ACQ_LAST_IN_SEGMENT         				= 18,
-
-        ACQ_IS_NOISE_MEASUREMENT                	= 19,
-        ACQ_IS_PARALLEL_CALIBRATION             	= 20,
-        ACQ_IS_PARALLEL_CALIBRATION_AND_IMAGING 	= 21,
-        ACQ_IS_REVERSE              				= 22,
-        ACQ_IS_NAVIGATION_DATA      				= 23,
-
-        ACQ_USER1                   				= 57,
-        ACQ_USER2                   				= 58,
-        ACQ_USER3                   				= 59,
-        ACQ_USER4                   				= 60,
-        ACQ_USER5                   				= 61,
-        ACQ_USER6                   				= 62,
-        ACQ_USER7                   				= 63,
-        ACQ_USER8                   				= 64
-    end
-    
-end
\ No newline at end of file
diff --git a/matlab/+ismrmrd/AcquisitionHeader.m b/matlab/+ismrmrd/AcquisitionHeader.m
index 024ce7a..09fddf8 100644
--- a/matlab/+ismrmrd/AcquisitionHeader.m
+++ b/matlab/+ismrmrd/AcquisitionHeader.m
@@ -1,47 +1,432 @@
-function hdr = AcquisitionHeader()
-% Return an initialized ISMRMRD AcquisitionHeader
+classdef AcquisitionHeader < handle
+    
+    properties
+        
+        version = uint16([]);                          % First unsigned int indicates the version %
+        flags = uint64([]);                            % bit field with flags %
+        measurement_uid = uint32([]);                  % Unique ID for the measurement %
+        scan_counter = uint32([]);                     % Current acquisition number in the measurement %
+        acquisition_time_stamp = uint32([]);           % Acquisition clock %
+        physiology_time_stamp = uint32([]);            % Physiology time stamps, e.g. ecg, breating, etc. %
+        number_of_samples = uint16([]);                % Number of samples acquired %
+        available_channels = uint16([]);               % Available coils %
+        active_channels = uint16([]);                  % Active coils on current acquisiton %
+        channel_mask = uint64([]);                     % Mask to indicate which channels are active. Support for 1024 channels %
+        discard_pre = uint16([]);                      % Samples to be discarded at the beginning of acquisition %
+        discard_post = uint16([]);                     % Samples to be discarded at the end of acquisition %
+        center_sample = uint16([]);                    % Sample at the center of k-space %
+        encoding_space_ref = uint16([]);               % Reference to an encoding space, typically only one per acquisition %
+        trajectory_dimensions = uint16([]);            % Indicates the dimensionality of the trajectory vector (0 means no trajectory) %
+        sample_time_us = single([]);                   % Time between samples in micro seconds, sampling BW %
+        position = single([]);                         % Three-dimensional spatial offsets from isocenter %
+        read_dir = single([]);                         % Directional cosines of the readout/frequency encoding %
+        phase_dir = single([]);                        % Directional cosines of the phase encoding %
+        slice_dir = single([]);                        % Directional cosines of the slice %
+        patient_table_position = single([]);           % Patient table off-center %
+        idx = struct(  ...                             % Encoding loop counters, see above %
+            'kspace_encode_step_1', uint16([]), ...   
+            'kspace_encode_step_2', uint16([]), ...
+            'average', uint16([]), ...
+            'slice', uint16([]), ...
+            'contrast', uint16([]), ...
+            'phase', uint16([]), ...
+            'repetition', uint16([]), ...
+            'set', uint16([]), ...
+            'segment', uint16([]), ...
+            'user', uint16([]));
+        user_int = int32([]);                 % Free user parameters %
+        user_float = single([]);              % Free user parameters %
+        
+    end
+    
+    properties(Constant)
+        FLAGS = struct( ...
+            'ACQ_FIRST_IN_ENCODE_STEP1',                1, ...
+            'ACQ_LAST_IN_ENCODE_STEP1',                 2, ...
+            'ACQ_FIRST_IN_ENCODE_STEP2',                3, ...
+            'ACQ_LAST_IN_ENCODE_STEP2',                 4, ...
+            'ACQ_FIRST_IN_AVERAGE',                     5, ...
+            'ACQ_LAST_IN_AVERAGE',                      6, ...
+            'ACQ_FIRST_IN_SLICE',                       7, ...
+            'ACQ_LAST_IN_SLICE',                        8, ...
+            'ACQ_FIRST_IN_CONTRAST',                    9, ...
+            'ACQ_LAST_IN_CONTRAST',                    10, ...
+            'ACQ_FIRST_IN_PHASE',                      11, ...
+            'ACQ_LAST_IN_PHASE',                       12, ...
+            'ACQ_FIRST_IN_REPETITION',                 13, ...
+            'ACQ_LAST_IN_REPETITION',                  14, ...
+            'ACQ_FIRST_IN_SET',                        15, ...
+            'ACQ_LAST_IN_SET',                         16, ...
+            'ACQ_FIRST_IN_SEGMENT',                    17, ...
+            'ACQ_LAST_IN_SEGMENT',                     18, ...
+            'ACQ_IS_NOISE_MEASUREMENT',                19, ...
+            'ACQ_IS_PARALLEL_CALIBRATION',             20, ...
+            'ACQ_IS_PARALLEL_CALIBRATION_AND_IMAGING', 21, ...
+            'ACQ_IS_REVERSE',                          22, ...
+            'ACQ_IS_NAVIGATION_DATA',                  23, ...
+            'ACQ_USER1',                               57, ...
+            'ACQ_USER2',                               58, ...
+            'ACQ_USER3',                               59, ...
+            'ACQ_USER4',                               60, ...
+            'ACQ_USER5',                               61, ...
+            'ACQ_USER6',                               62, ...
+            'ACQ_USER7',                               63, ...
+            'ACQ_USER8',                               64);
+    end
+    
+    methods
+        
+        function obj = AcquisitionHeader(arg)
+            switch nargin
+                case 0
+                    % No argument constructor
+                    % initialize to a single acquisition header
+                    extend(obj,1);
+                    
+                case 1
+                    % One argument constructor
+                    if isstruct(arg)
+                        % plain struct
+                        fromStruct(obj,arg);
+                    elseif (length(arg)==1 && ismrmrd.util.isInt(arg)) == 1
+                        % number
+                        extend(obj,arg);
+                    elseif isa(arg,'int8')
+                        % Byte array
+                        fromBytes(obj,arg);
+                    else
+                        % Unknown type
+                        error('Unknown argument type.')
+                    end
+                    
+                otherwise
+                    error('Wrong number of arguments.')
+                    
+            end
+        end
+        
+        function nacq = getNumber(obj)
+            nacq = length(obj.version);
+        end
 
-hdr = struct( ...
-    'version',                uint16(0),            ... % First unsigned int indicates the version %
-    'flags',                  uint64(0),            ... % bit field with flags %
-    'measurement_uid',        uint32(0),            ... % Unique ID for the measurement %
-    'scan_counter',           uint32(0),            ... % Current acquisition number in the measurement %
-    'acquisition_time_stamp', uint32(0),            ... % Acquisition clock %
-    'physiology_time_stamp',  zeros(3,1,'uint32'),  ... % Physiology time stamps, e.g. ecg, breating, etc. %
-                                                    ... %   TODO: the C header has a bug.  3 is correct
-    'number_of_samples',      uint16(0),            ... % Number of samples acquired %
-    'available_channels',     uint16(0),            ... % Available coils %
-    'active_channels',        uint16(0),            ... % Active coils on current acquisiton %
-    'channel_mask',           zeros(16,1,'uint64'), ... % Mask to indicate which channels are active. Support for 1024 channels %
-    'discard_pre',            uint16(0),            ... % Samples to be discarded at the beginning of acquisition %
-    'discard_post',           uint16(0),            ... % Samples to be discarded at the end of acquisition %
-    'center_sample',          uint16(0),            ... % Sample at the center of k-space %
-    'encoding_space_ref',     uint16(0),            ... % Reference to an encoding space, typically only one per acquisition %
-    'trajectory_dimensions',  uint16(0),            ... % Indicates the dimensionality of the trajectory vector (0 means no trajectory) %
-    'sample_time_us',         single(0),            ... % Time between samples in micro seconds, sampling BW %
-    'position',               zeros(3,1,'single'),  ... % Three-dimensional spatial offsets from isocenter %
-    'read_dir',               zeros(3,1,'single'),  ... % Directional cosines of the readout/frequency encoding %
-    'phase_dir',              zeros(3,1,'single'),  ... % Directional cosines of the phase encoding %
-    'slice_dir',              zeros(3,1,'single'),  ... % Directional cosines of the slice %
-    'patient_table_position', zeros(3,1, 'single'), ... % Patient table off-center %
-    'idx',                    struct(),             ... % Encoding counters %
-    'user_int',               zeros(8,1,'int32'),   ... % Free user parameters %
-    'user_float',             zeros(8,1,'single')   ... % Free user parameters %
-    );
+        function hdr = select(obj, range)
+            % Return a copy of a range of acquisition headers
+            
+            % create an empty acquisition header
+            M = length(range);
+            hdr = ismrmrd.Acquisition(M);
+            
+            % Fill
+            hdr.version = obj.version(range);
+            hdr.flags = obj.flags(range);
+            hdr.measurement_uid = obj.measurement_uid(range);
+            hdr.scan_counter = obj.scan_counter(range);
+            hdr.acquisition_time_stamp = obj.acquisition_time_stamp(range);
+            hdr.physiology_time_stamp = obj.physiology_time_stamp(:,range);
+            hdr.number_of_samples = obj.number_of_samples(range);
+            hdr.available_channels = obj.available_channels(range);
+            hdr.active_channels = obj.active_channels(range);
+            hdr.channel_mask = obj.channel_mask(:,range);
+            hdr.discard_pre = obj.discard_pre(range);
+            hdr.discard_post = obj.discard_post(range);
+            hdr.center_sample = obj.center_sample(range);
+            hdr.encoding_space_ref = obj.encoding_space_ref(range);
+            hdr.trajectory_dimensions = obj.trajectory_dimensions(range);
+            hdr.sample_time_us = obj.sample_time_us(range);
+            hdr.position = obj.position(:,range);
+            hdr.read_dir = obj.read_dir(:,range);
+            hdr.phase_dir = obj.phase_dir(:,range);
+            hdr.slice_dir = obj.slice_dir(:,range);
+            hdr.patient_table_position = obj.patient_table_position(:,range);
+            hdr.idx.kspace_encode_step_1 = obj.idx.kspace_encode_step_1(range);
+            hdr.idx.kspace_encode_step_2 = obj.idx.kspace_encode_step_2(range);
+            hdr.idx.average = obj.idx.average(range);
+            hdr.idx.slice = obj.idx.slice(range);
+            hdr.idx.contrast = obj.idx.contrast(range);
+            hdr.idx.phase = obj.idx.phase(range);
+            hdr.idx.repetition = obj.idx.repetition(range);
+            hdr.idx.set = obj.idx.set(range);
+            hdr.idx.segment = obj.idx.segment(range);
+            hdr.idx.user = obj.idx.user(:,range);
+            hdr.user_int = obj.user_int(:,range);
+            hdr.user_float = obj.user_float(:,range);
+            
+        end        
+        
+        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');
+            obj.measurement_uid(1,range)          = zeros(1,N,'uint32');
+            obj.scan_counter(1,range)             = zeros(1,N,'uint32');
+            obj.acquisition_time_stamp(1,range)   = zeros(1,N,'uint32');
+            obj.physiology_time_stamp(1:3,range)  = zeros(3,N,'uint32');
+            obj.number_of_samples(1,range)        = zeros(1,N,'uint16');
+            obj.available_channels(1,range)       = zeros(1,N,'uint16');
+            obj.active_channels(1,range)          = zeros(1,N,'uint16');
+            obj.channel_mask(1:16,range)          = zeros(16,N,'uint64');
+            obj.discard_pre(1,range)              = zeros(1,N,'uint16');
+            obj.discard_post(1,range)             = zeros(1,N,'uint16');
+            obj.center_sample(1,range)            = zeros(1,N,'uint16');
+            obj.encoding_space_ref(1,range)       = zeros(1,N,'uint16');
+            obj.trajectory_dimensions(1,range)    = zeros(1,N,'uint16');
+            obj.sample_time_us(1,range)           = zeros(1,N,'uint16');
+            obj.position(1:3,range)               = zeros(3,N,'single');
+            obj.read_dir(1:3,range)               = zeros(3,N,'single');
+            obj.phase_dir(1:3,range)              = zeros(3,N,'single');
+            obj.slice_dir(1:3,range)              = zeros(3,N,'single');
+            obj.patient_table_position(1:3,range) = zeros(3,N,'single');
+            obj.idx.kspace_encode_step_1(1,range) = zeros(1,N,'uint16');
+            obj.idx.kspace_encode_step_2(1,range) = zeros(1,N,'uint16');
+            obj.idx.average(1,range)              = zeros(1,N,'uint16');
+            obj.idx.slice(1,range)                = zeros(1,N,'uint16');
+            obj.idx.contrast(1,range)             = zeros(1,N,'uint16');
+            obj.idx.phase(1,range)                = zeros(1,N,'uint16');
+            obj.idx.repetition(1,range)           = zeros(1,N,'uint16');
+            obj.idx.set(1,range)                  = zeros(1,N,'uint16');
+            obj.idx.segment(1,range)              = zeros(1,N,'uint16');
+            obj.idx.user(1:8,range)               = zeros(8,N,'uint16');
+            obj.user_int(1:8,range)               = zeros(8,N,'int32');
+            obj.user_float(1:8,range)             = zeros(8,N,'single');
+        end
+        
+        function append(obj, head)
+            Nstart = obj.getNumber + 1;
+            Nend   = obj.getNumber + length(head.version);
+            Nrange = Nstart:Nend;
+            obj.version(Nrange) = hdr.version;
+            obj.flags(Nrange) = hdr.flags;
+            obj.measurement_uid(Nrange) = hdr.measurement_uid;
+            obj.scan_counter(Nrange) = hdr.scan_counter;
+            obj.acquisition_time_stamp(Nrange) = hdr.acquisition_time_stamp;
+            obj.physiology_time_stamp(:,Nrange) = hdr.physiology_time_stamp;
+            obj.number_of_samples(Nrange) = hdr.number_of_samples;
+            obj.available_channels(Nrange) = hdr.available_channels;
+            obj.active_channels(Nrange) = hdr.active_channels;
+            obj.channel_mask(:,Nrange) = hdr.channel_mask;
+            obj.discard_pre(Nrange) = hdr.discard_pre;
+            obj.discard_post(Nrange) = hdr.discard_post;
+            obj.center_sample(Nrange) = hdr.center_sample;
+            obj.encoding_space_ref(Nrange) = hdr.encoding_space_ref;
+            obj.trajectory_dimensions(Nrange) = hdr.trajectory_dimensions;
+            obj.sample_time_us(Nrange) = hdr.sample_time_us;
+            obj.position(:,Nrange) = hdr.position;
+            obj.read_dir(:,Nrange) = hdr.read_dir;
+            obj.phase_dir(:,Nrange) = hdr.phase_dir;
+            obj.slice_dir(:,Nrange) = hdr.slice_dir;
+            obj.patient_table_position(:,Nrange) = hdr.patient_table_position;
+            obj.idx.kspace_encode_step_1(Nrange) = hdr.idx.kspace_encode_step_1;
+            obj.idx.kspace_encode_step_2(Nrange) = hdr.idx.kspace_encode_step_2;
+            obj.idx.average(Nrange) = hdr.idx.average;
+            obj.idx.slice(Nrange) = hdr.idx.slice;
+            obj.idx.contrast(Nrange) = hdr.idx.contrast;
+            obj.idx.phase(Nrange) = hdr.idx.phase;
+            obj.idx.repetition(Nrange) = hdr.idx.repetition;
+            obj.idx.set(Nrange) = hdr.idx.set;
+            obj.idx.segment(Nrange) = hdr.idx.segment;
+            obj.idx.user(:,Nrange) = hdr.idx.user;
+            obj.user_int(:,Nrange) = hdr.user_int;
+            obj.user_float(:,Nrange) = hdr.user_float;            
+        end
 
-    
-% Encoding Counters
-hdr.idx = struct( ...
-    'kspace_encode_step_1',   uint16(0),            ... % phase encoding line number %
-    'kspace_encode_step_2',   uint16(0),            ... % partition encodning number %
-    'average',                uint16(0),            ... % signal average number %
-    'slice',                  uint16(0),            ... % imaging slice number %
-    'contrast',               uint16(0),            ... % echo number in multi-echo %
-    'phase',                  uint16(0),            ... % cardiac phase number %
-    'repetition',             uint16(0),            ... % dynamic number for dynamic scanning %
-    'set',                    uint16(0),            ... % flow encoding set %
-    'segment',                uint16(0),            ... % segment number for segmented acquisition %
-    'user',                   zeros(8,1,'uint16')   ... % Free user parameters %
-    );
+        function fromStruct(obj, hdr)
+            %warning! no error checking
+            obj.version = hdr.version;
+            obj.flags = hdr.flags;
+            obj.measurement_uid = hdr.measurement_uid;
+            obj.scan_counter = hdr.scan_counter;
+            obj.acquisition_time_stamp = hdr.acquisition_time_stamp;
+            obj.physiology_time_stamp = hdr.physiology_time_stamp;
+            obj.number_of_samples = hdr.number_of_samples;
+            obj.available_channels = hdr.available_channels;
+            obj.active_channels = hdr.active_channels;
+            obj.channel_mask = hdr.channel_mask;
+            obj.discard_pre = hdr.discard_pre;
+            obj.discard_post = hdr.discard_post;
+            obj.center_sample = hdr.center_sample;
+            obj.encoding_space_ref = hdr.encoding_space_ref;
+            obj.trajectory_dimensions = hdr.trajectory_dimensions;
+            obj.sample_time_us = hdr.sample_time_us;
+            obj.position = hdr.position;
+            obj.read_dir = hdr.read_dir;
+            obj.phase_dir = hdr.phase_dir;
+            obj.slice_dir = hdr.slice_dir;
+            obj.patient_table_position = hdr.patient_table_position;
+            obj.idx.kspace_encode_step_1 = hdr.idx.kspace_encode_step_1;
+            obj.idx.kspace_encode_step_2 = hdr.idx.kspace_encode_step_2;
+            obj.idx.average = hdr.idx.average;
+            obj.idx.slice = hdr.idx.slice;
+            obj.idx.contrast = hdr.idx.contrast;
+            obj.idx.phase = hdr.idx.phase;
+            obj.idx.repetition = hdr.idx.repetition;
+            obj.idx.set = hdr.idx.set;
+            obj.idx.segment = hdr.idx.segment;
+            obj.idx.user = hdr.idx.user;
+            obj.user_int = hdr.user_int;
+            obj.user_float = hdr.user_float;            
+        end
+        
+        function fromBytes(obj, bytearray)
+
+            % 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
+            N = size(bytearray,2);
+            for p = 1:N
+                obj.version(p) =                  typecast(bytearray(  1:  2,p), 'uint16'); ... % First unsigned int indicates the version %
+                obj.flags(p) =                    typecast(bytearray(  3: 10,p), 'uint64'); ... % bit field with flags %
+                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.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 %
+                obj.channel_mask(:,p) =           typecast(bytearray( 61:188,p), 'uint64'); ... % Mask to indicate which channels are active. Support for 1024 channels %
+                obj.discard_pre(p) =              typecast(bytearray(189:190,p), 'uint16'); ... % Samples to be discarded at the beginning of acquisition %
+                obj.discard_post(p) =             typecast(bytearray(191:192,p), 'uint16'); ... % Samples to be discarded at the end of acquisition %
+                obj.center_sample(p) =            typecast(bytearray(193:194,p), 'uint16'); ... % Sample at the center of k-space %
+                obj.encoding_space_ref(p) =       typecast(bytearray(195:196,p), 'uint16'); ... % Reference to an encoding space, typically only one per acquisition %
+                obj.trajectory_dimensions(p) =    typecast(bytearray(197:198,p), 'uint16'); ... % Indicates the dimensionality of the trajectory vector (0 means no trajectory) %
+                obj.sample_time_us(p) =           typecast(bytearray(199:202,p), 'single'); ... % Time between samples in micro seconds, sampling BW %
+                obj.position(:,p) =               typecast(bytearray(203:214,p), 'single'); ... % Three-dimensional spatial offsets from isocenter %
+                obj.read_dir(:,p) =               typecast(bytearray(215:226,p), 'single'); ... % Directional cosines of the readout/frequency encoding %
+                obj.phase_dir(:,p) =              typecast(bytearray(227:238,p), 'single'); ... % Directional cosines of the phase encoding %
+                obj.slice_dir(:,p) =              typecast(bytearray(239:250,p), 'single'); ... % Directional cosines of the slice %
+                obj.patient_table_position(:,p) = typecast(bytearray(251:262,p), 'single'); ... % Patient table off-center %
+                obj.idx.kspace_encode_step_1(p) = typecast(bytearray(263:264,p), 'uint16'); ... % phase encoding line number %
+                obj.idx.kspace_encode_step_2(p) = typecast(bytearray(265:266,p), 'uint16'); ... % partition encodning number %
+                obj.idx.average(p) =              typecast(bytearray(267:268,p), 'uint16'); ... % signal average number %
+                obj.idx.slice(p) =                typecast(bytearray(269:270,p), 'uint16'); ... % imaging slice number %
+                obj.idx.contrast(p) =             typecast(bytearray(271:272,p), 'uint16'); ... % echo number in multi-echo %
+                obj.idx.phase(p) =                typecast(bytearray(273:274,p), 'uint16'); ... % cardiac phase number %
+                obj.idx.repetition(p) =           typecast(bytearray(275:276,p), 'uint16'); ... % dynamic number for dynamic scanning %
+                obj.idx.set(p) =                  typecast(bytearray(277:278,p), 'uint16'); ... % flow encoding set %
+                obj.idx.segment(p) =              typecast(bytearray(279:280,p), 'uint16'); ... % segment number for segmented acquisition %
+                obj.idx.user(:,p) =               typecast(bytearray(281:296,p), 'uint16'); ... % Free user parameters %
+                obj.user_int(:,p) =               typecast(bytearray(297:328,p), 'int32');  ... % Free user parameters %
+                obj.user_float(:,p) =             typecast(bytearray(329:360,p), 'single'); ... % Free user parameters %
+            end              
+        end
+        
+        function bytes = toBytes(obj)
+            % Convert to an ISMRMRD AcquisitionHeader struct to a byte array.
 
+            N = obj.getNumber;
+            
+            % TODO: physiology_time_stamp should be 3.
+            %bytes = zeros(340,N,'int8');
+            bytes = zeros(360,N,'int8');
+            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;
+                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');
+            end
+        end
+        
+        function ret = flagIsSet(obj, flag, range)
+            if nargin < 3
+                range = 1:obj.getNumber;
+            end
+            if isa(flag, 'char')
+                b = obj.FLAGS.(flag);
+            elseif (flag>0)
+                b = uint64(flag);
+            else
+                error('Flag is of the wrong type.'); 
+            end
+            bitmask = bitshift(uint64(1),(b-1));
+            ret = zeros(size(range));
+            for p = 1:length(range)
+                ret(p) = (bitand(obj.flags(range(p)), bitmask)>0);
+            end
+        end
+        
+        function flagSet(obj, flag, range)
+            if nargin < 3
+                range = 1:obj.getNumber;
+            end
+            if isa(flag, 'char')
+                b = obj.FLAGS.(flag);
+            elseif (flag>0)
+                b = uint64(flag);
+            else
+                error('Flag is of the wrong type.'); 
+            end
+            bitmask = bitshift(uint64(1),(b-1));
+
+            alreadyset = obj.flagIsSet(flag,range);
+            for p = 1:length(range)
+                if ~alreadyset(p)
+                    obj.flags(range(p)) = obj.flags(range(p)) + bitmask;
+                end
+            end
+        end
+        
+        function flagClear(obj, flag, range)
+            if nargin < 3
+                range = 1:obj.getNumber;
+            end
+            
+            if isa(flag, 'char')
+                b = obj.FLAGS.(flag);
+            elseif (flag>0)
+                b = uint64(flag);
+            else
+                error('Flag is of the wrong type.'); 
+            end
+            bitmask = bitshift(uint64(1),(b-1));
+            
+            alreadyset = obj.flagIsSet(flag,range);
+            for p = 1:length(range)
+                if alreadyset(p)
+                    obj.flags(range(p)) = obj.flags(range(p)) - bitmask;
+                end
+            end
+                
+            
+        end
+        
+    end
+    
 end
diff --git a/matlab/+ismrmrd/FlagBit.m b/matlab/+ismrmrd/FlagBit.m
deleted file mode 100644
index a3482f2..0000000
--- a/matlab/+ismrmrd/FlagBit.m
+++ /dev/null
@@ -1,32 +0,0 @@
-classdef FlagBit
-    
-    properties
-        bitmask = uint64(0);
-    end
-    
-    methods
-        function obj = FlagBit(b)
-            if ~(b>0)
-                error('b must be positive');
-            else
-                obj.bitmask = bitshift(uint64(1),(b-1));
-            end
-        end % FlagBit
-    end
-    
-    methods
-        
-        function obj = set.bitmask(obj,b)
-            obj.bitmask = uint64(b);
-        end % bitmask set function
-        
-        function b = isSet(obj,m)
-            if (bitand(obj.bitmask, uint64(m))>0)
-                b = true;
-            else
-                b = false;
-            end
-        end % isSet
-    end
-    
-end % classdef
diff --git a/matlab/+ismrmrd/Flags.m b/matlab/+ismrmrd/Flags.m
deleted file mode 100644
index dc056c1..0000000
--- a/matlab/+ismrmrd/Flags.m
+++ /dev/null
@@ -1,65 +0,0 @@
-classdef Flags
-   
-    methods
-        
-        function ret = isSet(obj, flagbits, flag)
-            if isa(flag, 'char')
-                b = obj.(flag);
-            elseif (flag>0)
-                b = uint64(flag);
-            else
-                error('Flag is of the wrong type.'); 
-            end
-            bitmask = bitshift(uint64(1),(b-1));
-            
-            ret = (bitand(flagbits, bitmask)>0);
-
-        end
-        
-        function ret = set(obj, flagbits, flag)
-
-            if isa(flag, 'char')
-                b = obj.(flag);
-            elseif (flag>0)
-                b = uint64(flag);
-            else
-                error('Flag is of the wrong type.'); 
-            end
-            bitmask = bitshift(uint64(1),(b-1));
-
-            if (obj.isSet(flagbits, flag))
-                % Already set
-                ret = flagbits;
-            else
-                ret = flagbits + bitmask;
-            end
-            
-        end
-        
-        function ret =  clear(obj, flagbits, flag)
-            if (nargin < 3)
-                ret = uint64(0);
-                return
-            end
-            
-            if isa(flag, 'char')
-                b = obj.(flag);
-            elseif (flag>0)
-                b = uint64(flag);
-            else
-                error('Flag is of the wrong type.'); 
-            end
-            bitmask = bitshift(uint64(1),(b-1));
-            
-            if ~(obj.isSet(flagbits, flag))
-                % Already cleared
-                ret = flagbits;
-            else
-                ret = flagbits - bitmask;
-            end
-
-        end
-
-    end
-  
-end % classdef
\ No newline at end of file
diff --git a/matlab/+ismrmrd/IsmrmrdDataset.m b/matlab/+ismrmrd/IsmrmrdDataset.m
index 909d92c..c465621 100644
--- a/matlab/+ismrmrd/IsmrmrdDataset.m
+++ b/matlab/+ismrmrd/IsmrmrdDataset.m
@@ -13,10 +13,10 @@ classdef IsmrmrdDataset
 
         function obj = IsmrmrdDataset(filename,groupname)
             % add the ismrmrd jar to the javaclasspath
-            ismrmrd.includejar();
+            ismrmrd.util.includejar();
 
             % Set the hdf types
-            obj.htypes = ismrmrd.utils.hdf5_datatypes;
+            obj.htypes = ismrmrd.util.hdf5_datatypes;
                       
             % If the file exists, open it for read/write
             % otherwise, create it
@@ -204,9 +204,6 @@ classdef IsmrmrdDataset
                      
             % Pack'em
             block = ismrmrd.Acquisition(d.head, d.traj, d.data);
-            %block.head = d.head;
-            %block.traj = d.traj;
-            %block.dataFromFloat(d.data);
 
             % Clean up
             H5S.close(mem_space);

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