Skip to content

Commit

Permalink
us4r-api version 0.8.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjarosik committed Mar 11, 2022
1 parent b4a6ab2 commit bab02b5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ set(ARRUS_DOCS_INSTALL_DIR docs)
################################################################################
# Common dependencies
################################################################################
find_package(Us4 0.7.2 EXACT REQUIRED US4OEM HV256 DBARLite)
find_package(Us4 0.8.0 EXACT REQUIRED US4OEM HV256 DBARLite)
find_package(Boost REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
find_package(Protobuf REQUIRED)
Expand Down
71 changes: 55 additions & 16 deletions api/python/examples/classical_beamforming.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,87 @@
"""
import numpy as np
import arrus
from arrus.ops.us4r import Scheme, Pulse
from arrus.ops.us4r import Scheme, Pulse, DataBufferSpec
from arrus.ops.imaging import LinSequence
from arrus.utils.gui import Display2D
from arrus.utils.imaging import get_bmode_imaging, get_extent
from arrus.utils.imaging import *

arrus.set_clog_level(arrus.logging.INFO)
arrus.add_log_file("test.log", arrus.logging.INFO)


last_timestamp = 0.0

# Here starts communication with the device.
with arrus.Session() as sess:
with arrus.Session("/home/pjarosik/us4r.prototxt") as sess:
us4r = sess.get_device("/Us4R:0")
us4r.set_hv_voltage(20)
us4r.set_hv_voltage(5)

sequence = LinSequence(
tx_aperture_center_element=np.arange(0, 128),
tx_aperture_center_element=np.arange(8, 183),
tx_aperture_size=64,
tx_focus=24e-3,
tx_focus=10e-3,
pulse=Pulse(center_frequency=6e6, n_periods=2, inverse=False),
rx_aperture_center_element=np.arange(0, 128),
rx_aperture_center_element=np.arange(8, 183),
rx_aperture_size=64,
rx_sample_range=(0, 2048),
pri=200e-6,
rx_sample_range=(0, 1024),
pri=100e-6,
tgc_start=14,
tgc_slope=2e2,
downsampling_factor=2,
speed_of_sound=1450)
speed_of_sound=1450,
sri=17.5e-3,
)

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


def lambda_func(data):
global last_timestamp
t = data[0, 4:8].get().view(np.uint64).item()/65e6
print(t-last_timestamp)
last_timestamp = t
return data

scheme = Scheme(
tx_rx_sequence=sequence,
processing=get_bmode_imaging(sequence=sequence, grid=(x_grid, z_grid)))
processing=Pipeline(
steps=(
# Channel data pre-processing.
Lambda(lambda_func),
RemapToLogicalOrder(),
Transpose(axes=(0, 1, 3, 2)),
BandpassFilter(),
QuadratureDemodulation(),
Decimation(decimation_factor=4,
cic_order=2),
# # Data beamforming.
RxBeamforming(),
# # Post-processing to B-mode image.
EnvelopeDetection(),
Transpose(axes=(0, 2, 1)),
ScanConversion(x_grid, z_grid),
LogCompression(),
Squeeze()
),
placement="/GPU:0"),
# get_bmode_imaging(sequence=sequence, grid=(x_grid, z_grid)),
rx_buffer_size=15,
output_buffer=DataBufferSpec(type="FIFO", n_elements=15),
work_mode="ASYNC"
)
# 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)
# 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)
[]
for i in range(100):
frame = buffer.get()[0]

# When we exit the above scope, the session and scheme is properly closed.
print("Stopping the example.")
12 changes: 7 additions & 5 deletions api/python/examples/plane_wave_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from arrus.utils.gui import Display2D
from arrus.utils.imaging import get_bmode_imaging, get_extent

arrus.set_clog_level(arrus.logging.INFO)
arrus.add_log_file("test.log", arrus.logging.INFO)
arrus.set_clog_level(arrus.logging.TRACE)
arrus.add_log_file("test.log", arrus.logging.TRACE)

# Here starts communication with the device.
with arrus.Session() as sess:
with arrus.Session("/home/pjarosik/us4r.prototxt") as sess:
us4r = sess.get_device("/Us4R:0")
us4r.set_hv_voltage(40)
us4r.set_hv_voltage(20)

sequence = PwiSequence(
angles=np.linspace(-10, 10, 7)*np.pi/180,
Expand All @@ -33,7 +33,9 @@

scheme = Scheme(
tx_rx_sequence=sequence,
processing=get_bmode_imaging(sequence=sequence, grid=(x_grid, z_grid)))
processing=get_bmode_imaging(sequence=sequence, grid=(x_grid, z_grid)),
# work_mode="ASYNC"
)
# Upload sequence on the us4r-lite device.
buffer, metadata = sess.upload(scheme)
display = Display2D(metadata=metadata, value_range=(20, 80), cmap="gray",
Expand Down

0 comments on commit bab02b5

Please sign in to comment.