rotate_3d

Contents

rotate_3d#

pypulseqpp.rotate_3d()[source]#

Rotate and sum gradient projections onto the output axes.

Non-gradient events are returned unchanged, before the rotated gradients.

Parameters:
  • rotation (array_like) – A 3x3 matrix, a scalar-first quaternion [w, x, y, z], one angle about z, or two angles read as Rz(phi) Ry(theta).

  • *args (SimpleNamespace or list) – Block events, or one block. At most one gradient per axis.

  • system (Opts, default=None) – System limits, used when two projections are summed.

Returns:

The events that were not gradients, then the rotated gradients.

Return type:

list

Raises:

ValueError – On a rotation that is none of the accepted forms, on a gradient outside x, y and z, or on two gradients on one axis.

Examples

>>> import numpy as np
>>> import pypulseqpp as pp
>>> gx = pp.make_trapezoid("x", area=1000, duration=2e-3)

A quarter turn about z moves a readout from x to y with its area unchanged:

>>> about_z = np.array([[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]])
>>> (rotated,) = pp.rotate_3d(about_z, gx)
>>> rotated.channel, round(float(rotated.area))
('y', 1000)

The same turn, named as a quaternion and as an angle:

>>> quarter = np.pi / 2
>>> quaternion = [np.cos(quarter / 2), 0.0, 0.0, np.sin(quarter / 2)]
>>> pp.rotate_3d(quaternion, gx)[0].channel
'y'
>>> pp.rotate_3d([quarter], gx)[0].channel
'y'

Anything that is not a gradient comes back untouched, and first:

>>> adc = pp.make_adc(num_samples=64, duration=1e-3)
>>> [event.type for event in pp.rotate_3d(about_z, gx, adc)]
['adc', 'trap']