[ismrmrd] 53/281: Working Java xml handling for Matlab. Examples in progress.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:00:55 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 ef7e6a261f57fb609070c75a14ae221c75647345
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Thu Sep 27 11:29:40 2012 -0400

    Working Java xml handling for Matlab.  Examples in progress.
---
 examples/matlab/testsynth.m | 78 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/examples/matlab/testsynth.m b/examples/matlab/testsynth.m
new file mode 100644
index 0000000..5beacc1
--- /dev/null
+++ b/examples/matlab/testsynth.m
@@ -0,0 +1,78 @@
+% Read an existing file
+f = ismrmrd.file('../examples/data/testdata.h5');
+
+% Output file
+synthfile = 'test_mat_synth.h5';
+
+
+% Get its header
+xmlhdr = f.readxml();
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Generate a Synthetic Data Set %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Create a fake signal
+nx = 256; ny = 256;
+rho = zeros(nx,ny,'single');
+rho(nx/4+1:3*nx/4,ny/4+1:3*ny/4) = 1;
+kdat = fftshift(fft2(fftshift(rho)));
+
+% Create a new ISMRMRD file
+g = ismrmrd.file(synthfile);
+
+% Write the xml header
+g.writexml(xmlhdr);
+
+% Initialize the acquisition object
+acq = ismrmrd.Acquisition;
+acq.head.available_channels = 1;
+acq.head.active_channels = 1;
+acq.head.number_of_samples = nx;
+acq.head.center_sample = nx/2;
+
+% Loop over the acquisitions, set the looping variables, 
+% stuff the data, and append.  For this example, read ky from top to bottom.
+for p = ny:-1:1
+    acq.head.idx.kspace_encode_step_1 = p-1;
+    acq.data = kdat(:,p);
+    g.appendAcquisition(acq);
+end
+
+% close
+g.close();
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Read it in and reconstruct it %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Open the ISMRMRD file
+g = ismrmrd.file(synthfile);
+
+% Read the XML header
+xml = g.readxml();
+
+% Read the number of acquisitions
+nky = g.getNumberOfAcquisitions();
+% Read the first acquisition
+acq1 = g.readAcquisition(1);
+nx = acq1.head.number_of_samples;
+
+% Loop over the acquisitions and read them in
+% stuffing into the correct part of the k-space data array
+kdata = zeros(nx,nky);
+for p = 1:nky
+    acq = f.readAcquisition(p);
+    kdata(:,acq.head.idx.kspace_encode_step_1+1) = acq.data;
+end
+
+% Simple reconstruction
+rhohat = fftshift(ifft2(fftshift(kdata)));
+
+imagesc(abs(rhohat)); axis image; axis off; colorbar
+title('Reconstructed image');
+
+% close
+g.close();
+
+% close the original dataset
+f.close();

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