Skip to content

Mx-bluesky 221 document gridscan coordinate systems#958

Merged
rtuck99 merged 6 commits intomainfrom
mx-bluesky_221_document_gridscan_coordinate_systems
Dec 18, 2024
Merged

Mx-bluesky 221 document gridscan coordinate systems#958
rtuck99 merged 6 commits intomainfrom
mx-bluesky_221_document_gridscan_coordinate_systems

Conversation

@rtuck99
Copy link
Contributor

@rtuck99 rtuck99 commented Dec 12, 2024

Fixes DiamondLightSource/mx-bluesky#221 in particular the issue discovered in DiamondLightSource/mx-bluesky#697

See also DiamondLightSource/mx-bluesky#715

This issue was caused by a soft-signal in the ZocaloResults device being of integer type and causing a rounding issue.

Adds additional documentation and comments describing how the centre-of-mass and bounding boxes of the results from Zocalo are represented and transformed.

Instructions to reviewer on how to test:

  1. Tests pass
  2. Hyperion no longer reports
IndexError(f"{grid_position} is outside the bounds of the grid")

when performing a gridscan (this happens maybe ~10% of the time or slightly more when the crystal is near the edge of the grid

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@codecov
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.38%. Comparing base (420e11f) to head (6530f4a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #958   +/-   ##
=======================================
  Coverage   97.38%   97.38%           
=======================================
  Files         143      143           
  Lines        6087     6087           
=======================================
  Hits         5928     5928           
  Misses        159      159           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rtuck99 rtuck99 marked this pull request as ready for review December 13, 2024 09:59
@rtuck99 rtuck99 requested a review from a team as a code owner December 13, 2024 09:59
Copy link
Contributor

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the extra documentation is really useful. A few suggestions in the comments

Comment on lines +63 to +73
centre_of_mass: The position of the centre of mass of the crystal, adjusted so that
grid box centres lie on integer grid coordinates, such that a 1x1x1 crystal detected in
a single grid box at 0, 0, 0, has c.o.m. of 0, 0, 0, not 0.5, 0.5, 0.5
max_voxel: Position of the maximum voxel, in integer coordinates
max_count: max count achieved in a single voxel for the crystal
n_voxels: Number of voxels in the diffracting centre
total_count: Total of above-threshold spot counts in the labelled voxels
bounding_box: The rectangular prism that bounds the crystal, expressed
as the volume of whole boxes as a half-open range i.e such that
p1 = (x1, y1, z1) <= p < p2 = (x2, y2, z2) and
p2 - p1 gives the dimensions in whole voxels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful comments! I think it's also worth mentioning that (0,0) corresponds to the top left.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also that p1 and p2 refer to the top left and bottom right of the prism

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to wait until I have more feedback on DiamondLightSource/python-dlstbx#263 before I assert that 0,0 is at the top-left - it may not actually be true depending on where the snake scan starts!

centre_of_mass: The position of the centre of mass of the crystal, adjusted so that
grid box centres lie on integer grid coordinates, such that a 1x1x1 crystal detected in
a single grid box at 0, 0, 0, has c.o.m. of 0, 0, 0, not 0.5, 0.5, 0.5
max_voxel: Position of the maximum voxel, in integer coordinates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first read this, I assumed a voxel was a different thing to a box

Suggested change
max_voxel: Position of the maximum voxel, in integer coordinates
max_voxel: Position of the box with the largest integer coordinates

Also, what exactly do we mean by maximum coordinates? Is (5,0) larger than (0,5)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maximum voxel means the voxel with the highest spot count, not the box with the highest coordinates

a single grid box at 0, 0, 0, has c.o.m. of 0, 0, 0, not 0.5, 0.5, 0.5
max_voxel: Position of the maximum voxel, in integer coordinates
max_count: max count achieved in a single voxel for the crystal
n_voxels: Number of voxels in the diffracting centre
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
n_voxels: Number of voxels in the diffracting centre
n_voxels: Number of boxes in the diffracting centre

yield from bps.trigger(zocalo_device)
full_results = yield from get_full_processing_results(zocalo_device)
assert len(full_results) == 3
assert len(full_results) == 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert len(full_results) == 5
assert len(full_results) == len(TEST_RESULTS)

@rtuck99 rtuck99 force-pushed the mx-bluesky_221_document_gridscan_coordinate_systems branch from 5a2ae11 to 6530f4a Compare December 18, 2024 14:06
@rtuck99 rtuck99 merged commit a9ec03c into main Dec 18, 2024
@rtuck99 rtuck99 deleted the mx-bluesky_221_document_gridscan_coordinate_systems branch December 18, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document grid scan coordinate systems

2 participants