| 1 |
function hdr = ImageHeaderFromBytes(bytes) |
| 2 |
% Construct an ISMRMRD Image Header structure from a byte array. |
| 3 |
|
| 4 |
off = 1; |
| 5 |
hdr = struct(); |
| 6 |
hdr.version = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 7 |
hdr.flags = typecast(bytes(off:off+7), 'uint64'); off=off+8; |
| 8 |
hdr.measurement_uid = typecast(bytes(off:off+3), 'uint32'); off=off+4; |
| 9 |
hdr.matrix_size = typecast(bytes(off:off+5), 'uint16'); off=off+6; |
| 10 |
hdr.field_of_view = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 11 |
hdr.channels = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 12 |
hdr.position = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 13 |
hdr.read_dir = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 14 |
hdr.phase_dir = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 15 |
hdr.slice_dir = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 16 |
hdr.patient_table_position = typecast(bytes(off:off+11), 'single'); off=off+12; |
| 17 |
hdr.average = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 18 |
hdr.slice = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 19 |
hdr.contrast = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 20 |
hdr.phase = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 21 |
hdr.repetition = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 22 |
hdr.set = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 23 |
hdr.acquisition_time_stamp = typecast(bytes(off:off+3), 'uint32'); off=off+4; |
| 24 |
hdr.physiology_time_stamp = typecast(bytes(off:off+31), 'uint32'); off=off+32; |
| 25 |
hdr.image_data_type = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 26 |
hdr.image_type = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 27 |
hdr.image_index = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 28 |
hdr.image_series_index = typecast(bytes(off:off+1), 'uint16'); off=off+2; |
| 29 |
hdr.user_int = typecast(bytes(off:off+31), 'uint32'); off=off+32; |
| 30 |
hdr.user_float = typecast(bytes(off:off+31), 'single'); |
| 31 |
|
| 32 |
end |