Reconstruction client

Reconstruction client#

The reconstruction client is the scanner-side program that streams the raw data of each series to the reconstruction proxy and returns the images to the console. It connects to the proxy’s TCP port (Services), sends one series per connection as MRD messages with the message identifiers of Gadgetron’s streaming protocol, and reads what the reconstruction returns on the same connection.

The proxy replaces the encoding counters, flags, encoding spaces and trajectory of the series with those the sequence states (MRD enrichment). Your client therefore sends what the scanner measured, the identifier of the design the series was played from and the reconstruction plugin to run, and leaves the Pulseq structure of the scan to the proxy.

Messages#

A series is sent in this order:

Message

Identifier

Content

CONFIG_FILE or CONFIG_TEXT

1 or 2

The reconstruction plugin: a config file message holding its name, or a config text holding a bare name or the path of its <plugin>.py file, or either under parameters.config of a JSON, YAML or XML text

HEADER

3

The MRD XML header, once

ACQUISITION

1008

One per readout of the sequence chain, in play order

WAVEFORM

1026

Optional, anywhere after the header: physiological waveforms, passed to the reconstruction unchanged

CLOSE

4

The end of the series

The design names no reconstruction, so the proxy refuses a series whose config names none, or that sends no config, unless it forwards with a --forward-config. A path ending in .py names the plugin by the file’s stem; the proxy searches its own --plugins directories for that name, whatever the path’s directory.

The client then reads until the proxy’s CLOSE: images (IMAGE, 1022), DICOM datasets (DICOM_WITHNAME, 1018) and texts (TEXT, 5), in the order the reconstruction produces them. Nothing is returned before the series has ended whole, with the client’s CLOSE or a last acquisition flagged LAST_IN_MEASUREMENT: a reconstruction may finish on the last readout, and what it produces then is held until that end. A text beginning pulserver: reports a series that failed. A refused series receives that text and a CLOSE at once; the proxy then discards what the client still sends until it closes the connection, so the client can finish sending and read the reason.

A client ends a scan the scanner stopped by shutting its side of the connection for writing without a CLOSE, then reading the reply as usual. The series is refused and nothing it produced is returned, even when every readout arrived.

Acquisitions#

The proxy matches acquisitions to readouts by their position in the stream, so your client sends every readout the sequence chain plays, those of dummy scans, noise scans and navigators included, and no other.

Field

Client

Proxy

number_of_samples

The sample count of the readout’s ADC event

Checked

active_channels, data

The samples, demodulated by each ADC’s frequency and phase offsets

Multiplied by the phase a field-of-view offset adds to a readout under a moving gradient, by the phase that centres the reconstruction grid (below), and by any phase modulation the sequence file stores

scan_counter

0 on every acquisition, or increasing by one from any start

Checked

flags

None, or LAST_IN_MEASUREMENT on the last acquisition

Replaced

idx, sample_time_us, encoding_space_ref

Any value

Replaced

center_sample

Any value

Replaced, except on a readout whose k-space location does not change

trajectory_dimensions, traj

Any value

Replaced on a readout whose k-space location changes, in 1/m along the sequence’s gradient axes

position

The prescribed field-of-view centre, in mm from isocentre

Moved along slice_dir to the centre of the readout’s slice, for a stack of 2D slices whose sequence defines SlicePositions, and by half a voxel along each axis of even matrix size (below); an image takes it from its reference acquisition

measurement_uid, read_dir, phase_dir, slice_dir, patient_table_position, acquisition_time_stamp, physiology_time_stamp, user_int, user_float

The scanner’s values, as MRD defines them

Passed on unchanged; an image takes them from its reference acquisition

The reconstruction grid is centred on the field of view: the voxel centres of an axis of n voxels lie symmetrically about the prescribed centre, at (i - (n - 1) / 2) voxels from it. An FFT puts the centre on voxel n // 2 instead, half a voxel off along an axis of even n, so each acquisition’s position is moved by FOV / (2 n) along each such axis of its encoding space’s matrix, and its samples are given the phase of the same shift of the field of view. Voxel n // 2 of the reconstruction, which MRD’s position locates, then lies half a voxel past the prescribed centre, and the content moves with it.

A series is refused, and its reconstruction stopped, when an acquisition has a sample count other than its readout’s, when the scan counters skip or repeat one, when an acquisition before the last is flagged LAST_IN_MEASUREMENT, when the stream carries more or fewer acquisitions than the chain plays, or when it ends without a CLOSE or a last acquisition flagged LAST_IN_MEASUREMENT.

See also#