-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: use cartesian coordinate system in WellPlatePlan (-x left, +x right, -y down and +y up) #175
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #175 +/- ##
==========================================
+ Coverage 95.54% 95.65% +0.10%
==========================================
Files 15 15
Lines 1056 1058 +2
==========================================
+ Hits 1009 1012 +3
+ Misses 47 46 -1 ☔ View full report in Codecov by Sentry. |
src/useq/_plate.py
Outdated
return (transformed[:2].T).reshape(coords.shape) # type: ignore[no-any-return] | ||
transformed_coords = (transformed[:2].T).reshape(coords.shape) | ||
# invert Y values | ||
transformed_coords[:, 0] = -transformed_coords[:, 0] |
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.
probably better to do this in the affine transform itself, just invert the scaling factor in the y axis:
scaling[:2, :2] = np.diag([self.plate.well_spacing[0], -self.plate.well_spacing[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.
But is it the same? The output won't be identical...
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.
theoretically it should be? did you try and it wasn't?
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.
yeah, it does work, but the example I gave above was xy, instead of yx... use this:
# we invert the Y axis here to go from linearly increasing "index coordinates"
# to cartesian "plate" coordinates (where y position decreases with increasing index)
scale_y, scale_x = self.plate.well_spacing
scaling[:2, :2] = np.diag([-scale_y, scale_x])
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.
yup, I tried that as well but then the test give a slightly different result and if you use a rotation and plot the plate it is rotating in the opposite direction...
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.
Ok I think I was not convinced for another reason...I was a bit confused with the output numbers of the positions. But I think it was because we had to also consider the units of a1_center_xy
. I think we can say that a1_center_xy
is in µm
since most likely the stage coords are in µm (and the well_points_plan
too) and we covert it during translation.
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.
yeah, it's confusing! Should we consider expressing well sizes in microns too just to keep everything consistent? Is this the only place in useq where we use mm?
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.
Yes I believe is the only place we use mm...you're right, maybe it is worth using µm for everything at this point...
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 know that's also problematic since all plates specs will be in mm... maybe skip that for now
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.
then I think this is ready for review
please also fix a new scaling issue that we now have in random points: if value.max_width == np.inf:
kwargs["max_width"] = plate.well_size[0] - (value.fov_width or 0.1)
if value.max_height == np.inf:
kwargs["max_height"] = plate.well_size[1] - (
value.fov_height or 0.1
) the |
@tlambert03 out of curiosity, if you run the |
nope, and not on CI either obviously... whats your traceback |
the well_points_plan is always defaulting to Position()...
|
strange... not sure. what's in your env? |
ok fixed it, not sure what was the conflict... |
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.
good stuff, thanks
linked to #173
I removed all the change of sign we had in the
WellPlatePlan
code and only invert the y axis when we apply the transformation so that the y axis is-y down
and+y up
. This way we use the same cartesian coordinate system that we are already using in the_PointsPlans
.