block_to_events

block_to_events#

pypulseqpp.block_to_events()[source]#

Split a block into its events, or pass events through unchanged.

A block is a namespace with an rf field, and its events are its fields in the order they are stored – a field holding several, as a label chain does, contributing each of them. Anything else is already a list of events and comes back as a tuple of the same events, so a caller may hand over either without knowing which it has.

Parameters:

*args (SimpleNamespace or list) – One block, or the events themselves.

Returns:

The events.

Return type:

tuple

Raises:

ValueError – When more than one block is passed.

Examples

>>> import pypulseqpp as pp
>>> gx = pp.make_trapezoid("x", area=1000, duration=1e-3)
>>> adc = pp.make_adc(num_samples=128, duration=1e-3)
>>> len(pp.block_to_events([gx, adc]))
2