Beispiel #1
0
def main():
    # Here starts communication with the device.
    with arrus.Session() as sess:
        us4r = sess.get_device("/Us4R:0")
        us4r.set_hv_voltage(10)

        n_elements = us4r.get_probe_model().n_elements
        # Full transmit aperture, full receive aperture.
        seq = TxRxSequence(
            ops=[
                TxRx(
                    Tx(
                        aperture=[True] * n_elements,
                        excitation=Pulse(center_frequency=6e6,
                                         n_periods=2,
                                         inverse=False),
                        # Custom delays 1.
                        delays=[0] * n_elements),
                    Rx(aperture=[True] * n_elements,
                       sample_range=(0, 2048),
                       downsampling_factor=1),
                    pri=200e-6),
            ],
            # Turn off TGC.
            tgc_curve=[14] * 200,  # [dB]
            # Time between consecutive acquisitions, i.e. 1/frame rate.
            sri=50e-3)
        # Declare the complete scheme to execute on the devices.
        scheme = Scheme(
            # Run the provided sequence.
            tx_rx_sequence=seq,
            # Processing pipeline to perform on the GPU device.
            processing=Pipeline(
                steps=(RemapToLogicalOrder(), SelectFrames([0]), Squeeze(),
                       Lambda(lambda data: data -
                              (data.mean(axis=0).astype(np.int16)))),
                placement="/GPU:0"))
        # Upload the scheme on the us4r-lite device.
        buffer, metadata = sess.upload(scheme)
        # Created 2D image display.
        display = Display2D(metadata=metadata, value_range=(-1000, 1000))
        # Start the scheme.
        sess.start_scheme()
        # Start the 2D display.
        # The 2D display will consume data put the the input queue.
        # The below function blocks current thread until the window is closed.
        display.start(buffer)

        print("Display closed, stopping the script.")

    # When we exit the above scope, the session and scheme is properly closed.
    print("Stopping the example.")
Beispiel #2
0
    sequence = StaSequence(
        tx_aperture_center=np.linspace(-15, 15, 11)*1e-3,
        tx_aperture_size=32,
        tx_focus=-6e-3,
        pulse=Pulse(center_frequency=6e6, n_periods=2, inverse=False),
        rx_sample_range=(0, 2048),
        downsampling_factor=2,
        speed_of_sound=1450,
        pri=200e-6,
        tgc_start=14,
        tgc_slope=2e2)

    # Imaging output grid.
    x_grid = np.arange(-15, 15, 0.2) * 1e-3
    z_grid = np.arange(5, 45, 0.2) * 1e-3

    scheme = Scheme(
        tx_rx_sequence=sequence,
        processing=get_bmode_imaging(sequence=sequence, grid=(x_grid, z_grid)))
    # Upload sequence on the us4r-lite device.
    buffer, metadata = sess.upload(scheme)
    display = Display2D(metadata=metadata, value_range=(20, 80), cmap="gray",
                        title="B-mode", xlabel="OX (mm)", ylabel="OZ (mm)",
                        extent=get_extent(x_grid, z_grid)*1e3,
                        show_colorbar=True)
    sess.start_scheme()
    display.start(buffer)

# When we exit the above scope, the session and scheme is properly closed.
print("Stopping the example.")