pyfast_adt.main.tracking

Submodules

Attributes

path1

insitu_tracker

Classes

KalmanFilter

Tomography_tracker

this is the core of the patchworkCC algorithm, main method run the tracking asking the user to selct a ROI to

Tomography_tracker

this is the core of the patchworkCC algorithm, main method run the tracking asking the user to selct a ROI to

InSituTracker

MastronardeRigidBody

Package Contents

class pyfast_adt.main.tracking.KalmanFilter(dt, u_x, u_y, std_acc, x_std_meas, y_std_meas)

Bases: object

dt
u
x
A
B
H
Q
R
P
predict()
update(z)
class pyfast_adt.main.tracking.Tomography_tracker(images=None, visualization=False, existing_roi=None, dt=0.1, exp_type='continuous')

this is the core of the patchworkCC algorithm, main method run the tracking asking the user to selct a ROI to track, and return the tracked positions as a list of tuples (predicted_pos (pure KF), template_match (CC), filtered_pos (CC corrected by KF))) just to clarify:

–self.CC_positions is brutally pure CC –self.template_matching_result is CC with on top the patchwork to remove ambiguities –predicted_pos is predicted by pureKF using self.template_matching_result to learn(newton law) (-1 iteration) –filtered_pos is template_matching res. corrected by the KF (CC+newton) == more math

the self.support1 contain the tracked positions of all the methods.

this method is based on a liner KF at constant velocity where the acceleration act as control input if not overwritten in the init step. to overwrite with another KF model after construct the class should be possible to just assign self.KF to another KF model. if intersted check at the bottom the function self.select_other_KF_model(KF_model = your_model)

KF
KF_lost_position = []
KF_corrected_position = []
lost_counter = 0
support1 = []
series = None
n = None
backup_roi = None
series_support = []
support_manual = []
exp_type = 'continuous'
list_templates = []
counter_img = None
visualization = False
existing_roi = None
custom_model = [False, 'linear_KF_2D', 0]
bilateral_d = 9
bilateral_sigmacolor = 150
bilateral_sigmaspace = 150
main()
user_defined_ROI(img)
plot_single_track(visualization=False)
plot_tracking()
plot_tracking_reevaluation()
save_tracking(datapoints)
draw_circle(event, x, y, flags, param)
plot_result(color=(255, 0, 0))
manual_tracking(images=None, visualization=False)
display_tracking(images, tracking_dict, method, beam_size_diff=None)
select_other_KF_model(KF_model=None, KF_from_list=None)

function to overwrite the KF model used. the KF should be a class with at least 2 functions predict and update to work properly. a custom KF model can be passed in the argument KF_model (a class to construct). otherwise you can use the argument KF_from_list to select an already implemented KF model. the function construct the class for you. as it’s builded the experiment up to now the KF model should be using as measurement for the update step only the x,y position obtained from an object detection method.

pyfast_adt.main.tracking.path1 = 'L:\\Marco\\hardware_microscopes\\TecnaiF30\\sergi_track\\Tracking\\Tomography\\Sequential\\18\\clean'
class pyfast_adt.main.tracking.Tomography_tracker(images=None, visualization=False, existing_roi=None, dt=0.1, exp_type='continuous')

this is the core of the patchworkCC algorithm, main method run the tracking asking the user to selct a ROI to track, and return the tracked positions as a list of tuples (predicted_pos (pure KF), template_match (CC), filtered_pos (CC corrected by KF))) just to clarify:

–self.CC_positions is brutally pure CC –self.template_matching_result is CC with on top the patchwork to remove ambiguities –predicted_pos is predicted by pureKF using self.template_matching_result to learn(newton law) (-1 iteration) –filtered_pos is template_matching res. corrected by the KF (CC+newton) == more math

the self.support1 contain the tracked positions of all the methods.

this method is based on a liner KF at constant velocity where the acceleration act as control input if not overwritten in the init step. to overwrite with another KF model after construct the class should be possible to just assign self.KF to another KF model. if intersted check at the bottom the function self.select_other_KF_model(KF_model = your_model)

KF
KF_lost_position = []
KF_corrected_position = []
lost_counter = 0
support1 = []
series = None
n = None
backup_roi = None
series_support = []
support_manual = []
exp_type = 'continuous'
list_templates = []
counter_img = None
visualization = False
existing_roi = None
custom_model = [False, 'linear_KF_2D', 0]
bilateral_d = 9
bilateral_sigmacolor = 150
bilateral_sigmaspace = 150
main()
user_defined_ROI(img)
plot_single_track(visualization=False)
plot_tracking()
plot_tracking_reevaluation()
save_tracking(datapoints)
draw_circle(event, x, y, flags, param)
plot_result(color=(255, 0, 0))
manual_tracking(images=None, visualization=False)
display_tracking(images, tracking_dict, method, beam_size_diff=None)
select_other_KF_model(KF_model=None, KF_from_list=None)

function to overwrite the KF model used. the KF should be a class with at least 2 functions predict and update to work properly. a custom KF model can be passed in the argument KF_model (a class to construct). otherwise you can use the argument KF_from_list to select an already implemented KF model. the function construct the class for you. as it’s builded the experiment up to now the KF model should be using as measurement for the update step only the x,y position obtained from an object detection method.

class pyfast_adt.main.tracking.InSituTracker(shift=None, tilt_step=5, sim_mode=False, tomo_tracker=None)
a = []
dt = 0.1
tilt_step = 5
updated_positions = []
updated_positions_2 = []
second_iteration = False
tomo_tracker = None
main()
shift_image(image_array, shift)
insitu_obj_detection_sim()
in_situ_run(image, frame_number)
plot_insitu_result()
pyfast_adt.main.tracking.insitu_tracker
class pyfast_adt.main.tracking.MastronardeRigidBody(folder_path, fit_range, pixelsize_nm, delimiter='\t', plot_intermediate=False, theta_sim_deg=0)
folder_path
pixelsize_nm
pixelsize_um
delimiter = '\t'
plot_intermediate = False
theta_sim_deg = 0
results = []
datasets = []
_get_dataset(dataset_index=0)
static mastronarde_rot2D(alpha_rad, y0, z0, ys, theta_deg, y_mean)
mastronarde_point(alpha_rad, y0, z0, ys, theta_deg, y_mean=0.0)

Return rotated (y, x) coordinates from Mastronarde model

zheng_point(alpha_rad, y0, z0, ys, theta_deg, y_mean=0.0)
fit_dataset(idx)
fit_single_dataset_from_gui(data_path=None, switch_axis=False)
load_tracking_data_pyfast(path)
plot_intermediate_dataset(alpha, x_ccd, y_ccd, alpha_rad, popt, fname)
run_fits()
compute_linear_fits()
plot_summary(save=True)
plot_trajectories_stacked(dy_offset=1.0, out_path=None, filename='trajectories_all_datasets_stacked.png')

Plot stacked rotated XY trajectories with Mastronarde model overlay. Theoretical model is split for positive and negative alpha values and plotted with a small offset to inspect symmetry.

plot_z_scan(alpha_range_deg=np.linspace(-60, 60, 300), out_path=None, filename='plot_z_scan.png')

Plot n–z arcs using Mastronarde rigid body model

plot_single_dataset_summary(dataset_index=0, save=False)

Summary plots for a SINGLE dataset.

analyze_xy_dynamics(dataset_index=0, n_alpha=500, deg_step=5, out_path=None, scaling=1, original_range=False, deg_markers=False, pixels=True)

Analyze velocity and acceleration of projected CCD motion assuming linear relation between tilt angle and time (1 deg = 1 time unit).

Markers are placed EXACTLY every deg_step degrees.

analyze_xy_dynamics_multiple(deg_step=5, n_alpha=500, scaling=1, original_range=False, deg_markers=False, out_path=None, pixels=True)

Analyze XY dynamics for all datasets and compute max velocity & acceleration. Also plots max |v| and |a| vs Z stage (dataset index).

Includes the same style as analyze_xy_dynamics: - Optional deg markers with text - Velocity & acceleration twin y-axis - Component plots