Skip to content

Conversation

@tieneupin
Copy link
Contributor

@tieneupin tieneupin commented Dec 16, 2025

TIFFs apparently cannot be used for web-based data visualisation, so animated PNGs of the processed images/image stacks need to be created.

This PR adds logic to the CLEM workflows (both the services and wrappers) to send additional messages to the Images service to create scaled down animated PNGs of the processed images. These are saved in hidden .thumbnails folders in their parent image's directory.

Additionally, the cryoemservices_cpu Dockerfile was updated to accommodate the presence of offline IMOD installers, instead of forcibly downloading from the IMOD website every time. A .dockerignore file was also added to the repository to ensure only the bare minimum files are copied across to the Docker image during the build. The .gitignore file was also updated to ignore the cache directories of the newer pre-commit hooks.

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 86.76471% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.98%. Comparing base (9c64f9f) to head (f56ea2f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #221      +/-   ##
==========================================
+ Coverage   82.71%   82.98%   +0.27%     
==========================================
  Files          62       62              
  Lines        8112     8342     +230     
  Branches     1130     1218      +88     
==========================================
+ Hits         6710     6923     +213     
- Misses        960      974      +14     
- Partials      442      445       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tieneupin tieneupin marked this pull request as ready for review December 18, 2025 18:15
@tieneupin tieneupin self-assigned this Dec 18, 2025
@tieneupin tieneupin added the enhancement New feature or request label Dec 18, 2025
Copy link
Contributor

@stephen-riggs stephen-riggs left a comment

Choose a reason for hiding this comment

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

Looks fine. A couple of minor comments.
Also in the Dockerfiles there are currently various references to a "packages" folder which will can probably become your "installers" folder, but maybe not in this PR

# Collect image frames
frames: list[PIL.Image.ImageFile.ImageFile] = []
try:
while True:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be possible to read using tifffile and loop over the frames rather than doing the image seek. Not essential, just my preference for for loops rather than while blocks

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'll have a look at replacing it with the use of tifffile, sure. I just need to make sure that the image doesn't get flipped upside down when doing so, as I'm aware that different image/plotting packages treat the y-axis differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found a solution involving minimal changes to the existing logic. Let me know what you think!

"composite_image": str(save_name.resolve()),
"output_file": str(save_name),
"thumbnail": str(save_name.parent / ".thumbnails" / f"{save_name.stem}.png"),
"thumbnail_size": (512, 512), # height, row
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for choosing to hard-code the 512, 512 here rather than in the images service? I think all of the other plugins do it in the images service

Copy link
Contributor Author

@tieneupin tieneupin Jan 7, 2026

Choose a reason for hiding this comment

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

The thumbnail size is needed on the Murfey side to work out the relative positions of the grid square thumbnails on the atlas thumbnail. At the point the message is passed back to Murfey, you cannot be sure that the 'images' plugin will have generated the thumbnail, so trying to read the dimensions by opening the thumbnail will potentially fail.

As discussed, the repetition could be avoid by setting the target thumbnail size on Murfey when the image processing request is first sent to CryoEM Services. I can implement this in a subsequent PR further down the line.

Copy link
Contributor

@stephen-riggs stephen-riggs left a comment

Choose a reason for hiding this comment

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

The loop looks much nicer now, thanks for changing it

@tieneupin tieneupin merged commit bdf67bc into main Jan 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants