@@ -595,7 +595,7 @@ def signal_func(self):
595595 )
596596 if self .current_idx >= self .position_count :
597597 return False
598- pos_dict = self .multiposition_table [self .current_idx ]
598+ pos_dict = dict ( zip ([ "x" , "y" , "z" , "theta" , "f" ], self .multiposition_table [self .current_idx ]))
599599 # pause data thread if necessary
600600 if self .current_idx == 0 :
601601 temp = self .model .get_stage_position ()
@@ -606,7 +606,7 @@ def signal_func(self):
606606 )
607607 )
608608 else :
609- pre_stage_pos = self .multiposition_table [self .current_idx - 1 ]
609+ pre_stage_pos = dict ( zip ([ "x" , "y" , "z" , "theta" , "f" ], self .multiposition_table [self .current_idx - 1 ]))
610610 delta_x = abs (pos_dict ["x" ] - pre_stage_pos ["x" ])
611611 delta_y = abs (pos_dict ["y" ] - pre_stage_pos ["y" ])
612612 delta_z = abs (pos_dict ["z" ] - pre_stage_pos ["z" ])
@@ -872,31 +872,32 @@ def pre_signal_func(self):
872872 #: float: The f position of the channel being acquired in the z-stack
873873 self .restore_f = pos_dict ["f_pos" ]
874874
875+ # position: x, y, z, theta, f
875876 if bool (microscope_state ["is_multiposition" ]):
876877 self .positions = self .model .configuration ["experiment" ]["MultiPositions" ]
877878 else :
878879 self .positions = [
879- {
880- "x" : float (pos_dict ["x_pos" ]),
881- "y" : float (pos_dict ["y_pos" ]),
882- "z" : float (
880+ [
881+ float (pos_dict ["x_pos" ]),
882+ float (pos_dict ["y_pos" ]),
883+ float (
883884 microscope_state .get (
884885 "stack_z_origin" ,
885886 pos_dict ["z_pos" ],
886887 )
887888 if not self .get_origin
888889 else pos_dict ["z_pos" ]
889890 ),
890- "theta" : float (pos_dict ["theta_pos" ]),
891- "f" : float (
891+ float (pos_dict ["theta_pos" ]),
892+ float (
892893 microscope_state .get (
893894 "stack_focus_origin" ,
894895 pos_dict ["f_pos" ],
895896 )
896897 if not self .get_origin
897898 else pos_dict ["f_pos" ]
898899 ),
899- }
900+ ]
900901 ]
901902
902903 # Setup next channel down here, to ensure defocus isn't merged into
@@ -910,6 +911,7 @@ def pre_signal_func(self):
910911 f"{ self .start_z_position } "
911912 )
912913 self .current_position_idx = 0
914+ self .current_position = dict (zip (["x" , "y" , "z" , "theta" , "f" ], self .positions [0 ]))
913915 self .z_position_moved_time = 0
914916 self .need_to_move_new_position = True
915917 self .need_to_move_z_position = True
@@ -941,16 +943,20 @@ def signal_func(self):
941943 if self .model .stop_acquisition :
942944 return False
943945 data_thread_is_paused = False
946+
944947 # move stage X, Y, Theta
945948 if self .need_to_move_new_position :
946949 self .need_to_move_new_position = False
947950
951+ self .pre_position = self .current_position
952+ self .current_position = dict (zip (["x" , "y" , "z" , "theta" , "f" ], self .positions [self .current_position_idx ]))
953+
948954 # calculate first z, f position
949955 self .current_z_position = (
950- self .start_z_position + self .positions [ self . current_position_idx ] ["z" ]
956+ self .start_z_position + self .current_position ["z" ]
951957 )
952958 self .current_focus_position = (
953- self .start_focus + self .positions [ self . current_position_idx ] ["f" ]
959+ self .start_focus + self .current_position ["f" ]
954960 )
955961 if self .defocus is not None :
956962 self .current_focus_position += self .defocus [
@@ -963,29 +969,29 @@ def signal_func(self):
963969 map (
964970 lambda ax : (
965971 f"{ ax } _abs" ,
966- self .positions [ self . current_position_idx ] [ax ],
972+ self .current_position [ax ],
967973 ),
968974 ["x" , "y" , "theta" ],
969975 )
970976 )
971977
972978 if self .current_position_idx > 0 :
973979 delta_x = (
974- self .positions [ self . current_position_idx ] ["x" ]
975- - self .positions [ self . current_position_idx - 1 ] ["x" ]
980+ self .current_position ["x" ]
981+ - self .pre_position ["x" ]
976982 )
977983 delta_y = (
978- self .positions [ self . current_position_idx ] ["y" ]
979- - self .positions [ self . current_position_idx - 1 ] ["y" ]
984+ self .current_position ["y" ]
985+ - self .pre_position ["y" ]
980986 )
981987 delta_z = (
982- self .positions [ self . current_position_idx ] ["z" ]
983- - self .positions [ self . current_position_idx - 1 ] ["z" ]
988+ self .current_position ["z" ]
989+ - self .pre_position ["z" ]
984990 + self .z_stack_distance
985991 )
986992 delta_f = (
987- self .positions [ self . current_position_idx ] ["f" ]
988- - self .positions [ self . current_position_idx - 1 ] ["f" ]
993+ self .current_position ["f" ]
994+ - self .pre_position ["f" ]
989995 + self .f_stack_distance
990996 )
991997 else :
@@ -1076,10 +1082,10 @@ def signal_end(self):
10761082 self .z_position_moved_time = 0
10771083 # calculate first z, f position
10781084 self .current_z_position = (
1079- self .start_z_position + self .positions [ self . current_position_idx ] ["z" ]
1085+ self .start_z_position + self .current_position ["z" ]
10801086 )
10811087 self .current_focus_position = (
1082- self .start_focus + self .positions [ self . current_position_idx ] ["f" ]
1088+ self .start_focus + self .current_position ["f" ]
10831089 )
10841090 if (
10851091 self .z_stack_distance > self .stage_distance_threshold
0 commit comments