@@ -162,7 +162,7 @@ def register_search_map_in_database(
162162 dcg .atlas_binning ,
163163 ]
164164 ):
165- M = np .array (
165+ reference_shift_matrix = np .array (
166166 [
167167 [
168168 search_map .reference_matrix_m11 ,
@@ -174,8 +174,10 @@ def register_search_map_in_database(
174174 ],
175175 ]
176176 )
177- B = np .array ([search_map .x_stage_position , search_map .y_stage_position ])
178- R = np .array (
177+ stage_vector = np .array (
178+ [search_map .x_stage_position , search_map .y_stage_position ]
179+ )
180+ stage_correction_matrix = np .array (
179181 [
180182 [
181183 search_map .stage_correction_m11 ,
@@ -187,22 +189,27 @@ def register_search_map_in_database(
187189 ],
188190 ]
189191 )
190- vector_pixel = np .matmul (np .linalg .inv (M ), np .matmul (R , np .matmul (M , B )))
192+ corrected_vector = np .matmul (
193+ np .linalg .inv (reference_shift_matrix ),
194+ np .matmul (
195+ stage_correction_matrix , np .matmul (reference_shift_matrix , stage_vector )
196+ ),
197+ )
191198
192199 camera = getattr (Camera , machine_config .camera )
193200 if camera == Camera .FALCON or Camera .K3_FLIPY :
194- vector_pixel = np .matmul (np .array ([[1 , 0 ], [0 , - 1 ]]), vector_pixel )
201+ corrected_vector = np .matmul (np .array ([[1 , 0 ], [0 , - 1 ]]), corrected_vector )
195202 elif camera == Camera .K3_FLIPX :
196- vector_pixel = np .matmul (np .array ([[- 1 , 0 ], [0 , 1 ]]), vector_pixel )
203+ corrected_vector = np .matmul (np .array ([[- 1 , 0 ], [0 , 1 ]]), corrected_vector )
197204
198205 search_map_params .height_on_atlas = int (
199206 search_map .height * search_map .pixel_size / dcg .atlas_pixel_size
200207 )
201208 search_map_params .width_on_atlas = int (
202209 search_map .width * search_map .pixel_size / dcg .atlas_pixel_size
203210 )
204- search_map_params .x_location = vector_pixel [0 ] / dcg .atlas_pixel_size + 2003
205- search_map_params .y_location = vector_pixel [1 ] / dcg .atlas_pixel_size + 2003
211+ search_map_params .x_location = corrected_vector [0 ] / dcg .atlas_pixel_size + 2003
212+ search_map_params .y_location = corrected_vector [1 ] / dcg .atlas_pixel_size + 2003
206213 search_map .x_location = search_map_params .x_location
207214 search_map .y_location = search_map_params .y_location
208215 if _transport_object :
@@ -256,7 +263,7 @@ def register_batch_position_in_database(
256263 search_map .width ,
257264 ]
258265 ):
259- M = np .array (
266+ reference_shift_matrix = np .array (
260267 [
261268 [
262269 search_map .reference_matrix_m11 ,
@@ -268,7 +275,7 @@ def register_batch_position_in_database(
268275 ],
269276 ]
270277 )
271- R1 = np .array (
278+ stage_correction_matrix = np .array (
272279 [
273280 [
274281 search_map .stage_correction_m11 ,
@@ -280,7 +287,7 @@ def register_batch_position_in_database(
280287 ],
281288 ]
282289 )
283- R2 = np .array (
290+ image_shift_matrix = np .array (
284291 [
285292 [
286293 search_map .image_shift_correction_m11 ,
@@ -293,18 +300,24 @@ def register_batch_position_in_database(
293300 ]
294301 )
295302
296- A = np .array ([search_map .x_stage_position , search_map .y_stage_position ])
297- B = np .array (
298- [batch_parameters .x_stage_position , batch_parameters .y_stage_position ]
303+ stage_vector = np .array (
304+ [
305+ batch_parameters .x_stage_position - search_map .x_stage_position ,
306+ batch_parameters .y_stage_position - search_map .y_stage_position ,
307+ ]
299308 )
300309
301- vector_pixel = np .matmul (
302- np .linalg .inv (M ),
310+ corrected_vector = np .matmul (
311+ np .linalg .inv (reference_shift_matrix ),
303312 np .matmul (
304- np .linalg .inv (R1 ), np .matmul (np .linalg .inv (R2 ), np .matmul (M , B - A ))
313+ np .linalg .inv (stage_correction_matrix ),
314+ np .matmul (
315+ np .linalg .inv (image_shift_matrix ),
316+ np .matmul (reference_shift_matrix , stage_vector ),
317+ ),
305318 ),
306319 )
307- centre_batch_pixel = vector_pixel / search_map .pixel_size + [
320+ centre_batch_pixel = corrected_vector / search_map .pixel_size + [
308321 search_map .width / 2 ,
309322 search_map .height / 2 ,
310323 ]
0 commit comments