Skip to content

Quick Start ​

Install ​

The MRD MATLAB toolbox requires MATLAB R2022b or newer.

See MRD Github Releases for the most recent version of the MRD MATLAB Toolbox.

Download the *.mltbx file and double-click on it from within the MATLAB Current Folder browser to install it.

Reading and Writing MRD Streams ​

To read and write MRD streams, start with the following example:

matlab
header = mrd.Header();
% Populate Header
% ...

w = mrd.binary.MrdWriter("test.bin");
w.write_header(header);

nreps = 2;
for r = 1:nreps
    acq = mrd.Acquisition();
    % Populate Acquisition
    % ...

    w.write_data(mrd.StreamItem.Acquisition(acq));
end
w.end_data();
w.close();

r = mrd.binary.MrdReader("test.bin");
header = r.read_header();
while r.has_data()
    item = r.read_data();
    acq = item.value;
end
r.close();

Examples ​

See matlab/toolbox/examples in the MRD repository for example MATLAB program using the MRD toolbox.

For example, to generate a cartesian Shepp-Logan phantom:

matlab
>> cd matlab/toolbox/examples
>> addpath("../");
>> generate_phantom("test.bin", matrix_size=256, ncoils=8);