zea.interface

Convenience interface for loading and displaying ultrasound data.

Example usage

import zea
from zea.internal.setup_zea import setup_config

config = setup_config("hf://zeahub/configs/config_camus.yaml")

interface = zea.Interface(config)
interface.run(plot=True)

Classes

Interface([config, verbose, validate_file])

Interface for selecting / loading / processing single ultrasound images.

class zea.interface.Interface(config=None, verbose=True, validate_file=True)[source]

Bases: object

Interface for selecting / loading / processing single ultrasound images.

Useful for inspecting datasets and single ultrasound images.

# TODO: maybe we can refactor such that it is clear what needs to be in config.

check_for_display()[source]

check if in headless mode (no monitor available)

choose_file_path()[source]

Choose file path from window dialog.

property data_root

Root path to data file.

data_to_display(data=None)[source]

Get data and convert to display to_dtype.

property dataset_folder

Path to dataset folder.

property dtype

Data type of data when loaded from file.

property file_path

Path to data file.

property frame_no

Frame number to display.

get_data()[source]

Get data. Chosen datafile should be listed in the dataset.

Using either file specified in config or if None, the ui window.

Returns:

data array of shape (n_tx, n_el, n_ax, N_ch)

Return type:

data (np.ndarray)

plot(data=None, save=False, block=True)[source]

Plot image using matplotlib or opencv.

Parameters:
  • save (bool) – whether to save the image to disk.

  • block (bool) – whether to block the UI while plotting.

Returns:

plotted image (grabbed from figure).

Return type:

image (np.ndarray)

run(plot=False, block=True)[source]

Run ui. Will retrieve, process and plot data if set to True.

async run_movie(save=False)[source]

Run all frames in file in sequence

save_image(fig, path=None)[source]

Save image to disk.

Parameters:
  • fig (fig object) – figure.

  • path (str, optional) – path to save image to. Defaults to None.

save_video(images, path=None)[source]

Save video to disk.

Parameters:
  • images (list) – list of images.

  • path (str, optional) – path to save image to. Defaults to None.

set_backend_for_notebooks()[source]

Set backend to QtAgg if running in notebook

property to_dtype

Data type to convert to for display.