Skip to content

device_configuration

device_configuration

Implementation of the device configuration models.

TxConfiguration

Bases: BaseModel

Transmit card (AWG) configuration, section TxConfiguration of the device configuration file.

device_path class-attribute instance-attribute

device_path: str = Field(..., strict=True)

Device path of the transmit card, e.g. /dev/spcm1.

sampling_rate class-attribute instance-attribute

sampling_rate: int = Field(..., strict=True)

Sampling rate in MHz. The card runs on the clock of the receive card but sets its own sampling rate. Currently, it must equal the receive card sampling rate (see NexusConfiguration).

channel_max_amplitude class-attribute instance-attribute

channel_max_amplitude: tuple[TxAmplitudeType, TxAmplitudeType, TxAmplitudeType, TxAmplitudeType] = Field(...)

Output range per channel [RF, gradient 1, gradient 2, gradient 3] in mV (1 to 6000 mV, into 50 Ohm).

channel_filter_type class-attribute instance-attribute

channel_filter_type: tuple[FilterTypeInt, FilterTypeInt, FilterTypeInt, FilterTypeInt] = Field(...)

Output filter setting per channel (0 to 3, see card manual).

rf_terminated_50ohm class-attribute instance-attribute

rf_terminated_50ohm: bool = Field(..., strict=True)

True if the RF output is terminated into 50 Ohm, False for high impedance (output voltage doubles).

gradients_terminated_50ohm class-attribute instance-attribute

gradients_terminated_50ohm: bool = Field(..., strict=True)

True if the gradient outputs are terminated into 50 Ohm, False for high impedance (output voltage doubles).

gradient_efficiency class-attribute instance-attribute

gradient_efficiency: tuple[float, float, float] = Field(...)

Gradient coil efficiency in T/m/A per physical gradient channel.

gpa_gain class-attribute instance-attribute

gpa_gain: tuple[float, float, float] = Field(...)

Gradient power amplifier transconductance in A/V per physical gradient channel.

rf_to_mvolt class-attribute instance-attribute

rf_to_mvolt: float = Field(..., strict=True)

Conversion factor from PyPulseq RF amplitude (Hz) to output voltage (mV), i.e. mV per Hz.

rf_gain_lut_path class-attribute instance-attribute

rf_gain_lut_path: Path | None = Field(default=None)

Optional path to an RF power amplifier linearisation lookup table (.npy, 65536 int16 values).

RxConfiguration

Bases: BaseModel

Receive card (digitizer) configuration, section RxConfiguration of the device configuration file.

device_path class-attribute instance-attribute

device_path: str = Field(..., strict=True)

Device path of the receive card, e.g. /dev/spcm0.

sampling_rate class-attribute instance-attribute

sampling_rate: int = Field(..., strict=True)

Sampling rate in MHz. The receive card is the clock master and provides its clock to the transmit card, which sets its own sampling rate. Currently, it must equal the transmit card sampling rate (see NexusConfiguration).

max_available_channels class-attribute instance-attribute

max_available_channels: int = Field(..., strict=True)

Number of input channels of the card; length of all channel lists (8 for the M2p.5933-x4).

channel_enable class-attribute instance-attribute

channel_enable: tuple[bool, ...] = Field(...)

Enable flag per channel. The number of enabled channels must be 1, 2, 4 or 8.

channel_max_amplitude class-attribute instance-attribute

channel_max_amplitude: tuple[RxAmplitudeType, ...] = Field(...)

Input range per channel in mV (200, 500, 1000, 2000, 5000 or 10000).

channel_terminated_50ohm class-attribute instance-attribute

channel_terminated_50ohm: tuple[bool, ...] = Field(...)

Input termination per channel, True for 50 Ohm, False for high impedance.

num_processing_workers class-attribute instance-attribute

num_processing_workers: int = Field(default=1, ge=0, description='Number of worker processes for parallel RxData processing. Set to 0 to always process in the main process (no multiprocessing).')

Number of worker processes for parallel processing of the receive data. Set to 0 to process in the main process after the acquisition.

validate_channel_lengths

validate_channel_lengths() -> RxConfiguration

Validate channel lengths.

This ensures that max_available_channels is length of channel_enable, channel_max_amplitude and channel_terminated_50ohm.

Source code in src/console/interfaces/device_configuration.py
@model_validator(mode="after")
def validate_channel_lengths(self) -> "RxConfiguration":
    """Validate channel lengths.

    This ensures that `max_available_channels` is length of `channel_enable`,
    `channel_max_amplitude` and  `channel_terminated_50ohm`.
    """
    target_len = self.max_available_channels
    dependent_fields = [
        "channel_enable",
        "channel_max_amplitude",
        "channel_terminated_50ohm",
    ]
    errors = []
    for field_name in dependent_fields:
        current_val = getattr(self, field_name)
        if len(current_val) != target_len:
            errors.append(
                f"{field_name} length ({len(current_val)}) "
                f"must be exactly {target_len}"
            )
    if errors:
        # Raising ValueError here is the standard Pydantic way
        raise ValueError(" ; ".join(errors))
    return self

SystemLimits

Bases: BaseModel

MR system limits, section SystemLimits of the device configuration file.

Translated into a PyPulseq Opts object by get_opts. All values must be given as floats (e.g. 20.e-6, not 20e-6, which YAML parses as string).

max_grad class-attribute instance-attribute

max_grad: float = Field(..., strict=True, gt=0)

Maximum gradient amplitude in Hz/m.

max_slew class-attribute instance-attribute

max_slew: float = Field(..., strict=True, gt=0)

Maximum gradient slew rate in Hz/m/s.

rf_dead_time class-attribute instance-attribute

rf_dead_time: float = Field(..., strict=True, ge=0)

Dead time before an RF pulse in s; the RF unblanking signal is set this time before the pulse.

rf_ringdown_time class-attribute instance-attribute

rf_ringdown_time: float = Field(..., strict=True, ge=0)

Ring-down time after an RF pulse in s.

adc_dead_time class-attribute instance-attribute

adc_dead_time: float = Field(..., strict=True, ge=0)

Dead time around an ADC event in s; the ADC gate is extended by this time on both sides.

block_duration_raster class-attribute instance-attribute

block_duration_raster: float = Field(..., strict=True, gt=0)

Raster time of block durations in s.

rf_raster_time class-attribute instance-attribute

rf_raster_time: float = Field(..., strict=True, ge=0)

Raster time of RF waveforms in s.

grad_raster_time class-attribute instance-attribute

grad_raster_time: float = Field(..., strict=True, gt=0)

Raster time of gradient waveforms in s.

adc_raster_time class-attribute instance-attribute

adc_raster_time: float = Field(..., strict=True, gt=0)

Raster time of ADC dwell times in s.

B0 class-attribute instance-attribute

B0: float = Field(default=0.05, strict=True, gt=0)

Static magnetic field strength in T.

get_opts

get_opts() -> Opts

Return system limits of the MR scanner as PyPulseq Opts object.

Source code in src/console/interfaces/device_configuration.py
def get_opts(self) -> Opts:
    """Return system limits of the MR scanner as PyPulseq `Opts` object."""
    return Opts(
        max_grad=self.max_grad,
        max_slew=self.max_slew,
        grad_unit="Hz/m",
        slew_unit="Hz/m/s",
        rf_dead_time=self.rf_dead_time,
        rf_ringdown_time=self.rf_ringdown_time,
        adc_dead_time=self.adc_dead_time,
        block_duration_raster=self.block_duration_raster,
        rf_raster_time=self.rf_raster_time,
        grad_raster_time=self.grad_raster_time,
        adc_raster_time=self.adc_raster_time,
        B0=self.B0
    )

NexusConfiguration

Bases: BaseModel

Nexus console device configuration, as loaded from the device configuration YAML file.

tx class-attribute instance-attribute

tx: TxConfiguration = Field(..., alias='TxConfiguration')

Transmit card configuration (YAML section TxConfiguration).

rx class-attribute instance-attribute

rx: RxConfiguration = Field(..., alias='RxConfiguration')

Receive card configuration (YAML section RxConfiguration).

system class-attribute instance-attribute

system: SystemLimits = Field(..., alias='SystemLimits')

MR system limits (YAML section SystemLimits).

validate_sampling_rates

validate_sampling_rates() -> NexusConfiguration

Validate that the transmit and receive card use the same sampling rate.

Both cards share the clock of the receive card, but each card sets its own sampling rate, so the hardware supports different sampling rates. The sequence calculation and the processing of the receive data currently assume a common sampling rate. Support for different sampling rates will be added in a future update.

Source code in src/console/interfaces/device_configuration.py
@model_validator(mode="after")
def validate_sampling_rates(self) -> "NexusConfiguration":
    """Validate that the transmit and receive card use the same sampling rate.

    Both cards share the clock of the receive card, but each card sets its own sampling rate, so the
    hardware supports different sampling rates. The sequence calculation and the processing of the
    receive data currently assume a common sampling rate. Support for different sampling rates will be
    added in a future update.
    """
    if self.tx.sampling_rate != self.rx.sampling_rate:
        raise ValueError(
            f"Transmit card sampling rate ({self.tx.sampling_rate} MHz) must equal receive card "
            f"sampling rate ({self.rx.sampling_rate} MHz); different sampling rates are not supported yet"
        )
    return self