Gadget

Contents

Gadget#

class pulserver.recon.Gadget[source]#

Bases: ABC

One per-acquisition step of a plugin’s gadgets.

A gadget keeps what it learns from earlier acquisitions of its stream – a noise covariance, a coil basis – on self. ReconPlugin.spawn() copies the gadgets, so each stream has its own.

A gadget that changes the samples of a readout states where its echo lies in the readout it returns by assigning center_sample, discard_pre and discard_post of the acquisition it was given, as Gadgetron’s gadgets update the header they pass on. The next gadget and the buffers read them, and the length of the returned array is the readout’s number of samples. The plugin gives each gadget a copy of the received acquisition, so an assignment changes neither the acquisition the stream delivered nor what ReconData.acquisitions lists.

Attributes:

context (ReconContext) – Set by startup().

Examples

>>> import pulserver.mrd as mrd
>>> import pulserver.recon as recon
>>> class DropNavigators(recon.Gadget):
...     def __call__(self, acquisition, data):
...         if mrd.has_acquisition_flag(acquisition, "ACQ_IS_NAVIGATION_DATA"):
...             return None
...         return data
>>> isinstance(DropNavigators(), recon.Gadget)
True

Methods

startup

Prepare for one stream; the default stores context, so overrides call it.