-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2nd round of modifications to improve/extend the Kapton correction tool. #1968
Conversation
This round includes modifications to enable Kapton absorption correction for higher angles of rotation of the Kapton tape.
Ah, so this is in the ImageViewer? the last newsfragment just said "Ability to Plot" and so I wasn't sure. |
Yeah, thanks for adding this comment because it might help clear up some confusion that others might have. Yes, ultimately all these modifications are to improve the Kapton plugin used by the image viewer. I may have inadvertently confused this issue because two different code bases are involved to make these improvements: the logic to render the effects of the Kapton absorption correction lives in CCTBX ('kapton_2019_correction_frame_frame_plugin.py') while the logic that generates the data used by the aforementioned plugin lives in dials (i.e., the file modified in this PR ' kapton_2019_correction.py'). |
Yah, here's how you can look at it:
Then click Actions->Show 2019 kapton tool. @voklejas2 is working on the 'show kapton absorption edge and max' button. |
This round includes modifications to enable Kapton absorption correction for higher angles of rotation of the Kapton tape.
@@ -323,21 +323,9 @@ def _check_int_edge_pts(int_edge_pts): | |||
# Sort out the edge points and the int_edge_points which are on the same side | |||
kapton_edge_1 = (col(int_edge_pts[0]) - col(int_edge_pts[1])).normalize() | |||
kapton_edge_2 = (col(int_edge_pts[2]) - col(int_edge_pts[3])).normalize() | |||
min_loss_func = -999.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original intent of this now deleted logic was to reorder the indices of the detector edge points from counterclockwise to clockwise (starting from origin) based on how well the edges associated with kapton absorption max and min align with the sides of the detector. For example, if the kapton absortion edges are more parallel to the top/bottom sides of the detector, then the detector edge point are re-ordered to reflect that.
This logic was deleted because this re-ordering causes a divide by zero error on line 329
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't attempt to re-implement a working version of this logic because I'm not certain if what the ultimate outcome the original logic sought to obtain or of its validity.
@@ -350,24 +338,14 @@ def _check_int_edge_pts(int_edge_pts): | |||
# Now make sure the edges and the kapton lines are on the right side (i.e not swapped). | |||
# Let's look at edge_idx[0:2] i,e the first edge of detector parallel to the kapton | |||
pt1 = edge_pts[edge_idx[0]] | |||
pt2 = edge_pts[edge_idx[1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused variable
# Now find the distance between each of these points and the kapton lines. | ||
d1_kapton_1 = self.distance_of_point_from_line( | ||
pt1, int_edge_pts[0], int_edge_pts[1] | ||
) | ||
d1_kapton_2 = self.distance_of_point_from_line( | ||
pt1, int_edge_pts[2], int_edge_pts[3] | ||
) | ||
d2_kapton_1 = self.distance_of_point_from_line( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 361-366: unused variables
if d1_kapton_1 < d1_kapton_2: # closer to max than edge | ||
assert ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion breaks the ability to calculate absorption edge/max for higher angles of Kapton tape.
It seems to me that this now deleted logic is enforcing a relative orientation of the kapton tape absortion max and edge with detector edges that isn't necessarily always true. That said, I'm not sure what is lost by deleting this logic. I did find, however, that the deletion didn't result in any weird behavior at lower angles (negative or positive).
@@ -217,6 +218,20 @@ def distance_of_point_from_line(self, r0, r1, r2): | |||
denom = math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1)) | |||
return abs(num) / denom | |||
|
|||
def get_edge_distances(self, edges): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-factored redundant logic in abs_bounding_lines_in_mm into class method
@@ -242,6 +257,85 @@ def _check_int_edge_pts(int_edge_pts): | |||
new_int_edge_pts[3] = int_edge_pts[1] | |||
return new_int_edge_pts | |||
|
|||
def _orient_det_edge_pts(det_edge_pts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original logic makes an unstated assumption that the detector edge points used to help calculate the location of the absorption max and edge (aka min) will be perpendicular to the y-axis. The original logic ran into edge cases where this was no longer true. This logic attempts to skirt this issue by enforcing the detector edge points to listed in a certain order based on location relative to the origin of the detector.
det_edge_pts[edge_3], | ||
] | ||
|
||
def _make_kapton_distance_vec( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utility function used to help define the relative location of a given kapton intersection edge point relative to the detector center. This is useful when determining how to order the kapton intersection edge points when returning out of the abs_bounding_lines_in_mm function
@@ -250,18 +344,9 @@ def _check_int_edge_pts(int_edge_pts): | |||
for point in [(0, 0), (0, s_size), (f_size, 0), (f_size, s_size)]: | |||
x, y = panel.get_pixel_lab_coord(point)[0:2] | |||
edges.append((x, y, detz)) | |||
# Use the idea that the corners of the detector are end points of the diagonal and will be the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced this original logic with call to class method
This round includes modifications to enable Kapton absorption correction
for higher angles of rotation of the Kapton tape.
Note: that in order to see the effects of these modifications, you must also change to cctbx_project branch 'katon_plugin_pt2'.