[ismrmrd] 205/281: Add type checking to matlab ImageHeader
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:15 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 6ec4fcdb232c33fcf1c6db0bbb0f01a79be7a162
Author: Souheil Inati <souheil.inati at nih.gov>
Date: Wed Feb 12 11:22:01 2014 -0500
Add type checking to matlab ImageHeader
---
matlab/+ismrmrd/ImageHeader.m | 130 +++++++++++++++++++++++++++++++++++++++
matlab/+ismrmrd/IsmrmrdDataset.m | 2 +-
2 files changed, 131 insertions(+), 1 deletion(-)
diff --git a/matlab/+ismrmrd/ImageHeader.m b/matlab/+ismrmrd/ImageHeader.m
index 3822246..f5555f4 100644
--- a/matlab/+ismrmrd/ImageHeader.m
+++ b/matlab/+ismrmrd/ImageHeader.m
@@ -327,6 +327,136 @@ classdef ImageHeader < handle
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)
if nargin < 3
range = 1:obj.getNumber;
diff --git a/matlab/+ismrmrd/IsmrmrdDataset.m b/matlab/+ismrmrd/IsmrmrdDataset.m
index 71793bb..6ca12e8 100644
--- a/matlab/+ismrmrd/IsmrmrdDataset.m
+++ b/matlab/+ismrmrd/IsmrmrdDataset.m
@@ -268,7 +268,7 @@ classdef IsmrmrdDataset
mem_space_id = H5S.create_simple(2,[N 1],[]);
% Check and fix the acquisition header types
- acq.head = acq.head.check();
+ acq.head.check();
% TODO: Error checking on the sizes of the data and trajectories.
% Pack the acquisition into the correct struct for writing
--
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