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 constructor 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. Explicit register calls preserve the supplied structure, including one-element lists.

Parameters:
  • *args – Forwarded to init_module.

  • **kwargs – Forwarded to init_module.

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 in seconds 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. Only calculate_kspace, check_timing, 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 without requiring prior block registration.

Attributes

blocks

Return block tuples in play order, retaining the original event objects.

duration

Duration of the module in seconds.

seq

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

Examples using SequenceModule#

Spiral readout

Spiral readout

Excitation modules

Excitation modules

Readout modules

Readout modules

A sequence application

A sequence application

A minimum-phase excitation module

A minimum-phase excitation module

A ramp-sampled readout module

A ramp-sampled readout module

A twisting radial readout module

A twisting radial readout module