Skip to content

Gradients

Gradient blocks represent three-channel gradient waveforms. The API reference documents the exact constructors; this page collects the longer conceptual examples.

Addition

Gradient instances can be added with +. Breakpoints are combined and the waveform is linearly interpolated per channel between breakpoints.

from pint import Quantity
import numpy as np

import cmrseq

trap1 = cmrseq.bausteine.TrapezoidalGradient.from_dur_amp(
    system_specs,
    orientation=np.array([1.0, 0.0, 0.0]),
    duration=Quantity(1, "ms"),
    amplitude=Quantity(10, "mT/m"),
    name="trap_1",
)

trap2 = cmrseq.bausteine.TrapezoidalGradient.from_dur_amp(
    system_specs,
    orientation=np.array([1.0, 0.0, 0.0]),
    duration=Quantity(1, "ms"),
    amplitude=Quantity(10, "mT/m"),
    delay=Quantity(0.2, "ms"),
    name="trap_2",
)

combined_t, combined_wf = trap1 + trap2
combined_gradient = cmrseq.bausteine.ArbitraryGradient(
    system_specs, combined_t, combined_wf, name="combined_trap"
)
seq = cmrseq.Sequence([combined_gradient], system_specs)

Trapezoidal Shape

.                     |-flat_dur-|                                      .
.                     ____________                                      .
.          |-delay-| /            \           |      amplitude          .
.          _________/              \______    |                         .
.                  |--|         |--|                                    .
.                rise_time    fall_time                                 .
.          |--------duration-------|                                    .

Validation

Gradient validation checks maximum gradient strength, maximum slew rate, and adherence to the gradient raster time. snap_to_raster can round temporal definitions to the closest raster point, but that may change moments and should be used deliberately.

Future cleanup

These examples are retained from the old documentation. They should become tested examples before the public re-release.