Skip to content

Conversation

@garrettwrong
Copy link
Collaborator

Resolves #1310 #1311 #1312

I put this together hastily so I'll want to self-review and consider/discuss the changes more carefully before going farther...

@garrettwrong garrettwrong self-assigned this Aug 4, 2025
@garrettwrong garrettwrong added documentation Improvements or additions to documentation enhancement New feature or request cleanup labels Aug 4, 2025
@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.60%. Comparing base (15effd7) to head (7444617).
⚠️ Report is 23 commits behind head on develop.

Files with missing lines Patch % Lines
src/aspire/source/image.py 82.35% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1314      +/-   ##
===========================================
- Coverage    90.61%   90.60%   -0.01%     
===========================================
  Files          133      133              
  Lines        14373    14394      +21     
===========================================
+ Hits         13024    13042      +18     
- Misses        1349     1352       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@garrettwrong garrettwrong force-pushed the ppdbg branch 3 times, most recently from daf3608 to e0052ec Compare August 11, 2025 12:02
@garrettwrong
Copy link
Collaborator Author

Currently testing the JSB gallery updates for this merged with the mctf work. If it seems okay I'll move this pr onto review.

@garrettwrong
Copy link
Collaborator Author

For 10028 80S dataset loaded as single precision and processed to 129 pixels in ASPIRE-Python these changes achieve max nrmse 7.6313734e-07 and avg nrmse 3.7122902e-07 across all images as compared to the MATLAB cryo_workflow_preprocess utilizing the expected sequence (as I understand it).

Phase Flip (360x360)  - phase_flip()
Crop to 359  - crop(359)
Downsample 129. - legacy_downsample(129)
Normalize Background - legacy_normalize_background()
Whiten - legacy_whiten()
Global Phase Flip - invert_contrast()

Note, that comparison included merging in the tentative CTF changes proposed in #1315 .


Besides the different defaults I also had to alter our code to upcast some (most) of the internal processing computations to double precision. This is essentially what the MATLAB code does in general, casting to singles at the end via the mrc save. Some computations test well for small/single image cases but differences show on larger images/stacks.

I expect there will be discussion about how to take the changes, but we can at least replicate the preprocessed dataset to my satisfaction now.

@garrettwrong garrettwrong requested a review from j-c-c August 22, 2025 15:08
@garrettwrong
Copy link
Collaborator Author

Alright @j-c-c , this should be ready to review. Then I can get to the CTF stuff that is holding up your other PRs.

@j-c-c
Copy link
Collaborator

j-c-c commented Aug 22, 2025

Alright @j-c-c , this should be ready to review. Then I can get to the CTF stuff that is holding up your other PRs.

Sounds good. I'll start reviewing!

Copy link
Collaborator

@j-c-c j-c-c left a comment

Choose a reason for hiding this comment

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

Looks good! Just one small docstring fix and two typos while you're in there.

"""
Initialize Xform to crop Image to a specific size.
:param L: int - new size, should be <= the current size
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the should be <= the current size in there by mistake? If we're padding wouldn't L > current size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea I forgot to delete this after I extended from just crop to crop_pad. removed. thanks

np.testing.assert_allclose(pad_odd_to_even_many.images[:], ref)

# Padding odd to odd by many should pad the first and last cols equally.
# This test will also excecise `fill_value`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not important, but "exercise".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed comment typo

np.testing.assert_allclose(pad_even_to_even_many.images[:], ref)

# Padding even to odd by many should pad the first and last+1 cols equally.
# This test will also excecise `fill_value`
Copy link
Collaborator

Choose a reason for hiding this comment

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

same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed comment typo

@garrettwrong garrettwrong requested a review from j-c-c August 25, 2025 18:31
@garrettwrong garrettwrong marked this pull request as ready for review August 25, 2025 18:31
@garrettwrong garrettwrong requested a review from janden as a code owner August 25, 2025 18:31
j-c-c
j-c-c previously approved these changes Aug 26, 2025
Copy link
Collaborator

@j-c-c j-c-c left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@janden janden left a comment

Choose a reason for hiding this comment

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

Thank you for going through all this stuff. Just some minor formulation stuff.

Copy link
Collaborator

@janden janden left a comment

Choose a reason for hiding this comment

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

LGTM

@garrettwrong garrettwrong merged commit 87c5976 into develop Sep 4, 2025
35 checks passed
@garrettwrong garrettwrong deleted the ppdbg branch September 4, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants