pyfast_adt.main

Submodules

Attributes

path1

insitu_tracker

Classes

Tem_fei

every angle for moving the stage must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

Tem_gatan_fei

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

Tem_gatan_jeol

Tem_jeol

every angle for moving the stage must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

Tem_fei_temspy

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

Tem_base

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

MastronardeRigidBody

KalmanFilter

Tomography_tracker

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

InSituTracker

Package Contents

class pyfast_adt.main.Tem_fei(ip='192.168.21.1', port=8080, cam_table=None, master=None)

Bases: pyfast_adt.main.adaptor.microscope.adaptor_tem.Tem_base

every angle for moving the stage must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

tem = None
result = []
master = None
client
calibrated_speed = None
move_stage_up(stage_ampl)

‘ take a float as stage ampl (um) and move the stage on +y of that quantity, rotation and scale to um already inside

move_stage_down(stage_ampl)
move_stage_left(stage_ampl)
move_stage_right(stage_ampl)
move_stage_z_up(stage_ampl)
move_stage_z_down(stage_ampl)
move_beam_up(beam_ampl)
move_beam_down(beam_ampl)
move_beam_left(beam_ampl)
move_beam_right(beam_ampl)
move_stem_beam_up(beam_ampl)
move_stem_beam_down(beam_ampl)
move_stem_beam_left(beam_ampl)
move_stem_beam_right(beam_ampl)
diffraction(checked_diff_value, kl=None)

“ this function set directly to 350 KL to fix a bug in temscript, this is ok only for the tecnai spirit, we should set in an external file which is the standard KL to set

get_defocus()
set_defocus(defocus)
euc_focus()
wobbler(checked_wobbler_value)
move_screen(checked_screen_value)
get_screen_position()
beam_blank(checked_blank_value)
apply_rotation(vector, theta=216.4)
fake()
get_stage(standard=False)

“get the stage position in um and deg

set_stage_position(x=None, y=None, z=None, a=None, b=None, speed=1)

“set the stage position in um and deg

get_beam_shift()

return the value of the beam shift

set_beam_shift(beam_pos)

set the value of the beam shift

connect(ip, port)
get_projection_mode()

return ‘IMAGING’ or ‘DIFFRACTION’ depending on what you are using

set_magnification(mag_value)
get_magnification()
set_KL(kl_value)
get_KL()

“return the KL value in mm

get_intensity(slot=0)

slot: 0,1,2, where 0 is not store the c2% value, 1 is store in beam_intensity_1, and 2 in the beam_intensity_2

set_intensity(intensity=0, slot=0)
get_spotsize()

return the c1 index value, in fei/termofisher this is the spotsize

load_calibration_table(cam_table)
set_alpha(angle, velocity=1)
set_xyz_tui(axis)

move an axis of the gonio using stage tui bot

microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None, timer=None, event=None, stop_event=None)

“this function read the tracking file and set up the threads necessary for the acqusition. 3 sockets are necessary to work. if tracking_positions == None and experiment_type == “continuous”, the stage is threaded only for continuous rotation (trackless experiment). if tracking positions != None and experiment_type == “continuous”, the stage is threaded for continuous rotation and the beam is threaded for tracking. if experiment_type == “stepwise”, the beam only is threaded for tracking waiting to pass the target angle to apply the tracking beamshift. in the case of cred, results are displayed in the variable self.result

calc_stage_speed(speed)

“calculate the speed in rad/s for the tecnai series, 1 is equivalent to the maximum (normalized). speed is provided in degrees/s and return it in rad/s.

angle_tracking(final_angle, result: list, timer=None, event=None, stop_event=None)
beamshift_tracking(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

beamshift_tracking_stem(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

get_voltage()
test_tracking(tracking, ub_class=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

test_tracking_stem(ub_class)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

continuous_rotation(a, speed, event=None, stop_event=None)
get_illumination_mode()

return micro or nanoprobe for the condenser minilens fei

set_illumination_mode(mode)

set micro or nanoprobe for the condenser minilens fei

get_instrument_mode()

return the current instrument mode i.e. TEM/STEM

set_instrument_mode(mode)

set the current instrument mode i.e. TEM/STEM

class pyfast_adt.main.Tem_gatan_fei(ip='192.168.21.1', port=8080, cam_table=None)

Bases: pyfast_adt.main.adaptor.microscope.adaptor_tem.Tem_base

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

tem = None
move_stage_up(stage_ampl)

‘ take a float as stage ampl (um) and move the stage on +y of that quantity, rotation and scale to um already inside

move_stage_down(stage_ampl)
move_stage_left(stage_ampl)
move_stage_right(stage_ampl)
move_stage_z_up(stage_ampl)
move_stage_z_down(stage_ampl)
move_beam_up(beam_ampl)
move_beam_down(beam_ampl)
move_beam_left(beam_ampl)
move_beam_right(beam_ampl)
diffraction(checked_diff_value, kl=None)
euc_focus()
wobbler(checked_wobbler_value)
move_screen(checked_screen_value)
get_screen_position()
apply_rotation(vector, theta=212)
fake()
get_stage()
get_beam_shift()
connect(ip, port)
microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None)
calc_stage_speed(speed)

“calculate the speed in degrees/s for the tecnai series, 1 is equivalent to the maximum (normalized). speed is provided in degrees/s and return it in rad/s.

beamshift_tracking(experiment_type, tracking_step, tracking_positions)
get_voltage()
get_projection_mode()
class pyfast_adt.main.Tem_gatan_jeol(ip='192.168.21.1', port=8080, cam_table=None)

Bases: pyfast_adt.main.adaptor.microscope.adaptor_tem.Tem_base

tem = None
move_stage_up(stage_ampl)
move_stage_down(stage_ampl)
move_stage_left(stage_ampl)
move_stage_right(stage_ampl)
move_stage_z_up(stage_ampl)
move_stage_z_down(stage_ampl)
move_beam_up(beam_ampl)
move_beam_down(beam_ampl)
move_beam_left(beam_ampl)
move_beam_right(beam_ampl)
diffraction(checked_diff_value, kl=None)
euc_focus()
wobbler(checked_wobbler_value)
move_screen(checked_screen_value)
get_screen_position()
apply_rotation(vector, theta=212)
fake()
get_stage()
get_beam_shift()
connect(ip, port)
microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None)
calc_stage_speed(speed)

“calculate the speed in degrees/s for the tecnai series, 1 is equivalent to the maximum (normalized). speed is provided in degrees/s and return it in rad/s.

beamshift_tracking(experiment_type, tracking_step, tracking_positions)
get_voltage()
get_projection_mode()
class pyfast_adt.main.Tem_jeol(ip_gonio='198.162.x.x', port_gonio=8083, cam_table=None, master=None)

Bases: pyfast_adt.main.adaptor.microscope.adaptor_tem.Tem_base

every angle for moving the stage must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

tem = None
result = []
master = None
calibrated_speed = None
FUNCTION_MODES = ('mag1', 'mag2', 'lowmag', 'samag', 'diff')
FUNCTION_MODES_stem = ('Alignment', 'LMAG', 'MAG', 'AMAG', 'uuDIFF', 'Rocking')
client = None
move_stage_up(stage_ampl)

stage ampl is in um and need to be converted to m to work in FEI/ThermoFisher (from API FEI works in m). before was set at -90 as fei, but is needed another 90 deg clockwise to be sincronized properly that’s why now is -180 if it doesn’t work try 0 deg

move_stage_down(stage_ampl)
move_stage_left(stage_ampl)
move_stage_right(stage_ampl)
move_stage_z_up(stage_ampl)
move_stage_z_down(stage_ampl)
move_beam_up(beam_ampl)

beamshift function by CLA1 lens in JEOL, the method self.def3.SetCLA1(x,y) use uint16 bit values for x and y. looking the fluoscreen in front of you the beamshift is settled as the following:

fluoscreen

0 65k y
XX XXXXXXX XX

XXXX XXXXX X XX XXX

X XX XXX X X XXX X X XXX XX X

X XX XX X XXXX XXX

XX XXXXXXX XX

0 XX 65k x

in the image above, if you are looking the fluoscreen, x and y are rotate around 45 deg like in fei, but the origin of every axis is on the left respectively up for the x and bottom for the y. i think we should remove the convertion to 10**-6. i input 1000000000 and got 1000 shift which is visible

move_beam_down(beam_ampl)
move_beam_left(beam_ampl)
move_beam_right(beam_ampl)
move_stem_beam_up(beam_ampl)

not tested stem mode up to now

move_stem_beam_down(beam_ampl)
move_stem_beam_left(beam_ampl)
move_stem_beam_right(beam_ampl)
getFunctionMode()

return one of these strings in TEM mode: mag1, mag2, lowmag, samag, diff. in STEM mode should return one of these strings: Alignment, LMAG, MAG, AMAG, uuDIFF, Rocking.

setFunctionMode(value)

it’s acceppted as input for value both integers or string corresponding to the function mode to change. in TEM mode we have available mag1:0, mag2:1, lowmag:2, samag:3, diff:4, while in STEM mode we have Alignment:0, LMAG:1, MAG:2, AMAG:3, uuDIFF:4, Rocking:5. when you jump in a different state the microscope remember which setting was using and automatically restore it.

diffraction(checked_diff_value, kl=None)

“ toggle button to switch diffraction mode on off. up to now it works but it return to samag always, we can store the previous mode and restore it

get_defocus()

return the objective lens defocus value as a uint16 value. there are 2 functions OLc and OLf, meaning to coarse and fine, and they need to be stored together. these are indentical as in free lens control (FLC)

set_defocus(defocus)

set the objective lens defocus value. there are 2 functions OLc and OLf, meaning to coarse and fine, and they need to be set together if you want a specific condition to store/restore. these are indentical as in free lens control (FLC)

euc_focus()

“called standard focus button in JEOL

wobbler(checked_wobbler_value)

in jeol exist 2 image wobbler (x and y, which are in FEI/TFS called beam tilt pp x and y) instead of a conventional alpha wobbler. thsi function is not implemented for JEOL up to now

move_screen(checked_screen_value)

function to move the fluorescent screen if checked_screen_value is True will move up, otherwise move it down.

get_screen_position()

return if the screen is up or down as ‘UP’ or ‘DOWN’.

beam_blank(checked_blank_value)

function to enable beam blanking if checked_blank_value is True blank the beam, otherwise unblank it. in JEOL this function is called blacking (f6 button in our microscope)

apply_rotation(vector, theta=216.4)

input an x,y vector and return a rotated vector of theta degree, usually used for syncronize the movement of the beam shift with the user reference. the rotation is counterclockwise

fake()

just a placeholder that print a string, for testing purposes

get_stage(standard=False)

return the current stage position of x, y, z in um a and b in deg. from JEOL API this return nm and deg, while we return instead um and deg to be consistent with FEI/TFS.

set_stage_position(x=None, y=None, z=None, a=None, b=None)

set the stage position of x, y, z in um a and b in deg. from JEOL API this uses nm and deg so the convertion is done in place for consistency with FEI/TFS. for angles value usually you don’t get the exact angle you asked for but relatively close to it (i.e. set for 1 deg you get 0.7 deg). multiple call could fix it

get_beam_shift()

get the beam shift value in uint16 value. CLA1 lens is used in JEOL

set_beam_shift(beam_pos)

set the beam shift value, it must be an uint16 value. CLA1 lens is used in JEOL

connect()

microscope remote connection trough JEOL COM interface generated by TemExt.dll

get_projection_mode()

return ‘IMAGING’ or ‘DIFFRACTION’ depending on the current mode. if you are in diff you get ‘DIFFRACTION’, else ‘IMAGING’.

set_magnification(mag_value)

this function set the magnification value in JEOL, the value is in the same unit as the GUI of JEOL.

get_magnification()

tricky function there are 2 ways to get the info using: getMagnification that return a value integer or using getMagnificationIndex that return an integer as index. the function return the magnification value in the same unit as the GUI of JEOL. i.e. selector, mag, status = self.eos3.GetCurrentMagSelectorID() you return mag = 15000

set_KL(kl_value)

as set_magnification this function use the same self.eos3.SetSelector(kl_value). change the camera length in diffraction mode

get_KL()

“return the KL value in mm if you are in diffraction

get_intensity(slot=0)

return the value of the CL3 in FLC, this is a uint16 value. if slot is 1 or 2 the value is stored in the slot and can be restored by using set_intensity

set_intensity(intensity=0, slot=0)

set the value of the CL3 in FLC, this must be a uint16 value. if slot is 1 or 2 restore the value stored in that slot. must be previously stored using get_intensity with the same slot.

get_spotsize()

return the CL1 lens index value, in JEOL this is the spotsize in FEI/TFS. 0-based indexing for GetSpotSize function, added 1 to be consistent with JEOL GUI and TFS. in JEOL, spotsize is ranging from 1 to 5, whereas FEI/TFS spotsize 1 is the most bright mode and 5 the least.

set_spotsize(value)

Set the spotsize in JEOL (CL1 lens), available from 1 to 5, where 1 is the most bright and 5 the least.

load_calibration_table(cam_table)

initialize the lookup table of the camera used. this contains also the magnification and KL calibrations of the microscope used. in JEOL up to now is supported only for mag1 and diff respectively.

set_alpha(angle, velocity=1, wait=False)

set the stage alpha value in degrees. velocity cannot be set directly. the function will wait for the goniometer to stop. the angle should be provided in deg. to access velocity you need to enable the goniotool feature and passing trough another specialized method. check docs.

continuous_rotation(a, speed, event=None, stop_event=None)

method to change speed of the rotation before starting it, the delay for confirm comes from the event passed that wait until the user press yes in the popup message in the GUI. in jeol the gonio velocity can be changed only using goniotool, an external software .exe from service.

isStageMoving()

return 1 if at least one axis is moving and 0 if all the axis are not moving.

microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None, timer=None, event=None, stop_event=None)

“this function read the tracking file and set up the threads necessary for the acqusition. 3 sockets are necessary to work. if tracking_positions == None and experiment_type == “continuous”, the stage is threaded only for continuous rotation (trackless experiment). if tracking positions != None and experiment_type == “continuous”, the stage is threaded for continuous rotation and the beam is threaded for tracking. if experiment_type == “stepwise”, the beam only is threaded for tracking waiting to pass the target angle to apply the tracking beamshift. in the case of cred, results are displayed in the variable self.result

calc_stage_speed(speed)

“calculate the speed in rad/s for JEOL. speed is provided in degrees/s and return it in rad/s.

angle_tracking(final_angle, result: list, timer=None, event=None, stop_event=None)
beamshift_tracking(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

beamshift_tracking_stem(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

get_voltage()

return the actual acceleration voltage in kV.

test_tracking(tracking, ub_class=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

test_tracking_stem(ub_class)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

get_illumination_mode()

return micro or nanoprobe for the condenser minilens. in JEOL there are several extra modes like CBED, NBD and so on. i don’t know which one correspond to our nanoprobe

set_illumination_mode(mode)

set micro or nanoprobe for the condenser minilens. not implemented

get_instrument_mode()

return the current instrument mode i.e. TEM/STEM. return always TEM up to now.

set_instrument_mode(mode)

set the current instrument mode i.e. TEM/STEM. not implemented.

class pyfast_adt.main.Tem_fei_temspy(ip='192.168.21.1', port=8080, cam_table=None, master=None)

Bases: pyfast_adt.main.adaptor.microscope.adaptor_tem.Tem_base

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

tem = None
result = []
master = None
client
calibrated_speed = None
move_stage_up(stage_ampl)

‘ take a float as stage ampl (um) and move the stage on +y of that quantity, rotation and scale to um already inside

move_stage_down(stage_ampl)
move_stage_left(stage_ampl)
move_stage_right(stage_ampl)
move_stage_z_up(stage_ampl)
move_stage_z_down(stage_ampl)
move_beam_up(beam_ampl)
move_beam_down(beam_ampl)
move_beam_left(beam_ampl)
move_beam_right(beam_ampl)
move_stem_beam_up(beam_ampl)
move_stem_beam_down(beam_ampl)
move_stem_beam_left(beam_ampl)
move_stem_beam_right(beam_ampl)
diffraction(checked_diff_value, kl=None)

“ this function set directly to 350 KL to fix a bug in temscript, this is ok only for the tecnai spirit, we should set in an external file which is the standard KL to set

get_defocus()
set_defocus(defocus)
euc_focus()
wobbler(checked_wobbler_value)
move_screen(checked_screen_value)
get_screen_position()
beam_blank(checked_blank_value)
apply_rotation(vector, theta=216.4)
fake()
get_stage(standard=False)

return it in deg and um if standard == True return also the measuring units

set_stage_position(x=None, y=None, z=None, a=None, b=None)
get_beam_shift()

return the value of the beam shift

set_beam_shift(beam_pos)

set the value of the beam shift

connect(ip, port)
get_projection_mode()
set_magnification(mag_value)
get_magnification()
set_KL(kl_value)
get_KL()

“return the KL value in mm

get_intensity(slot=0)

slot: 0,1,2, where 0 is not store the c2% value, 1 is store in beam_intensity_1, and 2 in the beam_intensity_2

set_intensity(intensity=0, slot=0)
get_spotsize()

return the c1 index value, in fei/termofisher this is the spotsize

load_calibration_table(cam_table)
set_alpha(angle, velocity=1)
set_alpha_temspy(angle, velocity=1, event=None, stop_event=None)

this is not really compatible with the prague method right now, because the bot start changing the value and the wait event will only press the button but all the threads starts together

set_xyz_temspy(value, axis, velocity=1, event=None, stop_event=None)

move an axis of the gonio using compustage temspy

set_xyz_tui(axis)

move an axis of the gonio using stage tui bot

microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None, timer=None, event=None, stop_event=None)

“this function read the tracking file and set up the threads necessary for the acqusition. 3 sockets are necessary to work. if tracking_positions == None and experiment_type == “continuous”, the stage is threaded only for continuous rotation (trackless experiment). if tracking positions != None and experiment_type == “continuous”, the stage is threaded for continuous rotation and the beam is threaded for tracking. if experiment_type == “stepwise”, the beam only is threaded for tracking waiting to pass the target angle to apply the tracking beamshift. in the case of cred, results are displayed in the variable self.result

calc_stage_speed(speed)

“calculate the speed in degrees/s for the tecnai series, 1 is equivalent to the maximum (normalized). speed is provided in degrees/s and return it in rad/s.

angle_tracking(final_angle, result: list, timer=None, event=None, stop_event=None)
beamshift_tracking(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

beamshift_tracking_stem(tracking_dict, result=None, timer=None, event=None, stop_event=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

get_voltage()
test_tracking(tracking, ub_class=None)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

test_tracking_stem(ub_class)

this thread live in a separate socket and check continuously the position of the stage. when the angle is in the one to apply the tracking, the beamshift is applied to track the crystal. the thread work passivly waiting for the angle to be reached/passed to work

continuous_rotation(a, speed, event=None, stop_event=None)

modified cred function for fei_temspy because the stage is rotated by the bot. so it’s normal that the wait here is commented because the wait is in the set_alpha_temspy function. a input in deg and speed in a.u. (radians)

get_illumination_mode()

return micro or nanoprobe for the condenser minilens fei

set_illumination_mode(mode)

set micro or nanoprobe for the condenser minilens fei

get_instrument_mode()

return the current instrument mode i.e. TEM/STEM

set_instrument_mode(mode)

set the current instrument mode i.e. TEM/STEM

class pyfast_adt.main.Tem_base

Bases: abc.ABC

every angle for moving the satge must be in deg as input and output, velocity for the stage in radian/s and um for the stage xyz movement

var = None
x = 0
y = 0
beam_intensity_1 = None
beam_intensity_2 = None
abstract move_stage_up(stage_ampl)

‘ take a float as stage ampl (um) and move the stage on +y of that quantity, rotation and scale to um already inside

abstract move_stage_down(stage_ampl)
abstract move_stage_left(stage_ampl)
abstract move_stage_right(stage_ampl)
abstract move_stage_z_up(stage_ampl)
abstract move_stage_z_down(stage_ampl)
abstract move_beam_up(beam_ampl)
abstract move_beam_down(beam_ampl)
abstract move_beam_left(beam_ampl)
abstract move_beam_right(beam_ampl)
abstract diffraction(checked_diff_value, kl=None)
abstract euc_focus()
abstract wobbler(checked_wobbler_value)
abstract move_screen(checked_screen_value)
abstract get_screen_position()
abstract beam_blank(checked_blank_value)
abstract apply_rotation(vector, theta=212)
abstract fake()
abstract get_stage(standard=False)
abstract set_stage_position(x=None, y=None, z=None, a=None, b=None)
abstract get_beam_shift()
abstract set_beam_shift(beam_pos)
abstract connect(ip, port)
abstract get_projection_mode()
abstract set_magnification(mag_value)
abstract get_magnification()
abstract set_KL(kl_value)
abstract get_KL()
abstract get_intensity(slot=0)

slot: 0,1,2, where 0 is not store the c2% value, 1 is store in beam_intensity_1, and 2 in the beam_intensity_2

abstract set_intensity(intensity=0, slot=0)
abstract load_calibration_table(cam_table)
abstract set_alpha(angle, velocity=1)
abstract microscope_thread_setup(tracking_file='tracking.txt', tracking_dict=None)
abstract calc_stage_speed(speed)
abstract beamshift_tracking(tracking_dict, result)
abstract beamshift_tracking_stem(tracking_dict, result)
abstract get_voltage()
abstract get_illumination_mode()
abstract set_illumination_mode(mode)
abstract get_instrument_mode()
abstract set_instrument_mode(mode)
class pyfast_adt.main.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

class pyfast_adt.main.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.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.path1 = 'L:\\Marco\\hardware_microscopes\\TecnaiF30\\sergi_track\\Tracking\\Tomography\\Sequential\\18\\clean'
class pyfast_adt.main.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.insitu_tracker