compose_spinor#

torchsim.compose_spinor(drive, turn_z)[source]#

The Cayley-Klein pair a shaped pulse leaves, sample by sample.

One SU(2) element per raster sample, composed in the order the scanner plays them. Each is the rotation about the effective field a spin sees while that sample lasts: the RF in the transverse plane, the gradient along z.

Parameters:
  • drive – The transverse field per sample, radians turned per sample. A tensor with the sample axis first, or any iterable of per-sample tensors – which is how a per-voxel field is composed without ever holding one for every sample at once.

  • turn_z – The longitudinal turn per sample, radians, one per spin. A tensor is the turn every sample makes – a gradient the scanner holds – and an iterable of per-sample tensors is one it moves, in the same form drive takes.

Returns:

a, b – Complex128, shaped like the turn. Each sample turns the magnetisation right-handedly about (drive.real, drive.imag, turn_z) by that vector’s length, so a spin starting along +z ends with Mxy = -2 conj(a b) and Mz = |a|^2 - |b|^2. A real drive of area t on resonance gives (cos(t/2), -i sin(t/2)).

Return type:

torch.Tensor

Raises:

ValueError – If a moving gradient runs out before the pulse does, or the other way about.

Examples using torchsim.compose_spinor#

Designing an RF pulse by optimal control

Designing an RF pulse by optimal control