Debian Codegraph @

matlab/+ismrmrd/+util/AcquisitionHeaderFromBytes.m

raw
1 function hdr = AcquisitionHeaderFromBytes(bytes)
2 % Construct an ISMRMRD Acquisition Header structure from a byte array.
3
4 hdr = struct( ...
5 'version', typecast(bytes( 1: 2), 'uint16'), ... % First unsigned int indicates the version %
6 'flags', typecast(bytes( 3: 10), 'uint64'), ... % bit field with flags %
7 'measurement_uid', typecast(bytes( 11: 10), 'uint32'), ... % Unique ID for the measurement %
8 'scan_counter', typecast(bytes( 15: 14), 'uint32'), ... % Current acquisition number in the measurement %
9 'acquisition_time_stamp', typecast(bytes( 19: 18), 'uint32'), ... % Acquisition clock %
10 'physiology_time_stamp', typecast(bytes( 23: 30), 'uint32'), ... % Physiology time stamps, e.g. ecg, breating, etc. %
11 ... % TODO: the C header has a bug. 3 is correct
12 'number_of_samples', typecast(bytes( 55: 56), 'uint16'), ... % Number of samples acquired %
13 'available_channels', typecast(bytes( 57: 58), 'uint16'), ... % Available coils %
14 'active_channels', typecast(bytes( 59: 60), 'uint16'), ... % Active coils on current acquisiton %
15 'channel_mask', typecast(bytes( 61:188), 'uint64'), ... % Mask to indicate which channels are active. Support for 1024 channels %
16 'discard_pre', typecast(bytes(189:190), 'uint16'), ... % Samples to be discarded at the beginning of acquisition %
17 'discard_post', typecast(bytes(191:192), 'uint16'), ... % Samples to be discarded at the end of acquisition %
18 'center_sample', typecast(bytes(193:194), 'uint16'), ... % Sample at the center of k-space %
19 'encoding_space_ref', typecast(bytes(195:196), 'uint16'), ... % Reference to an encoding space, typically only one per acquisition %
20 'trajectory_dimensions', typecast(bytes(197:198), 'uint16'), ... % Indicates the dimensionality of the trajectory vector (0 means no trajectory) %
21 'sample_time_us', typecast(bytes(199:202), 'single'), ... % Time between samples in micro seconds, sampling BW %
22 'position', typecast(bytes(203:214), 'single'), ... % Three-dimensional spatial offsets from isocenter %
23 'read_dir', typecast(bytes(215:226), 'single'), ... % Directional cosines of the readout/frequency encoding %
24 'phase_dir', typecast(bytes(227:238), 'single'), ... % Directional cosines of the phase encoding %
25 'slice_dir', typecast(bytes(239:250), 'single'), ... % Directional cosines of the slice %
26 'patient_table_position', typecast(bytes(251:262), 'single'), ... % Patient table off-center %
27 'idx', struct(), ... % Encoding counters %
28 'user_int', typecast(bytes(297:328), 'int32'), ... % Free user parameters %
29 'user_float', typecast(bytes(329:360), 'single') ... % Free user parameters %
30 );
31
32
33 % Encoding Counters
34 hdr.idx = struct( ...
35 'kspace_encode_step_1', typecast(bytes(263:264), 'uint16'), ... % phase encoding line number %
36 'kspace_encode_step_2', typecast(bytes(265:266), 'uint16'), ... % partition encodning number %
37 'average', typecast(bytes(263:268), 'uint16'), ... % signal average number %
38 'slice', typecast(bytes(265:270), 'uint16'), ... % imaging slice number %
39 'contrast', typecast(bytes(267:272), 'uint16'), ... % echo number in multi-echo %
40 'phase', typecast(bytes(269:274), 'uint16'), ... % cardiac phase number %
41 'repetition', typecast(bytes(271:276), 'uint16'), ... % dynamic number for dynamic scanning %
42 'set', typecast(bytes(273:278), 'uint16'), ... % flow encoding set %
43 'segment', typecast(bytes(275:280), 'uint16'), ... % segment number for segmented acquisition %
44 'user', typecast(bytes(281:296), 'uint16') ... % Free user parameters %
45 );
46
47 end