Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion src/aspire/image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
_im_translate2,
normalize_bg,
)
from .preprocess import crop_pad, downsample, fuzzy_mask
212 changes: 0 additions & 212 deletions src/aspire/image/preprocess.py

This file was deleted.

1 change: 1 addition & 0 deletions src/aspire/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
pairs_to_linear,
powerset,
sha256sum,
fuzzy_mask,
)

from .logging import get_full_version, tqdm, trange
Expand Down
28 changes: 28 additions & 0 deletions src/aspire/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from itertools import chain, combinations

import numpy as np
from scipy.special import erf

from aspire.utils import grid_1d, grid_2d, grid_3d
from aspire.utils.rotation import Rotation
Expand Down Expand Up @@ -257,6 +258,33 @@ def inverse_r(size, x0=0, y0=0, peak=1, dtype=np.float64):
return (peak / vals).astype(dtype)


def fuzzy_mask(L, r0, risetime, origin=None):
"""
Create a centered 1D to 3D fuzzy mask of radius r0

Made with an error function with effective rise time.

:param L: The sizes of image in tuple structure
:param r0: The specified radius
:param risetime: The rise time for `erf` function
:param origin: The coordinates of origin
:return: The desired fuzzy mask
"""

center = [sz // 2 + 1 for sz in L]
if origin is None:
origin = center

grids = [np.arange(1 - org, ell - org + 1) for ell, org in zip(L, origin)]
XYZ = np.meshgrid(*grids, indexing="ij")
XYZ_sq = [X**2 for X in XYZ]
R = np.sqrt(np.sum(XYZ_sq, axis=0))
k = 1.782 / risetime
m = 0.5 * (1 - erf(k * (R - r0)))

return m


def all_pairs(n):
"""
All pairs indexing (i,j) for i<j.
Expand Down
121 changes: 0 additions & 121 deletions tests/test_preprocess.py

This file was deleted.

Loading