SequenceModule#

class pypulseqpp.sequences.SequenceModule[source]#

Bases: ABC

A reusable block layout with named, mutable event templates.

Subclasses assign self.seq and add blocks in init_module. Events are published from the constructor’s locals onto events and onto the module itself. Repeated references are deduplicated by identity: one distinct object becomes a scalar event, several become a list in first-seen order. register() preserves the supplied structure, including one-element lists.

Parameters:
Attributes:
  • events (types.SimpleNamespace) – Published events. Use this namespace when a name conflicts with a module attribute; publication warns about conflicts.

  • center (float) – Timing reference (s) from the module start, set by the subclass: typically an RF centre or an echo.

Notes

blocks retains the original event objects for replay. Mutating those objects does not rewrite the stored sequence used for analysis. Of the sequence’s methods, only calculate_kspace, check_timing, paper_plot, test_report and waveforms_and_times are forwarded to seq.

Examples

A subclass assigns seq and adds its blocks; the constructor’s locals are published under their own names and on events:

>>> import pypulseqpp as pp
>>> import pypulseqpp.sequences as design
>>> class OneTrapezoid(design.SequenceModule):
...     def init_module(self, system):
...         self.seq = pp.Sequence(system=system)
...         gx = pp.make_trapezoid("x", area=500, system=system)
...         self.seq.add_block(gx)
...         self.center = 0.5 * pp.calc_duration(gx)
>>> module = OneTrapezoid(pp.Opts())
>>> module.gx.channel, len(module.blocks)
('x', 1)
>>> module.gx is module.events.gx
True

Methods

init_module

Build the module's block layout; implemented by the subclass.

publish

Publish events from the caller's locals and register keyword aliases.

register

Publish named events, whether or not they were added to a block.

Attributes

blocks

Block tuples in play order, holding the original event objects.

duration

Duration of the module (s).

seq

Sequence holding the module's construction-time block layout.

Examples using SequenceModule#

9. Sequence modules

9. Sequence modules

10. Custom sequence module

10. Custom sequence module

Slice-selective excitation

Slice-selective excitation

Spiral readout

Spiral readout

Ramp-sampled readout

Ramp-sampled readout

Twisting radial readout

Twisting radial readout

Minimum-phase excitation

Minimum-phase excitation