[ismrmrd] 166/177: Matlab simple spiral example works with the new api. Modified matlab trajectory (fixed shape).
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:02:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag v1.1.0.beta.1
in repository ismrmrd.
commit 1dbaf4b8924afbd9c70e83d8abd94932d453b7f1
Author: Souheil Inati <souheil.inati at nih.gov>
Date: Fri Oct 24 16:17:53 2014 -0400
Matlab simple spiral example works with the new api. Modified matlab trajectory (fixed shape).
---
examples/matlab/simple_spiral_recon.m | 24 ++++++++++++++----------
examples/matlab/test_create_dataset.m | 12 ++++++------
examples/matlab/test_recon_dataset.m | 2 +-
matlab/+ismrmrd/Acquisition.m | 15 +++++++++++++--
4 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/examples/matlab/simple_spiral_recon.m b/examples/matlab/simple_spiral_recon.m
index 3815580..42bd8b2 100644
--- a/examples/matlab/simple_spiral_recon.m
+++ b/examples/matlab/simple_spiral_recon.m
@@ -8,19 +8,20 @@ function [images] = simple_spiral_recon(ismrmrdfile)
% Michael S. Hansen (michael.hansen at nih.gov), 2012
%
-header = ismrmrd_header2struct(h5read(ismrmrdfile,'/dataset/xml'));
+dset = ismrmrd.Dataset(ismrmrdfile);
+header = ismrmrd.xml.deserialize(dset.readxml());
%Is this a spiral acquisition
-if (~strcmp(header.ismrmrdHeader.encoding.trajectory.Text,'spiral')),
+if (~strcmp(header.encoding.trajectory,'spiral')),
error('This is not a spiral dataset');
end
%Let's get the matrix size
-matrix_size = [str2num(header.ismrmrdHeader.encoding.encodedSpace.matrixSize.x.Text), ...
- str2num(header.ismrmrdHeader.encoding.encodedSpace.matrixSize.y.Text)];
+matrix_size = [header.encoding.encodedSpace.matrixSize.x, ...
+ header.encoding.encodedSpace.matrixSize.y];
%Let's load the data
-raw_data = h5read(ismrmrdfile,'/dataset/data');
+raw_data = dset.readAcquisition(); % read all the acquisitions
interleaves = max(raw_data.head.idx.kspace_encode_step_1)+1;
repetitions = max(raw_data.head.idx.repetition)+1;
@@ -38,20 +39,23 @@ images = [];
counter = 0;
for p=1:length(raw_data.head.flags),
- if (bitget(uint64(raw_data.head.flags(p)),19)), %if this is noise, we will skip it
+ %if this is noise, we will skip it
+ if raw_data.head.flagIsSet('ACQ_IS_NOISE_MEASUREMENT',p)
continue;
end
- d = reshape(complex(raw_data.data{p}(1:2:end), raw_data.data{p}(2:2:end)), samples, channels);
- t = reshape(raw_data.traj{p}, raw_data.head.trajectory_dimensions(p), samples);
+ d = raw_data.data{p};
+ t = raw_data.traj{p};
current_interleave = raw_data.head.idx.kspace_encode_step_1(p)+1;
start_sample = samples_to_skip_start+1;
end_sample = samples-samples_to_skip_end;
data(:,current_interleave,:) = reshape(d(start_sample:end_sample,:), net_samples, 1, channels);
trajectory(:,:,current_interleave) = t(:,start_sample:end_sample);
-
- if (bitget(uint64(raw_data.head.flags(p)),8)), %Is this the last in slice? We should make an image
+
+ %Is this the last in slice? We should make an image
+ if raw_data.head.flagIsSet('ACQ_LAST_IN_SLICE',p)
+
fprintf('Reconstructing image %d....', counter+1);
co = permute(trajectory(:,:),[2 1]);
diff --git a/examples/matlab/test_create_dataset.m b/examples/matlab/test_create_dataset.m
index 71b7a6c..4b230f7 100644
--- a/examples/matlab/test_create_dataset.m
+++ b/examples/matlab/test_create_dataset.m
@@ -71,13 +71,13 @@ for rep = 1:nReps
% Set the flags
acqblock.head.flagClearAll(acqno);
if acqno == 1
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_FIRST_IN_ENCODE_STEP1, acqno);
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_FIRST_IN_SLICE, acqno);
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_FIRST_IN_REPETITION, acqno);
+ acqblock.head.flagSet('ACQ_FIRST_IN_ENCODE_STEP1', acqno);
+ acqblock.head.flagSet('ACQ_FIRST_IN_SLICE', acqno);
+ acqblock.head.flagSet('ACQ_FIRST_IN_REPETITION', acqno);
elseif acqno==size(K,2)
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_LAST_IN_ENCODE_STEP1, acqno);
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_LAST_IN_SLICE, acqno);
- acqblock.head.flagSet(acqblock.head.FLAGS.ACQ_LAST_IN_REPETITION, acqno);
+ acqblock.head.flagSet('ACQ_LAST_IN_ENCODE_STEP1', acqno);
+ acqblock.head.flagSet('ACQ_LAST_IN_SLICE', acqno);
+ acqblock.head.flagSet('ACQ_LAST_IN_REPETITION', acqno);
end
% fill the data
diff --git a/examples/matlab/test_recon_dataset.m b/examples/matlab/test_recon_dataset.m
index 70e0078..6a6a6f7 100644
--- a/examples/matlab/test_recon_dataset.m
+++ b/examples/matlab/test_recon_dataset.m
@@ -104,7 +104,7 @@ D = dset.readAcquisition();
% TODO add a pre-whitening example
% Find the first non-noise scan
% This is how to check if a flag is set in the acquisition header
-isNoise = D.head.flagIsSet(D.head.FLAGS.ACQ_IS_NOISE_MEASUREMENT);
+isNoise = D.head.flagIsSet('ACQ_IS_NOISE_MEASUREMENT');
firstScan = find(isNoise==0,1,'first');
if firstScan > 1
noise = D.select(1:firstScan-1);
diff --git a/matlab/+ismrmrd/Acquisition.m b/matlab/+ismrmrd/Acquisition.m
index cdb8dcf..5b7dc23 100644
--- a/matlab/+ismrmrd/Acquisition.m
+++ b/matlab/+ismrmrd/Acquisition.m
@@ -36,7 +36,7 @@ classdef Acquisition < handle
if isempty(traj)
obj.traj{M} = [];
else
- obj.traj = traj;
+ trajFromFloat(obj,traj);
end
if isempty(data)
obj.data{M} = [];
@@ -122,13 +122,24 @@ classdef Acquisition < handle
end
end
+ function trajFromFloat(obj,v)
+ if (isempty(obj.head) || (length(v) ~= length(obj.head.version)))
+ error('Mismatch between size of head and trajectory. Please set head first.');
+ end
+ obj.traj = cell(1,length(v));
+ for p = 1:length(v)
+ dims = [obj.head.trajectory_dimensions(p), ...
+ obj.head.number_of_samples(p)];
+ obj.traj{p} = reshape(v{p}, dims);
+ 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
--
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