ReconContext

Contents

ReconContext#

class pulserver.recon.ReconContext[source]#

Bases: object

Scan context passed to every hook of a plugin.

The maps the series of an exam share are attributes of the context: a hook reads b0_map, b1_map and coil_sensitivities from it and assigns to them what it measures, and a later series of the exam reads what was assigned, whichever proxy reconstructs it. Each is None until some series of the exam has measured it.

Those three names are the whole vocabulary, so a misspelt one raises instead of being stored where nothing looks for it. A plugin carrying an artifact of its own puts it in exam under a key it chooses.

The calibration helpers keep the state of one stream on the context, empty when the stream starts and not shared with other series. coil_maps maps a slice counter to the CoilSensitivities the stream holds for it, noise is the prewhitening a Prewhiten applies and coil_compression the basis a CoilCompression applies; the last two are None until the stream has them. A hook may assign them.

The scan context itself does not change once built: assigning to header, exam, config or device raises.

Parameters:
  • header (Any) – Parsed MRD XML header; offline, None or any header-like object.

  • exam (pulserver.recon.plugin.ExamCache) – Artifact cache shared by the series of the exam, for artifacts the three names do not cover.

  • config (Any) – Configuration payload the client sent with the stream.

  • device (str | None) – The GPU the proxy gave this series, as a torch device such as "cuda:0"; None on the host, and offline.

Examples

>>> import pulserver.recon as recon
>>> context = recon.ReconContext.offline()
>>> context.b1_map is None
True
>>> context.b1_map = [1.0, 0.9]
>>> context.b1_map
[1.0, 0.9]
>>> context.exam[recon.B1_MAP]
[1.0, 0.9]
>>> context.b1_mpa = [1.0]
Traceback (most recent call last):
AttributeError: ReconContext has no attribute 'b1_mpa'

Methods

offline

Create a context with a new ExamCache.

Attributes