Skip to content

Commit f8f26ee

Browse files
authored
Merge pull request #1300 from ComputationalCryoEM/develop
v0.14.0
2 parents d0f3d09 + 60d1db6 commit f8f26ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2846
-682
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.13.2
2+
current_version = 0.14.0
33
commit = True
44
tag = True
55

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: ASPIRE Python Scheduled Workflow
2+
3+
on:
4+
schedule:
5+
- cron: '15 0 * * 0' # Every Sunday at 00:15 UTC
6+
7+
8+
jobs:
9+
scheduled-tests:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: develop
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.10'
20+
- name: Install Dependencies
21+
run: |
22+
pip install -e ".[dev]"
23+
- name: Scheduled Tests
24+
run: pytest -m scheduled

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ jobs:
156156
shell: bash -el {0}
157157
strategy:
158158
matrix:
159-
os: [ubuntu-latest, ubuntu-20.04, macOS-latest, macOS-13]
159+
os: [ubuntu-latest, ubuntu-22.04, macOS-latest, macOS-13]
160160
backend: [default, openblas]
161161
python-version: ['3.9']
162162
include:
163163
- os: ubuntu-latest
164164
backend: intel
165165
- os: macOS-latest
166166
backend: accelerate
167-
- os: windows-2019
167+
- os: windows-2022
168168
backend: win64
169169

170170
steps:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5657281.svg)](https://doi.org/10.5281/zenodo.5657281)
66
[![Downloads](https://static.pepy.tech/badge/aspire/month)](https://pepy.tech/project/aspire)
77

8-
# ASPIRE - Algorithms for Single Particle Reconstruction - v0.13.2
8+
# ASPIRE - Algorithms for Single Particle Reconstruction - v0.14.0
99

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

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

2222
```
23-
ComputationalCryoEM/ASPIRE-Python: v0.13.2 https://doi.org/10.5281/zenodo.5657281
23+
ComputationalCryoEM/ASPIRE-Python: v0.14.0 https://doi.org/10.5281/zenodo.5657281
2424
2525
```
2626

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
# built documents.
8787
#
8888
# The full version, including alpha/beta/rc tags.
89-
release = version = "0.13.2"
89+
release = version = "0.14.0"
9090

9191
# The language for content autogenerated by Sphinx. Refer to documentation
9292
# for a list of supported languages.

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Aspire v0.13.2
1+
Aspire v0.14.0
22
==============
33

44
Algorithms for Single Particle Reconstruction
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
"""
2+
Commonlines Method using LUD
3+
============================
4+
5+
This tutorial demonstrates using the Least Unsquared Deviations (LUD)
6+
commonlines method for estimating particle orientations. This tutorial
7+
reproduces the "Experiments on simulated images" found in the publication:
8+
9+
Orientation Determination of Cryo-EM Images Using Least Unsquared Deviations,
10+
L. Wang, A. Singer, and Z. Wen, SIAM J. Imaging Sciences, 6, 2450-2483 (2013).
11+
"""
12+
13+
# %%
14+
# Imports
15+
# -------
16+
17+
import logging
18+
from fractions import Fraction
19+
from itertools import product
20+
21+
import numpy as np
22+
23+
from aspire.abinitio import CommonlineIRLS, CommonlineLUD
24+
from aspire.noise import WhiteNoiseAdder
25+
from aspire.source import Simulation
26+
from aspire.utils import mean_aligned_angular_distance
27+
from aspire.volume import Volume
28+
29+
logger = logging.getLogger(__name__)
30+
31+
32+
# %%
33+
# Parameters
34+
# ----------
35+
# Set up some initializing parameters. We will run the LUD algorithm using ADMM
36+
# and IRLS methods under various spectral norm constraints and levels of noise.
37+
38+
SNR = ["1/8", "1/16", "1/32"] # Signal-to-noise ratio
39+
METHOD = ["ADMM", "IRLS"]
40+
ALPHA = [0.90, 0.75, 0.67] # Spectral norm constraint
41+
n_imgs = 500 # Number of images in our source
42+
dtype = np.float64
43+
pad_size = 129
44+
45+
# %%
46+
# Load Volume Map
47+
# ---------------
48+
# We will generate simulated noisy images from a low res volume
49+
# map available in our data folder. This volume map is a 65 x 65 x 65
50+
# voxel volume which we intend to upsample to 129 x 129 x 129.
51+
# To do this we use our ``downsample`` method which, when provided a voxel
52+
# size larger than the input volume, internally zero-pads in Fourier
53+
# space to increase the overall shape of the volume.
54+
vol = (
55+
Volume.load("../tutorials/data/clean70SRibosome_vol_65p.mrc")
56+
.astype(dtype)
57+
.downsample(pad_size)
58+
)
59+
logger.info("Volume map data" f" shape: {vol.shape} dtype:{vol.dtype}")
60+
61+
# %%
62+
# Generate Noisy Images and Estimate Rotations
63+
# --------------------------------------------
64+
# A ``Simulation`` object is used to generate simulated data at various
65+
# noise levels. Then rotations are estimated using the ``CommonlineLUD`` and
66+
# ``CommonlineIRLS`` algorithms. Results are measured by computing the mean
67+
# aligned angular distance between the ground truth rotations and the globally
68+
# aligned estimated rotations.
69+
70+
# Build table to dislay results.
71+
col_width = 21
72+
table = []
73+
table.append(
74+
f"{'METHOD':<{col_width}} {'SNR':<{col_width}} {'ALPHA':<{col_width}} {'Mean Angular Distance':<{col_width}}"
75+
)
76+
table.append("-" * (col_width * 4))
77+
78+
for method, snr, alpha in product(METHOD, SNR, ALPHA):
79+
# Generate a white noise adder with specified SNR.
80+
noise_adder = WhiteNoiseAdder.from_snr(snr=Fraction(snr))
81+
82+
# Initialize a Simulation source to generate noisy, centered images.
83+
src = Simulation(
84+
n=n_imgs,
85+
vols=vol,
86+
offsets=0,
87+
amplitudes=1,
88+
noise_adder=noise_adder,
89+
dtype=dtype,
90+
).cache()
91+
92+
# Estimate rotations using the LUD algorithm.
93+
if method == "ADMM":
94+
orient_est = CommonlineLUD(src, alpha=alpha)
95+
else:
96+
orient_est = CommonlineIRLS(src, alpha=alpha)
97+
est_rotations = orient_est.estimate_rotations()
98+
99+
# Find the mean aligned angular distance between estimates and ground truth rotations.
100+
mean_ang_dist = mean_aligned_angular_distance(est_rotations, src.rotations)
101+
102+
# Append results to table.
103+
table.append(
104+
f"{method:<{col_width}} {snr:<{col_width}} {str(alpha):<{col_width}} {mean_ang_dist:<{col_width}}"
105+
)
106+
107+
# %%
108+
# Display Results
109+
# ---------------
110+
# Display table of results for both methods using various spectral norm
111+
# constraints and noise levels.
112+
113+
logger.info("\n" + "\n".join(table))

0 commit comments

Comments
 (0)