Skip to content

Insert tomogram locations in SXT regions of interest - #860

Merged
stephen-riggs merged 8 commits into
mainfrom
sxt-tomo-locations
Aug 13, 2026
Merged

Insert tomogram locations in SXT regions of interest#860
stephen-riggs merged 8 commits into
mainfrom
sxt-tomo-locations

Conversation

@stephen-riggs

@stephen-riggs stephen-riggs commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Read the stage locations of the tilt series in SXT and send these as part of the recipe so they can be displayed on pato. Will need a recipe change for the insertion.

The actual ROI to match the tomogram to is unknown (although it would be possible to read from file names sometimes), so I have written this to read all ROIs for the grid and match the tomogram to the one with the closest stage position.

There are complications around the pixel sizes and coordinate systems used. This changes the atlas pixel size inserted into ispyb to be that of the thumbnail, which is consistent with the other workflows.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.64516% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.74%. Comparing base (a186050) to head (36aaaac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #860      +/-   ##
==========================================
+ Coverage   54.65%   54.74%   +0.09%     
==========================================
  Files         104      104              
  Lines       11160    11214      +54     
  Branches     1475     1481       +6     
==========================================
+ Hits         6099     6139      +40     
- Misses       4741     4750       +9     
- Partials      320      325       +5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +357 to +364
x_tiles = _get_ole_header_value(
txrm_ole, "ImageInfo/XPosition", np.float32
).tolist()
y_tiles = _get_ole_header_value(
txrm_ole, "ImageInfo/YPosition", np.float32
).tolist()
metadata["x_position"] = x_tiles[int(len(x_tiles) / 2)]
metadata["y_position"] = y_tiles[int(len(y_tiles) / 2)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be iterated, but works as-is.

for key, old_path in (("x_position", "ImageInfo/XPosition"), ("y_position", "ImageInfo/YPosition")):
    tiles = _get_ole_header_value(txrm_ole, ole_path, np.float32).tolist()
    metadata[key] = tiles[int(len(tiles) / 2)]

x_location_centered = (
(tilt_series_info.x_stage_position - matching_roi.x_stage_position)
/ matching_roi.pixel_size
/ 1e6

@tieneupin tieneupin Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that on the client side, you have been converting the pixel size to metres, is the /1e6 still needed here?

What are the units of the ..._stage_position and pixel_size attributes at this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

1e6 is needed as the stage position is microns and the pixel size is metres

@tieneupin tieneupin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks fine overall, but some comments to help other devs with keeping track of units throughout the workflow would be very helpful.

Comment thread src/murfey/workflows/sxt/sxt_metadata.py
Comment thread src/murfey/workflows/sxt/sxt_metadata.py
Comment thread src/murfey/client/contexts/sxt.py
@stephen-riggs
stephen-riggs merged commit b57c855 into main Aug 13, 2026
14 checks passed
@stephen-riggs
stephen-riggs deleted the sxt-tomo-locations branch August 13, 2026 14:15
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.

2 participants