Skip to content

Remote acquisition

The acquisition can be run in a separate service process that connects to the cards once and remains active between experiments. Experiment scripts connect to this service as clients, either on the host computer or, with an appropriate address configuration, from another computer.

Service

Start the service on the host computer with the device configuration of the system:

nexus -d path/to/device_config.yaml

The service asks for confirmation that the amplifiers are switched off before the cards are opened (see Console hardware). The available options are documented in start_manager.main.

Client

The client connects with AcquisitionControlManager and accesses the remote AcquisitionControl instance as mngr.acquisition. Sequence and acquisition parameters are transferred to the service, and the AcquisitionData is returned to the client.

examples/acquisition_manager.py
"""Remote acquisition via the Nexus acquisition service.

Start the service first in a separate terminal, e.g. ``nexus -d example_device_config.yaml``.
"""
# %%
import matplotlib.pyplot as plt
import numpy as np

import console
from console.interfaces.dimensions import Dimensions
from console.service.acquisition_manager import AcquisitionControlManager
from console.utilities.sequences import tse_3d

# %%

seq, _ = tse_3d.constructor(
    echo_time=20e-3,
    repetition_time=600e-3,
    etl=5,
    rf_duration=200e-6,
    fov=Dimensions(x=0.2, y=0.2, z=0.2),
    channel_ro="y",
    channel_pe1="z",
    channel_pe2="x",
    ro_bandwidth=20e3,
    n_enc=Dimensions(x=1, y=100, z=20),
)

# %%
with AcquisitionControlManager() as mngr:

    console.parameter.larmor_frequency = 1.995e6
    console.parameter.gradient_offset = Dimensions(x=0, y=0, z=0)
    print(console.parameter)

    mngr.acquisition.set_sequence(sequence=seq, parameter=console.parameter)
    data = mngr.acquisition.run()

# %%

scan_data = np.array([rx_data.processed_data for rx_data in data.receive_data])
num_coils = np.size(scan_data, 1)

fig, ax = plt.subplots(1, num_coils, figsize=(5 * num_coils, 5), squeeze=False)
for coil in range(num_coils):
    ax[0, coil].plot(np.abs(scan_data[:, coil, :]).T)
    ax[0, coil].set_xlabel("Sample")
    ax[0, coil].set_ylabel("Signal (mV)")
    ax[0, coil].set_title(f"RX channel: {coil}")
fig.set_layout_engine("tight")


# %%