@@ -135,7 +135,34 @@ def do_insert_grid_square(
135135 grid_square_id : int ,
136136 grid_square_parameters : GridSquareParameters ,
137137 ):
138- # need to correct height and weight by pixel ratio !!!!!
138+ if (
139+ grid_square_parameters .height is not None
140+ and grid_square_parameters .width is not None
141+ and grid_square_parameters .pixel_size is not None
142+ and grid_square_parameters .thumbnail_size_x is not None
143+ and grid_square_parameters .thumbnail_size_y is not None
144+ and grid_square_parameters .readout_area_x is not None
145+ and grid_square_parameters .readout_area_y is not None
146+ and grid_square_parameters .angle is not None
147+ ):
148+ grid_square_parameters .height = int (
149+ grid_square_parameters .height
150+ * (
151+ grid_square_parameters .thumbnail_size_y
152+ / grid_square_parameters .readout_area_y
153+ )
154+ )
155+ grid_square_parameters .width = int (
156+ grid_square_parameters .width
157+ * (
158+ grid_square_parameters .thumbnail_size_x
159+ / grid_square_parameters .readout_area_x
160+ )
161+ )
162+ grid_square_parameters .angle *= (
163+ grid_square_parameters .readout_area_x
164+ / grid_square_parameters .thumbnail_size_x
165+ )
139166 record = GridSquare (
140167 atlasId = atlas_id ,
141168 gridSquareLabel = grid_square_id ,
@@ -168,6 +195,23 @@ def do_insert_foil_hole(
168195 grid_square_id : int ,
169196 foil_hole_parameters : FoilHoleParameters ,
170197 ):
198+ if (
199+ foil_hole_parameters .diameter is not None
200+ and foil_hole_parameters .thumbnail_size_x is not None
201+ and foil_hole_parameters .readout_area_x is not None
202+ and foil_hole_parameters .pixel_size is not None
203+ ):
204+ foil_hole_parameters .diameter = int (
205+ foil_hole_parameters .diameter
206+ * (
207+ foil_hole_parameters .thumbnail_size_x
208+ / foil_hole_parameters .readout_area_x
209+ )
210+ )
211+ foil_hole_parameters .pixel_size *= (
212+ foil_hole_parameters .readout_area_x
213+ / foil_hole_parameters .thumbnail_size_x
214+ )
171215 record = FoilHole (
172216 gridSquareId = grid_square_id ,
173217 foilHoleLabel = foil_hole_parameters .name ,
0 commit comments