Skip to content

Add plugin to make thumbnails of xrm files#278

Merged
stephen-riggs merged 5 commits into
mainfrom
xrm-thumbnail
Jul 3, 2026
Merged

Add plugin to make thumbnails of xrm files#278
stephen-riggs merged 5 commits into
mainfrom
xrm-thumbnail

Conversation

@stephen-riggs

@stephen-riggs stephen-riggs commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Add an images plugin which runs txrm2tiff conversion of xrms to annotated tiffs, then makes a jpg thumbnail for display

Links to DiamondLightSource/python-murfey#837

@stephen-riggs stephen-riggs requested a review from tieneupin July 3, 2026 13:42
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.13%. Comparing base (b0b700d) to head (788ce91).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
- Coverage   83.13%   83.13%   -0.01%     
==========================================
  Files          75       75              
  Lines        9291     9356      +65     
  Branches     1264     1271       +7     
==========================================
+ Hits         7724     7778      +54     
- Misses       1075     1084       +9     
- Partials      492      494       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

import pandas as pd
import PIL.Image
import starfile
import tifffile

@tieneupin tieneupin Jul 3, 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.

Double import? tifffile has been imported as tf right below this.
I'll leave it to you to pick which convention to use for this file. 👍

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.

That was an accident. I've got for tifffile as tf is sometimes tensorflow

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.

Ah, yes, that's fair, they both have the same initials.

convert_and_save(
xrm_path, str(tiff_path).replace("_Annotated", ""), annotate=annotate or False
)
data = tifffile.imread(tiff_path)[0]

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.

Any plans to verify whether the read array is a stack, a 2D image, or something else?

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.

I've made this slightly safer, but it's not worth fully checking it. This at some point connects to questions around whether we continue to use txrm2tiff for conversion

@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.

tifffile has been imported twice. I leave it to you to decide on which convention to use for this file!

@stephen-riggs stephen-riggs merged commit 8e738b3 into main Jul 3, 2026
12 checks passed
@stephen-riggs stephen-riggs deleted the xrm-thumbnail branch July 3, 2026 16:21
stephen-riggs added a commit to DiamondLightSource/python-murfey that referenced this pull request Jul 3, 2026
This adds functionality to read xrm images and request these are converted to tiffs.

Currently this identifies atlas and roi images by finding out if they are montages, and splits them based on pixel size. Better methods may be possible but this should work for now.

Rather than doing the xrm to tiff conversion here it puts a message onto rabbitmq. See DiamondLightSource/cryoem-services#278

Also contains a stub for registering rois in the database.
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