RodTracker.ui.reconstruction

TBD

class ReconstructorUI(ui: QWidget, *args, **kwargs)[source]

Bases: QWidget

A custom QWidget to provide access to the reconstruction of 3D particle coordinates.

This widget interfaces with the ParticleDetection.reconstruct_3D library and provides these functionalities to the GUI, i.e. reconstruction of 3D particle coordinates and tracking of particles over multiple frames.

Parameters:
  • ui (QWidget) – Widget containing the tab that is the GUI for the reconstruction and tracking functionality.

  • *args (iterable) – Positional arguments for the QWidget superclass.

  • **kwargs (dict) – Keyword arguments for the QWidget superclass.

used_colors

Selected colors for reconstruction/tracking/plotting.

By default [].

Type:

List[str]

start_frame

Lower bound of the frame range selected for reconstruction/tracking/plotting. The bound is inclusive.

By default 0.

Type:

int

end_frame

Upper bound of the frame range selected for reconstruction/tracking/plotting. The bound is inclusive.

By default 0.

Type:

int

_solver_result(result: DataFrame)[source]

Hook to handle the result of each reconstruction process.

Updates the count of active reconstruction/tracking processes/threads and resets the UI for further reconstruction/tracking tasks after all have finished. Propagates the results of the finished task.

Parameters:

result (pd.DataFrame) – The DataFrame containing the result of the process, usually updated data of one color only but for all frames used during the finished process.

Hint

Emits:

add_plot(fig: Figure)[source]

Add a figure to the display section.

Attempts to add the given Figure as a new page for display in the UI.

Parameters:

fig (Figure) – Figure to be added to the stacked plots for display in the UI.

Returns:

None

cam_ids: List[str] = ['', '']

IDs of the two cameras intended for reconstruction of 3D coordinates.

The IDs are used to identify the 2D data columns during the reconstruction process. If at least one of them is an empty string, the process of reconstruction or tracking will be immediatly aborted, because the there either is not enough data or the data is not identifiable.

Default is ["", ""].

Type:

List[str]

data: DataFrame = None

Slice of the main DataFrame that is used for reconstruction/tracking.

Default is None.

Type:

DataFrame

data_loaded(f_min: int, f_max: int, colors: List[str])[source]

Hook to updated the available frame range and colors for reconstruction/tracking.

This function is intended as a slot for the data_loaded signal. The range of available frames, as well as the available colors in the loaded dataset is updated and presented to users in the UI.

Parameters:
  • f_min (int) – Lowest frame currently available in the particle position dataset.

  • f_max (int) – Highest frame currently available in the particle position dataset.

  • colors (List[str]) – Colors currently available in the particle position dataset.

Returns:

None

data_update(data: DataFrame)[source]

Accepts a new dataset that shall be used for reconstruction/tracking.

Accepts a new dataset and, depending on whether this is the first time data is given here, updates the plots or (re-)enables the button for updating the plots in the UI.

Parameters:

data (pd.DataFrame) – New data that shall be used for plotting, 3D coordinate reconstruction and tracking of particles.

is_busy

Notifies when a background task is started/finished.

Type:

pyqtSignal(bool)

position_scaling: float = 1.0

Scale factor to scale the loaded data for display (is usually kept as 1.0).

Default is 1.0.

Type:

float

request_data

Request a portion of the main dataset defined by

[0]: a list of frames, and
[1]: a list of colors.
Type:

pyqtSignal(list, list)

select_data()[source]

Request data defined by the selections in the UI.

Requests a portion of the main data that is defined by the selections of the user in the reconstruction tab, i.e. start/end frame and colors of particles to include.

Returns:

None

Hint

Emits:

set_calibration(path: str)[source]

Attempts to load a new set of stereo camera calibration data.

Attempt to load calibration data from the file given in path and activates the Solve button if both, calibration and transformation data, have been loaded. Additionally, the updating of plots is (re-)enabled upon successful loading of the calibration data.

Parameters:

path (str) – Path to the stereo camera calibration data that shall be loaded here.

Returns:

None

set_cam_ids(cam1: str, cam2: str)[source]

Setter function for cam_ids.

Parameters:
  • cam1 (str) – ID for the first camera of the stereo camera setup.

  • cam2 (str) – ID for the second camera of the stereo camera setup.

Returns:

None

set_transformation(path: str)[source]

Attempts to load a new set transformations to world/experiment coordinates.

Attempts to load transformation matrices fromt the file given in path and activates the Solve button if both, calibration and transformation data, have been loaded. Additionally, the updating of plots is (re-)enabled upon successful loading of the transformation data.

Parameters:

path (str) – Path to the transformation data that shall be loaded here.

solve()[source]

(Re-)Starts the reconstruction/tracking of particles.

Starts either the reconstruction or tracking of particles, depending on the state of a QCheckBox. One process/thread for every selected color (used_colors) is started, that will (re-)calculate the 3D values (and particle IDs) for all frames in between start_frame and end_frame.

Returns:

None

property solver

Not Implemented.

switch_plot_page(direction: int)[source]

Switch the displayed plot page relative to the currently displayed one.

Parameters:

direction (int) –

Direction of the plot to display next. Its the index relative to the currently displayed plot.

a) direction = 3-> displays the plot three positions further

  1. direction = -1-> displays the previous plot

  2. direction = 0-> stays on the current plot

update_frames(start: int, end: int)[source]

Update the selected frame range for reconstruction/tracking.

Parameters:
  • start (int) – Lowest selected frame.

  • end (int) – Highest selected frame.

update_plots()[source]

(Re-)Generate plots for evaluation of the 3D data in the dataset.

Starts a thread that generates the evaluation plots for the data selected by the state of UI, i.e. selected colors (self.used_colors) and frame range (start_frame, end_frame).

Returns:

None

update_settings(settings: dict) None[source]

Catches updates of the settings from a Settings class.

Checks for the keys relevant to itself and updates the corresponding attributes. Redraws itself with the new settings in place.

Parameters:

settings (dict) –

Returns:

None

updated_data

Sends an updated slice of the main dataset, that has been (re-)tracked or its 3D coordinates updated.

This signal is emitted once for every color during the reconstruction/tracking process. The DataFrame in the payload is effectively an updated slice of the main dataset and does not contain new rows.

Type:

pyqtSignal(DataFrame)

choose_calibration(line_edit: QLineEdit, destination_func: callable)[source]

Let a user select a calibration/transformation file and load it.

Lets a user select a *.json file that should contain one kind of calibration, i.e. stereo camera calibration or transformtion to world/experiment coordinates. The chosen file is then passed to the given loading function for further processing.

Parameters:
  • line_edit (QLineEdit) – Display object for the desired calibration file.

  • destination_func (callable) – Loading function for the desired calibration file.

Returns:

None

init_reconstruction(ui: Ui_MainWindow)[source]

Initialize the functionality of reconstructing 3D particle positions.

Parameters:

ui (Ui_MainWindow) – UI object of the main window of the application, i.e. also containing the UI tab/objects for 3D reconstruction tasks.

Returns:

None | ReconstructorUI – Returns None, if the system requirements for 3D particle position reconstruction are not met. Otherwise the ReconstructorUI object handling particle reconstructions is returned.