Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
eb45d01
Validate ArrayImageSource stack dim
garrettwrong Jul 28, 2025
95ed9c1
Add test for ArrayImageSource stack validation
garrettwrong Jul 28, 2025
64adf5f
Set default n_theta value for all commonline algos. Use default value…
j-c-c Jul 28, 2025
7ab79ab
fix polar cross corr fft axis
garrettwrong Aug 7, 2025
9210500
reduce sub pixel shift to 1
garrettwrong Aug 8, 2025
c815732
Fix pixel_size bug in Simulation. Add test for pixel_size pass-throug…
j-c-c Jun 9, 2025
f29afd9
DenoisedSource pixel_size passthrough test
j-c-c Jun 9, 2025
242845a
add pixel_size to ClassAvgSource and DenoisedSource
j-c-c Jun 9, 2025
7943351
test Simulation pixel size
j-c-c Jun 9, 2025
5729b9e
mean estimator pixel_size pass-through
j-c-c Jun 16, 2025
07e7613
Coef pixel_size attribute and testing
j-c-c Jun 23, 2025
8895056
expand pixel_size passthrough
j-c-c Jun 23, 2025
41ff258
shift/rotate pixel_size passthrough
j-c-c Jun 23, 2025
538719d
add param to docstring
j-c-c Jun 26, 2025
10aad20
move pixel_size_check logic in binary ops
j-c-c Jun 26, 2025
4ce3701
add comments
j-c-c Jun 26, 2025
72a7458
pixel_size in tests
j-c-c Jun 26, 2025
1f92a6d
use np.testing
j-c-c Jul 16, 2025
d4fde62
rip out async/threading and replace with mmap
garrettwrong Jul 28, 2025
e84e681
update code to do correct group-filter
garrettwrong Aug 27, 2025
47196d6
update comments and re-org
garrettwrong Aug 28, 2025
15effd7
fix docstring typo
garrettwrong Sep 3, 2025
f2c2a47
Add crop preprocess method
garrettwrong Aug 4, 2025
7508360
Create legacy_normalize_background with workflow default radius
garrettwrong Aug 4, 2025
a00cbb2
Create legacy_downsample and lightly refactor downsample/Downsample m…
garrettwrong Aug 4, 2025
18932a1
Adjust/cleanup Xforms
garrettwrong Aug 4, 2025
7806ed5
update unit tests
garrettwrong Aug 4, 2025
804cb55
update gallery jsb examples
garrettwrong Aug 4, 2025
f26552a
Add legacy crop to JSB examples
garrettwrong Aug 11, 2025
83d06c4
Use DiracBasis3D for jsb examples
garrettwrong Aug 11, 2025
004d3bb
forgot basis dtypes
garrettwrong Aug 12, 2025
1d936c4
use our existing crop_pad_2d
garrettwrong Aug 20, 2025
189e9fe
Normalize bg should be computed in double precision
garrettwrong Aug 21, 2025
64f7269
Whitening should also be in double precision
garrettwrong Aug 21, 2025
e0dd9a4
Might as well extend crop to crop_pad
garrettwrong Aug 21, 2025
e72b276
revert/postpose DiracBasis
garrettwrong Aug 22, 2025
a8140f7
cleanup docstrings
garrettwrong Aug 22, 2025
9c2d22e
cleanup docstrings
garrettwrong Aug 22, 2025
28f5d72
add crop_pad unit tests
garrettwrong Aug 22, 2025
10fc6c4
update crop comment
garrettwrong Aug 22, 2025
d59b822
words
garrettwrong Aug 22, 2025
5167416
add test for legacy_normalize_background
garrettwrong Aug 22, 2025
8ad7b53
remove CropPad docstring oversight
garrettwrong Aug 25, 2025
d7c7281
fixed comment typo
garrettwrong Aug 25, 2025
87c5976
Review string Updates
garrettwrong Sep 3, 2025
e8d4d0f
stashing, need port radialnorm methods
garrettwrong Aug 4, 2025
a11329c
quick and dirty implement MATLAB's ctf filter
garrettwrong Aug 4, 2025
0abd148
match matlab pf only temp file
garrettwrong Aug 8, 2025
25cce09
match single precision
garrettwrong Aug 8, 2025
241f3e4
replace CTFFilter with m_CTFFilter code
garrettwrong Aug 25, 2025
abeec19
rm dbg breakpoint
garrettwrong Aug 25, 2025
b4bb109
update filter unit tests
garrettwrong Aug 25, 2025
28ca57f
continue to update CTF and filter unit tests
garrettwrong Aug 25, 2025
86198aa
add back B factor to CTF
garrettwrong Aug 25, 2025
d13748c
default all Image filters to upcast the convolution
garrettwrong Aug 25, 2025
b9537bb
cleanup comments etc
garrettwrong Aug 26, 2025
17cee63
extend coverage to both ArrayFilter and CTFFilter
garrettwrong Aug 28, 2025
0aec7c7
fix dtype regression introduced in b1a0
garrettwrong Sep 5, 2025
b8f1fd7
revert to our centered wrappers
garrettwrong Sep 5, 2025
444b022
simplify example
garrettwrong Sep 5, 2025
6b4027c
Cleanup normalize_psd option
garrettwrong Sep 10, 2025
2a0cdb3
String cleanup
garrettwrong Sep 10, 2025
4a55806
Tox cleanup
garrettwrong Sep 10, 2025
4ee6321
Gallery formatting
garrettwrong Sep 10, 2025
36f9481
Update Dirac with xp
garrettwrong Sep 3, 2025
d054fbc
Change default basis
garrettwrong Sep 3, 2025
adcc0fe
Minor updates for passing utests
garrettwrong Sep 3, 2025
43ed6c6
xp type bug
garrettwrong Sep 3, 2025
54c2fdd
gpu updates
garrettwrong Sep 3, 2025
2a8fec0
array type passthrough in priv methods
garrettwrong Sep 8, 2025
609b7c1
more generic passthrough
garrettwrong Sep 12, 2025
fb26c6a
try reducing batch size
garrettwrong Sep 15, 2025
55b6cb1
remove workaround #703 cufinufft upcast now that we're 2.4.0
garrettwrong Sep 15, 2025
a4051de
add dirac prv method utests
garrettwrong Sep 16, 2025
0a5a65e
adjust a unit test for cufinufft singles
garrettwrong Sep 16, 2025
20b6d52
avoid conflicting volume orders in unit test
garrettwrong Sep 16, 2025
1ff81f3
flaky tests 1325
garrettwrong Sep 17, 2025
1d854c1
more tests
garrettwrong Sep 18, 2025
7c67fa0
rm missed deprecated comment
garrettwrong Sep 24, 2025
c21118e
Seeing what damage moving the pixel size out of CTF causes...
garrettwrong Aug 28, 2025
2cb3a2d
rebase conflict cleanup
garrettwrong Sep 11, 2025
2cede6a
update test_filters pixel_size use
garrettwrong Aug 29, 2025
5559d93
all but the double downsample px issue
garrettwrong Aug 29, 2025
dcc8bab
stashing
garrettwrong Aug 29, 2025
78574c8
more rebase test conflict cleanup
garrettwrong Sep 11, 2025
3115142
mark 1318 test as xfail
garrettwrong Sep 11, 2025
a524cad
cleanup filter_to_basis_mat pixel_size calls
garrettwrong Sep 11, 2025
72e06c8
first round cleanup tutorial pixel_size calls
garrettwrong Sep 11, 2025
35eabbf
cleanup pixel_sizes in CTF tutorial
garrettwrong Sep 12, 2025
04948e6
Fix two 1290 regressions
garrettwrong Sep 12, 2025
639903c
Yeast updates, uniform k=3, keep as singles
garrettwrong Sep 26, 2025
06e9469
Simulation pixel_size default=1.0. Private/public Image.downsample to…
j-c-c Jul 11, 2025
1f7a2c8
Fix gallery pixel_size
j-c-c Jul 14, 2025
0f72cc5
Adopt Relion 3.1 offset convention (_rlnOriginX(Y)Angst). Default pix…
j-c-c Jul 14, 2025
383461e
Require pixel_size for all ImageSource objects
j-c-c Jul 18, 2025
09fd90e
tox
j-c-c Jul 18, 2025
2f54515
cleanup Simulation pixel_size behavior. Fix docstring. Add test.
j-c-c Jul 23, 2025
312da4e
Resolve Errors and failing tests
j-c-c Sep 16, 2025
6a1f21d
Fix galleries
j-c-c Sep 16, 2025
559268b
fix param in gallery
j-c-c Sep 16, 2025
2fcd999
more rebase cleanup
j-c-c Sep 17, 2025
cfe99ef
Update Simulation pixel_size behavior. Warn on mismatch.
j-c-c Sep 18, 2025
39b87ad
_populate_pixel_size. Handle mismatches. tests
j-c-c Sep 19, 2025
4013d7c
Fix failing tests
j-c-c Sep 19, 2025
ecbe00b
pixel_size setter/getter.
j-c-c Sep 19, 2025
e05f065
add offset tests
j-c-c Sep 19, 2025
d1c568a
test src.downsample.pixel_size == src.img.downsample.pixel_size
j-c-c Sep 22, 2025
a2de46d
test downsample save.
j-c-c Sep 25, 2025
3200203
Remove detector metadata after src.downsample
j-c-c Sep 25, 2025
a1b4d95
Remove xfail and fix apply_sim_filters bug
j-c-c Sep 29, 2025
549eb98
ArrayImageSource pixel_size logic. Testing.
j-c-c Sep 30, 2025
97a3e06
fix gallery
j-c-c Sep 30, 2025
94b22c8
CoordinateSource pixel_size behavior. Testing
j-c-c Sep 30, 2025
705aa0d
Add pixel_size docstring to MicrographSimulation
j-c-c Sep 30, 2025
850d8f2
edit docstring
j-c-c Oct 1, 2025
e657d92
asnumpy
j-c-c Oct 1, 2025
8b5c681
update docstring for required pixel_size
j-c-c Oct 1, 2025
753fa6f
clean up _populate_pixel_size logic
j-c-c Oct 1, 2025
ee9e2e7
_projection_pixel_size. test projections and clean_images.
j-c-c Oct 2, 2025
515656f
pop_metadata
j-c-c Oct 2, 2025
37efd99
check_pixel_size_mismatch util function.
j-c-c Oct 3, 2025
a452fb8
tox
j-c-c Oct 3, 2025
c3bf783
offsets stored in doubles. pixels stored as float.
j-c-c Oct 7, 2025
02aa9fe
remove strict
j-c-c Oct 7, 2025
0c5bd60
pixel_size logic
j-c-c Oct 8, 2025
363ed87
update check_pixel_size
j-c-c Oct 8, 2025
6ec62f0
cast pixel_size as float correctly. Add test to check pixel_size is c…
j-c-c Oct 8, 2025
f7f5b8d
check for scalar pixel_size. Add test.
j-c-c Oct 8, 2025
f2c5728
change argument names
j-c-c Oct 9, 2025
8dccd6a
Remove None default for CoordinateSource pixel_size
j-c-c Oct 17, 2025
0ee2579
typos
j-c-c Oct 17, 2025
d0e771b
clarifying pixel_size comment in Downsample xform
j-c-c Oct 17, 2025
fb623dc
update check_pixel_size warning message. fix broken test.
j-c-c Oct 17, 2025
587add7
fix gallery
j-c-c Oct 17, 2025
38069c0
update extract_particles CLI
j-c-c Oct 17, 2025
f26be41
Bump version: 0.14.0 → 0.14.1
garrettwrong Oct 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.14.0
current_version = 0.14.1
commit = True
tag = True

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5657281.svg)](https://doi.org/10.5281/zenodo.5657281)
[![Downloads](https://static.pepy.tech/badge/aspire/month)](https://pepy.tech/project/aspire)

# ASPIRE - Algorithms for Single Particle Reconstruction - v0.14.0
# ASPIRE - Algorithms for Single Particle Reconstruction - v0.14.1

The ASPIRE-Python project supersedes [Matlab ASPIRE](https://github.com/PrincetonUniversity/aspire).

Expand All @@ -20,7 +20,7 @@ For more information about the project, algorithms, and related publications ple
Please cite using the following DOI. This DOI represents all versions, and will always resolve to the latest one.

```
ComputationalCryoEM/ASPIRE-Python: v0.14.0 https://doi.org/10.5281/zenodo.5657281
ComputationalCryoEM/ASPIRE-Python: v0.14.1 https://doi.org/10.5281/zenodo.5657281

```

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = version = "0.14.0"
release = version = "0.14.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Aspire v0.14.0
Aspire v0.14.1
==============

Algorithms for Single Particle Reconstruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@
logger.info("Perform phase flip to input images.")
src = src.phase_flip().cache()

# Legacy MATLAB cropped the images to an odd resolution.
src = src.crop_pad(src.L - 1).cache()

# Downsample the images.
logger.info(f"Set the resolution to {img_size} X {img_size}")
src = src.downsample(img_size).cache()
src = src.legacy_downsample(img_size).cache()

# Normalize the background of the images.
src = src.normalize_background().cache()
src = src.legacy_normalize_background().cache()

# Estimate the noise and whiten based on the estimated noise.
src = src.legacy_whiten().cache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import logging
from pathlib import Path

import numpy as np

from aspire.abinitio import CLSync3N
from aspire.denoising import LegacyClassAvgSource
from aspire.reconstruction import MeanEstimator
Expand Down Expand Up @@ -82,12 +80,15 @@
logger.info("Perform phase flip to input images.")
src = src.phase_flip().cache()

# Legacy MATLAB cropped the images to an odd resolution.
src = src.crop_pad(src.L - 1).cache()

# Downsample the images.
logger.info(f"Set the resolution to {img_size} X {img_size}")
src = src.downsample(img_size).cache()
src = src.legacy_downsample(img_size).cache()

# Normalize the background of the images.
src = src.normalize_background().cache()
src = src.legacy_normalize_background().cache()

# Estimate the noise and whiten based on the estimated noise.
src = src.legacy_whiten().cache()
Expand Down Expand Up @@ -115,8 +116,8 @@

# We'll continue our pipeline by selecting ``n_classes`` from ``avgs``.
# To capture a broader range of viewing angles, uniformly select every ``k`` image.
k = (avgs.n - 1) // n_classes
avgs = avgs[::k].cache()
k = 3
avgs = avgs[: n_classes * k : k].cache()


# %%
Expand All @@ -133,8 +134,7 @@
logger.info("Apply custom mask")
# 10073 benefits from a masking procedure that is more aggressive than the default.
# Note, since we've manually masked, the default masking is disabled below in `CLSync3N`.
# This also upcasts to double precision, which is helpful for this reconstruction.
mask = fuzzy_mask((img_size, img_size), np.float64, r0=0.4 * img_size, risetime=2)
mask = fuzzy_mask((img_size, img_size), avgs.dtype, r0=0.4 * img_size, risetime=2)
avgs = ArrayImageSource(avgs.images[:] * mask)

logger.info("Begin Orientation Estimation")
Expand Down
47 changes: 47 additions & 0 deletions gallery/experiments/legacy_preprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Legacy Preprocessing Pipeline
=============================

This notebook demonstrates reproducing preprocessing results from the
legacy ASPIRE MATLAB workflow system for the EMPIAR 10028 ribosome
dataset.

https://www.ebi.ac.uk/empiar/EMPIAR-10028
"""

# %%
# Source data and Preprocessing
# -----------------------------
#
# Load the data and apply preprocessing steps corresponding to the MATLAB prompts:
#
# >>> Phaseflip projections? (Y/N)? [Y] Y
# >>> Enter pixel size in Angstrom (-1 to read from STAR file): [-1.000000]
# >>> Number of projections to read? [105247]
# >>> Crop? (Y/N)? [Y] Y
# >>> Crop to size? [360]359
# >>> Downsample? (Y/N)? [Y] Y
# >>> Downsample to size? [360]179
# >>> Normalize background of images to variance 1? (Y/N)? [Y]
# >>> Prewhiten? (Y/N)? [Y]
# >>> Split data into groups? (Y/N)? [Y] N

from aspire.source import RelionSource

# Inputs
# Note the published ``shiny_2sets.star`` requires removal of a stray '9' character on line 5476.
starfile_in = "10028/data/shiny_2sets_fixed9.star"
# Caching, while not required, will increase speed in exchange for potentially increased memory usage.
src = RelionSource(starfile_in).cache()

# Define preprocessing steps.
src = src.phase_flip().cache()
src = src.crop_pad(359).cache()
src = src.legacy_downsample(179).cache()
src = src.legacy_normalize_background().cache()
src = src.legacy_whiten().cache()
src = src.invert_contrast().cache()

# Save the preprocessed images.
# `save_mode=single` will save a STAR file and single mrcs holding the image stack.
src.save("10028_legacy_preprocessed_179px.star", save_mode="single", overwrite=True)
2 changes: 1 addition & 1 deletion gallery/tutorials/aspire_introduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def noise_function(x, y):

# Generate several CTFs.
ctf_filters = [
RadialCTFFilter(pixel_size=vol_ds.pixel_size, defocus=d)
RadialCTFFilter(defocus=d)
for d in np.linspace(defocus_min, defocus_max, defocus_ct)
]

Expand Down
2 changes: 1 addition & 1 deletion gallery/tutorials/pipeline_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
defocus_ct = 7

ctf_filters = [
RadialCTFFilter(pixel_size=original_vol.pixel_size, defocus=d)
RadialCTFFilter(defocus=d)
for d in np.linspace(defocus_min, defocus_max, defocus_ct)
]

Expand Down
2 changes: 1 addition & 1 deletion gallery/tutorials/tutorials/basic_image_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def noise_function(x, y):
# The implementation of batching for memory management
# would be managed behind the scenes for you.

imgs_src = ArrayImageSource(imgs_with_noise)
imgs_src = ArrayImageSource(imgs_with_noise, pixel_size=1.0)

# We'll copy the orginals for comparison later, before we process them further.
noisy_imgs_copy = imgs_src.images[:n_imgs].asnumpy()
Expand Down
2 changes: 1 addition & 1 deletion gallery/tutorials/tutorials/class_averaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

# So now that we have cooked up an example dataset, lets create an
# ASPIRE source
src = ArrayImageSource(example_array)
src = ArrayImageSource(example_array, pixel_size=1.0)

# Let's peek at the images to make sure they're shuffled up nicely
src.images[:10].show()
Expand Down
7 changes: 5 additions & 2 deletions gallery/tutorials/tutorials/cov2d_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
print("Initialize simulation object and CTF filters.")
# Create filters
ctf_filters = [
RadialCTFFilter(pixel_size, voltage, defocus=d, Cs=2.0, alpha=0.1)
RadialCTFFilter(voltage, defocus=d, Cs=2.0, alpha=0.1)
for d in np.linspace(defocus_min, defocus_max, defocus_ct)
]

Expand All @@ -94,6 +94,7 @@
amplitudes=1.0,
dtype=dtype,
noise_adder=noise_adder,
pixel_size=pixel_size,
)


Expand All @@ -108,7 +109,9 @@
h_idx = sim.filter_indices

# Evaluate CTF in the 8X8 FB basis
h_ctf_fb = [ffbbasis.filter_to_basis_mat(filt) for filt in ctf_filters]
h_ctf_fb = [
ffbbasis.filter_to_basis_mat(filt, pixel_size=pixel_size) for filt in ctf_filters
]

# Get clean images from projections of 3D map.
print("Apply CTF filters to clean images.")
Expand Down
7 changes: 3 additions & 4 deletions gallery/tutorials/tutorials/cov3d_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@
L=img_size,
C=3,
dtype=dtype,
pixel_size=10,
).generate()

# Create a simulation object with specified filters
sim = Simulation(
L=img_size,
n=num_imgs,
vols=vols,
unique_filters=[
RadialCTFFilter(pixel_size=10, defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7)
],
unique_filters=[RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7)],
dtype=dtype,
)

Expand Down Expand Up @@ -89,7 +88,7 @@
eigs_est, lambdas_est = eigs(covar_est, num_eigs)

# Eigs returns column-major, so we transpose and construct a volume.
eigs_est = Volume(np.transpose(eigs_est, (3, 0, 1, 2)))
eigs_est = Volume(np.transpose(eigs_est, (3, 0, 1, 2)), pixel_size=vols.pixel_size)

# Truncate the eigendecomposition. Since we know the true rank of the
# covariance matrix, we enforce it here.
Expand Down
Loading
Loading