-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_square.py
More file actions
45 lines (31 loc) · 2.3 KB
/
Copy pathmax_square.py
File metadata and controls
45 lines (31 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import objective_parameters
'''
This script is used for calculating the maximum square side length for placing the alignment markers in your first print job.
This will give a general idea of how far apart the markers can be placed without having them outside of the microscope view.
How to use:
1) Set the alignment marker diameter, the highest magnification objective you will be using, and whether you expect your substrate will be rotated by more than 5 degrees during subsequent print steps.
2) Start the script. The maximum side length will be calculated based on the given parameters and the value will be displayed in microns.
'''
if __name__ == "__main__":
# Script parameters
marker_diameter = 12 # Diameter (in microns) of the alignment marker.
objective = '63x' # Specify the highest magnification objective to be used for your alignment as '63x', '25x', or '10x'.
small_rotation = True # Set this to True if the substrate will not be rotated more than 5 degrees (i.e. for square substrates), otherwise set this to False.
# The height and width (in pixels) of microscope view screenshots.
image_width, image_height = 1388, 1040
# Objective parameters are obtained depending on the objective being used.
origin_X, origin_Y, _, _, _, pixel_size = objective_parameters.main(objective)
# Marker diameter is converted from microns to pixels.
marker_dia_px = marker_diameter * pixel_size
# Calculates the maximum distance (in X and Y) that an alignment marker can be away from the print origin while still being in view.
R_max_X = min(image_width - origin_X, origin_X) - marker_dia_px / 2
R_max_Y = min(image_height - origin_Y, origin_Y) - marker_dia_px / 2
if not small_rotation: # For large rotations, the diagonal of the square will be the limiting factor for the maximum side length.
side_length_max_px = 2 * min(R_max_X, R_max_Y) / 1.414
else:
side_length_max_px = 2 * min(R_max_X, R_max_Y)
# The maximum side length is converted from pixels to microns and is rounded.
side_length_max = round(side_length_max_px / pixel_size)
print(f'Maximum square side length is approximately {side_length_max} um.')
if side_length_max < marker_diameter:
print("Markers are overlapping.")