Skip to content

Commit

Permalink
Increased the maximum downsampling factor to 10.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjarosik committed Dec 23, 2021
1 parent 30a1b64 commit 5c752c0
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 1 deletion.
97 changes: 97 additions & 0 deletions api/python/examples/diverging_beams_3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
This script acquires and reconstructs RF img for plane wave imaging
(synthetic aperture).
GPU usage is recommended.
"""

import arrus
import arrus.session
import arrus.utils.imaging
import arrus.utils.us4r
import queue
import numpy as np

from arrus.ops.us4r import (
Scheme,
Pulse,
Tx,
Rx,
TxRx,
TxRxSequence
)
from arrus.utils.imaging import (
Pipeline,
SelectFrames,
Squeeze,
Lambda,
RemapToLogicalOrder
)
from arrus.utils.gui import (
Display2D
)

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


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.")


if __name__ == "__main__":
main()
97 changes: 97 additions & 0 deletions api/python/examples/pwi_3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
This script acquires and reconstructs RF img for plane wave imaging
(synthetic aperture).
GPU usage is recommended.
"""

import arrus
import arrus.session
import arrus.utils.imaging
import arrus.utils.us4r
import queue
import numpy as np

from arrus.ops.us4r import (
Scheme,
Pulse,
Tx,
Rx,
TxRx,
TxRxSequence
)
from arrus.utils.imaging import (
Pipeline,
SelectFrames,
Squeeze,
Lambda,
RemapToLogicalOrder
)
from arrus.utils.gui import (
Display2D
)

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


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

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.")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion arrus/core/devices/us4r/us4oem/Us4OEMImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Us4OEMTxRxValidator : public Validator<TxRxParamsSequence> {
ARRUS_VALIDATOR_EXPECT_DIVISIBLE_M(
numberOfSamples, 64u, firingStr);
ARRUS_VALIDATOR_EXPECT_IN_RANGE_M(
op.getRxDecimationFactor(), 0, 5, firingStr);
op.getRxDecimationFactor(), 0, 10, firingStr);
ARRUS_VALIDATOR_EXPECT_IN_RANGE_M(
op.getPri(),
Us4OEMImpl::MIN_PRI, Us4OEMImpl::MAX_PRI,
Expand Down

0 comments on commit 5c752c0

Please sign in to comment.