ReconBuffer

Contents

ReconBuffer#

class pulserver.recon.ReconBuffer[source]#

Bases: object

K-space of one encoding space, filled one acquisition at a time.

Along the readout of a Cartesian space, the samples of an acquisition from discard_pre to number_of_samples - discard_post are placed so that its echo, center_sample, lies at sample samples // 2 of the buffer. Along an encoded axis of a Cartesian space, a counter is placed at counter - center + extent // 2, center being the counter of the k-space centre the header’s limits state, so the centre line lies at extent // 2 whatever the counters start at. A non-Cartesian space places a readout right-aligned and a counter as it is. The axes are those of space: its counters that vary and were asked for, then the encoded axes.

Parameters:
  • space – Encoding space to lay out.

  • coils – Channels to allocate; space.coils when not given. Fewer than the header declares is valid, for data compressed before placement.

  • samples – Samples to allocate along the readout; space.readout when not given.

  • crop – {axis: (first, stop)} for the phase_encode and partition axes: the positions of the space’s grid the buffer holds, the whole axis where an axis is not named.

  • dtype – Complex dtype of kspace.

Attributes:
  • kspace (ndarray) – Shaped as axes names.

  • mask (ndarray) – Boolean, kspace without the coil axis: samples that were placed.

  • origin (dict of str to int) – Position on the space’s grid of the first entry of each placement axis of axes; 0 along an axis that is not cropped.

  • readout (tuple of int or None) – First and last sample of the readout axis placed, inclusive; None until an acquisition is placed. The samples outside it are zero fill.

  • trajectory (ndarray or None) – (dimensions, ...) over the axes of mask, in the units the acquisitions carry. None until an acquisition carries a trajectory; widened to the most dimensions any acquisition carried, missing trailing dimensions reading 0.

  • center_sample (int or None) – Echo index along the readout axis. samples // 2 in a Cartesian space, where every echo is placed there; in a non-Cartesian space that of the first acquisition that states it, after alignment.

  • sample_time (float or None) – Dwell time in seconds, from the first acquisition that states it.

  • headers (list) – Placed acquisitions, in placement order.

Examples

>>> import pulserver.recon as recon
>>> import pulserver.mrd as mrd
>>> space = mrd.EncodingSpace(
...     index=0, coils=4, readout=64, phase_encodes=32, partitions=1,
...     loops=("slice",), loop_sizes=(2,), recon_matrix=(32, 32),
... )
>>> buffer = recon.ReconBuffer(space)
>>> buffer.kspace.shape
(4, 2, 32, 64)
>>> buffer.extents
{'coil': 4, 'slice': 2, 'phase_encode': 32, 'readout': 64}
>>> buffer.image_shape
(32, 32)

Methods

add

Place one acquisition where its counters and echo say it belongs.

grid_trajectory

Return the trajectory in grid units, laid out as bartorch.linop.NUFFT takes it.

points

Return the trajectory at one position, indexed as select() indexes.

position

Index along each placement axis of kspace this acquisition fills.

select

Return the (kspace, mask) at one position along named axes.

Attributes

axes

Name of every axis of kspace, in order.

extents

Extent of each axis of kspace, by name.

image_shape

Image matrix the header prescribes; see EncodingSpace.recon_matrix.

readout_time

Sample times relative to the echo, (readout,) in seconds.

reference

The placed acquisition nearest the k-space centre, None while none is placed.