Services#

pulserver runs two services. The design calls answer the scanner’s interpreter host processes: they resolve protocols and write the designs the scanner plays into a design store, one command per call or through a warm design server. The reconstruction proxy receives each series from the scanner’s reconstruction client, reads the design it was played from in a design store, and returns the images.

When the two run on different computers, either the design store is a directory both can reach, or the proxy keeps a store of its own and its design intake receives each design the design calls push to it. When the reconstructions run on a computer of their own, a reconstruction server runs there and the proxy forwards each series to it. The services and the design store are described in Architecture.

Design calls#

pulserver design list     --plugins DIR --plugin NAME [--values FILE] [--limits FILE --rf-definitions] [--socket PATH]
pulserver design validate --plugins DIR --plugin NAME --limits FILE [--rf-layout] [--exam DIR] [--socket PATH] < VALUES
pulserver design generate --plugins DIR --plugin NAME --limits FILE --store DIR --scan NAME [--exam DIR] [--push URL] [--socket PATH] < VALUES
pulserver design import   --limits FILE --store DIR --scan NAME [--push URL] [--socket PATH] < IMPORT
pulserver design push     --store DIR --scan NAME --to URL ID...
pulserver design prune    --store DIR [--max-age-days D] [--max-bytes B]

Each call is answered from its arguments and standard input alone and writes its reply to standard output; python -m pulserver.host takes the same arguments. --plugins is a directory of scanner-sequence plugin files, <plugin>.py, and may be repeated: a plugin is the file of the first directory that holds it, and the shipped plugins are searched last (Shipped sequences). --store is the design store, created when missing, and --scan the name of the scan the design is stored for: one directory name, not starting with ..

Call

Reply

list

PROTOCOL and the plugin’s listing block at the options of the value block in --values (Options); with --rf-definitions, the [RfDefinitions] block

validate

VALID <seconds> or INVALID, an INFO line and the value block of the resolved protocol; with --rf-layout, a valid reply continues with the [RfLayout] block; a valid reply whose evaluation states display figures ends with the [Display] block

generate

GENERATED <id>, the identifier of the design in the scan’s directory

import

IMPORTED <id>

push

PUSHED <count>: the designs sent, not counting those the intake already holds

prune

PRUNED <count>: the scans removed

A failed call replies ERROR <message> and exits with status 1; a plugin that ends its process ends the call without a reply and with a nonzero exit status. The listing and value blocks are those of pulserver.protocol, described in Protocol resolution.

The RF blocks are sent only when asked for, and only where the plugin’s evaluation states an RF layout (RF layout). --rf-definitions evaluates the plugin at its default protocol, with every explicit saturation band it offers placed, under --limits, which it then requires. --rf-layout follows a valid reply with the RF layout of the evaluated request, its amplitudes relative to the peaks the listing states. Without --rf-definitions, list depends on the plugin file, its options and the installed packages only, so its reply can be written once at installation and read without a call.

--exam names the directory of the current exam’s cache, which is passed to the plugin hooks that take exam (Exam cache); for such a plugin the files of that directory are part of the design’s identity.

generate designs a request once, in the logical frame, checks it in the physical frame of the prescription rotation, converts it to the IR cache at the prescribed field-of-view offset and stores it. A request that resolves to a stored design returns that design’s identifier without designing again.

Import block#

import stores a Pulseq file written by any sequence development tool with a Pulseq writer. The block names the first file of a NextSequence chain and, optionally, its prescription and its number of averages:

[Import]
file: /data/sequence.seq
fov_offset_x: 0.0
fov_offset_y: 20.0
fov_offset_z: 0.0
nex: 2
[Import End]

The offset is in mm along the logical readout, phase and slice axes, zero along an axis left out, and the rotation is given by the fov_rotation_ij lines of Protocol resolution. nex, a whole number from 1, plays the main sequence, the last file of the chain, that many times, numbering the averages in the AVG counter: blocks under the label ONCE 1 play before the first average only, under ONCE 2 after the last only (pypulseqpp.Sequence.expand_repeats()). A file that already writes AVG is refused with nex above 1, as is one with no block played every time. The chain is copied, then checked and converted as generate checks and converts a design.

Scanner limits#

--limits names a file holding a [Limits] block, one name: value per line, here system.txt:

[Limits]
max_grad: 40.0
grad_unit: mT/m
max_slew: 150.0
slew_unit: T/m/s
B0: 3.0
design_max_grad: 23.094
design_max_slew: 86.603
[Limits End]

The lines without a prefix are keyword arguments of pypulseqpp.Opts, of which B0, the field in T, is required: ppm offsets are resolved at it. The limits, less a design margin, are the system the plugin designs under, and the checks hold the design to them as sent, so include the scanner’s RF and ADC dead times, RF ringdown time and ADC sample divisor; pypulseqpp.Opts sets the dead times to zero and the divisor to four when they are left out.

max_b1 is the peak B1 the transmit chain allows, in µT, or in the b1_unit given beside it, as the scanner states it; left out, the pulses are not limited. The selective and non-selective excitation and refocusing modules of pypulseqpp keep their own duration while the pulse peaks within pypulseqpp.MAX_B1_DERATE of it, and are otherwise lengthened, flip angle and time-bandwidth product held, until it does; the shortest TE and TR a plugin reports follow. Spectral, adiabatic, two-dimensional and multiband pulses are designed as given.

max_grad and max_slew are the limits of the gradient coils, to which the checks hold every physical axis. Logical axes played together add on one physical axis, so under an oblique prescription a design held to max_grad and max_slew per logical axis can exceed them on a physical one and is refused. Two design limits cap what each logical axis is designed under, the scanner’s limits for the prescription’s rotation:

Limit

Meaning

design_max_grad

Gradient amplitude each logical axis is designed under, in the grad_unit of max_grad: the coil’s per-axis limit, scaled by the share the prescription’s rotation leaves each logical axis with all three active

design_max_slew

Slew rate each logical axis is designed under, in the slew_unit of max_slew, the coil’s per-axis slew rate scaled by the same share

design_max_grad_any_rotation, design_max_slew_any_rotation

The same for a design that must hold under any rotation, one whose scan follows motion-correction poses: limits derated by the scanner so that no rotation puts more than the per-axis limit on a physical axis

pmc_enable

1 when the scan follows the poses its reconstruction publishes, 0 otherwise

design_rf_dead_time

Least delay of an RF pulse in its block, in s

design_rf_ringdown_time

Least time from the end of an RF pulse to the end of its block, in s

design_adc_dead_time

Least delay of a readout in its block, and least time after it, in s

A sequence that sets EnablePmc, as the navigator option of fse3d and mprage3d does, is turned during the scan by the poses its reconstruction publishes when pmc_enable is 1: rotations neither its design nor the check saw. Such a design is made under the _any_rotation limits, and the check also holds its gradient amplitude and slew rate summed over the three axes to max_grad and max_slew, since a rotation can put the whole vector on one physical axis. A sequence without EnablePmc, or a scan with pmc_enable 0, is designed under design_max_grad and design_max_slew. The manifest’s design_rotation records which, any or prescribed.

A design at these limits can stimulate peripheral nerves past pns_limit, or, for a scan following poses, sum to a slew rate past max_slew over the axes. generate then designs it again at a lower slew rate, modelled on the response it measured, at most three times, lowering it further where the plugin cannot lay the design out at that rate, and checks every problem again on each new design; validate does the same on the representative sequence a plugin’s evaluation states (Protocol evaluation), so the console shows what generate designs. It models each step on the readings it has: the first on one reading, with the nerve response the plugin’s last search found or else that of one ramp under the nerve model, so a request past a limit is mostly evaluated twice. It holds a reading to 97 % of its limit: the representative sequence bounds the nerve response of the scan, but on an oblique prescription the scan can read up to about 11 % more slew rate on a physical axis, which the check of the generated design then finds, and generate lowers the slew rate again. A request still past 97 % of a limit after the last pass is refused. The slew rate a request ends at is remembered: generate starts there, the same request validated again is evaluated there once, and the plugin’s next request under the same limits is tried first where the readings of this one reach their target, kept where its own readings are within their limits and near them, and raised or lowered once, as modelled, where they are not. A request no validate searched is searched by generate the same way before it designs the scan. A design past a gradient amplitude limit is refused, since no slew rate brings it down. Each file of a design records the slew rate it was designed under, per logical axis, in its DesignMaxSlew definition, and the manifest records it as design_max_slew_t_per_m_per_s, with the passes as slew_passes. A strict plugin (strict_limits), whose files set StrictLimits, or a design whose sequence sets StrictLimits itself, is refused as designed; the manifest’s strict_limits records which. An imported chain is never designed again.

A design limit above the scanner’s leaves the scanner’s, and one left out is the scanner’s; a design dead time below the scanner’s leaves the scanner’s. The design dead times are the room a playout needs around an RF pulse or a readout in some layouts and not in others, such as a readout that starts right after its excitation: designs make it everywhere, and the checks, which hold a file to the scanner’s own dead times, do not ask it of an imported chain. The plugin designs under these limits derated once by pypulseqpp.apply_system_derates: the gradient amplitude, slew rate and peak B1 scaled by pypulseqpp.MAX_GRAD_DERATE, MAX_SLEW_DERATE and MAX_B1_DERATE. The checks, the design’s identity and its manifest keep the limits as the scanner sent them. validate resolves a request under the same limits as generate. An imported chain is not designed, and is checked against max_grad and max_slew alone.

Options prefixed ir_ configure the IR conversion:

Option

Meaning

ir_vendor

PULSEG_VENDOR_* code the cache is tagged with; 0 is vendor-neutral

ir_label_column_map

Three Pulseq label state indices, separated by spaces, filling the ADC label columns

ir_cache_ext

Extension of the cache file, .pseg by default

ir_vendor_file

Vendor file the cache is grouped and stored under, read by read_vendor(); a file it cannot read refuses the call

ir_wave_max_samples

Samples of waveform memory per gradient axis of the playout

ir_wave_raster_us

Gradient raster of the playout, in µs per sample

ir_wave_load_us_per_sample

Time the playout takes to load one sample on one axis, in µs; 0, the default, leaves loading unchecked

ir_wave_headroom

Fraction of the playout time that loading may take, 0.5 by default

ir_wave_slots

Slots per segment position that a streaming playout cycles through, 2 by default

The ir_wave_ options describe the playout’s waveform memory, for which the cache lays out the waveforms (WaveBudget); ir_wave_max_samples and ir_wave_raster_us are given together. Without them every waveform is held at once on the gradient raster of the chain’s first file, and a playout that holds them otherwise refuses the cache.

The remaining options are the limits of the checks besides the gradient limits and rasters (Safety checks). A scanner always sends its nerve model and forbidden bands, the acoustic transfer function of its gradient coil where it has one, and the VOPs for pTx. A check whose limits are left out is not run. For pTx, each subsequence’s SAR at the VOPs relative to a reference pulse is written into the cache; the vendor’s routines compute SAR and RF and gradient heating from it.

Limit

Meaning

pns_chronaxie, pns_rheobase, pns_alpha

Chronaxie nerve model: chronaxie in s, rheobase in T/m/s, alpha 1 when left out. The rheobase and the alpha are one value or three separated by spaces, one per physical axis

pns_<axis>_<field>

SAFE nerve model, for the axes x, y and z and the fields a1 to a3, tau1 to tau3 in ms, stim_limit in T/m/s and g_scale

pns_limit

Largest PNS response allowed, as a fraction of the model’s threshold; 1 when left out

forbidden_band_<n>

One forbidden band: its physical axis (x, y, z or all), its lowest and highest frequency in Hz and, optionally, the readout gradient amplitude in mT/m above which it is locked, as an echo-spacing lockout table states it, separated by spaces. Without an amplitude, the band is held to 8 mT/m (RESONANCE_FLOOR)

vop_file

.mat or .npz file of VOPs and the head SAR matrix of each body model, at a path the design calls can read; its safety_factor multiplies local SAR and its global_safety_factor, 1 when absent, global SAR

vop_head_limit, vop_local_limit

The scanner’s head and local SAR limits in W/kg in its current operating mode

vop_drive_per_hz

Channel drive per Hz of RF amplitude, one value or one per channel separated by spaces; a scale common to every channel cancels. Equal drives when left out

vop_default_shim

Magnitude and phase in rad of each channel’s weight for a pulse played without an RF shim, separated by spaces; equal weights whose squares sum to 1 when left out

vop_coil

Transmit configuration the scanner reports; the VOP file’s transmit metadata must name the same one

acoustic_file

HDF5 file of the gradient coil’s acoustic transfer function, at a path the design calls can read; the peak and A-weighted average sound pressure levels are held to the limits of IEC 60601-2-33 and written into the cache

acoustic_interval_us

Sampling interval in µs that the bins of acoustic_file refer to; given with it

segment_gap_us, segment_tail_us, segment_min_wait_us, segment_raster_us

How the scanner’s sequencer plays segments (SequencerTiming), in µs: the time it takes after every segment, how far an active segment plays past its blocks, the shortest wait a pure delay plays, and the raster a wait is played on. segment_gap_us is given with any of them

segment_quiet_margin_us, segment_rf_tail_us, segment_adc_tail_us

Whether and how the sequencer ends an active segment early, inside the silence it ends on, in µs: the silence it keeps, negative or left out for a sequencer that does not; and how long the playout stays busy after an RF pulse and after a readout, which counts as part of them. Given 0 or more, a single wait a segment ends on, shorter than the gap plus the least wait, stays in that segment as its quiet tail

With the sequencer’s timing, a design’s manifest records the time the scan plays, played_time_s, beside the time its blocks take, blocks_time_s (played_time()). A pure delay gives the time between segments back, so a scan whose repetitions end in a wait of more than about a millisecond plays the time its file states; one whose segments follow each other without a delay plays longer by that time per segment. A sequencer that ends a segment early takes that time out of the silence the segment ends on: leave at least the gap and tail plus the margins of silence after a segment’s last gradient, RF pulse or readout, and the segment plays the time its file states, to the raster. A validation states the TR the scanner plays where each repetition is a segment that does not end on enough silence.

A call refuses limits it cannot read. A design is identified by the contents of the VOP, vendor and acoustic files as well as by their paths.

In-process calls#

call() answers a design call in the calling process, which exercises a plugin without a scanner:

from pulserver.host import DesignStore, call

limits = {"max_grad": 40.0, "grad_unit": "mT/m", "max_slew": 150.0,
          "slew_unit": "T/m/s", "B0": 3.0}
block = "[Protocol]\nTE: 5000\nnx: 96\n[Protocol End]\n"
status, reply = call("validate", plugins="sequences", plugin="gre2d",
                     limits=limits, block=block)
status, reply = call("generate", plugins="sequences", plugin="gre2d",
                     limits=limits, block=block,
                     store=DesignStore("designs", "scan"))

A plugin file is imported again when its modification time changes or it holds another plugin, whatever modification time it shows.

Design store#

The store holds one directory per scan, <store>/<scan>/, and a scan’s directory holds its design, <store>/<scan>/<id>/, laid out as Architecture shows. A design is reused while its scan holds it: a call that resolves to the same design replies with it, and one that resolves to another stores the new design in place of the scan’s previous one. prune removes whole scans, least recently used first: those unused for longer than --max-age-days, then others until the store holds at most --max-bytes. A scan used within the last day is kept whatever the limits, since it may still be playing or reconstructing. A store that receives pushed designs is pruned the same way, on the reconstruction computer.

Design push#

With --push, or the PULSERVER_DESIGN_PUSH environment variable, naming the URL of a proxy’s design intake, http://<host>:<intake-port>, generate and import send their design to that intake before replying; push sends the stored designs it names to the intake --to names. A design travels as a bundle, a gzip-compressed tar of the files of its directory, and the intake stores it only when every file has the SHA-256 its manifest records. A design the intake already holds is not sent again.

A generate or import whose design cannot be pushed replies ERROR design <id> is stored but not pushed: <reason> and exits with status 1, so the interpreter receives no identifier of a design the intake lacks. The design stays stored, and the same call made again pushes it without designing again. push replies ERROR design <id> is not pushed: <reason> for the first design it cannot send.

Warm design server#

pulserver design serve --plugins DIR --socket PATH

A call answered in its own process spends most of its time importing the design engine. A warm server imports it once, designs, checks and converts one sequence of its own, imports blochsim and PyTorch without designing a refocusing train with them, since a forked child cannot differentiate after its parent has, and imports every plugin of its --plugins directories. It answers each call forwarded to its socket in a child process forked from it, so a plugin that ends its process fails only its own call, with ERROR the design call ended with exit status N. Calls run concurrently, one child each.

A child ends with its call, and what it worked out in memory with it. The server therefore keeps, in a directory it makes under the system’s temporary directory when it starts serving and removes when it stops, what the calls after it would work out again:

  • the reply of each list and validate call, replied again to the same call while the plugin file, what it holds and the files the limits name are unchanged. A validate reply is also dropped when a generate lowers the slew rate of its request further, and, for a plugin whose hooks take exam, when the files of the exam’s cache change;

  • the RF definitions a plugin lists under given limits, which validate states its [RfLayout] amplitudes over, so the plugin’s default protocol is evaluated once and not on every call;

  • the slew rate each request was lowered to, so the generate of a request starts where its validate ended, and the one the plugin’s last request ended at, where its next request is evaluated first;

  • the effective TE of each Busse or PD echo train fse3d and fse_pd3d evaluated, or why no train realizes it, so the inverse solve that finds it runs once per train and limits;

  • the SLR pulses pypulseqpp designs, which it caches only in the process that designed them: a selective spin echo, a saturation band or a fat saturation is designed by the first call that plays it and read by the calls after it.

The replies, the listed RF and the slew rates kept for a plugin are kept under what its file holds as well as its path, the replies and listed RF also under its modification time: another plugin staged at the same slot, or a slot linked to another plugin file, starts from none of these, even where the installer gave both files the same modification time, and a file replaced by an identical copy keeps its slew rate. The solved trains and pulses are keyed on their own arguments and shared by every plugin that asks for them.

Nothing kept outlives the server, which is restarted to take up a changed package in any case. A call answered in its own process keeps nothing.

list, validate, generate and import are forwarded when --socket, or the PULSERVER_DESIGN_SOCKET environment variable, names the socket of a running server, and are answered in their own process otherwise; the reply is the same either way. Forwarding a call imports neither NumPy nor pypulseqpp. The server stops on SIGINT or SIGTERM and ends the calls it is running. The socket is neither authenticated nor encrypted: its file permissions decide who may call.

The server logs one line per call to standard error, naming the call, its plugin, its exit status, its duration and the processor time it took. A request sent to the socket whose JSON carries log, a file path, has its child append everything else it logs and prints to that file, so an interpreter can keep the design calls of one scan beside the rest of that scan’s log.

Reconstruction proxy#

pulserver proxy --store DIR --port N --plugins DIR [--host ADDR] [--intake-port N] [--queue DIR] [--exams DIR] [--slots N] [--gpu-slots 1] [--spares 1] [--recon-timeout S] [--dicom] [--dicom-receiver HOST:PORT --dicom-receiver-title AE [--dicom-title AE] [--viewer-port N]] [--save-data DIR] [--idle-timeout S] [--logfile FILE] [--log-level LEVEL]
pulserver proxy --store DIR --port N --forward HOST:PORT [--forward-config NAME] [--host ADDR] [--intake-port N] [--recon-timeout S] [--dicom] [--dicom-receiver HOST:PORT --dicom-receiver-title AE [--dicom-title AE] [--viewer-port N]] [--save-data DIR] [--idle-timeout S] [--logfile FILE] [--log-level LEVEL]

Option

Meaning

--store

The design store the proxy reads: the one the design calls write, or the one the intake writes. It also holds each scan’s pose file, <store>/<scan>/motion.buf, for a scan corrected for motion, and beside it the poses published, motion.csv (pitch, roll and yaw about x, y and z in degrees, translation in mm) and their plot motion.png

--port

TCP port the scanner’s reconstruction client connects to

--host

Address to listen on; the loopback interface when unset, 0.0.0.0 for every interface

--intake-port

TCP port of the design intake, on the --host address; no intake when unset

--plugins

Directory of reconstruction plugin files, <plugin>.py, repeatable, searched in order before the shipped ones; required unless --forward is given

--queue

Directory the series waiting for a slot are written to; a temporary directory, removed when the proxy stops, when unset

--exams

Directory in which the proxies of this host share the caches of an exam, one directory per exam named by its identity: exam-<ExamID> for a header carrying ExamID. Created readable by the proxy’s user alone; one that exists is used with the permissions the site gave it, so design calls running as another user can read the exam’s maps. A location under the system temporary directory, private to the proxy’s user, when unset

--slots

Series reconstructed at once; derived from available memory and the GPUs when unset

--gpu-slots

Series reconstructed at once on each GPU when --slots is unset; 1 by default

--spares

Worker processes started ahead of a series; 1 by default

--recon-timeout

Seconds a reconstruction may run after its series ends; the worker is then terminated, or the connection to the server closed, and the client told. Unlimited when unset

--forward

HOST:PORT of the MRD server that reconstructs every series, instead of local workers

--forward-config

Config name sent to the --forward server; the series’ reconstruction plugin when unset

--dicom

Convert each image to DICOM before it is relayed, whatever reconstructed it; for a client that reads DICOM only

--dicom-receiver

HOST:PORT of a DICOM storage service the images of a series whose client has gone are stored to by C-STORE; held for the client’s return when unset. Needs pynetdicom (pulserver[dicom])

--dicom-receiver-title

Application entity title of the --dicom-receiver; required with it

--viewer-port

Port on the --dicom-receiver’s host of a viewer each stored image is also sent to, as an AVR1 message (four bytes AVR1, three -1 and the file’s length as big-endian 32-bit integers, then the DICOM file), so a series whose client has gone is still shown; none when unset

--dicom-title

Application entity title the proxy calls the --dicom-receiver as; PULSERVER when unset

--save-data

Directory each series is kept in, enriched; kept nowhere when unset

--idle-timeout

Seconds without a client after which the proxy closes, never while a series is reconstructed. Unlimited when unset

--logfile

File the log is appended to, together with the standard output and error of the proxy and its workers, so whatever a reconstruction plugin logs, prints or warns lands there too; standard error when unset

--log-level

DEBUG, INFO, WARNING or ERROR; INFO when unset

The proxy and its workers are described in Reconstruction session, and the messages and header fields the client sends in Reconstruction client.

Series routing#

The MRD header of each series names the scan in the pulserver_scan user parameter and the design it was played from in pulserver_design, and the proxy refuses a series whose header names no design stored for that scan. The client’s config names the reconstruction plugin, as a bare plugin name or the path of its file, or as either under parameters.config; the design names none. A series whose config names none is refused unless the proxy forwards with --forward-config.

A series that finds every slot busy, or the host’s available memory short of one reconstruction’s budget while another series runs, is written to the queue directory as it arrives and reconstructed once a slot and the memory are free; the client stays connected meanwhile. What goes back to a client whose connection has dropped is kept for a day: a client that opens a series with the same measurementID is sent it in place of a new reconstruction. With --dicom-receiver, the series’ DICOM images are stored to the receiver instead once its reconstruction ends, all of them, since which ones the client read before it went cannot be told; the output is kept only if the receiver did not store every one. A scanner client whose process may be ended before a slow reconstruction finishes names its image database here.

Saved series#

With --save-data, each series is also written to <save-data>/mrd_<timestamp>.h5 as the proxy reconstructs it: header and acquisitions enriched, the header marked pulserver_enriched, each acquisition as it arrives. Until the stream ends the file is mrd_<timestamp>.h5.part, so whatever collects the directory can tell a series still arriving. pulserver replay runs a plugin on that file as it stands and gives the image the proxy did (Series replay). The queue directory holds a series only until it is reconstructed.

Proxy lifetime#

A proxy started for one scan outlives whatever started it, so --idle-timeout ends it: it closes once no client has been connected for that long, counted from the last client leaving, and never while a series is being reconstructed. Without it, the proxy serves until it receives SIGINT or SIGTERM, and then waits for the series it is running before it exits.

Exam directory#

A reconstruction computer may run one proxy per acquisition, so the series of one exam are reconstructed by different processes. What a calibration series measures is kept under --exams, in a directory of the exam’s own, and read there by a later series whichever proxy takes it: a hook assigns context.b0_map, context.b1_map or context.coil_sensitivities and a later hook reads them (ReconContext). An exam’s directory is removed once the last proxy on that exam has moved to another, so a proxy on the next exam does not remove the data of one still reconstructing the last.

Forwarding#

With --forward, the proxy runs no workers: each series is enriched as it arrives and sent on to the MRD server at HOST:PORT, whose own slots and queue determine when it is reconstructed. The server receives a config file message naming the series’ reconstruction plugin, which a reconstruction server runs, or the --forward-config name, such as the configuration by which a Gadgetron or FIRE server selects its pipeline. The client’s config text is not forwarded. What the server returns is relayed to the client once the client’s stream has ended whole, as from a worker; a message type the proxy cannot read ends the relay, and the client receives a pulserver: text naming the type.

Sequence description#

Whether forwarded or reconstructed by a worker, the series carries, after its header and before its first acquisition, ISMRMRD waveforms describing the sequence chain for a signal simulation, so that every MRD writer keeps them with the series: per file of the chain a header (waveform_id 1024) and an event list (1025), and one waveform per RF definition (1026), in the word layout waveforms() documents. The event list holds one row per block of one repetition, RF at the pulse centre and ADC at the sample nearest the k-space centre. The repetition is the one whose readout passes nearest the k-space centre, navigators aside, as pypulseqpp.Sequence.repetition divides the file; a file that does not repeat is described whole. An RF definition states the bandwidth its slice is selected over, which with the event’s slice-select gradient gives the thickness. The description is meant for a reconstruction that simulates the signal, which chooses the signal model the rows drive, and is not relayed back to the client.

Design intake#

With --intake-port, the proxy runs a design intake beside it (DesignIntake), an HTTP endpoint that writes the designs pushed to it into --store. HEAD /designs/<scan>/<id> answers 200 when the scan holds the design and 404 otherwise; PUT /designs/<scan>/<id> stores a bundle as the scan’s design and answers 201, 200 for a design already stored, or 400 with the reason for a bundle that is not the design its path names. A HEAD for a stored design marks its scan as used for prune.

Network exposure#

The MRD stream is neither authenticated nor encrypted, and its header carries patient data. The design intake is neither authenticated nor encrypted either, and writes the designs it accepts into the store the proxy reconstructs from. Run both on the network between the scanner and the reconstruction computer, with --host naming the address of the interface on it; a scanner’s reconstruction client cannot reach the loopback default.

Reconstruction server#

pulserver recon --plugins DIR --port N [--host ADDR] [--queue DIR] [--slots N] [--gpu-slots 1] [--spares 1] [--recon-timeout S] [--save-data DIR] [--idle-timeout S] [--logfile FILE] [--log-level LEVEL]

The reconstruction server receives the series a forwarding proxy sends, on the computer that reconstructs them. It reconstructs each series with the plugin its config names, as a config file message or as a config text naming it as a bare name or under parameters.config, and enriches nothing: a forwarded series arrives enriched. Its options are those of the proxy, with the same workers, slots, queue and exam directories; --save-data keeps each series as the proxy forwarded it, enriched. Its stream is neither authenticated nor encrypted, and --host names the interface the proxy reaches it on. It stops on SIGINT or SIGTERM and waits for the series it is running.

Series replay#

pulserver replay SERIES --plugin FILE (--store DIR | --design SEQ) [--config TEXT] [--dicom] [--dicom-dictionary FILE] [--output DIR]

pulserver replay reconstructs one series kept by --save-data in the calling process, with no proxy running. The series is enriched from the design it was played from, at the field-of-view offset its header states, as the proxy enriches it, and runs through the plugin’s hooks (Offline reconstruction). The design is the one the header names in the store --store, or the one whose sequence file, the first of its chain, is --design. That file must be one the manifest beside it records, and the manifest must name the design the header names. A series exported beside a copy of its design’s files replays with no store. Images go to images.h5 in --output, and DICOM datasets to the files they are named by; with --dicom every image is written as DICOM, as the proxy’s --dicom writes it, and --dicom-dictionary names the private dictionary of the header’s DICOM attributes (DICOM attributes). An exception raised by the plugin is not caught, so its traceback names the line that raised it.

Playout validation#

pulserver validate SEQ [--vendor ge] [--played FILE] [--dead-time-us N] [--rf-wait-us N] [--tolerance MT] [--rf-tolerance PCT] [--limits FILE] [--cache-ext EXT]

Option

Meaning

SEQ

The sequence file to check

--vendor

The machine the recording came from. Without one, the check is against the sequence’s own IR cache

--played

The recording to check against; without one, and with a vendor named, the recording is requested from that vendor’s tooling if it is installed

--dead-time-us

Time by which the recording runs ahead of the sequence on every channel, in µs; 0 by default

--rf-wait-us

Time by which the transmit channels run further ahead, in µs; 0 by default

--tolerance

Largest gradient difference that counts as agreement, in mT/m; derived from the slew rate and raster of --limits when unset

--rf-tolerance

Largest transmit difference, as a percentage of the peak; 1 by default

--limits

The [Limits] block, for a sequence that has no cache yet

--cache-ext

Extension of the cache, dot included; .pseg by default

The command exits 0 where the two agree, 1 where they differ, and 2 where it could not compare, and prints the largest difference on each gradient axis against the peak that axis reaches.

Naming a vendor compares against a recording of a machine playing the sequence, which establishes that the machine plays what was written. Naming none compares against the waveforms the sequence’s own IR cache holds, which establishes only that the conversion preserved the sequence: a conversion and a playout that are wrong in the same way agree. The output states which comparison ran.

The gradients are compared in mT/m. The transmit channels are compared as the recording stores them: the phase over a converter that spans one cycle, and the magnitude by its shape, because converting a recorded count into Hz needs the peak B1 of the scan being played, which the recording does not carry. The fitted scale of the shape is printed; it is the number a machine’s own calibration would have to supply.

A machine starts a unit before it plays any of it, and drives its transmit and gradient channels on separate timelines, so a recording runs ahead of the sequence by one constant on every channel and by a second one on the transmit channels. State them with --dead-time-us and --rf-wait-us; they are not estimated, since an alignment fitted to the two waveforms could remove the disagreement the comparison is meant to find. The default gradient tolerance is what the gradients can slew through in the few raster steps by which the two renderings may differ.

The check leaves nothing beside the sequence: where no cache exists, one is built beside a copy and discarded.

See also#